forked from leftypol/leftypol
Backport: update twig to 2.9
This commit is contained in:
parent
9112bc05d3
commit
3544ff6041
|
@ -3,7 +3,7 @@
|
|||
"description": "leftypol imageboard",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"twig/twig": "^1.44.2",
|
||||
"twig/twig": "^2.9",
|
||||
"lifo/ip": "^1.0",
|
||||
"gettext/gettext": "^1.0",
|
||||
"mrclay/minify": "^2.1.6"
|
||||
|
|
143
composer.lock
generated
143
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "346d80deda89b0298a414b565213f312",
|
||||
"content-hash": "b3695c356f94b9226e689a31f8dc1463",
|
||||
"packages": [
|
||||
{
|
||||
"name": "gettext/gettext",
|
||||
|
@ -25,12 +25,12 @@
|
|||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Gettext": ""
|
||||
},
|
||||
"files": [
|
||||
"Gettext/translator_functions.php"
|
||||
]
|
||||
],
|
||||
"psr-0": {
|
||||
"Gettext": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
|
@ -191,12 +191,12 @@
|
|||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Ctype\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Ctype\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
|
@ -240,31 +240,113 @@
|
|||
"time": "2021-10-20T20:35:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.44.6",
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.29.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3"
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ae39480f010ef88adc7938503c9b02d3baf2f3b3",
|
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
||||
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"provide": {
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
"url": "https://github.com/symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-01-29T20:11:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v2.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "82a1c055c8ed4c4705023bfd0405f3c74db6e3ae"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/82a1c055c8ed4c4705023bfd0405f3c74db6e3ae",
|
||||
"reference": "82a1c055c8ed4c4705023bfd0405f3c74db6e3ae",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"symfony/polyfill-ctype": "^1.8",
|
||||
"symfony/polyfill-mbstring": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/container": "^1.0",
|
||||
"symfony/phpunit-bridge": "^4.4.9|^5.0.9"
|
||||
"symfony/debug": "^2.7",
|
||||
"symfony/phpunit-bridge": "^3.4.19|^4.1.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.44-dev"
|
||||
"dev-master": "2.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -286,14 +368,15 @@
|
|||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Twig Team",
|
||||
"role": "Contributors"
|
||||
},
|
||||
{
|
||||
"name": "Armin Ronacher",
|
||||
"email": "armin.ronacher@active-4.com",
|
||||
"role": "Project Founder"
|
||||
},
|
||||
{
|
||||
"name": "Twig Team",
|
||||
"homepage": "https://twig.symfony.com/contributors",
|
||||
"role": "Contributors"
|
||||
}
|
||||
],
|
||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||
|
@ -303,19 +386,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v1.44.6"
|
||||
"source": "https://github.com/twigphp/Twig/tree/v2.9.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-11-25T13:31:46+00:00"
|
||||
"time": "2019-04-28T06:57:38+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
|
@ -175,3 +175,30 @@ class Cache {
|
|||
}
|
||||
}
|
||||
|
||||
class Twig_Cache_TinyboardFilesystem extends Twig\Cache\FilesystemCache
|
||||
{
|
||||
private $directory;
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($directory, $options = 0)
|
||||
{
|
||||
parent::__construct($directory, $options);
|
||||
|
||||
$this->directory = $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function was removed in Twig 2.x due to developer views on the Twig library. Who says we can't keep it for ourselves though?
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->directory), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($file->isFile()) {
|
||||
@unlink($file->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,8 @@
|
|||
$config['check_updates'] = false;
|
||||
// How often to check for updates
|
||||
$config['check_updates_time'] = 43200; // 12 hours
|
||||
// Skip cache in twig. this is already enabled with debug
|
||||
$config['twig_auto_reload'] = true;
|
||||
|
||||
// Shows some extra information at the bottom of pages. Good for development/debugging.
|
||||
$config['debug'] = false;
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Twig_Extensions_Extension_I18n extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Returns the token parser instances to add to the existing list.
|
||||
*
|
||||
* @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Twig_Extensions_TokenParser_Trans());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFilter('trans', 'gettext'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'i18n';
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFilter('filesize', 'format_bytes'),
|
||||
new Twig_SimpleFilter('truncate', 'twig_truncate_filter'),
|
||||
new Twig_SimpleFilter('truncate_body', 'truncate'),
|
||||
new Twig_SimpleFilter('truncate_filename', 'twig_filename_truncate_filter'),
|
||||
new Twig_SimpleFilter('extension', 'twig_extension_filter'),
|
||||
new Twig_SimpleFilter('sprintf', 'sprintf'),
|
||||
new Twig_SimpleFilter('capcode', 'capcode'),
|
||||
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'),
|
||||
new Twig_SimpleFilter('remove_markup', 'remove_markup'),
|
||||
new Twig_SimpleFilter('newline_to_full_stop', 'newline_to_full_stop'),
|
||||
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'),
|
||||
new Twig_SimpleFilter('date', 'twig_date_filter'),
|
||||
new Twig_SimpleFilter('poster_id', 'poster_id'),
|
||||
new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'),
|
||||
new Twig_SimpleFilter('count', 'count'),
|
||||
new Twig_SimpleFilter('ago', 'ago'),
|
||||
new Twig_SimpleFilter('until', 'until'),
|
||||
new Twig_SimpleFilter('push', 'twig_push_filter'),
|
||||
new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'),
|
||||
new Twig_SimpleFilter('addslashes', 'addslashes'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction('time', 'time'),
|
||||
new Twig_SimpleFunction('floor', 'floor'),
|
||||
new Twig_SimpleFunction('timezone', 'twig_timezone_function'),
|
||||
new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'),
|
||||
new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'),
|
||||
new Twig_SimpleFunction('ratio', 'twig_ratio_function'),
|
||||
new Twig_SimpleFunction('secure_link_confirm', 'twig_secure_link_confirm'),
|
||||
new Twig_SimpleFunction('secure_link', 'twig_secure_link'),
|
||||
new Twig_SimpleFunction('link_for', 'link_for')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'tinyboard';
|
||||
}
|
||||
}
|
||||
|
||||
function twig_timezone_function() {
|
||||
return 'Z';
|
||||
}
|
||||
|
||||
function twig_push_filter($array, $value) {
|
||||
array_push($array, $value);
|
||||
return $array;
|
||||
}
|
||||
|
||||
function twig_remove_whitespace_filter($data) {
|
||||
return preg_replace('/[\t\r\n]/', '', $data);
|
||||
}
|
||||
|
||||
function twig_date_filter($date, $format) {
|
||||
return gmstrftime($format, $date);
|
||||
}
|
||||
|
||||
function twig_hasPermission_filter($mod, $permission, $board = null) {
|
||||
return hasPermission($permission, $board, $mod);
|
||||
}
|
||||
|
||||
function twig_extension_filter($value, $case_insensitive = true) {
|
||||
$ext = mb_substr($value, mb_strrpos($value, '.') + 1);
|
||||
if($case_insensitive)
|
||||
$ext = mb_strtolower($ext);
|
||||
return $ext;
|
||||
}
|
||||
|
||||
function twig_sprintf_filter( $value, $var) {
|
||||
return sprintf($value, $var);
|
||||
}
|
||||
|
||||
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') {
|
||||
if (mb_strlen($value) > $length) {
|
||||
if ($preserve) {
|
||||
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) {
|
||||
$length = $breakpoint;
|
||||
}
|
||||
}
|
||||
return mb_substr($value, 0, $length) . $separator;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') {
|
||||
if (mb_strlen($value) > $length) {
|
||||
$value = strrev($value);
|
||||
$array = array_reverse(explode(".", $value, 2));
|
||||
$array = array_map("strrev", $array);
|
||||
|
||||
$filename = &$array[0];
|
||||
$extension = isset($array[1]) ? $array[1] : false;
|
||||
|
||||
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator;
|
||||
|
||||
return implode(".", $array);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function twig_ratio_function($w, $h) {
|
||||
return fraction($w, $h, ':');
|
||||
}
|
||||
function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
|
||||
global $config;
|
||||
|
||||
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>';
|
||||
}
|
||||
function twig_secure_link($href) {
|
||||
return $href . '/' . make_secure_link_token($href);
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a trans node.
|
||||
*
|
||||
* @package twig
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class Twig_Extensions_Node_Trans extends Twig_Node
|
||||
{
|
||||
public function __construct(Twig_NodeInterface $body, Twig_NodeInterface $plural = null, Twig_Node_Expression $count = null, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('count' => $count, 'body' => $body, 'plural' => $plural), array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler A Twig_Compiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
list($msg, $vars) = $this->compileString($this->getNode('body'));
|
||||
|
||||
if (null !== $this->getNode('plural')) {
|
||||
list($msg1, $vars1) = $this->compileString($this->getNode('plural'));
|
||||
|
||||
$vars = array_merge($vars, $vars1);
|
||||
}
|
||||
|
||||
$function = null === $this->getNode('plural') ? 'gettext' : 'ngettext';
|
||||
|
||||
if ($vars) {
|
||||
$compiler
|
||||
->write('echo strtr('.$function.'(')
|
||||
->subcompile($msg)
|
||||
;
|
||||
|
||||
if (null !== $this->getNode('plural')) {
|
||||
$compiler
|
||||
->raw(', ')
|
||||
->subcompile($msg1)
|
||||
->raw(', abs(')
|
||||
->subcompile($this->getNode('count'))
|
||||
->raw(')')
|
||||
;
|
||||
}
|
||||
|
||||
$compiler->raw('), array(');
|
||||
|
||||
foreach ($vars as $var) {
|
||||
if ('count' === $var->getAttribute('name')) {
|
||||
$compiler
|
||||
->string('%count%')
|
||||
->raw(' => abs(')
|
||||
->subcompile($this->getNode('count'))
|
||||
->raw('), ')
|
||||
;
|
||||
} else {
|
||||
$compiler
|
||||
->string('%'.$var->getAttribute('name').'%')
|
||||
->raw(' => ')
|
||||
->subcompile($var)
|
||||
->raw(', ')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$compiler->raw("));\n");
|
||||
} else {
|
||||
$compiler
|
||||
->write('echo '.$function.'(')
|
||||
->subcompile($msg)
|
||||
;
|
||||
|
||||
if (null !== $this->getNode('plural')) {
|
||||
$compiler
|
||||
->raw(', ')
|
||||
->subcompile($msg1)
|
||||
->raw(', abs(')
|
||||
->subcompile($this->getNode('count'))
|
||||
->raw(')')
|
||||
;
|
||||
}
|
||||
|
||||
$compiler->raw(");\n");
|
||||
}
|
||||
}
|
||||
|
||||
protected function compileString(Twig_NodeInterface $body)
|
||||
{
|
||||
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) {
|
||||
return array($body, array());
|
||||
}
|
||||
|
||||
$vars = array();
|
||||
if (count($body)) {
|
||||
$msg = '';
|
||||
|
||||
foreach ($body as $node) {
|
||||
if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof Twig_Node_SetTemp) {
|
||||
$node = $node->getNode(1);
|
||||
}
|
||||
|
||||
if ($node instanceof Twig_Node_Print) {
|
||||
$n = $node->getNode('expr');
|
||||
while ($n instanceof Twig_Node_Expression_Filter) {
|
||||
$n = $n->getNode('node');
|
||||
}
|
||||
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
|
||||
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
|
||||
} else {
|
||||
$msg .= $node->getAttribute('data');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$msg = $body->getAttribute('data');
|
||||
}
|
||||
|
||||
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars);
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return Twig_NodeInterface A Twig_NodeInterface instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
$count = null;
|
||||
$plural = null;
|
||||
|
||||
if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
|
||||
$body = $this->parser->getExpressionParser()->parseExpression();
|
||||
} else {
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$body = $this->parser->subparse(array($this, 'decideForFork'));
|
||||
if ('plural' === $stream->next()->getValue()) {
|
||||
$count = $this->parser->getExpressionParser()->parseExpression();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$plural = $this->parser->subparse(array($this, 'decideForEnd'), true);
|
||||
}
|
||||
}
|
||||
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
$this->checkTransString($body, $lineno);
|
||||
|
||||
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag());
|
||||
}
|
||||
|
||||
public function decideForFork(Twig_Token $token)
|
||||
{
|
||||
return $token->test(array('plural', 'endtrans'));
|
||||
}
|
||||
|
||||
public function decideForEnd(Twig_Token $token)
|
||||
{
|
||||
return $token->test('endtrans');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tag name associated with this token parser.
|
||||
*
|
||||
* @param string The tag name
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return 'trans';
|
||||
}
|
||||
|
||||
protected function checkTransString(Twig_NodeInterface $body, $lineno)
|
||||
{
|
||||
foreach ($body as $i => $node) {
|
||||
if (
|
||||
$node instanceof Twig_Node_Text
|
||||
||
|
||||
($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_Name)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2698,75 +2698,75 @@ function mod_new_pm($username) {
|
|||
}
|
||||
|
||||
function mod_rebuild() {
|
||||
global $config, $twig;
|
||||
|
||||
if (!hasPermission($config['mod']['rebuild']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
if (isset($_POST['rebuild'])) {
|
||||
@set_time_limit($config['mod']['rebuild_timelimit']);
|
||||
|
||||
$log = array();
|
||||
$boards = listBoards();
|
||||
$rebuilt_scripts = array();
|
||||
|
||||
if (isset($_POST['rebuild_cache'])) {
|
||||
if ($config['cache']['enabled']) {
|
||||
$log[] = 'Flushing cache';
|
||||
Cache::flush();
|
||||
}
|
||||
|
||||
$log[] = 'Clearing template cache';
|
||||
load_twig();
|
||||
$twig->clearCacheFiles();
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_themes'])) {
|
||||
$log[] = 'Regenerating theme files';
|
||||
rebuildThemes('all');
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_javascript'])) {
|
||||
$log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>';
|
||||
buildJavascript();
|
||||
$rebuilt_scripts[] = $config['file_script'];
|
||||
}
|
||||
|
||||
foreach ($boards as $board) {
|
||||
if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']])))
|
||||
continue;
|
||||
|
||||
openBoard($board['uri']);
|
||||
$config['try_smarter'] = false;
|
||||
|
||||
if (isset($_POST['rebuild_index'])) {
|
||||
buildIndex();
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages';
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) {
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>';
|
||||
buildJavascript();
|
||||
$rebuilt_scripts[] = $config['file_script'];
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_thread'])) {
|
||||
$query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
|
||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id'];
|
||||
buildThread($post['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod_page(_('Rebuild'), 'mod/rebuilt.html', array('logs' => $log));
|
||||
return;
|
||||
}
|
||||
|
||||
mod_page(_('Rebuild'), 'mod/rebuild.html', array(
|
||||
'boards' => listBoards(),
|
||||
'token' => make_secure_link_token('rebuild')
|
||||
));
|
||||
global $config, $twig;
|
||||
|
||||
if (!hasPermission($config['mod']['rebuild']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
if (isset($_POST['rebuild'])) {
|
||||
@set_time_limit($config['mod']['rebuild_timelimit']);
|
||||
|
||||
$log = array();
|
||||
$boards = listBoards();
|
||||
$rebuilt_scripts = array();
|
||||
|
||||
if (isset($_POST['rebuild_cache'])) {
|
||||
if ($config['cache']['enabled']) {
|
||||
$log[] = 'Flushing cache';
|
||||
Cache::flush();
|
||||
}
|
||||
|
||||
$log[] = 'Clearing template cache';
|
||||
load_twig();
|
||||
$twig->getCache()->clear();
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_themes'])) {
|
||||
$log[] = 'Regenerating theme files';
|
||||
rebuildThemes('all');
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_javascript'])) {
|
||||
$log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>';
|
||||
buildJavascript();
|
||||
$rebuilt_scripts[] = $config['file_script'];
|
||||
}
|
||||
|
||||
foreach ($boards as $board) {
|
||||
if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']])))
|
||||
continue;
|
||||
|
||||
openBoard($board['uri']);
|
||||
$config['try_smarter'] = false;
|
||||
|
||||
if (isset($_POST['rebuild_index'])) {
|
||||
buildIndex();
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages';
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) {
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>';
|
||||
buildJavascript();
|
||||
$rebuilt_scripts[] = $config['file_script'];
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_thread'])) {
|
||||
$query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
|
||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id'];
|
||||
buildThread($post['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod_page(_('Rebuild'), $config['file_mod_rebuilt'], array('logs' => $log));
|
||||
return;
|
||||
}
|
||||
|
||||
mod_page(_('Rebuild'), $config['file_mod_rebuild'], array(
|
||||
'boards' => listBoards(),
|
||||
'token' => make_secure_link_token('rebuild')
|
||||
));
|
||||
}
|
||||
|
||||
function mod_reports() {
|
||||
|
|
151
inc/template.php
151
inc/template.php
|
@ -13,16 +13,20 @@ $twig = false;
|
|||
|
||||
function load_twig() {
|
||||
global $twig, $config;
|
||||
$loader = new Twig_Loader_Filesystem($config['dir']['template']);
|
||||
|
||||
$loader = new Twig\Loader\FilesystemLoader($config['dir']['template']);
|
||||
$loader->setPaths($config['dir']['template']);
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
$twig = new Twig\Environment($loader, array(
|
||||
'autoescape' => false,
|
||||
'cache' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')) ?
|
||||
"{$config['dir']['template']}/cache" : false,
|
||||
'debug' => $config['debug']
|
||||
new Twig_Cache_TinyboardFilesystem("{$config['dir']['template']}/cache") : false,
|
||||
'debug' => $config['debug'],
|
||||
'auto_reload' => $config['twig_auto_reload']
|
||||
));
|
||||
$twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
|
||||
$twig->addExtension(new Twig_Extensions_Extension_I18n());
|
||||
if ($config['debug'])
|
||||
$twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$twig->addExtension(new Tinyboard());
|
||||
$twig->addExtension(new PhpMyAdmin\Twig\Extensions\I18nExtension());
|
||||
}
|
||||
|
||||
function Element($templateFile, array $options) {
|
||||
|
@ -70,3 +74,138 @@ function Element($templateFile, array $options) {
|
|||
}
|
||||
}
|
||||
|
||||
class Tinyboard extends Twig\Extension\AbstractExtension
|
||||
{
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new Twig\TwigFilter('filesize', 'format_bytes'),
|
||||
new Twig\TwigFilter('truncate', 'twig_truncate_filter'),
|
||||
new Twig\TwigFilter('truncate_body', 'truncate'),
|
||||
new Twig\TwigFilter('truncate_filename', 'twig_filename_truncate_filter'),
|
||||
new Twig\TwigFilter('extension', 'twig_extension_filter'),
|
||||
new Twig\TwigFilter('sprintf', 'sprintf'),
|
||||
new Twig\TwigFilter('capcode', 'capcode'),
|
||||
new Twig\TwigFilter('remove_modifiers', 'remove_modifiers'),
|
||||
new Twig\TwigFilter('hasPermission', 'twig_hasPermission_filter'),
|
||||
new Twig\TwigFilter('date', 'twig_date_filter'),
|
||||
new Twig\TwigFilter('poster_id', 'poster_id'),
|
||||
new Twig\TwigFilter('remove_whitespace', 'twig_remove_whitespace_filter'),
|
||||
new Twig\TwigFilter('count', 'count'),
|
||||
new Twig\TwigFilter('ago', 'ago'),
|
||||
new Twig\TwigFilter('until', 'until'),
|
||||
new Twig\TwigFilter('push', 'twig_push_filter'),
|
||||
new Twig\TwigFilter('bidi_cleanup', 'bidi_cleanup'),
|
||||
new Twig\TwigFilter('addslashes', 'addslashes'),
|
||||
new Twig\TwigFilter('cloak_ip', 'cloak_ip'),
|
||||
new Twig\TwigFilter('cloak_mask', 'cloak_mask'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig\TwigFunction('time', 'time'),
|
||||
new Twig\TwigFunction('floor', 'floor'),
|
||||
new Twig\TwigFunction('timezone', 'twig_timezone_function'),
|
||||
new Twig\TwigFunction('hiddenInputs', 'hiddenInputs'),
|
||||
new Twig\TwigFunction('hiddenInputsHash', 'hiddenInputsHash'),
|
||||
new Twig\TwigFunction('ratio', 'twig_ratio_function'),
|
||||
new Twig\TwigFunction('secure_link_confirm', 'twig_secure_link_confirm'),
|
||||
new Twig\TwigFunction('secure_link', 'twig_secure_link'),
|
||||
new Twig\TwigFunction('link_for', 'link_for')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'tinyboard';
|
||||
}
|
||||
}
|
||||
|
||||
function twig_timezone_function() {
|
||||
return 'Z';
|
||||
}
|
||||
|
||||
function twig_push_filter($array, $value) {
|
||||
array_push($array, $value);
|
||||
return $array;
|
||||
}
|
||||
|
||||
function twig_remove_whitespace_filter($data) {
|
||||
return preg_replace('/[\t\r\n]/', '', $data);
|
||||
}
|
||||
|
||||
function twig_date_filter($date, $format) {
|
||||
return gmstrftime($format, $date);
|
||||
}
|
||||
|
||||
function twig_hasPermission_filter($mod, $permission, $board = null) {
|
||||
return hasPermission($permission, $board, $mod);
|
||||
}
|
||||
|
||||
function twig_extension_filter($value, $case_insensitive = true) {
|
||||
$ext = mb_substr($value, mb_strrpos($value, '.') + 1);
|
||||
if($case_insensitive)
|
||||
$ext = mb_strtolower($ext);
|
||||
return $ext;
|
||||
}
|
||||
|
||||
function twig_sprintf_filter( $value, $var) {
|
||||
return sprintf($value, $var);
|
||||
}
|
||||
|
||||
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') {
|
||||
if (mb_strlen($value) > $length) {
|
||||
if ($preserve) {
|
||||
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) {
|
||||
$length = $breakpoint;
|
||||
}
|
||||
}
|
||||
return mb_substr($value, 0, $length) . $separator;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') {
|
||||
if (mb_strlen($value) > $length) {
|
||||
$value = strrev($value);
|
||||
$array = array_reverse(explode(".", $value, 2));
|
||||
$array = array_map("strrev", $array);
|
||||
|
||||
$filename = &$array[0];
|
||||
$extension = isset($array[1]) ? $array[1] : false;
|
||||
|
||||
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator;
|
||||
|
||||
return implode(".", $array);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function twig_ratio_function($w, $h) {
|
||||
return fraction($w, $h, ':');
|
||||
}
|
||||
function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
|
||||
global $config;
|
||||
|
||||
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>';
|
||||
}
|
||||
function twig_secure_link($href) {
|
||||
return $href . '/' . make_secure_link_token($href);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
{# Automatically removes unnecessary whitespace #}
|
||||
<div class="ban">
|
||||
<iframe width="420" height="315" src="https://www.youtube.com/embed/FXPKJUE86d0" frameborder="0" allowfullscreen></iframe>
|
||||
|
@ -143,4 +143,4 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -31,15 +31,17 @@
|
|||
{% if errors or warnings %}
|
||||
<p><strong>There were {{ errors }} error(s) and {{ warnings }} warning(s).</strong></p>
|
||||
<ul>
|
||||
{% for test in tests if not test.result%}
|
||||
<li style="margin-bottom:5px">
|
||||
{% if test.required %}
|
||||
<i style="font-size:11pt;color:#d00" class="fa fa-exclamation"></i> <strong>Error:</strong>
|
||||
{% else %}
|
||||
<i style="font-size:11pt;color:#f80" class="fa fa-warning"></i> <strong>Warning:</strong>
|
||||
{% endif %}
|
||||
{{ test.message }}
|
||||
</li>
|
||||
{% for test in tests %}
|
||||
{% if not test.result %}
|
||||
<li style="margin-bottom:5px">
|
||||
{% if test.required %}
|
||||
<i style="font-size:11pt;color:#d00" class="fa fa-exclamation"></i> <strong>Error:</strong>
|
||||
{% else %}
|
||||
<i style="font-size:11pt;color:#f80" class="fa fa-warning"></i> <strong>Warning:</strong>
|
||||
{% endif %}
|
||||
{{ test.message }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if errors %}
|
||||
|
|
|
@ -2,15 +2,17 @@
|
|||
<p>
|
||||
Any changes you make here will simply be appended to <code>{{ file }}</code>. If you wish to make the most of Tinyboard's customizability, you can instead edit the file directly. This page is intended for making quick changes and for those who don't have a basic understanding of PHP code.
|
||||
</p>
|
||||
{% if boards|count %}
|
||||
{% if boards|length %}
|
||||
<ul>
|
||||
{% if board %}
|
||||
<li><a href="?/config">Edit site-wide config</a></li>
|
||||
{% endif %}
|
||||
{% for _board in boards if _board.uri != board %}
|
||||
<li>
|
||||
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
|
||||
</li>
|
||||
{% for _board in boards %}
|
||||
{% if _board.uri != board %}
|
||||
<li>
|
||||
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
{% if board %}
|
||||
<li><a href="?/config">Edit site-wide config</a></li>
|
||||
{% endif %}
|
||||
{% for _board in boards if _board.uri != board %}
|
||||
<li>
|
||||
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
|
||||
</li>
|
||||
{% for _board in boards %}
|
||||
{% if _board.uri != board %}
|
||||
<li>
|
||||
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@ -38,38 +40,48 @@
|
|||
{% endif %}
|
||||
</th>
|
||||
|
||||
<td>
|
||||
{% if var.type == 'string' %}
|
||||
<input name="{{ name }}" type="text" value="{{ var.value|e }}">
|
||||
{% elseif var.permissions %}
|
||||
<select name="{{ name }}">
|
||||
{% for group_value, group_name in config.mod.groups %}
|
||||
<option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}>
|
||||
{{ group_name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% elseif var.type == 'integer' %}
|
||||
<input name="{{ name }}" type="number" value="{{ var.value|e }}">
|
||||
{% elseif var.type == 'boolean' %}
|
||||
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th class="minimal">
|
||||
{% if var.name|length == 1 %}
|
||||
{{ var.name }}
|
||||
{% else %}
|
||||
{{ var.name|join(' → ') }}
|
||||
{% endif %}
|
||||
</th>
|
||||
|
||||
{% if var.type == 'integer' or var.type == 'boolean' %}
|
||||
<small>Default: <code>{{ var.default }}</code></small>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="minimal">
|
||||
{{ var.type|e }}
|
||||
</td>
|
||||
|
||||
<td style="word-wrap:break-word;width:50%">
|
||||
{{ var.comment|join(' ') }}
|
||||
</td>
|
||||
</tr>
|
||||
<td>
|
||||
{% if var.type == 'string' %}
|
||||
<input name="{{ name }}" type="text" value="{{ var.value|e }}">
|
||||
{% elseif var.permissions %}
|
||||
<select name="{{ name }}">
|
||||
{% for group_value, group_name in config.mod.groups %}
|
||||
<option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}>
|
||||
{{ group_name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% elseif var.type == 'integer' %}
|
||||
<input name="{{ name }}" type="number" value="{{ var.value|e }}">
|
||||
{% elseif var.type == 'boolean' %}
|
||||
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
|
||||
{% if var.type == 'integer' or var.type == 'boolean' %}
|
||||
<small>Default: <code>{{ var.default }}</code></small>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="minimal">
|
||||
{{ var.type|e }}
|
||||
</td>
|
||||
|
||||
<td style="word-wrap:break-word;width:50%">
|
||||
{{ var.comment|join(' ') }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
{% endif %}
|
||||
|
||||
{% if config.mod.dashboard_links|length %}
|
||||
{% if config.mod.dashboard_links and config.mod.dashboard_links|length %}
|
||||
|
||||
{% for label,link in config.mod.dashboard_links %}
|
||||
<li><a href="{{ link }}">{{ label }}</a></li>
|
||||
|
|
|
@ -6,13 +6,15 @@
|
|||
<th class="minimal">Expires</th>
|
||||
<th class="minimal">Size</th>
|
||||
</tr>
|
||||
{% for var in cached_vars if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %}
|
||||
<tr>
|
||||
<td class="minimal">{{ var.key is defined ? var.key : var.info }}</td>
|
||||
<td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td>
|
||||
<td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td>
|
||||
<td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td>
|
||||
<td class="minimal">{{ var.mem_size }} bytes</td>
|
||||
</tr>
|
||||
{% for var in cached_vars %}
|
||||
{% if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %}
|
||||
<tr>
|
||||
<td class="minimal">{{ var.key is defined ? var.key : var.info }}</td>
|
||||
<td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td>
|
||||
<td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td>
|
||||
<td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td>
|
||||
<td class="minimal">{{ var.mem_size }} bytes</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
|
@ -33,7 +33,7 @@
|
|||
</table>
|
||||
|
||||
<p style="text-align:center">
|
||||
Most recent {{ posts|count }} posts:
|
||||
Most recent {{ posts|length }} posts:
|
||||
</p>
|
||||
<table class="modlog" style="word-wrap: break-word;">
|
||||
<tr>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if not messages %}
|
||||
{% if messages|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">({% trans 'No private messages for you.' %})</p>
|
||||
{% else %}
|
||||
<table class="modlog">
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% if count > logs|count %}
|
||||
{% if count > logs|length %}
|
||||
<p class="unimportant" style="text-align:center;word-wrap:break-word">
|
||||
{% for i in range(0, (count - 1) / config.mod.modlog_page) %}
|
||||
{% if public %}
|
||||
|
|
|
@ -22,13 +22,15 @@
|
|||
<th>{% trans 'Target board' %}</th>
|
||||
<td>
|
||||
<ul style="list-style:none;padding:0">
|
||||
{% for targetboard in boards if targetboard.uri != board %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}>
|
||||
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
|
||||
</label>
|
||||
</li>
|
||||
{% for targetboard in boards %}
|
||||
{% if targetboard.uri != board %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
|
||||
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
|
||||
</label>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<ul style="list-style:none;padding:0">
|
||||
{% for targetboard in boards %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}>
|
||||
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
|
||||
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
|
||||
</label>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if count > news|count %}
|
||||
{% if count > news|length %}
|
||||
<p class="unimportant" style="text-align:center;word-wrap:break-word">
|
||||
{% for i in range(0, (count - 1) / config.mod.news_page) %}
|
||||
<a href="?/news/{{ i + 1 }}">[{{ i + 1 }}]</a>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if count > noticeboard|count %}
|
||||
{% if count > noticeboard|length %}
|
||||
<p class="unimportant" style="text-align:center;word-wrap:break-word">
|
||||
{% for i in range(0, (count - 1) / config.mod.noticeboard_page) %}
|
||||
<a href="?/noticeboard/{{ i + 1 }}">[{{ i + 1 }}]</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script src="{{ config.additional_javascript_url }}js/mod/recent_posts.js"></script>
|
||||
<script src="{{ config.additional_javascript_url }}js/mod/recent-posts-auto-reload.js"></script>
|
||||
{% if not posts %}
|
||||
{% if not posts|length %}
|
||||
<p style="text-align:center" class="unimportant">({% trans 'There are no active posts.' %})</p>
|
||||
{% else %}
|
||||
<h4>Viewing last {{ limit|e }} posts</h4>
|
||||
|
|
|
@ -259,7 +259,7 @@
|
|||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% if result_count > results|count %}
|
||||
{% if result_count > results|length %}
|
||||
<p class="unimportant" style="text-align:center;word-wrap:break-word">
|
||||
{% for i in range(0, (result_count - 1) / config.mod.search_page) %}
|
||||
<a href="?/search/{{ search_type }}/{{ search_query_escaped }}/{{ i + 1 }}">[{{ i + 1 }}]</a>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if not themes %}
|
||||
{% if themes|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">({% trans 'There are no themes available.' %})</p>
|
||||
{% else %}
|
||||
<table class="modlog">
|
||||
|
|
|
@ -32,11 +32,13 @@
|
|||
<th>{% trans 'Group' %}</th>
|
||||
<td>
|
||||
<ul style="padding:5px 8px;list-style:none">
|
||||
{% for group_value, group_name in config.mod.groups if group_name != 'Disabled' %}
|
||||
<li>
|
||||
<input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}">
|
||||
<label for="group_{{ group_name }}">{% trans group_name %}</label>
|
||||
</li>
|
||||
{% for group_value, group_name in config.mod.groups %}
|
||||
{% if group_name != 'Disabled' %}
|
||||
<li>
|
||||
<input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}">
|
||||
<label for="group_{{ group_name }}">{% trans group_name %}</label>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
|
@ -87,7 +89,7 @@
|
|||
</ul>
|
||||
</form>
|
||||
|
||||
{% if logs and logslength > 0 %}
|
||||
{% if logs and logs|length > 0 %}
|
||||
<table class="modlog" style="width:600px">
|
||||
<tr>
|
||||
<th>{% trans 'IP address' %}</th>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% if mod|hasPermission(config.mod.view_notes) %}
|
||||
<fieldset id="notes">
|
||||
<legend>
|
||||
{% set notes_on_record = 'note' ~ (notes|count != 1 ? 's' : '') ~ ' on record' %}
|
||||
<legend>{{ notes|count }} {% trans notes_on_record %}</legend>
|
||||
{% set notes_length = notes|length %}
|
||||
<legend>{{ notes_length }} {% trans %}note on record{% plural notes_length %}notes on record{% endtrans %}</legend>
|
||||
</legend>
|
||||
|
||||
{% if notes and notes|length > 0 %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
{# Automatically removes unnecessary whitespace #}
|
||||
<div class="ban">
|
||||
<h2>You are not banned!</h2>
|
||||
<p class="reason">Well done on not being terrible!</p>
|
||||
</div>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
{# tabs and new lines will be ignored #}
|
||||
<div class="post reply" id="reply_{{ post.id }}" data-board="{{ board.uri }}">
|
||||
<p class="intro">
|
||||
|
@ -18,7 +18,7 @@
|
|||
{% include 'post/fileinfo.html' %}
|
||||
{% include 'post/post_controls.html' %}
|
||||
<div class="body" {% if post.files|length > 1 %}style="clear:both"{% endif %}>
|
||||
{% endfilter %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% filter remove_whitespace %}
|
||||
{% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply spaceless %}
|
||||
{% if post.modifiers['ban message'] %}
|
||||
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
|
||||
{% endif %}
|
||||
|
@ -27,5 +27,5 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</br>
|
||||
{% endfilter %}
|
||||
<br/>
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
{# tabs and new lines will be ignored #}
|
||||
|
||||
<div class="thread" id="thread_{{ post.id }}" data-board="{{ board.uri }}">
|
||||
|
@ -58,7 +58,7 @@
|
|||
{% include 'post/post_controls.html' %}
|
||||
</p>
|
||||
<div class="body">
|
||||
{% endfilter %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% filter remove_whitespace %}
|
||||
{% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply spaceless %}
|
||||
{% if post.modifiers['ban message'] %}
|
||||
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
|
||||
{% endif %}
|
||||
|
@ -89,7 +89,7 @@
|
|||
{% endif %}
|
||||
{% if not index %}
|
||||
{% endif %}
|
||||
</div>{% endfilter %}
|
||||
</div>{% endapply %}
|
||||
{% set iparray = [post.ip] %}
|
||||
{% set hr = post.hr %}
|
||||
{% for post in post.posts %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
{# tabs and new lines will be ignored #}
|
||||
|
||||
{# we are intentionally breaking the thread_ID convention: the jses need to handle this case differently #}
|
||||
|
@ -39,4 +39,4 @@
|
|||
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}Reply{% endtrans %}]</a>
|
||||
|
||||
</tr>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<img src="static/lain_is_cute_datass_small_teal.png" alt="mascot"/>
|
||||
</center>
|
||||
<div class="ban">
|
||||
{% if not news %}
|
||||
{% if news|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">(No news to show.)</p>
|
||||
{% else %}
|
||||
{% for entry in news %}
|
||||
|
@ -54,4 +54,4 @@
|
|||
{% endraw %}</script>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -112,4 +112,4 @@
|
|||
{% endraw %}</script>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<div class="introduction">
|
||||
<style style="display:none;">
|
||||
.home-logo {
|
||||
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
<div class="content">
|
||||
<div class="ban">
|
||||
{% if not news %}
|
||||
{% if news|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p>
|
||||
{% else %}
|
||||
{% for entry in news %}
|
||||
|
@ -107,5 +107,4 @@
|
|||
<br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
|
||||
</footer>
|
||||
</div>
|
||||
{% endfilter %}
|
||||
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<div class="sidebar">
|
||||
<fieldset>
|
||||
<legend>{{ settings.title }}</legend>
|
||||
|
@ -42,4 +42,4 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</header>
|
||||
|
||||
<div class="ban">
|
||||
{% if not news %}
|
||||
{% if news|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">(No news to show.)</p>
|
||||
{% else %}
|
||||
{% for entry in news %}
|
||||
|
@ -38,4 +38,4 @@
|
|||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -38,4 +38,4 @@
|
|||
</fieldset>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -98,4 +98,4 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
version="2.0">
|
||||
|
@ -25,4 +25,4 @@
|
|||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% filter remove_whitespace %}
|
||||
{% apply spaceless %}
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
{% for board in boards %}
|
||||
|
@ -16,4 +16,4 @@
|
|||
{% endfor %}
|
||||
{% endfor %}
|
||||
</urlset>
|
||||
{% endfilter %}
|
||||
{% endapply %}
|
||||
|
|
|
@ -42,7 +42,7 @@ if(!$options['quiet'])
|
|||
echo "Clearing template cache...\n";
|
||||
|
||||
load_twig();
|
||||
$twig->clearCacheFiles();
|
||||
$twig->getCache()->clear();
|
||||
|
||||
if(!$options['quiet'])
|
||||
echo "Regenerating theme files...\n";
|
||||
|
|
|
@ -44,7 +44,7 @@ echo "== Tinyboard + vichan {$config['version']} ==\n";
|
|||
if ($options['cache']) {
|
||||
echo "Clearing template cache...\n";
|
||||
load_twig();
|
||||
$twig->clearCacheFiles();
|
||||
$twig->getCache()->clear();
|
||||
}
|
||||
|
||||
if($options['themes']) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user