mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-07-22 22:40:48 -04:00
Doc blocks added, available templates may be set in the general configuration file
This commit is contained in:
parent
c7a4ced9e1
commit
a4b0a993c7
4 changed files with 46 additions and 11 deletions
|
@ -3940,6 +3940,14 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the template in a cookie and reloads the page
|
||||||
|
*
|
||||||
|
* @name TopNav.setTemplate
|
||||||
|
* @private
|
||||||
|
* @function
|
||||||
|
* @param {Event} event
|
||||||
|
*/
|
||||||
function setTemplate(event)
|
function setTemplate(event)
|
||||||
{
|
{
|
||||||
let template = $(event.target).data('template') || event.target.value;
|
let template = $(event.target).data('template') || event.target.value;
|
||||||
|
|
|
@ -78,6 +78,14 @@ class Configuration
|
||||||
'syntaxhighlighting' => 'Source Code',
|
'syntaxhighlighting' => 'Source Code',
|
||||||
'markdown' => 'Markdown',
|
'markdown' => 'Markdown',
|
||||||
),
|
),
|
||||||
|
'available_templates' => array(
|
||||||
|
'page',
|
||||||
|
'bootstrap',
|
||||||
|
'bootstrap-compact',
|
||||||
|
'bootstrap-dark',
|
||||||
|
'bootstrap-page',
|
||||||
|
'bootstrap5',
|
||||||
|
),
|
||||||
'traffic' => array(
|
'traffic' => array(
|
||||||
'limit' => 10,
|
'limit' => 10,
|
||||||
'header' => '',
|
'header' => '',
|
||||||
|
@ -109,7 +117,7 @@ class Configuration
|
||||||
'js/kjua-0.9.0.js' => 'sha512-CVn7af+vTMBd9RjoS4QM5fpLFEOtBCoB0zPtaqIDC7sF4F8qgUSRFQQpIyEDGsr6yrjbuOLzdf20tkHHmpaqwQ==',
|
'js/kjua-0.9.0.js' => 'sha512-CVn7af+vTMBd9RjoS4QM5fpLFEOtBCoB0zPtaqIDC7sF4F8qgUSRFQQpIyEDGsr6yrjbuOLzdf20tkHHmpaqwQ==',
|
||||||
'js/legacy.js' => 'sha512-UxW/TOZKon83n6dk/09GsYKIyeO5LeBHokxyIq+r7KFS5KMBeIB/EM7NrkVYIezwZBaovnyNtY2d9tKFicRlXg==',
|
'js/legacy.js' => 'sha512-UxW/TOZKon83n6dk/09GsYKIyeO5LeBHokxyIq+r7KFS5KMBeIB/EM7NrkVYIezwZBaovnyNtY2d9tKFicRlXg==',
|
||||||
'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
|
'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
|
||||||
'js/privatebin.js' => 'sha512-YDgd0cFfFHP/DLHQH2CWkGMjdFC5YjwDuWSoEsc1gU4h5sRd+T88mPYva1cdoviKEoty6F8pDe3E6chcMEzRag==',
|
'js/privatebin.js' => 'sha512-BfzmQFxBXq4lOVT6wVzcDUnBXCvZaeqiq+Xapp9eyIg8nPC2B6x96LMwSZgA+QwCAE/Ps7P9/a4P5wYEfKNnOA==',
|
||||||
'js/purify-3.2.4.js' => 'sha512-Mu9BqoHURMeycg6AgqTpokUv9guq88pajfaFqz53fx1OxohyROkydXPLEIbdKCQ7EdDs9hgcrYeZ9zTiPQQ4CA==',
|
'js/purify-3.2.4.js' => 'sha512-Mu9BqoHURMeycg6AgqTpokUv9guq88pajfaFqz53fx1OxohyROkydXPLEIbdKCQ7EdDs9hgcrYeZ9zTiPQQ4CA==',
|
||||||
'js/rawinflate-0.3.js' => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
|
'js/rawinflate-0.3.js' => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
|
||||||
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
||||||
|
|
|
@ -183,6 +183,12 @@ class Controller
|
||||||
$this->_setDefaultTemplate();
|
$this->_setDefaultTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default language
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
private function _setDefaultLanguage()
|
private function _setDefaultLanguage()
|
||||||
{
|
{
|
||||||
$this->_conf = new Configuration;
|
$this->_conf = new Configuration;
|
||||||
|
@ -197,14 +203,21 @@ class Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default template
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
private function _setDefaultTemplate()
|
private function _setDefaultTemplate()
|
||||||
{
|
{
|
||||||
$this->_conf = new Configuration;
|
$this->_conf = new Configuration;
|
||||||
|
|
||||||
|
$templates = $this->_conf->getSection('available_templates');
|
||||||
$template = $this->_conf->getKey('templatedefault');
|
$template = $this->_conf->getKey('templatedefault');
|
||||||
|
TemplateSwitcher::setAvailableTemplates($templates);
|
||||||
TemplateSwitcher::setTemplateFallback($template);
|
TemplateSwitcher::setTemplateFallback($template);
|
||||||
// force default template, if template selection is disabled and a default is set
|
// force default template, if template selection is disabled and a default is set
|
||||||
if (!$this->_conf->getKey('languageselection') && strlen($template) == 2) {
|
if (!$this->_conf->getKey('templateselection') && !empty($template)) {
|
||||||
$_COOKIE['template'] = $template;
|
$_COOKIE['template'] = $template;
|
||||||
setcookie('template', $template, array('SameSite' => 'Lax', 'Secure' => true));
|
setcookie('template', $template, array('SameSite' => 'Lax', 'Secure' => true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,20 @@ class TemplateSwitcher {
|
||||||
* @static
|
* @static
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $_availableTemplates = [
|
protected static $_availableTemplates = array();
|
||||||
'page',
|
|
||||||
'bootstrap',
|
|
||||||
'bootstrap-compact',
|
/**
|
||||||
'bootstrap-dark',
|
* set available templates
|
||||||
'bootstrap-page',
|
*
|
||||||
'bootstrap5',
|
* @access public
|
||||||
];
|
* @static
|
||||||
|
* @param array $templates
|
||||||
|
*/
|
||||||
|
public static function setAvailableTemplates(array $templates)
|
||||||
|
{
|
||||||
|
self::$_availableTemplates = $templates;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the default template
|
* set the default template
|
||||||
|
@ -101,7 +107,7 @@ class TemplateSwitcher {
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @static
|
* @static
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
private static function getSelectedByUserTemplate(): ?string
|
private static function getSelectedByUserTemplate(): ?string
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue