From d2de4419bddbb7b0e09ced1f01d3ccb45aecc50f Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 14 Jan 2016 21:05:24 +0100 Subject: Added: config option to hide email in post. (prevent emailfag but let the possibility to sage and noko) --- templates/post/name.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/post/name.html b/templates/post/name.html index 13c676c7..e7f85f8b 100644 --- a/templates/post/name.html +++ b/templates/post/name.html @@ -1,5 +1,5 @@ {% set capcode = post.capcode|capcode %} -{% if post.email|length > 0 and (config.hide_sage!=true or post.email!='sage') %} +{% if post.email|length > 0 and (config.hide_sage!=true or post.email!='sage') and config.hide_email!=true %} {# start email #} {% endif %} @@ -7,7 +7,7 @@ {% if post.trip|length > 0 %} {{ post.trip }} {% endif %} -{% if post.email|length > 0 %} +{% if post.email|length > 0 and (config.hide_sage!=true or post.email!='sage') and config.hide_email!=true %} {# end email #} {% endif %} -- cgit v1.3 From 028fd3df15b2e2edc96c5b84156b0b039ea16562 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 14 Jan 2016 20:16:51 +0100 Subject: Added: RSS theme --- templates/themes/rss/info.php | 61 ++++++++++++++++++++ templates/themes/rss/rss.xml | 28 ++++++++++ templates/themes/rss/theme.php | 124 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100755 templates/themes/rss/info.php create mode 100644 templates/themes/rss/rss.xml create mode 100755 templates/themes/rss/theme.php (limited to 'templates') diff --git a/templates/themes/rss/info.php b/templates/themes/rss/info.php new file mode 100755 index 00000000..14b39eb9 --- /dev/null +++ b/templates/themes/rss/info.php @@ -0,0 +1,61 @@ + 'Title', + 'name' => 'title', + 'type' => 'text', + 'default' => 'Recent Posts RSS' + ); + + $theme['config'][] = Array( + 'title' => 'Excluded boards', + 'name' => 'exclude', + 'type' => 'text', + 'comment' => '(space seperated)' + ); + + $theme['config'][] = Array( + 'title' => '# of recent posts', + 'name' => 'limit_posts', + 'type' => 'text', + 'default' => '30', + 'comment' => '(maximum posts to display)' + ); + + $theme['config'][] = Array( + 'title' => 'XML file', + 'name' => 'xml', + 'type' => 'text', + 'default' => 'recent.xml', + 'comment' => '(eg. "recent.xml")' + ); + + $theme['config'][] = Array( + 'title' => 'Base URL', + 'name' => 'base_url', + 'type' => 'text', + 'default' => 'http://test.com', + 'comment' => '(eg. "http://test.com")' + ); + + // Unique function name for building everything + $theme['build_function'] = 'rss_recentposts_build'; + $theme['install_callback'] = 'rss_recentposts_install'; + + if (!function_exists('rss_recentposts_install')) { + function rss_recentposts_install($settings) { + if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0) + return Array(false, '' . utf8tohtml($settings['limit_posts']) . ' is not a non-negative integer.'); + } + } + diff --git a/templates/themes/rss/rss.xml b/templates/themes/rss/rss.xml new file mode 100644 index 00000000..30fdb473 --- /dev/null +++ b/templates/themes/rss/rss.xml @@ -0,0 +1,28 @@ +{% filter remove_whitespace %} + + + + + + + {{ settings.title }} + Tinyboard {{ config.version }} + {{ settings.base_url }}{{ config.root }}{{ settings.html }} + {% for post in recent_posts %} + + {{ post.board_name }} + + + {{ post.snippet }} + + ]]> + + {{ settings.base_url }}{{ post.link }} + {{ settings.base_url }}{{ post.link }} + + {% endfor %} + + +{% endfilter %} diff --git a/templates/themes/rss/theme.php b/templates/themes/rss/theme.php new file mode 100755 index 00000000..33c1b210 --- /dev/null +++ b/templates/themes/rss/theme.php @@ -0,0 +1,124 @@ +build($action, $settings); + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class RSSRecentPosts { + public function build($action, $settings) { + global $config, $_theme; + + /*if ($action == 'all') { + copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); + }*/ + + $this->excluded = explode(' ', $settings['exclude']); + + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . $settings['xml'], $this->homepage($settings)); + } + + // Build news page + public function homepage($settings) { + global $config, $board; + + //$recent_images = Array(); + $recent_posts = Array(); + //$stats = Array(); + + $boards = listBoards(); + + /*$query = ''; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query); + $query = query($query) or error(db_error()); + + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + openBoard($post['board']); + + // board settings won't be available in the template file, so generate links now + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['src'] = $config['uri_thumb'] . $post['thumb']; + + //$recent_images[] = $post; + }*/ + + + $query = ''; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query); + $query = query($query) or error(db_error()); + + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + openBoard($post['board']); + + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['snippet'] = pm_snippet($post['body'], 30); + $post['board_name'] = $board['name']; + + $recent_posts[] = $post; + } + + // Total posts + /*$query = 'SELECT SUM(`top`) FROM ('; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error());*/ + //$stats['total_posts'] = number_format($query->fetchColumn()); + + // Unique IPs + /*$query = 'SELECT COUNT(DISTINCT(`ip`)) FROM ('; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + //$stats['unique_posters'] = number_format($query->fetchColumn());*/ + + // Active content + /*$query = 'SELECT SUM(`filesize`) FROM ('; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT `filesize` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + //$stats['active_content'] = $query->fetchColumn();*/ + + return Element('themes/rss/rss.xml', Array( + 'settings' => $settings, + 'config' => $config, + //'boardlist' => createBoardlist(), + //'recent_images' => $recent_images, + 'recent_posts' => $recent_posts, + //'stats' => $stats + )); + } + }; + +?> -- cgit v1.3 From 199931dc1a609503932848be9a276e1d2275d881 Mon Sep 17 00:00:00 2001 From: 27chan <27chan@openmailbox.org> Date: Fri, 29 Apr 2016 18:00:33 -0300 Subject: Fix default theme and add Font Awesome Icons --- templates/themes/recent/recent.html | 2 ++ 1 file changed, 2 insertions(+) (limited to 'templates') diff --git a/templates/themes/recent/recent.html b/templates/themes/recent/recent.html index 31c839e7..75880484 100644 --- a/templates/themes/recent/recent.html +++ b/templates/themes/recent/recent.html @@ -7,6 +7,8 @@ {% if config.url_favicon %}{% endif %} + {% if config.default_stylesheet.1 != '' %}{% endif %} + {% if config.font_awesome %}{% endif %} {{ boardlist.top }} -- cgit v1.3 From 8dac72e924d658e66c5efe3334aa8ab41d00daca Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 5 May 2016 09:16:09 +0200 Subject: update installer --- install.php | 103 +++++++++++++++++++++++++++------------- templates/installer/config.html | 3 ++ 2 files changed, 73 insertions(+), 33 deletions(-) (limited to 'templates') diff --git a/install.php b/install.php index 968c41de..7a146c8e 100644 --- a/install.php +++ b/install.php @@ -581,6 +581,25 @@ if (file_exists($config['has_installed'])) { die(Element('page.html', $page)); } +function create_config_from_array(&$instance_config, &$array, $prefix = '') { + foreach ($array as $name => $value) { + if (is_array($value)) { + $instance_config .= "\n"; + create_config_from_array($instance_config, $value, $prefix . '[\'' . addslashes($name) . '\']'); + $instance_config .= "\n"; + } else { + $instance_config .= ' $config' . $prefix . '[\'' . addslashes($name) . '\'] = '; + + if (is_numeric($value)) + $instance_config .= $value; + else + $instance_config .= "'" . addslashes($value) . "'"; + + $instance_config .= ";\n"; + } + } +} + if ($step == 0) { // Agreeement $page['body'] = ' @@ -614,7 +633,7 @@ if ($step == 0) { 'installed' => extension_loaded('pdo'), 'required' => true ), - 'PDO' => array( + 'GD' => array( 'installed' => extension_loaded('gd'), 'required' => true ), @@ -627,17 +646,17 @@ if ($step == 0) { $tests = array( array( 'category' => 'PHP', - 'name' => 'PHP ≥ 5.3', - 'result' => PHP_VERSION_ID >= 50300, + 'name' => 'PHP ≥ 5.4', + 'result' => PHP_VERSION_ID >= 50400, 'required' => true, - 'message' => 'vichan requires PHP 5.3 or better.', + 'message' => 'vichan requires PHP 5.4 or better.', ), array( 'category' => 'PHP', - 'name' => 'PHP ≥ 5.4', - 'result' => PHP_VERSION_ID >= 50400, + 'name' => 'PHP ≥ 5.6', + 'result' => PHP_VERSION_ID >= 50600, 'required' => false, - 'message' => 'vichan works best on PHP 5.4 or better.', + 'message' => 'vichan works best on PHP 5.6 or better.', ), array( 'category' => 'PHP', @@ -694,6 +713,7 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which convert'), 'required' => false, 'message' => '(Optional) `convert` was not found or executable; command-line ImageMagick image processing cannot be enabled.', + 'effect' => function (&$config) { $config['thumb_method'] = 'convert'; }, ), array( 'category' => 'Image processing', @@ -708,6 +728,7 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which gm'), 'required' => false, 'message' => '(Optional) `gm` was not found or executable; command-line GraphicsMagick (faster than ImageMagick) cannot be enabled.', + 'effect' => function (&$config) { $config['thumb_method'] = 'gm'; }, ), array( 'category' => 'Image processing', @@ -715,13 +736,25 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which gifsicle'), 'required' => false, 'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.', + 'effect' => function (&$config) { if ($config['thumb_method'] == 'gm') $config['thumb_method'] = 'gm+gifsicle'; + if ($config['thumb_method'] == 'convert') $config['thumb_method'] = 'convert+gifsicle'; }, ), array( 'category' => 'Image processing', - 'name' => '`md5sum` (quick file hashing)', + 'name' => '`md5sum` (quick file hashing on GNU/Linux)', + 'prereq' => '', 'result' => $can_exec && shell_exec('echo "vichan" | md5sum') == "141225c362da02b5c359c45b665168de -\n", 'required' => false, - 'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower.', + 'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower. Ignore if not using Linux.', + 'effect' => function (&$config) { $config['gnu_md5'] = true; }, + ), + array( + 'category' => 'Image processing', + 'name' => '`/sbin/md5` (quick file hashing on BSDs)', + 'result' => $can_exec && shell_exec('echo "vichan" | /sbin/md5 -r') == "141225c362da02b5c359c45b665168de\n", + 'required' => false, + 'message' => '(Optional) `/sbin/md5` was not found or executable; file hashing for multiple images will be slower. Ignore if not using BSD.', + 'effect' => function (&$config) { $config['bsd_md5'] = true; }, ), array( 'category' => 'File permissions', @@ -737,6 +770,13 @@ if ($step == 0) { 'required' => true, 'message' => 'You must give vichan permission to create (and write to) the templates/cache directory or performance will be drastically reduced.' ), + array( + 'category' => 'File permissions', + 'name' => getcwd() . '/tmp/cache', + 'result' => is_dir('tmp/cache') && is_writable('tmp/cache'), + 'required' => true, + 'message' => 'You must give vichan permission to write to the tmp/cache directory.' + ), array( 'category' => 'File permissions', 'name' => getcwd() . '/inc/instance-config.php', @@ -760,17 +800,27 @@ if ($step == 0) { 'message' => 'vichan is still beta software and it\'s not going to come out of beta any time soon. As there are often many months between releases yet changes and bug fixes are very frequent, it\'s recommended to use the git repository to maintain your vichan installation. Using git makes upgrading much easier.' ) ); - + $config['font_awesome'] = true; + $additional_config = array(); + foreach ($tests as $test) { + if ($test['result'] && $test['effect']) { + $test['effect']($additional_config); + } + } + $more = ''; + create_config_from_array($more, $additional_config); + $_SESSION['more'] = $more; + echo Element('page.html', array( 'body' => Element('installer/check-requirements.html', array( 'extensions' => $extensions, 'tests' => $tests, - 'config' => $config + 'config' => $config, )), 'title' => 'Checking environment', - 'config' => $config + 'config' => $config, )); } elseif ($step == 2) { // Basic config @@ -781,14 +831,18 @@ if ($step == 0) { echo Element('page.html', array( 'body' => Element('installer/config.html', array( - 'config' => $config + 'config' => $config, + 'more' => $more, )), 'title' => 'Configuration', 'config' => $config )); } elseif ($step == 3) { + $more = $_POST['more']; + unset($_POST['more']); + $instance_config = -' $value) { - if (is_array($value)) { - $instance_config .= "\n"; - create_config_from_array($instance_config, $value, $prefix . '[\'' . addslashes($name) . '\']'); - $instance_config .= "\n"; - } else { - $instance_config .= ' $config' . $prefix . '[\'' . addslashes($name) . '\'] = '; - - if (is_numeric($value)) - $instance_config .= $value; - else - $instance_config .= "'" . addslashes($value) . "'"; - - $instance_config .= ";\n"; - } - } - } - create_config_from_array($instance_config, $_POST); + $instance_config .= "\n"; + $instance_config .= $more; $instance_config .= "\n"; if (@file_put_contents('inc/instance-config.php', $instance_config)) { diff --git a/templates/installer/config.html b/templates/installer/config.html index 193bb98b..973328f5 100644 --- a/templates/installer/config.html +++ b/templates/installer/config.html @@ -87,6 +87,9 @@ Miscellaneous + + +

-- cgit v1.3 From 38bf3276e4ffd4b82c4a7bc9eb8e1cf692147bb2 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 5 May 2016 09:39:23 +0200 Subject: update copyright years; remove a link to tinyboard (website is dead) --- templates/generic_page.html | 8 ++++---- templates/index.html | 8 ++++---- templates/page.html | 8 ++++---- templates/themes/basic/index.html | 8 ++++---- templates/themes/catalog/catalog.html | 8 ++++---- templates/themes/categories/news.html | 8 ++++---- templates/themes/frameset/news.html | 8 ++++---- templates/themes/recent/recent.html | 8 ++++---- templates/thread.html | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) (limited to 'templates') diff --git a/templates/generic_page.html b/templates/generic_page.html index 965cbc2c..35b58df3 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -36,10 +36,10 @@ {% endfor %} {{ btn.next }} {{ boardlist.bottom }}

-

- Tinyboard + - vichan {{ config.version }} - -
Tinyboard Copyright © 2010-2014 Tinyboard Development Group -
vichan Copyright © 2012-2015 vichan-devel

+

- Tinyboard + + vichan {{ config.version }} - +
Tinyboard Copyright © 2010-2014 Tinyboard Development Group +
vichan Copyright © 2012-2016 vichan-devel

{% for footer in config.footer %}

{{ footer }}

{% endfor %}
diff --git a/templates/main.js b/templates/main.js index 7e3b2dc1..c2a6f6c0 100644 --- a/templates/main.js +++ b/templates/main.js @@ -115,7 +115,10 @@ var styles = { {% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}', {% endraw %}{% endfor %}{% raw %} }; -var board_name = false; + +if (typeof board_name === 'undefined') { + var board_name = false; +} function changeStyle(styleName, link) { {% endraw %} @@ -159,13 +162,7 @@ function changeStyle(styleName, link) { {% endraw %} {% if config.stylesheets_board %} - {# This is such an unacceptable mess. There needs to be an easier way. #} - {# Needs fix for slugify #} - var matches = document.URL.match(/\/(\w+)\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }})/); {% raw %} - if (matches) { - board_name = matches[1]; - } if (!localStorage.board_stylesheets) { localStorage.board_stylesheets = '{}'; diff --git a/templates/page.html b/templates/page.html index 3522702f..816bb72b 100644 --- a/templates/page.html +++ b/templates/page.html @@ -3,7 +3,7 @@ {% include 'header.html' %} {{ title }} diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 1011fdaf..1f5e8b05 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -4,7 +4,8 @@ {% include 'header.html' %} {{ settings.title }} diff --git a/templates/thread.html b/templates/thread.html index b7bb5f6b..506b9cc2 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -4,7 +4,9 @@ {% include 'header.html' %} -- cgit v1.3 From d46bf4e2f2209a38e11dad436b0abb5d89ef4448 Mon Sep 17 00:00:00 2001 From: Bui Date: Fri, 3 Oct 2014 00:12:15 +0900 Subject: add id to thread links --- templates/thread.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 506b9cc2..0899c414 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -49,8 +49,12 @@ {{ body }} {% include 'report_delete.html' %} - [{% trans %}Return{% endtrans %}] - [{% trans %}Go to top{% endtrans %}] + + + [{% trans %}Return{% endtrans %}] + [{% trans %}Go to top{% endtrans %}] + [{% trans %}Catalog{% endtrans %}] + {{ boardlist.bottom }} -- cgit v1.3 From 6c334a3b4494a9b1b3e9f801dab45e6e027dceed Mon Sep 17 00:00:00 2001 From: Bui Date: Fri, 3 Oct 2014 00:16:41 +0900 Subject: lol spaces --- templates/thread.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 0899c414..c909f843 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -52,9 +52,9 @@ [{% trans %}Return{% endtrans %}] - [{% trans %}Go to top{% endtrans %}] - [{% trans %}Catalog{% endtrans %}] - + [{% trans %}Go to top{% endtrans %}] + [{% trans %}Catalog{% endtrans %}] + {{ boardlist.bottom }} -- cgit v1.3 From 293543878a10e1ef93990acb373f8f22ca655f64 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 12:10:50 +0200 Subject: backport parts of 2d6d449bd2d72, in particular html classes --- stylesheets/style.css | 2 +- templates/generic_page.html | 2 +- templates/index.html | 2 +- templates/page.html | 2 +- templates/post_thread.html | 2 +- templates/themes/basic/index.html | 2 +- templates/thread.html | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/stylesheets/style.css b/stylesheets/style.css index 6b4b19d9..2c5663bd 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -666,7 +666,7 @@ pre { margin-left: -20px; } -div.thread:hover { +.theme-catalog div.thread:hover { background: #D6DAF0; border-color: #B7C5D9; } diff --git a/templates/generic_page.html b/templates/generic_page.html index 35b58df3..fbfc3c50 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -6,7 +6,7 @@ {{ board.url }} - {{ board.name }} {% endblock %} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %} diff --git a/templates/index.html b/templates/index.html index d4c56707..1eea6e6b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,7 +16,7 @@ {% include 'header.html' %} {{ board.url }} - {{ board.title|e }} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} diff --git a/templates/page.html b/templates/page.html index 816bb72b..296b517e 100644 --- a/templates/page.html +++ b/templates/page.html @@ -8,7 +8,7 @@ {% include 'header.html' %} {{ title }} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} diff --git a/templates/post_thread.html b/templates/post_thread.html index 61146491..72ca2998 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -1,7 +1,7 @@ {% filter remove_whitespace %} {# tabs and new lines will be ignored #} -
+
{% if not index %}{% endif %} {% include 'post/fileinfo.html' %} diff --git a/templates/themes/basic/index.html b/templates/themes/basic/index.html index 8cdaf182..9d7a2c41 100644 --- a/templates/themes/basic/index.html +++ b/templates/themes/basic/index.html @@ -11,7 +11,7 @@ {% if config.default_stylesheet.1 != '' %}{% endif %} {% if config.font_awesome %}{% endif %} - + {{ boardlist.top }}

{{ settings.title }}

diff --git a/templates/thread.html b/templates/thread.html index c909f843..425394bb 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -12,7 +12,7 @@ {% include 'header.html' %} {{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ board.title|e }}{% endif %} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %} -- cgit v1.3 From b6f3d440809f87a803632cefe66a861c8e20bd9b Mon Sep 17 00:00:00 2001 From: 8chan Date: Sun, 9 Nov 2014 23:24:00 -0800 Subject: Go to bottom link --- templates/thread.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 425394bb..7f8668a3 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -32,7 +32,8 @@ {% include 'attention_bar.html' %} - + {{ config.ad.top }} -- cgit v1.3 From aa0d3395b181671907800cd7110c00e35d8a8a13 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 20 Dec 2014 07:02:42 -0800 Subject: Show first 256 chars of body in --- templates/thread.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 7f8668a3..335cd610 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -10,7 +10,7 @@ </script> {% include 'header.html' %} - <title>{{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ board.title|e }}{% endif %} + {{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ thread.body_nomarkup[:256]|e }}{% endif %} {{ boardlist.top }} -- cgit v1.3 From ce62673a2cf1dd4667b75756c80c44cc5746a63b Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 16 Feb 2015 16:31:15 -0800 Subject: OpenGraph information in thread pages https://en.wikipedia.org/wiki/Facebook_Platform#Open_Graph_protocol --- templates/thread.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 335cd610..9051d8e0 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -10,7 +10,18 @@ {% include 'header.html' %} - {{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ thread.body_nomarkup[:256]|e }}{% endif %} + + {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|e }}{% endif %}{% endset %} + + + + + + + {% if thread.files.0.thumb %}{% endif %} + + + {{ board.url }} - {{ meta_subject }} {{ boardlist.top }} -- cgit v1.3 From 3f29170f1bebba532c73e4188b15cdc7e4335c15 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 12:23:18 +0200 Subject: debrand 8chan; btw. the previous commit was [SECURITY] i think? --- templates/thread.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 9051d8e0..4314fa5e 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -13,12 +13,12 @@ {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|e }}{% endif %}{% endset %} - + - - {% if thread.files.0.thumb %}{% endif %} + + {% if thread.files.0.thumb %}{% endif %} {{ board.url }} - {{ meta_subject }} -- cgit v1.3 From cb97029d0d95e54d7e78e46b26b366060fb7e547 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sun, 28 Sep 2014 10:01:17 -0700 Subject: Update catalog.html Changed title from being - "Catalog /board/" to "/board/ - Catalog" --- templates/themes/catalog/catalog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 1f5e8b05..226c00d3 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -8,7 +8,7 @@ , board_name = "{{ board }}"; {% include 'header.html' %} - {{ settings.title }} + {{ board }} - Catalog {{ boardlist.top }} -- cgit v1.3 From 632d0a76d0afc5bd7a8cc90e6625a74fe432065a Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 31 Dec 2014 22:37:19 -0800 Subject: Display placeholder if no file in catalog/theme.php; czaks: fix the code a bit --- inc/config.php | 2 +- templates/themes/catalog/theme.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index ad659343..21f7b5cc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -766,7 +766,7 @@ // Location of thumbnail to use for spoiler images. $config['spoiler_image'] = 'static/spoiler.png'; // Location of thumbnail to use for deleted images. - // $config['image_deleted'] = 'static/deleted.png'; + $config['image_deleted'] = 'static/deleted.png'; // When a thumbnailed image is going to be the same (in dimension), just copy the entire file and use // that as a thumbnail instead of resizing/redrawing. diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 34b28e48..c7a8ee95 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -88,6 +88,8 @@ $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } } + } else { + $post['file'] = $config['root'] . $config['image_deleted']; } if (empty($post['image_count'])) $post['image_count'] = 0; -- cgit v1.3 From ae4eb4d3d9c390d4c203a468313154aa59809e59 Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 9 Mar 2015 02:31:08 -0700 Subject: RSS --- templates/themes/catalog/index.rss | 19 +++++++++++++++++++ templates/themes/catalog/theme.php | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 templates/themes/catalog/index.rss (limited to 'templates') diff --git a/templates/themes/catalog/index.rss b/templates/themes/catalog/index.rss new file mode 100644 index 00000000..c187e45a --- /dev/null +++ b/templates/themes/catalog/index.rss @@ -0,0 +1,19 @@ + + + + /{{ board.uri }}/ - {{ board.title|e }} + https://8ch.net/{{ board.uri }}/ + Live feed of new threads on the 8chan board /{{ board.uri }}/ - {{ board.title|e }}. + + {% for post in recent_posts %} + + {% if post.subject %}{{ post.subject|e }}{% else %}{{ post.body_nomarkup[:256]|e }}{% endif %} + https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html + https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html + https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html + {{ post.pubdate }} + {{ post.body }} ]]> + + {% endfor %} + + diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index c7a8ee95..239d4dff 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -93,6 +93,7 @@ } if (empty($post['image_count'])) $post['image_count'] = 0; + $post['pubdate'] = date('r', $post['time']); $recent_posts[] = $post; } @@ -113,5 +114,11 @@ 'board' => $board_name, 'link' => $config['root'] . $board['dir'] ))); + + file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array( + 'config' => $config, + 'recent_posts' => $recent_posts, + 'board' => $board + ))); } }; -- cgit v1.3 From 6da7f4d25aed8daf14f705e2acabbac8f755fe01 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 14 Mar 2015 22:03:08 -0700 Subject: No more country flags in --- inc/lib/Twig/Extensions/Extension/Tinyboard.php | 1 + templates/themes/catalog/index.rss | 2 +- templates/thread.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 028db438..3d964c71 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -17,6 +17,7 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension 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('hasPermission', 'twig_hasPermission_filter'), new Twig_SimpleFilter('date', 'twig_date_filter'), new Twig_SimpleFilter('poster_id', 'poster_id'), diff --git a/templates/themes/catalog/index.rss b/templates/themes/catalog/index.rss index c187e45a..248b494a 100644 --- a/templates/themes/catalog/index.rss +++ b/templates/themes/catalog/index.rss @@ -7,7 +7,7 @@ <atom:link href="https://8ch.net/{{ board.uri }}/index.rss" rel="self" type="application/rss+xml"/> {% for post in recent_posts %} <item> - <title>{% if post.subject %}{{ post.subject|e }}{% else %}{{ post.body_nomarkup[:256]|e }}{% endif %} + {% if post.subject %}{{ post.subject|e }}{% else %}{{ post.body_nomarkup[:256]|remove_modifiers|e }}{% endif %} https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html diff --git a/templates/thread.html b/templates/thread.html index 4314fa5e..2ca81e2e 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -11,7 +11,7 @@ {% include 'header.html' %} - {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|e }}{% endif %}{% endset %} + {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|remove_modifiers|e }}{% endif %}{% endset %} -- cgit v1.3 From 6644ff666a1c794c6536c895e322dbcb50710134 Mon Sep 17 00:00:00 2001 From: 8n-tech <8n-tech@users.noreply.github.com> Date: Sat, 18 Apr 2015 04:39:50 +1000 Subject: Also improved some CSS and HTML aspects of the thread layout. Signed-off-by: 8n-tech <8n-tech@users.noreply.github.com> --- stylesheets/style.css | 86 ++++++++++++++++++++++++++++++++++++-------- templates/report_delete.html | 21 ++++++----- templates/thread.html | 31 ++++++++++------ 3 files changed, 105 insertions(+), 33 deletions(-) (limited to 'templates') diff --git a/stylesheets/style.css b/stylesheets/style.css index 2c5663bd..bb7c2634 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -468,20 +468,6 @@ hr { clear: left; } -div.boardlist { - color: #89A; - font-size: 9pt; - margin-top: 3px; -} - -div.boardlist.bottom { - margin-top: 20px; -} - -div.boardlist a { - text-decoration: none; -} - div.report { color: #333; } @@ -944,6 +930,78 @@ span.pln { } } +.clearfix { + display: block; + clear: both; + visibility: hidden; + overflow: hidden; + + font-size: 0px; + line-height: 0px; + + box-sizing: border-box; + border: none; + height: 0; + margin: 0; + padding: 0; + width: 100%; + zoom: 1; +} + +/* === SPECIFIC PAGES & FEATURES === */ + +/* Board List */ +div.boardlist { + margin-top: 3px; + + color: #89A; + font-size: 9pt; +} +div.boardlist.bottom { + margin-top: 12px; + clear: both; +} +div.boardlist a { + text-decoration: none; +} + +/* Threads */ +/* Thread Footer */ +#thread-interactions { + margin: 8px 0; + clear: both; +} +#thread-links { + float: left; +} +#thread-links > a { + padding-left: none; + padding-right: 10px; +} +#thread-quick-reply { + display: none; + position: absolute; + left: 50%; + right: 50%; + text-align: center; + width: 100px; + margin-left: -50px; +} +#thread_stats { + float: right; +} + +#post-moderation-fields { + float: right; + text-align: right; +} +#delete-fields { +} +#report-fields { +} + + + /* threadwatcher */ #watchlist { diff --git a/templates/report_delete.html b/templates/report_delete.html index 2fcb7259..e246da9e 100644 --- a/templates/report_delete.html +++ b/templates/report_delete.html @@ -1,13 +1,16 @@ -{% if config.allow_delete %} -
- {% trans %}Delete Post{% endtrans %} [ - ] +
+ {% if config.allow_delete %} +
+ {% trans %}Delete Post{% endtrans %} [ + ] -
-{% endif %} -
- +
+ {% endif %} + +
+ -
+
+
\ No newline at end of file diff --git a/templates/thread.html b/templates/thread.html index 2ca81e2e..1cbb6d20 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -24,6 +24,7 @@ {{ board.url }} - {{ meta_subject }} + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %} @@ -56,18 +57,28 @@ [{% trans %}Go to bottom{% endtrans %}]
- - {% if mod %}{% endif %} - {{ body }} - {% include 'report_delete.html' %} + + {% if mod %}{% endif %} + + {{ body }} + + + +
- - [{% trans %}Return{% endtrans %}] - [{% trans %}Go to top{% endtrans %}] - [{% trans %}Catalog{% endtrans %}] - - {{ boardlist.bottom }} {{ config.ad.bottom }} -- cgit v1.3 From 33ef1d2123749db43bba372cbc0aa7ab3df4839a Mon Sep 17 00:00:00 2001 From: Bui Date: Sat, 26 Sep 2015 00:17:05 +0900 Subject: add active page classes to body; czaks: go to bottom @ thread: fixes --- templates/index.html | 2 +- templates/page.html | 2 +- templates/themes/catalog/catalog.html | 2 +- templates/thread.html | 8 ++------ 4 files changed, 5 insertions(+), 9 deletions(-) (limited to 'templates') diff --git a/templates/index.html b/templates/index.html index 1eea6e6b..d1871fc8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,7 +16,7 @@ {% include 'header.html' %} {{ board.url }} - {{ board.title|e }} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} diff --git a/templates/page.html b/templates/page.html index 296b517e..027ed3b9 100644 --- a/templates/page.html +++ b/templates/page.html @@ -8,7 +8,7 @@ {% include 'header.html' %} {{ title }} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 226c00d3..0626b376 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -10,7 +10,7 @@ {% include 'header.html' %} {{ board }} - Catalog - + {{ boardlist.top }}

{{ settings.title }} (/{{ board }}/)

diff --git a/templates/thread.html b/templates/thread.html index 1cbb6d20..2d4ae262 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -23,7 +23,7 @@ {{ board.url }} - {{ meta_subject }} - + {{ boardlist.top }} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} @@ -44,8 +44,7 @@ {% include 'attention_bar.html' %} - + {{ config.ad.top }} @@ -53,9 +52,6 @@ {% if config.global_message %}
{{ config.global_message }}
{% endif %}
- [{% trans %}Return{% endtrans %}] - [{% trans %}Go to bottom{% endtrans %}] -
{% if mod %}{% endif %} -- cgit v1.3 From 33ef3f9b013f9848a39df6aaa2ed092a3478fd11 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 14:14:22 +0200 Subject: synchronize catalog_link --- inc/config.php | 4 ++-- templates/thread.html | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index 21f7b5cc..a3087162 100644 --- a/inc/config.php +++ b/inc/config.php @@ -931,8 +931,8 @@ // Show page navigation links at the top as well. $config['page_nav_top'] = false; - // Show "Catalog" link in page navigation. Use with the Catalog theme. - // $config['catalog_link'] = 'catalog.html'; + // Show "Catalog" link in page navigation. Use with the Catalog theme. Set to false to disable. + $config['catalog_link'] = 'catalog.html'; // Board categories. Only used in the "Categories" theme. // $config['categories'] = array( diff --git a/templates/thread.html b/templates/thread.html index 2d4ae262..3ddb5b1f 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -62,7 +62,9 @@ [{% trans %}Return{% endtrans %}] [{% trans %}Go to top{% endtrans %}] - [{% trans %}Catalog{% endtrans %}] + {% if config.catalog_link %} + [{% trans %}Catalog{% endtrans %}] + {% endif %} -- cgit v1.3 From d069a4c9fd9efb995fffa1d705dd201c09b7d13e Mon Sep 17 00:00:00 2001 From: Forkless Date: Mon, 3 Nov 2014 02:28:04 -0600 Subject: Added option for hiding IDs. --- js/forced-anon.js | 72 ++++++++++++++++++++++++++++--------------- stylesheets/style.css | 8 +++++ templates/post/poster_id.html | 4 +-- 3 files changed, 57 insertions(+), 27 deletions(-) (limited to 'templates') diff --git a/js/forced-anon.js b/js/forced-anon.js index 11327ec9..26d0cb4f 100644 --- a/js/forced-anon.js +++ b/js/forced-anon.js @@ -18,10 +18,10 @@ if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || (window.Options && Options.get_tab('general'))) $(document).ready(function() { var force_anon = function() { - if($(this).children('a.capcode').length == 0) { + if ($(this).children('a.capcode').length == 0) { var id = $(this).parent().children('a.post_no:eq(1)').text(); - if($(this).children('a.email').length != 0) + if ($(this).children('a.email').length != 0) var p = $(this).children('a.email'); else var p = $(this); @@ -29,7 +29,7 @@ $(document).ready(function() { old_info[id] = {'name': p.children('span.name').text(), 'trip': p.children('span.trip').text()}; p.children('span.name').text('Anonymous'); - if(p.children('span.trip').length != 0) + if (p.children('span.trip').length != 0) p.children('span.trip').text(''); } }; @@ -40,44 +40,60 @@ $(document).ready(function() { var disable_fa = function() { $('p.intro label').each(function() { - if($(this).children('a.capcode').length == 0) { + if ($(this).children('a.capcode').length == 0) { var id = $(this).parent().children('a.post_no:eq(1)').text(); if(old_info[id]) { - if($(this).children('a.email').length != 0) + if ($(this).children('a.email').length != 0) var p = $(this).children('a.email'); else var p = $(this); p.children('span.name').text(old_info[id]['name']); - if(p.children('span.trip').length != 0) + if (p.children('span.trip').length != 0) p.children('span.trip').text(old_info[id]['trip']); } } }); }; + var toggle_id = function() { + if (localStorage.hideids == 'true'){ + $(this).addClass('hidden'); + } else { + $(this).removeClass('hidden'); + } + }; + old_info = {}; forced_anon = localStorage['forcedanon'] ? true : false; - var selector, event; - if (window.Options && Options.get_tab('general')) { - selector = '#forced-anon'; - event = 'change'; - Options.extend_tab("general", ""); - } - else { - selector = '#forced-anon'; - event = 'click'; + if (window.Options && Options.get_tab('general')) { + var s1 = '#hide-ids', s2 = '#forced-anon', e = 'change'; + Options.extend_tab("general", ""); + Options.extend_tab("general", ""); + } + else { + var s1 = '#hide-ids', s2 = '#forced-anon', e = 'click'; + $('hr:first').before(''); $('hr:first').before(''); $('div#forced-anon a').text(_('Forced anonymity')+' (' + (forced_anon ? _('enabled') : _('disabled')) + ')'); - } + } + $(s1).on(e, function(e) { + if (!localStorage.hideids || localStorage.hideids == 'false') { + localStorage.hideids = 'true'; + if (window.Options && Options.get_tab('general')) e.target.checked = true; + } else { + localStorage.hideids = 'false'; + if (window.Options && Options.get_tab('general')) e.target.checked = false; + } + $('.poster_id').each(toggle_id); + }); - $(selector).on(event, function() { + $(s2).on(e, function() { forced_anon = !forced_anon; - - if(forced_anon) { + if (forced_anon) { $('div#forced-anon a').text(_('Forced anonymity')+' ('+_('enabled')+')'); localStorage.forcedanon = true; enable_fa(); @@ -86,21 +102,27 @@ $(document).ready(function() { delete localStorage.forcedanon; disable_fa(); } - return false; }); + // initial option setup on script load + if (localStorage.hideids == 'true'){ + if (window.Options && Options.get_tab('general')) $('#hide-ids>input').prop('checked',true); + $('.poster_id').each(toggle_id); + } + if(forced_anon) { enable_fa(); - - if (window.Options && Options.get_tab('general')) { - $('#toggle-locked-threads>input').prop('checked', true); - } + if (window.Options && Options.get_tab('general')) { + $('#toggle-locked-threads>input').prop('checked', true); + } } $(document).on('new_post', function(e, post) { - if(forced_anon) + if (forced_anon) $(post).find('p.intro label').each(force_anon); + if (localStorage.hideids == 'true') + $(post).find('.poster_id').each(toggle_id); }); }); diff --git a/stylesheets/style.css b/stylesheets/style.css index bb7c2634..e54faf93 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -8,6 +8,10 @@ body { padding-right: 4px; } +.hidden { + display:none; +} + a,a:visited { text-decoration: underline; color: #34345C; @@ -905,6 +909,10 @@ pre { cursor: pointer; } +.poster_id::before { + content: " ID: "; +} + pre { /* Better code tags */ max-width:inherit; diff --git a/templates/post/poster_id.html b/templates/post/poster_id.html index 4efc56ff..51f0624f 100644 --- a/templates/post/poster_id.html +++ b/templates/post/poster_id.html @@ -1,7 +1,7 @@ {% if config.poster_ids %} {% if post.thread %} - ID: {{ post.ip|poster_id(post.thread) }} + {{ post.ip|poster_id(post.thread) }} {% else %} - ID: {{ post.ip|poster_id(post.id) }} + {{ post.ip|poster_id(post.id) }} {% endif %} {% endif %} -- cgit v1.3 From 2fa37278db9ad0e802a2b4c6a54c5d179ce6df35 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 15:09:25 +0200 Subject: boardlist goes before #top --- templates/thread.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 3ddb5b1f..88e6ec6d 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -24,8 +24,8 @@ {{ board.url }} - {{ meta_subject }} - {{ boardlist.top }} + {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %}
-- cgit v1.3 From 7911c374e86ef8fa69c4545867b9d9d3de12d5c6 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 25 Feb 2015 17:21:49 -0800 Subject: Public action logs commit (log.php) Note: In a previous commit, I began making inc/mod/auth.php more modular with the check_login() function. Including it does NOT check mod login by default anymore like it does on vichan. You have to call check_login(). I've finally included it in inc/functions.php. If you have any custom pages that use inc/mod/auth.php, just including functions.php is enough now. =================================== Also: backports 351375185e5 (early 404) --- inc/config.php | 22 +++++++++++++++++----- inc/functions.php | 22 ++++++++++++++++++++-- inc/mod/auth.php | 2 +- inc/mod/pages.php | 36 ++++++++++++++++++++++++++++++++++++ install.sql | 1 + log.php | 24 ++++++++++++++++++++++++ mod.php | 6 +++--- post.php | 5 +++-- templates/mod/log.html | 16 ++++++++++++++-- tools/inc/cli.php | 1 - 10 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 log.php (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index a3087162..b6bc3b69 100644 --- a/inc/config.php +++ b/inc/config.php @@ -511,6 +511,13 @@ // The timeout for the above, in seconds. $config['upload_by_url_timeout'] = 15; + // Enable early 404? With default settings, a thread would 404 if it was to leave page 3, if it had less + // than 3 replies. + $config['early_404'] = false; + + $config['early_404_page'] = 3; + $config['early_404_replies'] = 5; + // A wordfilter (sometimes referred to as just a "filter" or "censor") automatically scans users’ posts // as they are submitted and changes or censors particular words or phrases. @@ -1537,25 +1544,30 @@ /* * ==================== - * Public post search + * Public pages * ==================== */ + + // Public post search settings $config['search'] = array(); // Enable the search form $config['search']['enable'] = false; // Maximal number of queries per IP address per minutes - $config['search']['queries_per_minutes'] = Array(15, 2); + $config['search']['queries_per_minutes'] = Array(15, 2); // Global maximal number of queries per minutes - $config['search']['queries_per_minutes_all'] = Array(50, 2); + $config['search']['queries_per_minutes_all'] = Array(50, 2); // Limit of search results - $config['search']['search_limit'] = 100; + $config['search']['search_limit'] = 100; // Boards for searching - //$config['search']['boards'] = array('a', 'b', 'c', 'd', 'e'); + //$config['search']['boards'] = array('a', 'b', 'c', 'd', 'e'); + + // Enable public logs? 0: NO, 1: YES, 2: YES, but drop names + $config['public_logs'] = 0; /* * ==================== diff --git a/inc/functions.php b/inc/functions.php index 8f650828..378e40b3 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -18,6 +18,7 @@ require_once 'inc/template.php'; require_once 'inc/database.php'; require_once 'inc/events.php'; require_once 'inc/api.php'; +require_once 'inc/mod/auth.php'; require_once 'inc/polyfill.php'; if (!extension_loaded('gettext')) { @@ -524,7 +525,8 @@ function setupBoard($array) { $board = array( 'uri' => $array['uri'], 'title' => $array['title'], - 'subtitle' => $array['subtitle'] + 'subtitle' => $array['subtitle'], + #'indexed' => $array['indexed'], ); // older versions @@ -1270,7 +1272,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { return true; } -function clean() { +function clean($pid = false) { global $board, $config; $offset = round($config['max_pages']*$config['threads_per_page']); @@ -1281,6 +1283,22 @@ function clean() { $query->execute() or error(db_error($query)); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { deletePost($post['id'], false, false); + if ($pid) modLog("Automatically deleting thread #{$post['id']} due to new thread #{$pid}"); + } + + // Bump off threads with X replies earlier, spam prevention method + if ($config['early_404']) { + $offset = round($config['early_404_page']*$config['threads_per_page']); + $query = prepare(sprintf("SELECT `id` AS `thread_id`, (SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset, 9001", $board['uri'], $board['uri'])); + $query->bindValue(':offset', $offset, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + if ($post['reply_count'] < $config['early_404_replies']) { + deletePost($post['thread_id'], false, false); + if ($pid) modLog("Automatically deleting thread #{$post['thread_id']} due to new thread #{$pid} (early 404 is set, #{$post['thread_id']} had {$post['reply_count']} replies)"); + } + } } } diff --git a/inc/mod/auth.php b/inc/mod/auth.php index 009e93ad..42f34196 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -130,7 +130,7 @@ function destroyCookies() { function modLog($action, $_board=null) { global $mod, $board, $config; $query = prepare("INSERT INTO ``modlogs`` VALUES (:id, :ip, :board, :time, :text)"); - $query->bindValue(':id', $mod['id'], PDO::PARAM_INT); + $query->bindValue(':id', (isset($mod['id']) ? $mod['id'] : -1), PDO::PARAM_INT); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->bindValue(':text', $action); diff --git a/inc/mod/pages.php b/inc/mod/pages.php index a90fbbd6..ca12eaf1 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -698,6 +698,42 @@ function mod_user_log($username, $page_no = 1) { mod_page(_('Moderation log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'username' => $username)); } +function mod_board_log($board, $page_no = 1, $hide_names = false, $public = false) { + global $config; + + if ($page_no < 1) + error($config['error']['404']); + + if (!hasPermission($config['mod']['mod_board_log'], $board) && !$public) + error($config['error']['noaccess']); + + $query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `board` = :board ORDER BY `time` DESC LIMIT :offset, :limit"); + $query->bindValue(':board', $board); + $query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->bindValue(':offset', ($page_no - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + $logs = $query->fetchAll(PDO::FETCH_ASSOC); + + if (empty($logs) && $page_no > 1) + error($config['error']['404']); + + if (!hasPermission($config['mod']['show_ip'])) { + // Supports ipv4 only! + foreach ($logs as $i => &$log) { + $log['text'] = preg_replace_callback('/(?:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:<\/a>)?/', function($matches) { + return "xxxx";//less_ip($matches[1]); + }, $log['text']); + } + } + + $query = prepare("SELECT COUNT(*) FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `board` = :board"); + $query->bindValue(':board', $board); + $query->execute() or error(db_error($query)); + $count = $query->fetchColumn(); + + mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'board' => $board, 'hide_names' => $hide_names, 'public' => $public)); +} + function mod_view_board($boardName, $page_no = 1) { global $config, $mod; diff --git a/install.sql b/install.sql index 7e661450..024cb349 100644 --- a/install.sql +++ b/install.sql @@ -65,6 +65,7 @@ CREATE TABLE IF NOT EXISTS `boards` ( `uri` varchar(58) CHARACTER SET utf8 NOT NULL, `title` tinytext NOT NULL, `subtitle` tinytext, + -- `indexed` boolean default true, PRIMARY KEY (`uri`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; diff --git a/log.php b/log.php new file mode 100644 index 00000000..1a660c4c --- /dev/null +++ b/log.php @@ -0,0 +1,24 @@ + {% if log.username %} - {{ log.username|e }} + {% if hide_names %} + hidden + {% else %} + {% if not mod|hasPermission(config.mod.modlog) %} + {{ log.username|e }} + {% else %} + {{ log.username|e }} + {% endif %} + {% endif %} {% elseif log.mod == -1 %} system {% else %} @@ -44,7 +52,11 @@ {% if count > logs|count %}

{% for i in range(0, (count - 1) / config.mod.modlog_page) %} - [{{ i + 1 }}] + {% if public %} + [{{ i + 1 }}] + {% else %} + [{{ i + 1 }}] + {% endif %} {% endfor %}

{% endif %} diff --git a/tools/inc/cli.php b/tools/inc/cli.php index f3e8824f..95d51573 100644 --- a/tools/inc/cli.php +++ b/tools/inc/cli.php @@ -39,7 +39,6 @@ if(!getenv('TINYBOARD_PATH')) { putenv('TINYBOARD_PATH=' . getcwd()); require 'inc/functions.php'; -require 'inc/mod/auth.php'; $mod = Array( 'id' => -1, -- cgit v1.3 From 95b1e103cb9f349d7d82dca071636d5cde855ead Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sun, 29 Mar 2015 09:18:14 +0800 Subject: Edit static pages commit --- .gitmodules | 6 ++ inc/config.php | 6 ++ inc/functions.php | 43 ++++++++++++ inc/mod/pages.php | 162 +++++++++++++++++++++++++++++++++++++++++++ install.sql | 20 +++++- mod.php | 18 +++-- templates/mod/edit_page.html | 29 ++++++++ templates/mod/pages.html | 34 +++++++++ tools/import_rules.php | 16 +++++ 9 files changed, 328 insertions(+), 6 deletions(-) create mode 100644 templates/mod/edit_page.html create mode 100644 templates/mod/pages.html create mode 100644 tools/import_rules.php (limited to 'templates') diff --git a/.gitmodules b/.gitmodules index 73f90e0a..df07fdf3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "js/wPaint"] path = js/wPaint url = https://github.com/vichan-devel/wPaint.git + branch = master + +[submodule "inc/lib/parsedown"] + path = inc/lib/parsedown + url = https://github.com/vichan-devel/parsedown + branch = master diff --git a/inc/config.php b/inc/config.php index b6bc3b69..3fdb8d2f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1498,6 +1498,9 @@ $config['mod']['ban_appeals'] = MOD; // View the recent posts page $config['mod']['recent'] = MOD; + // Create pages + $config['mod']['edit_pages'] = MOD; + $config['pages_max'] = 10; // Config editor permissions $config['mod']['config'] = array(); @@ -1702,3 +1705,6 @@ // Use CAPTCHA for reports? $config['report_captcha'] = false; + + // Allowed HTML tags in ?/edit_pages. + $config['allowed_html'] = 'a[href|title],p,br,li,ol,ul,strong,em,u,h2,b,i,tt,div,img[src|alt|title],hr'; diff --git a/inc/functions.php b/inc/functions.php index 378e40b3..7970d05a 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -20,6 +20,7 @@ require_once 'inc/events.php'; require_once 'inc/api.php'; require_once 'inc/mod/auth.php'; require_once 'inc/polyfill.php'; +//require_once 'inc/lib/parsedown/Parsedown.php'; // we don't need that right now, do we? if (!extension_loaded('gettext')) { require_once 'inc/lib/gettext/gettext.inc'; @@ -2739,3 +2740,45 @@ function link_for($post, $page50 = false, $foreignlink = false, $thread = false) return sprintf($tpl, $id, $slug); } + +function prettify_textarea($s){ + return str_replace("\t", ' ', str_replace("\n", ' ', htmlentities($s))); +} + +class HTMLPurifier_URIFilter_NoExternalImages extends HTMLPurifier_URIFilter { + public $name = 'NoExternalImages'; + public function filter(&$uri, $c, $context) { + global $config; + $ct = $context->get('CurrentToken'); + + if (!$ct || $ct->name !== 'img') return true; + + if (!isset($uri->host) && !isset($uri->scheme)) return true; + + if (!in_array($uri->scheme . '://' . $uri->host . '/', $config['allowed_offsite_urls'])) { + error('No off-site links in board announcement images.'); + } + + return true; + } +} + +function purify_html($s) { + global $config; + + $c = HTMLPurifier_Config::createDefault(); + $c->set('HTML.Allowed', $config['allowed_html']); + $uri = $c->getDefinition('URI'); + $uri->addFilter(new HTMLPurifier_URIFilter_NoExternalImages(), $c); + $purifier = new HTMLPurifier($c); + $clean_html = $purifier->purify($s); + return $clean_html; +} + +function markdown($s) { + $pd = new Parsedown(); + $pd->setMarkupEscaped(true); + $pd->setimagesEnabled(false); + + return $pd->text($s); +} diff --git a/inc/mod/pages.php b/inc/mod/pages.php index ca12eaf1..328380d8 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2628,6 +2628,167 @@ function mod_theme_rebuild($theme_name) { )); } +// This needs to be done for `secure` CSRF prevention compatibility, otherwise the $board will be read in as the token if editing global pages. +function delete_page_base($page = '', $board = false) { + global $config, $mod; + + if (empty($board)) + $board = false; + + if (!$board && $mod['boards'][0] !== '*') + error($config['error']['noaccess']); + + if (!hasPermission($config['mod']['edit_pages'], $board)) + error($config['error']['noaccess']); + + if ($board !== FALSE && !openBoard($board)) + error($config['error']['noboard']); + + if ($board) { + $query = prepare('DELETE FROM ``pages`` WHERE `board` = :board AND `name` = :name'); + $query->bindValue(':board', ($board ? $board : NULL)); + } else { + $query = prepare('DELETE FROM ``pages`` WHERE `board` IS NULL AND `name` = :name'); + } + $query->bindValue(':name', $page); + $query->execute() or error(db_error($query)); + + header('Location: ?/edit_pages' . ($board ? ('/' . $board) : ''), true, $config['redirect_http']); +} + +function mod_delete_page($page = '') { + delete_page_base($page); +} + +function mod_delete_page_board($page = '', $board = false) { + delete_page_base($page, $board); +} + +function mod_edit_page($id) { + global $config, $mod, $board; + + $query = prepare('SELECT * FROM ``pages`` WHERE `id` = :id'); + $query->bindValue(':id', $id); + $query->execute() or error(db_error($query)); + $page = $query->fetch(); + + if (!$page) + error(_('Could not find the page you are trying to edit.')); + + if (!$page['board'] && $mod['boards'][0] !== '*') + error($config['error']['noaccess']); + + if (!hasPermission($config['mod']['edit_pages'], $page['board'])) + error($config['error']['noaccess']); + + if ($page['board'] && !openBoard($page['board'])) + error($config['error']['noboard']); + + if (isset($_POST['method'], $_POST['content'])) { + $content = $_POST['content']; + $method = $_POST['method']; + $page['type'] = $method; + + if (!in_array($method, array('markdown', 'html', 'infinity'))) + error(_('Unrecognized page markup method.')); + + switch ($method) { + case 'markdown': + $write = markdown($content); + break; + case 'html': + if (hasPermission($config['mod']['rawhtml'])) { + $write = $content; + } else { + $write = purify_html($content); + } + break; + case 'infinity': + $c = $content; + markup($content); + $write = $content; + $content = $c; + } + + if (!isset($write) or !$write) + error(_('Failed to mark up your input for some reason...')); + + $query = prepare('UPDATE ``pages`` SET `type` = :method, `content` = :content WHERE `id` = :id'); + $query->bindValue(':method', $method); + $query->bindValue(':content', $content); + $query->bindValue(':id', $id); + $query->execute() or error(db_error($query)); + + $fn = ($board['uri'] ? ($board['uri'] . '/') : '') . $page['name'] . '.html'; + $body = "
$write
"; + $html = Element('page.html', array('config' => $config, 'body' => $body, 'title' => utf8tohtml($page['title']))); + file_write($fn, $html); + } + + if (!isset($content)) { + $query = prepare('SELECT `content` FROM ``pages`` WHERE `id` = :id'); + $query->bindValue(':id', $id); + $query->execute() or error(db_error($query)); + $content = $query->fetchColumn(); + } + + mod_page(sprintf(_('Editing static page: %s'), $page['name']), 'mod/edit_page.html', array('page' => $page, 'token' => make_secure_link_token("edit_page/$id"), 'content' => prettify_textarea($content), 'board' => $board)); +} + +function mod_pages($board = false) { + global $config, $mod, $pdo; + + if (empty($board)) + $board = false; + + if (!$board && $mod['boards'][0] !== '*') + error($config['error']['noaccess']); + + if (!hasPermission($config['mod']['edit_pages'], $board)) + error($config['error']['noaccess']); + + if ($board !== FALSE && !openBoard($board)) + error($config['error']['noboard']); + + if ($board) { + $query = prepare('SELECT * FROM ``pages`` WHERE `board` = :board'); + $query->bindValue(':board', $board); + } else { + $query = query('SELECT * FROM ``pages`` WHERE `board` IS NULL'); + } + $query->execute() or error(db_error($query)); + $pages = $query->fetchAll(PDO::FETCH_ASSOC); + + if (isset($_POST['page'])) { + if ($board and sizeof($pages) > $config['pages_max']) + error(sprintf(_('Sorry, this site only allows %d pages per board.'), $config['pages_max'])); + + if (!preg_match('/^[a-z0-9]{1,255}$/', $_POST['page'])) + error(_('Page names must be < 255 chars and may only contain lowercase letters A-Z and digits 1-9.')); + + foreach ($pages as $i => $p) { + if ($_POST['page'] === $p['name']) + error(_('Refusing to create a new page with the same name as an existing one.')); + } + + $title = ($_POST['title'] ? $_POST['title'] : NULL); + + $query = prepare('INSERT INTO ``pages``(board, title, name) VALUES(:board, :title, :name)'); + $query->bindValue(':board', ($board ? $board : NULL)); + $query->bindValue(':title', $title); + $query->bindValue(':name', $_POST['page']); + $query->execute() or error(db_error($query)); + + $pages[] = array('id' => $pdo->lastInsertId(), 'name' => $_POST['page'], 'board' => $board, 'title' => $title); + } + + foreach ($pages as $i => &$p) { + $p['delete_token'] = make_secure_link_token('edit_pages/delete/' . $p['name'] . ($board ? ('/' . $board) : '')); + } + + mod_page(_('Pages'), 'mod/pages.html', array('pages' => $pages, 'token' => make_secure_link_token('edit_pages' . ($board ? ('/' . $board) : '')), 'board' => $board)); +} + function mod_debug_antispam() { global $pdo, $config; @@ -2744,3 +2905,4 @@ function mod_debug_apc() { mod_page(_('Debug: APC'), 'mod/debug/apc.html', array('cached_vars' => $cached_vars)); } + diff --git a/install.sql b/install.sql index 024cb349..720e4ed5 100644 --- a/install.sql +++ b/install.sql @@ -245,7 +245,7 @@ CREATE TABLE IF NOT EXISTS `search_queries` ( `ip` varchar(39) NOT NULL, `time` int(11) NOT NULL, `query` text NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -297,6 +297,24 @@ CREATE TABLE IF NOT EXISTS `ban_appeals` ( KEY `ban_id` (`ban_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; +-- -------------------------------------------------------- + +-- +-- Table structure for table `pages` +-- + +CREATE TABLE `pages` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `board` varchar(255) DEFAULT NULL, + `name` varchar(255) NOT NULL, + `title` varchar(255) DEFAULT NULL, + `type` varchar(255) DEFAULT NULL, + `content` text, + PRIMARY KEY (`id`), + UNIQUE KEY `u_pages` (`name`,`board`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; + +>>>>>>> 12fa8ec... Edit static pages commit /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/mod.php b/mod.php index a6ff00cf..fbe679ac 100644 --- a/mod.php +++ b/mod.php @@ -33,11 +33,19 @@ $pages = array( '/log' => 'log', // modlog '/log/(\d+)' => 'log', // modlog - '/log:([^/]+)' => 'user_log', // modlog - '/log:([^/]+)/(\d+)' => 'user_log', // modlog - '/news' => 'secure_POST news', // view news - '/news/(\d+)' => 'secure_POST news', // view news - '/news/delete/(\d+)' => 'secure news_delete', // delete from news + '/log:([^/:]+)' => 'user_log', // modlog + '/log:([^/:]+)/(\d+)' => 'user_log', // modlog + '/log:b:([^/]+)' => 'board_log', // modlog + '/log:b:([^/]+)/(\d+)' => 'board_log', // modlog + + '/edit_news' => 'secure_POST news', // view news + '/edit_news/(\d+)' => 'secure_POST news', // view news + '/edit_news/delete/(\d+)' => 'secure news_delete', // delete from news + + '/edit_pages(?:/?(\%b)?)' => 'secure_POST pages', + '/edit_page/(\d+)' => 'secure_POST edit_page', + '/edit_pages/delete/([a-z0-9]+)' => 'secure delete_page', + '/edit_pages/delete/([a-z0-9]+)/(\%b)' => 'secure delete_page_board', '/noticeboard' => 'secure_POST noticeboard', // view noticeboard '/noticeboard/(\d+)' => 'secure_POST noticeboard', // view noticeboard diff --git a/templates/mod/edit_page.html b/templates/mod/edit_page.html new file mode 100644 index 00000000..3d132767 --- /dev/null +++ b/templates/mod/edit_page.html @@ -0,0 +1,29 @@ +
+ + + + + + + +
{% trans %}Markup method{% endtrans %} + {% set allowed_html = config.allowed_html %} + {% trans %}

"markdown" is provided by parsedown. Note: images disabled.

+

"html" allows the following tags:
{{ allowed_html }}

+

"infinity" is the same as what is used in posts.

+

This page will not convert between formats,
choose it once or do the conversion yourself!

{% endtrans %} +
+ +
{% trans %}Page content{% endtrans %} +
+ {% trans %}Page will appear at:{% endtrans %} + {% if board %} {{ config.domain }}/{{ board.uri }}/{{ page.name }}.html + {% else %} {{ config.site }}/{{ page.name }}.html + {% endif %}
+ + +
diff --git a/templates/mod/pages.html b/templates/mod/pages.html new file mode 100644 index 00000000..c2395c02 --- /dev/null +++ b/templates/mod/pages.html @@ -0,0 +1,34 @@ + +
+

+{% if board %} +{% set page_max = config.pages_max %} +{% trans %}This page allows you to create static pages for your board. The limit is {{ page_max }} pages per board. You will still have to link to your pages somewhere in your board, for example in a sticky or in the board's announcement. To make links in the board's announcement, use <a> HTML tags.{% endtrans %} +{% else %} +{% trans %}This page allows you to create static pages for your imageboard.{% endtrans %} +{% endif %} +

{% trans %}Existing pages{% endtrans %}

+{% if pages %} +
+ + +{% for page in pages %} + +{% endfor %} +{% else %} +No pages yet! +{% endif %} +
{% trans %}URL{% endtrans %}{% trans %}Title{% endtrans %}{% trans %}Edit{% endtrans %}{% trans %}Delete{% endtrans %}
{{ page.name }}{{ page.title }}{% trans %}Edit{% endtrans %}{% trans %}Delete{% endtrans %}
+
+
+

{% trans %}Create a new page{% endtrans %}

+
+ + + + +
{% trans %}URL{% endtrans %}{% trans %}Title{% endtrans %}
+ +
+ +
diff --git a/tools/import_rules.php b/tools/import_rules.php new file mode 100644 index 00000000..f583f035 --- /dev/null +++ b/tools/import_rules.php @@ -0,0 +1,16 @@ + $b) { + $rules = @file_get_contents($b.'/rules.txt'); + if ($rules && !empty(trim($rules))) { + $query = prepare('INSERT INTO ``pages``(name, title, type, board, content) VALUES("rules", "Rules", "html", :board, :content)'); + $query->bindValue(':board', $b); + $query->bindValue(':content', $rules); + $query->execute() or error(db_error($query)); + } +} -- cgit v1.3 From d788131202604a32986c4ba2bfca841c844ff010 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sun, 14 Dec 2014 03:27:26 -0800 Subject: Allow a board called news to exist --- inc/mod/pages.php | 8 ++++---- templates/mod/dashboard.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 328380d8..6d1e20b4 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -608,7 +608,7 @@ function mod_news($page_no = 1) { rebuildThemes('news'); - header('Location: ?/news#' . $pdo->lastInsertId(), true, $config['redirect_http']); + header('Location: ?/edit_news#' . $pdo->lastInsertId(), true, $config['redirect_http']); } $query = prepare("SELECT * FROM ``news`` ORDER BY `id` DESC LIMIT :offset, :limit"); @@ -621,14 +621,14 @@ function mod_news($page_no = 1) { error($config['error']['404']); foreach ($news as &$entry) { - $entry['delete_token'] = make_secure_link_token('news/delete/' . $entry['id']); + $entry['delete_token'] = make_secure_link_token('edit_news/delete/' . $entry['id']); } $query = prepare("SELECT COUNT(*) FROM ``news``"); $query->execute() or error(db_error($query)); $count = $query->fetchColumn(); - mod_page(_('News'), 'mod/news.html', array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('news'))); + mod_page(_('News'), 'mod/news.html', array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('edit_news'))); } function mod_news_delete($id) { @@ -643,7 +643,7 @@ function mod_news_delete($id) { modLog('Deleted a news entry'); - header('Location: ?/news', true, $config['redirect_http']); + header('Location: ?/edit_news', true, $config['redirect_http']); } function mod_log($page_no = 1) { diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 7e25555b..5c44a522 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -62,7 +62,7 @@ {% endif %}
  • {% trans 'View all noticeboard entries' %}
  • {% endif %} -
  • {% trans 'News' %}
  • +
  • {% trans 'News' %}
  • {% trans 'PM inbox' %} -- cgit v1.3 From 505adffcdca1c1141b7b46f862b7939f2f4acf45 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Fri, 3 Apr 2015 14:56:28 +0800 Subject: Cyclical threads ♺ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/api.php | 1 + inc/config.php | 5 +++++ inc/functions.php | 8 +++++++- inc/mod/pages.php | 22 ++++++++++++++++++++++ install.php | 7 ++++++- mod.php | 1 + post.php | 11 ++++++++++- templates/post/post_controls.html | 8 +++++++- templates/post_thread.html | 13 ++++++++++--- templates/posts.sql | 1 + 10 files changed, 70 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/inc/api.php b/inc/api.php index b2d8adec..b280c25b 100644 --- a/inc/api.php +++ b/inc/api.php @@ -32,6 +32,7 @@ class Api { 'images' => 'images', 'sticky' => 'sticky', 'locked' => 'locked', + 'cycle' => 'cyclical', 'bump' => 'last_modified', 'embed' => 'embed', ); diff --git a/inc/config.php b/inc/config.php index 3fdb8d2f..82fdc882 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1245,6 +1245,8 @@ $config['mod']['link_bumpunlock'] = '[-Sage]'; $config['mod']['link_editpost'] = '[Edit]'; $config['mod']['link_move'] = '[Move]'; + $config['mod']['link_cycle'] = '[Cycle]'; + $config['mod']['link_uncycle'] = '[-Cycle]'; // Moderator capcodes. $config['capcode'] = ' ## %s'; @@ -1388,6 +1390,9 @@ $config['mod']['deletebyip_global'] = ADMIN; // Sticky a thread $config['mod']['sticky'] = MOD; + // Cycle a thread + $config['mod']['cycle'] = MOD; + $config['cycle_limit'] = &$config['reply_limit']; // Lock a thread $config['mod']['lock'] = MOD; // Post in a locked thread diff --git a/inc/functions.php b/inc/functions.php index e9692d56..1bd1f32f 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1021,7 +1021,7 @@ function insertFloodPost(array $post) { function post(array $post) { global $pdo, $board; - $query = prepare(sprintf("INSERT INTO ``posts_%s`` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :body_nomarkup, :time, :time, :files, :num_files, :filehash, :password, :ip, :sticky, :locked, 0, :embed, :slug)", $board['uri'])); + $query = prepare(sprintf("INSERT INTO ``posts_%s`` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :body_nomarkup, :time, :time, :files, :num_files, :filehash, :password, :ip, :sticky, :locked, :cycle, 0, :embed, :slug)", $board['uri'])); // Basic stuff if (!empty($post['subject'])) { @@ -1061,6 +1061,12 @@ function post(array $post) { $query->bindValue(':locked', false, PDO::PARAM_INT); } + if ($post['op'] && $post['mod'] && isset($post['cycle']) && $post['cycle']) { + $query->bindValue(':cycle', true, PDO::PARAM_INT); + } else { + $query->bindValue(':cycle', false, PDO::PARAM_INT); + } + if ($post['mod'] && isset($post['capcode']) && $post['capcode']) { $query->bindValue(':capcode', $post['capcode'], PDO::PARAM_INT); } else { diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 6d1e20b4..303fa3dd 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1089,6 +1089,28 @@ function mod_sticky($board, $unsticky, $post) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); } +function mod_cycle($board, $uncycle, $post) { + global $config; + + if (!openBoard($board)) + error($config['error']['noboard']); + + if (!hasPermission($config['mod']['cycle'], $board)) + error($config['error']['noaccess']); + + $query = prepare(sprintf('UPDATE ``posts_%s`` SET `cycle` = :cycle WHERE `id` = :id AND `thread` IS NULL', $board)); + $query->bindValue(':id', $post); + $query->bindValue(':cycle', $uncycle ? 0 : 1); + $query->execute() or error(db_error($query)); + if ($query->rowCount()) { + modLog(($uncycle ? 'Made not cyclical' : 'Made cyclical') . " thread #{$post}"); + buildThread($post); + buildIndex(); + } + + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); +} + function mod_bumplock($board, $unbumplock, $post) { global $config; diff --git a/install.php b/install.php index 5a6512ba..de4d3dd0 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ vichan upgrade path. query("CREATE TABLE IF NOT EXISTS ``search_queries`` ( `ip` varchar(39) NOT NULL, `time` int(11) NOT NULL, `query` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;") or error(db_error()); diff --git a/mod.php b/mod.php index fbe679ac..0378d55c 100644 --- a/mod.php +++ b/mod.php @@ -82,6 +82,7 @@ $pages = array( '/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread + '/(\%b)/(un)?cycle/(\d+)' => 'secure cycle', // cycle thread '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread '/themes' => 'themes_list', // manage themes diff --git a/post.php b/post.php index 0d3292bb..98aefe05 100644 --- a/post.php +++ b/post.php @@ -265,7 +265,7 @@ if (isset($_POST['delete'])) { //Check if thread exists if (!$post['op']) { - $query = prepare(sprintf("SELECT `sticky`,`locked`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri'])); + $query = prepare(sprintf("SELECT `sticky`,`locked`,`cycle`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri'])); $query->bindValue(':id', $post['thread'], PDO::PARAM_INT); $query->execute() or error(db_error()); @@ -867,6 +867,15 @@ if (isset($_POST['delete'])) { $post['slug'] = slugify($post); insertFloodPost($post); + + // Handle cyclical threads + if (!$post['op'] && isset($thread['cycle']) && $thread['cycle']) { + // Query is a bit weird due to "This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'" (MariaDB Ver 15.1 Distrib 10.0.17-MariaDB, for Linux (x86_64)) + $query = prepare(sprintf('DELETE FROM ``posts_%s`` WHERE `thread` = :thread AND `id` NOT IN (SELECT `id` FROM (SELECT `id` FROM ``posts_%s`` WHERE `thread` = :thread ORDER BY `id` DESC LIMIT :limit) i)', $board['uri'], $board['uri'])); + $query->bindValue(':thread', $post['thread']); + $query->bindValue(':limit', $config['cycle_limit'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + } if (isset($post['antispam_hash'])) { incrementSpamHash($post['antispam_hash']); diff --git a/templates/post/post_controls.html b/templates/post/post_controls.html index 99a8484c..60dc6fc4 100644 --- a/templates/post/post_controls.html +++ b/templates/post/post_controls.html @@ -41,7 +41,6 @@ {% endif %} {% endif %} - {% if mod|hasPermission(config.mod.move, board.uri) %} {% if not post.thread %} {{ config.mod.link_move }}  @@ -49,6 +48,13 @@ {{ config.mod.link_move }}  {% endif %} {% endif %} +{% if mod|hasPermission(config.mod.cycle, board.uri) %} + {% if post.cycle %} + {{ config.mod.link_uncycle }}  + {% else %} + {{ config.mod.link_cycle }}  + {% endif %} +{% endif %} {% if mod|hasPermission(config.mod.editpost, board.uri) %} {{ config.mod.link_editpost }}  {% endif %} diff --git a/templates/post_thread.html b/templates/post_thread.html index 72ca2998..125d5f78 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -19,25 +19,32 @@ {{ post.id }} {% if post.sticky %} {% if config.font_awesome %} - + {% else %} Sticky {% endif %} {% endif %} {% if post.locked %} {% if config.font_awesome %} - + {% else %} Locked {% endif %} {% endif %} {% if post.bumplocked and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %} {% if config.font_awesome %} - + {% else %} Bumplocked {% endif %} {% endif %} + {% if post.cycle %} + {% if config.font_awesome %} + + {% else %} + Cyclical + {% endif %} + {% endif %} {% if index %} [{% trans %}Reply{% endtrans %}] {% endif %} diff --git a/templates/posts.sql b/templates/posts.sql index 6b2249ef..070e687b 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS ``posts_{{ board }}`` ( `ip` varchar(39) CHARACTER SET ascii NOT NULL, `sticky` int(1) NOT NULL, `locked` int(1) NOT NULL, + `cycle` int(1) NOT NULL, `sage` int(1) NOT NULL, `embed` text, `slug` varchar(256) DEFAULT NULL, -- cgit v1.3 From a5bd39dc4ab2394db7f87d80a01480b22e4a74e1 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 16:49:35 +0200 Subject: mod dashboard html: link to page editor --- templates/mod/dashboard.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'templates') diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 5c44a522..d13bf7f2 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -19,6 +19,9 @@ {% if mod|hasPermission(config.mod.manageboards) %} [{% trans 'edit' %}] {% endif %} + {% if mod|hasPermission(config.mod.edit_pages) %} + [{% trans 'pages' %}] + {% endif %}
  • {% endfor %} @@ -100,6 +103,9 @@ {% if mod|hasPermission(config.mod.modlog) %}
  • {% trans 'Moderation log' %}
  • {% endif %} + {% if mod|hasPermission(config.mod.edit_pages) %} +
  • {% trans 'Global static pages' %}
  • + {% endif %} {% if mod|hasPermission(config.mod.recent) %}
  • {% trans 'Recent posts' %}
  • {% endif %} -- cgit v1.3 From 3571670b98b2e6293e429f3e629510ab9f38e70a Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 16:51:34 +0200 Subject: fix catalog link someone? --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/index.html b/templates/index.html index d1871fc8..1be614e3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -69,7 +69,7 @@ [{{ page.num }}]{% if loop.last %} {% endif %} {% endfor %} {{ btn.next }} {% if config.catalog_link %} - | Catalog + | {% trans %}Catalog{% endtrans %} {% endif %}
    -- cgit v1.3 From 3f405b3484ae6b621ca1fdacbf20e1ef9f3b553a Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 6 May 2016 16:53:28 +0200 Subject: what if IP address contained bad characters? (highly local) --- templates/mod/ban_form.html | 2 +- templates/mod/view_ip.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/mod/ban_form.html b/templates/mod/ban_form.html index 6c7560ad..98cc34b2 100644 --- a/templates/mod/ban_form.html +++ b/templates/mod/ban_form.html @@ -21,7 +21,7 @@ {% if not hide_ip %} - + {% else %} {% trans 'hidden' %} {% endif %} diff --git a/templates/mod/view_ip.html b/templates/mod/view_ip.html index 1c1c7fa6..4bacc7f6 100644 --- a/templates/mod/view_ip.html +++ b/templates/mod/view_ip.html @@ -45,7 +45,7 @@ {% if mod|hasPermission(config.mod.remove_notes) %} - + [{% trans 'remove' %}] -- cgit v1.3 From b6f0317bde1b6d9a9ac5d81a660865a7aa9ad13d Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 8 May 2016 10:54:30 +0200 Subject: advanced build (1/2): a small refactor of index generating procedure; generation strategies --- inc/config.php | 70 ++++++++++++++++++++++--- inc/functions.php | 102 +++++++++++++++++++++++++++---------- inc/route.php | 5 +- smart_build.php | 9 +++- templates/themes/catalog/theme.php | 13 +++-- templates/themes/recent/theme.php | 5 +- templates/themes/sitemap/theme.php | 6 ++- templates/themes/ukko/theme.php | 6 ++- 8 files changed, 169 insertions(+), 47 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index 82fdc882..91804429 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1203,16 +1203,74 @@ // Try not to build pages when we shouldn't have to. $config['try_smarter'] = true; - // EXPERIMENTAL: Defer static HTML building to a moment, when a given file is actually accessed. - // Warning: This option won't run out of the box. You need to tell your webserver, that a file - // for serving 403 and 404 pages is /smart_build.php. Also, you need to turn off indexes. +/* + * ==================== + * Advanced build + * ==================== + */ + + // Strategies for file generation. Also known as an "advanced build". If you don't have performance + // issues, you can safely ignore that part, because it's hard to configure and won't even work on + // your free webhosting. + // + // A strategy is a function, that given the PHP environment and ($fun, $array) variable pair, returns + // an $action array or false. + // + // $fun - a controller function name, see inc/controller.php. This is named after functions, so that + // we can generate the files in daemon. + // + // $array - arguments to be passed + // + // $action - action to be taken. It's an array, and the first element of it is one of the following: + // * "immediate" - generate the page immediately + // * "defer" - defer page generation to a moment a worker daemon gets to build it (serving a stale + // page in the meantime). The remaining arguments are daemon-specific. Daemon isn't + // implemented yet :DDDD inb4 while(true) { generate(Queue::Get()) }; (which is probably it). + // * "build_on_load" - defer page generation to a moment, when the user actually accesses the page. + // This is a smart_build behaviour. You shouldn't use this one too much, if you + // use it for active boards, the server may choke due to a possible race condition. + // See my blog post: https://engine.vichan.net/blog/res/2.html + // + // So, let's assume we want to build a thread 1324 on board /b/, because a new post appeared there. + // We try the first strategy, giving it arguments: 'sb_thread', array('b', 1324). The strategy will + // now return a value $action, denoting an action to do. If $action is false, we try another strategy. + // + // As I said, configuration isn't easy. + // + // 1. chmod 0777 directories: tmp/locks/ and tmp/queue/. + // 2. serve 403 and 404 requests to go thru smart_build.php + // for nginx, this blog post contains config snippets: https://engine.vichan.net/blog/res/2.html + // 3. disable indexes in your webserver + // 4. launch any number of daemons (eg. twice your number of threads?) using the command: + // $ tools/worker.php + // You don't need to do that step if you are not going to use the "defer" option. + // 5. enable smart_build_helper (see below) + // 6. edit the strategies (see inc/functions.php for the builtin ones). You can use lambdas. I will test + // various ones and include one that works best for me. + $config['generation_strategies'] = array(); + // Add a sane strategy. It forces to immediately generate a page user is about to land on. Otherwise, + // it has no opinion, so it needs a fallback strategy. + $config['generation_strategies'][] = 'strategy_sane'; + // Add an immediate catch-all strategy. This is the default function of imageboards: generate all pages + // on post time. + $config['generation_strategies'][] = 'strategy_immediate'; + // NOT RECOMMENDED: Instead of an all-"immediate" strategy, you can use an all-"build_on_load" one (used + // to be initialized using $config['smart_build']; ) for all pages instead of those to be build + // immediately. A rebuild done in this mode should remove all your static files + // $config['generation_strategies'][1] = 'strategy_smart_build'; + + // Deprecated. Leave it false. See above. $config['smart_build'] = false; - // Smart build related: when a file doesn't exist, where should we redirect? + // Use smart_build.php for dispatching missing requests. It may be useful without smart_build or advanced + // build, for example it will regenerate the missing files. + $config['smart_build_helper'] = true; + + // smart_build.php: when a file doesn't exist, where should we redirect? $config['page_404'] = '/404.html'; - // Smart build related: extra entrypoints. - $config['smart_build_entrypoints'] = array(); + // Extra controller entrypoints. Controller is used only by smart_build and advanced build. + $config['controller_entrypoints'] = array(); /* * ==================== diff --git a/inc/functions.php b/inc/functions.php index 1bd1f32f..2957c680 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1319,7 +1319,8 @@ function thread_find_page($thread) { return floor(($config['threads_per_page'] + $index) / $config['threads_per_page']); } -function index($page, $mod=false) { +// $brief means that we won't need to generate anything yet +function index($page, $mod=false, $brief = false) { global $board, $config, $debug; $body = ''; @@ -1350,6 +1351,7 @@ function index($page, $mod=false) { unset($cached); } } + if (!isset($cached)) { $posts = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri'])); $posts->bindValue(':id', $th['id']); @@ -1389,7 +1391,10 @@ function index($page, $mod=false) { } $threads[] = $thread; - $body .= $thread->build(true); + + if (!$brief) { + $body .= $thread->build(true); + } } if ($config['file_board']) { @@ -1610,27 +1615,28 @@ function checkMute() { function buildIndex($global_api = "yes") { global $board, $config, $build_pages; - if (!$config['smart_build']) { - $pages = getPages(); - if (!$config['try_smarter']) - $antibot = create_antibot($board['uri']); + $catalog_api_action = generation_strategy('sb_api', array($board['uri'])); - if ($config['api']['enabled']) { - $api = new Api(); - $catalog = array(); - } + $pages = null; + $antibot = null; + + if ($config['api']['enabled']) { + $api = new Api(); + $catalog = array(); } for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - if ((!$config['api']['enabled'] || $global_api == "skip" || $config['smart_build']) && $config['try_smarter'] - && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) + $wont_build_this_page = $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages); + + if ((!$config['api']['enabled'] || $global_api == "skip") && $wont_build_this_page) continue; - if (!$config['smart_build']) { - $content = index($page); + $action = generation_strategy('sb_board', array($board['uri'], $page)); + if ($action == 'rebuild' || $catalog_api_action == 'rebuild') { + $content = index($page, false, $wont_build_this_page); if (!$content) break; @@ -1641,17 +1647,21 @@ function buildIndex($global_api = "yes") { file_write($jsonFilename, $json); $catalog[$page-1] = $threads; - } - if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) - continue; + if ($wont_build_this_page) continue; + } if ($config['try_smarter']) { $antibot = create_antibot($board['uri'], 0 - $page); $content['current_page'] = $page; } + elseif (!$antibot) { + create_antibot($board['uri']); + } $antibot->reset(); + if (!$pages) { + $pages = getPages(); + } $content['pages'] = $pages; $content['pages'][$page-1]['selected'] = true; $content['btn'] = getPageButtons($content['pages']); @@ -1659,13 +1669,14 @@ function buildIndex($global_api = "yes") { file_write($filename, Element('index.html', $content)); } - else { + elseif ($action == 'delete' || $catalog_api_action == 'delete') { file_unlink($filename); file_unlink($jsonFilename); } } - if (!$config['smart_build'] && $page < $config['max_pages']) { + // $action is an action for our last page + if (($catalog_api_action == 'rebuild' || $action == 'rebuild' || $action == 'delete') && $page < $config['max_pages']) { for (;$page<=$config['max_pages'];$page++) { $filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page)); file_unlink($filename); @@ -1679,13 +1690,13 @@ function buildIndex($global_api = "yes") { // json api catalog if ($config['api']['enabled'] && $global_api != "skip") { - if ($config['smart_build']) { + if ($catalog_api_action == 'delete') { $jsonFilename = $board['dir'] . 'catalog.json'; file_unlink($jsonFilename); $jsonFilename = $board['dir'] . 'threads.json'; file_unlink($jsonFilename); } - else { + elseif ($catalog_api_action == 'rebuild') { $json = json_encode($api->translateCatalog($catalog)); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); @@ -2204,7 +2215,9 @@ function buildThread($id, $return = false, $mod = false) { if ($config['try_smarter'] && !$mod) $build_pages[] = thread_find_page($id); - if (!$config['smart_build'] || $return || $mod) { + $action = generation_strategy('sb_thread', array($board['uri'], $id)); + + if ($action == 'rebuild' || $return || $mod) { $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); @@ -2239,26 +2252,26 @@ function buildThread($id, $return = false, $mod = false) { )); // json api - if ($config['api']['enabled']) { + if ($config['api']['enabled'] && !$mod) { $api = new Api(); $json = json_encode($api->translateThread($thread)); $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; file_write($jsonFilename, $json); } } - else { + elseif($action == 'delete') { $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; file_unlink($jsonFilename); } - if ($config['smart_build'] && !$return && !$mod) { + if ($action == 'delete' && !$return && !$mod) { $noko50fn = $board['dir'] . $config['dir']['res'] . link_for(array('id' => $id), true); file_unlink($noko50fn); file_unlink($board['dir'] . $config['dir']['res'] . link_for(array('id' => $id))); - } else if ($return) { + } elseif ($return) { return $body; - } else { + } elseif ($action == 'rebuild') { $noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true); if ($hasnoko50 || file_exists($noko50fn)) { buildThread50($id, $return, $mod, $thread, $antibot); @@ -2788,3 +2801,36 @@ function markdown($s) { return $pd->text($s); } + +function generation_strategy($fun, $array=array()) { global $config; + $action = false; + + foreach ($config['generation_strategies'] as $s) { + if ($strategy = $s($fun, $array)) { + break; + } + } + + switch ($strategy[0]) { + case 'immediate': + return 'rebuild'; + case 'defer': + // Ok, it gets interesting here :) + Queue::add(serialize(array('build', $fun, $array))); + return 'ignore'; + case 'build_on_load': + return 'delete'; + } +} + +function strategy_immediate($fun, $array) { + return array('immediate'); +} + +function strategy_smart_build($fun, $array) { + return array('build_on_load'); +} + +function strategy_sane($fun, $array) { global $config; + return false; +} diff --git a/inc/route.php b/inc/route.php index 66602d77..2a5c1732 100644 --- a/inc/route.php +++ b/inc/route.php @@ -7,7 +7,7 @@ defined('TINYBOARD') or exit; -function route($path) { +function route($path) { global $config; $entrypoints = array(); $entrypoints['/%b/'] = 'sb_board'; @@ -33,8 +33,11 @@ function route($path) { $entrypoints['/*/index.html'] = 'sb_ukko'; $entrypoints['/recent.html'] = 'sb_recent'; $entrypoints['/%b/catalog.html'] = 'sb_catalog'; + $entrypoints['/%b/index.rss'] = 'sb_catalog'; $entrypoints['/sitemap.xml'] = 'sb_sitemap'; + $entrypoints = array_merge($entrypoints, $config['controller_entrypoints']); + $reached = false; list($request) = explode('?', $path); diff --git a/smart_build.php b/smart_build.php index 58596055..7ca5fcbf 100644 --- a/smart_build.php +++ b/smart_build.php @@ -3,14 +3,16 @@ require_once("inc/functions.php"); require_once("inc/route.php"); require_once("inc/controller.php"); -if (!$config['smart_build'] && !$config["smart_build_helper"]) { - die('You need to enable $config["smart_build"] or $config["smart_build_helper"]'); +if (!$config["smart_build_helper"]) { + die('You need to enable $config["smart_build_helper"]'); } $config['smart_build'] = false; // Let's disable it, so we can build the page for real +$config['generation_strategies'] = array('strategy_immediate'); function after_open_board() { global $config; $config['smart_build'] = false; + $config['generation_strategies'] = array('strategy_immediate'); }; $request = $_SERVER['REQUEST_URI']; @@ -59,6 +61,9 @@ if ($reached) { elseif (preg_match('/\.xml$/', $request)) { header("Content-Type", "application/xml"); } + elseif (preg_match('/\.rss$/', $request)) { + header("Content-Type", "application/rss+xml"); + } else { header("Content-Type", "text/html; charset=utf-8"); } diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 239d4dff..4f512c03 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -16,20 +16,25 @@ if ($action == 'all') { foreach ($boards as $board) { $b = new Catalog(); - if ($config['smart_build']) { + + $action = generation_strategy("sb_catalog", array($board)); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); + file_unlink($config['dir']['home'] . $board . '/index.rss'); } - else { + elseif ($action == 'rebuild') { $b->build($settings, $board); } } } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) { $b = new Catalog(); - if ($config['smart_build']) { + $action = generation_strategy("sb_catalog", array($board)); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); + file_unlink($config['dir']['home'] . $board . '/index.rss'); } - else { + elseif ($action == 'rebuild') { $b->build($settings, $board); } } diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index f44e2529..95921c35 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -25,10 +25,11 @@ $this->excluded = explode(' ', $settings['exclude']); if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { - if ($config['smart_build']) { + $action = generation_strategy('sb_recent', array()); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $settings['html']); } - else { + elseif ($action == 'rebuild') { file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } } diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 52779d53..6bc035bb 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -23,10 +23,12 @@ } } - if ($config['smart_build']) { + $action = generation_strategy('sb_sitemap', array()); + + if ($action == 'delete') { file_unlink($settings['path']); } - else { + elseif ($action == 'rebuild') { $boards = explode(' ', $settings['boards']); $threads = array(); diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index d6fc303c..e572c467 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -11,10 +11,12 @@ return; } - if ($config['smart_build']) { + $action = generation_strategy('sb_ukko', array()); + + if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); } - else { + elseif ($action == 'rebuild') { file_write($settings['uri'] . '/index.html', $ukko->build()); } } -- cgit v1.3 From d285a796674f170b0e7a71ffa0cc7bbee2d5421a Mon Sep 17 00:00:00 2001 From: fatchan Date: Tue, 31 May 2016 23:28:55 +1000 Subject: Move the 'Go back and rebuild again' to the top of the rebuilt page so you dont have to scroll --- templates/mod/rebuilt.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/mod/rebuilt.html b/templates/mod/rebuilt.html index 57d16fff..f27cdf56 100644 --- a/templates/mod/rebuilt.html +++ b/templates/mod/rebuilt.html @@ -1,12 +1,12 @@

    {% trans 'Rebuilt' %}

    +

    + {% trans 'Go back and rebuild again' %}. +

      {% for log in logs %}
    • {{ log }}
    • {% endfor %}
    -

    - {% trans 'Go back and rebuild again' %}. -

    -- cgit v1.3 From 94c91db097c034c46f66b27d16eb84a4ea814bb6 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 9 Jun 2016 04:51:05 +0200 Subject: fix news deletion; thanks MrFreeman --- templates/mod/news.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/mod/news.html b/templates/mod/news.html index 510d60ce..57058291 100644 --- a/templates/mod/news.html +++ b/templates/mod/news.html @@ -40,7 +40,7 @@
    {% if mod|hasPermission(config.mod.news_delete) %} - [{% trans 'delete' %}] + [{% trans 'delete' %}] {% endif %}

    -- cgit v1.3 From cdd963e79e0ffc5a7bcd69c9cd79d41c8ad74f52 Mon Sep 17 00:00:00 2001 From: fatchan Date: Wed, 1 Jun 2016 00:20:20 +1000 Subject: fix flag spacing --- templates/post/flag.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/post/flag.html b/templates/post/flag.html index 61622368..481e40ae 100644 --- a/templates/post/flag.html +++ b/templates/post/flag.html @@ -1,5 +1,5 @@ {% if config.display_flags and post.modifiers.flag %} - Date: Tue, 7 Jun 2016 23:20:38 +1000 Subject: Remove hardcoded 8chan links in catalog RSS --- templates/themes/catalog/index.rss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'templates') diff --git a/templates/themes/catalog/index.rss b/templates/themes/catalog/index.rss index 248b494a..7add8869 100644 --- a/templates/themes/catalog/index.rss +++ b/templates/themes/catalog/index.rss @@ -2,17 +2,17 @@ /{{ board.uri }}/ - {{ board.title|e }} - https://8ch.net/{{ board.uri }}/ + {{ config.root }}{{ board.uri }}/ Live feed of new threads on the 8chan board /{{ board.uri }}/ - {{ board.title|e }}. - + {% for post in recent_posts %} {% if post.subject %}{{ post.subject|e }}{% else %}{{ post.body_nomarkup[:256]|remove_modifiers|e }}{% endif %} - https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html - https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html - https://8ch.net/{{ board.uri }}/res/{{ post.id }}.html + {{ config.root }}{{ board.uri }}/res/{{ post.id }}.html + {{ config.root }}{{ board.uri }}/res/{{ post.id }}.html + {{ config.root }}{{ board.uri }}/res/{{ post.id }}.html {{ post.pubdate }} - {{ post.body }} ]]> + {{ post.body }} ]]> {% endfor %} -- cgit v1.3 From 4f3cc7f316d18b159ed5aef3878a9d30d1717d4e Mon Sep 17 00:00:00 2001 From: fatchan Date: Tue, 7 Jun 2016 23:29:19 +1000 Subject: Whoops --- templates/themes/catalog/index.rss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/catalog/index.rss b/templates/themes/catalog/index.rss index 7add8869..e6576ffc 100644 --- a/templates/themes/catalog/index.rss +++ b/templates/themes/catalog/index.rss @@ -3,7 +3,7 @@ /{{ board.uri }}/ - {{ board.title|e }} {{ config.root }}{{ board.uri }}/ - Live feed of new threads on the 8chan board /{{ board.uri }}/ - {{ board.title|e }}. + Live feed of new threads on the board /{{ board.uri }}/ - {{ board.title|e }}. {% for post in recent_posts %} -- cgit v1.3 From fed9065cf1fe759e20ec10baf0aba1309ee6f8ab Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 19 Jun 2016 02:23:24 +0200 Subject: skip non-image files in recent themes; fixes vichan-devel/vichan#185 --- templates/themes/recent/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 95921c35..a826048f 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -65,7 +65,7 @@ if (isset($post['files'])) $files = json_decode($post['files']); - if ($files[0]->file == 'deleted') continue; + if ($files[0]->file == 'deleted' || $files[0]->thumb == 'file') continue; // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] -- cgit v1.3 From 05569d150abac93b306d923679af6122c89e3b62 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:29:35 +0900 Subject: Updated copyright year --- templates/thread.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/thread.html b/templates/thread.html index 62fe2c12..346db449 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -40,8 +40,10 @@ {% if config.global_message %}
    {{ config.global_message }}
    {% endif %}
    - [{% trans %}Return{% endtrans %}] - [{% trans %}Go to bottom{% endtrans %}] +
    @@ -60,8 +62,8 @@ vichan + lainchan {{ config.version }} -
    Tinyboard Copyright © 2010-2014 Tinyboard Development Group -
    vichan Copyright © 2012-2015 vichan-devel -
    lainchan Copyright © 2014-2015 lainchan Administration

    +
    vichan Copyright © 2012-2016 vichan-devel +
    lainchan Copyright © 2014-2016 lainchan Administration

    {% for footer in config.footer %}

    {{ footer }}

    {% endfor %}
    -- cgit v1.3 From 8b5688e12a3687f86c8c40d36a1327445cfb8143 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:33:20 +0900 Subject: Add porn to public banlist theme --- templates/themes/public_banlist/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php index c9f7e6f0..62a794dd 100644 --- a/templates/themes/public_banlist/theme.php +++ b/templates/themes/public_banlist/theme.php @@ -25,7 +25,7 @@ public static function gen_json($settings) { ob_start(); - Bans::stream_json(false, true, true, array(), array("/\bcp\b/i")); + Bans::stream_json(false, true, true, array(), array("/\bcp\b/i", "/porn/i")); $out = ob_get_contents(); ob_end_clean(); return $out; -- cgit v1.3 From 31b69902bbfdccffd0ed7ba32f04aaf1479d41b7 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:38:24 +0900 Subject: Add catalog support to all of rand, semi,rand and ukko themes --- templates/index.html | 9 +++++-- templates/themes/catalog/info.php | 7 ++++++ templates/themes/catalog/theme.php | 47 +++++++++++++++++++++++++++++++++++++ templates/themes/rand/theme.php | 1 + templates/themes/semirand/theme.php | 1 + templates/themes/ukko/theme.php | 1 + 6 files changed, 64 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/index.html b/templates/index.html index 1878d455..2241b13c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -58,6 +58,11 @@ {% if config.global_message %}
    {{ config.global_message }}
    {% endif %}
    + {% if config.catalog_link %} + | Catalog + {% endif %} +
    + {% if mod %}{% endif %} @@ -72,8 +77,8 @@ vichan + lainchan {{ config.version }} -
    Tinyboard Copyright © 2010-2014 Tinyboard Development Group -
    vichan Copyright © 2012-2015 vichan-devel -
    lainchan Copyright © 2014-2015 lainchan Administration

    +
    vichan Copyright © 2012-2016 vichan-devel +
    lainchan Copyright © 2014-2016 lainchan Administration

    {% for footer in config.footer %}

    {{ footer }}

    {% endfor %} diff --git a/templates/themes/catalog/info.php b/templates/themes/catalog/info.php index e2b13307..66c45082 100644 --- a/templates/themes/catalog/info.php +++ b/templates/themes/catalog/info.php @@ -46,6 +46,13 @@ 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko theme to be enabled.' ); + $theme['config'][] = Array( + 'title' => 'Enable Rand catalog', + 'name' => 'enable_rand', + 'type' => 'checkbox', + 'default' => false, + 'comment' => 'Enable catalog for the Rand theme. This requires the Rand theme to be enabled.' + ); $theme['config'][] = Array( 'title' => 'Use tooltipster', 'name' => 'use_tooltipster', diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 9ecdb9d1..1199b54a 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -40,6 +40,14 @@ { $b->buildUkko(); } + + // FIXME: Check that Rand is actually enabled + if ($settings['enable_rand'] && ( + $action === 'all' || $action === 'post' || + $action === 'post-thread' || $action === 'post-delete')) + { + $b->buildRand(); + } } // Wrap functions in a class so they don't interfere with normal Tinyboard operations @@ -90,6 +98,45 @@ $this->saveForBoard($ukkoSettings['uri'], $recent_posts, $config['root'] . $ukkoSettings['uri']); } + + /** + * Build and save the HTML of the catalog for the Rand theme + */ + public function buildRand() { + global $config; + + $randSettings = themeSettings('rand'); + $queries = array(); + $threads = array(); + + $exclusions = explode(' ', $randSettings['exclude']); + $boards = array_diff(listBoards(true), $exclusions); + + foreach ($boards as $b) { + if (array_key_exists($b, $this->threadsCache)) { + $threads = array_merge($threads, $this->threadsCache[$b]); + } else { + $queries[] = $this->buildThreadsQuery($b); + } + } + + // Fetch threads from boards that haven't beenp processed yet + if (!empty($queries)) { + $sql = implode(' UNION ALL ', $queries); + $res = query($sql) or error(db_error()); + $threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC)); + } + + // Sort in bump order + usort($threads, function($a, $b) { + return strcmp($b['bump'], $a['bump']); + }); + // Generate data for the template + $recent_posts = $this->generateRecentPosts($threads); + + $this->saveForBoard($randSettings['uri'], $recent_posts, + $config['root'] . $randSettings['uri']); + } /** * Build and save the HTML of the catalog for the given board diff --git a/templates/themes/rand/theme.php b/templates/themes/rand/theme.php index b4cfb4ff..e3814c4e 100644 --- a/templates/themes/rand/theme.php +++ b/templates/themes/rand/theme.php @@ -18,6 +18,7 @@ $body = ''; $overflow = array(); $board = array( + 'dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index 1acecbfb..e8d3e56c 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -225,6 +225,7 @@ return Element('index.html', array( 'config' => $config, 'board' => array( + 'dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'title' => $this->settings['title'], 'subtitle' => str_replace('%s', $this->settings['thread_limit'], diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 05525299..92dfb317 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -28,6 +28,7 @@ $body = ''; $overflow = array(); $board = array( + 'dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], -- cgit v1.3 From ac4ddfec8ab8fb2d63524deb28be0de222e7ea0f Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:39:21 +0900 Subject: Update donate page --- templates/themes/donate/donate.html | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'templates') diff --git a/templates/themes/donate/donate.html b/templates/themes/donate/donate.html index 73c06cb4..1ffe0976 100644 --- a/templates/themes/donate/donate.html +++ b/templates/themes/donate/donate.html @@ -16,32 +16,18 @@

    {{ settings.title }}

    {{ settings.subtitle }}
    - +
    mascot - -
    +
    +

    Thanks for donating

    -

    The server costs $55 per month. If you buy stickers we get about 45-55% of whatever you spend. I have to pay my phone bill to keep two-factor authentication working thats $45 (I pay this myself if im not homeless for the month). I just purchased a few lainchan related domains with whatever BTC we had. $50 or so of donations needs to go to darkengine soon to reimburse him for stickers. I have to pay the bill for my Macbook too sometimes. I want to spend a bunch of donation money on a bulk order of stickers and give em away as prizes or just spam shit in the city. FOOFDOOF is the top donator, hes given us like almost $1000. Sometimes I spend the donation money on food when i'm starving. I transfer all donations into, and keep them as cash. - +

    The server costs $55 per month. If you buy stickers we get about 45-55% of whatever you spend. ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. We spent $100 for advertising in March.

    -

    The most secure and private way to donate is probably to send cash in the mail to me, but this option is only available to select people until I set up a PO box or something.

    https://www.stickermule.com/marketplace/tags/lainchan

    -

    Localbitcoins.com is a good place to buy BTC. You can donate BTC to this address: 18CshTkxW6HRFoBhXo9mLJcjkReMmjvuq9

    - buttcoin qr - -

    The absolute fastest way for me to receive and process the money is with a Credit/Debit/Prepaid card via paypal here:

    - - - - - - - - -
    + {% endfilter %} -- cgit v1.3 From e7662d385e9e852f98177435769aa9d9b08d8c4d Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:40:22 +0900 Subject: Fix irc theme to actually be IRC --- templates/themes/irc/irc.html | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'templates') diff --git a/templates/themes/irc/irc.html b/templates/themes/irc/irc.html index 9fadff99..2828b6e0 100644 --- a/templates/themes/irc/irc.html +++ b/templates/themes/irc/irc.html @@ -1,48 +1,29 @@ {% filter remove_whitespace %} - + {{ settings.title }} - + + - - -
    - {{ boardlist.top }} + + +
    + {{ boardlist.top }}
    - {% if config.url_banner %}{% endif %}

    {{ settings.title }}

    {{ settings.subtitle }}
    - mascot -
    -

    WELCOME TO CYBERIA

    - -

    Welcome to lainchan's #BADA55 radio stream.
    Statistics - about this stream such as current listeners, song title, et - cetera will soon be added to this page. -

    - - - - +
    +

    Web Client - Point your own clients to #lainchan on irc.freenode.net.

    +
    -- cgit v1.3 From e7506c1961664c7eb2390803f4f5bd89e5b730d3 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Fri, 23 Sep 2016 22:40:55 +0900 Subject: Fix radio them to actually be Radio --- templates/themes/radio/radio.html | 66 +++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 10 deletions(-) (limited to 'templates') diff --git a/templates/themes/radio/radio.html b/templates/themes/radio/radio.html index 2828b6e0..b19d703a 100644 --- a/templates/themes/radio/radio.html +++ b/templates/themes/radio/radio.html @@ -1,29 +1,75 @@ {% filter remove_whitespace %} - + {{ settings.title }} - - + - - -
    - {{ boardlist.top }} + + + + +
    + {{ boardlist.top }}
    + {% if config.url_banner %}{% endif %}

    {{ settings.title }}

    {{ settings.subtitle }}
    + mascot + +
    +

    WELCOME TO CYBERIA

    + +

    Welcome to lainchan's radio stream. +

    + + +

    Now playing: +

    +

    Current listeners: +

    + + -
    -

    Web Client - Point your own clients to #lainchan on irc.freenode.net.

    - +
    -- cgit v1.3 From 9436524a306c8e3d6d8a6ed195e2a3c56d5cde39 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 24 Sep 2016 20:19:08 +0900 Subject: Added donation progress bar to donate theme --- templates/themes/donate/donate.html | 179 +++++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/themes/donate/donate.html b/templates/themes/donate/donate.html index 1ffe0976..551eea62 100644 --- a/templates/themes/donate/donate.html +++ b/templates/themes/donate/donate.html @@ -8,6 +8,166 @@ {% if config.font_awesome %}{% endif %} +
    {{ boardlist.top }}
    @@ -21,10 +181,25 @@

    Thanks for donating

    -

    The server costs $55 per month. If you buy stickers we get about 45-55% of whatever you spend. ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. We spent $100 for advertising in March. +

    The server costs $55 per month. If you buy stickers we get about 45-55% of whatever you spend. Historical donation records to the former owner are ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. If you don't want to buy stickers, but want to donate something else please either ask in /q/ or contact the Lainchan administration on IRC at #lainchan on Freenode.

    -

    https://www.stickermule.com/marketplace/tags/lainchan

    +

    Buy stickers here +

    + +

    Monthly Funding Progress Bar

    + +

    Cost per month $55

    + +

    Funds from stickers $37.75

    + +
    +
    + +
    +
    $-19.25
    +
    -- cgit v1.3 From ea9da7da611509fbe9c5f23867414242a443e3a8 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sun, 2 Oct 2016 01:15:34 +0900 Subject: Make slack report notifier, donate page, irc page and radio page use configuration variables instead of hard coding values. --- inc/config.php | 6 +- post.php | 52 +++++------ stylesheets/progressbar.css | 159 +++++++++++++++++++++++++++++++++ templates/themes/donate/donate.html | 173 ++---------------------------------- templates/themes/donate/info.php | 33 ++++++- templates/themes/irc/info.php | 7 +- templates/themes/irc/irc.html | 4 +- templates/themes/irc/radio.html | 29 ------ templates/themes/radio/info.php | 9 +- templates/themes/radio/radio.html | 2 +- 10 files changed, 244 insertions(+), 230 deletions(-) create mode 100644 stylesheets/progressbar.css delete mode 100644 templates/themes/irc/radio.html (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index dc65068f..0f2d40fc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1811,9 +1811,9 @@ '
    '; // Slack Report Notification - $config['slack'] = true; - $config['slack_channel'] = "reports"; - $config['slack_incoming_webhook_endpoint'] = "https://hooks.slack.com/services/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"; + $config['slack'] = false; + $config['slack_channel'] = ""; + $config['slack_incoming_webhook_endpoint'] = "https://hooks.slack.com/services/"; // Password hashing function // diff --git a/post.php b/post.php index 070cbd88..84858bb2 100644 --- a/post.php +++ b/post.php @@ -342,36 +342,38 @@ if (isset($_POST['delete'])) { $query->bindValue(':post', $id, PDO::PARAM_INT); $query->bindValue(':reason', $reason, PDO::PARAM_STR); $query->execute() or error(db_error($query)); - if ($config['slack']) - { - function slack($message, $room = "reports", $icon = ":no_entry_sign:") - { - $room = ($room) ? $room : "reports"; - $data = "payload=" . json_encode(array( - "channel" => "#{$room}", - "text" => urlencode($message), - "icon_emoji" => $icon - )); - - // You can get your webhook endpoint from your Slack settings - // For some reason using the configuration key doesn't work - //$ch = curl_init($config['slack_incoming_webhook_endpoint']); - $ch = curl_init("https://hooks.slack.com/services/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"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $result = curl_exec($ch); - curl_close($ch); - - return $result; - } + + if ($config['slack']) + { + + function slack($message, $room = "reports", $icon = ":no_entry_sign:") + { + $room = ($room) ? $room : "reports"; + $data = "payload=" . json_encode(array( + "channel" => "#{$room}", + "text" => urlencode($message), + "icon_emoji" => $icon + )); + + // You can get your webhook endpoint from your Slack settings + // For some reason using the configuration key doesn't work + $ch = curl_init($config['slack_incoming_webhook_endpoint']); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($ch); + curl_close($ch); + + return $result; + } $postcontent = mb_substr($thread['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_'; $slackmessage = '<' .$config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html" . ($thread['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n'; $slackresult = slack($slackmessage, $config['slack_channel']); - } + + } } diff --git a/stylesheets/progressbar.css b/stylesheets/progressbar.css new file mode 100644 index 00000000..6083e72e --- /dev/null +++ b/stylesheets/progressbar.css @@ -0,0 +1,159 @@ + /*---------------------------*/ + .container { + margin: auto; + width : 50%; + } + .progress-bar { + background-color: #1a1a1a; + height: 25px; + padding: 5px; + width: 350px; + position: relative; + margin: 70px 0 20px 0; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + -moz-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444; + -webkit-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444; + box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444; + } + + .progress-bar span { + display: inline-block; + height: 100%; + background-color: #777; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset; + -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset; + box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset; + -webkit-transition: width .4s ease-in-out; + -moz-transition: width .4s ease-in-out; + -ms-transition: width .4s ease-in-out; + -o-transition: width .4s ease-in-out; + transition: width .4s ease-in-out; + } + + + .blue span { + background-color: #34c2e3; + } + + .red span { + background-color: #f42323; + background-image: -webkit-gradient(linear, left top, left bottom, from(#f42323), to(#ff0000)); + background-image: -webkit-linear-gradient(top, #f42323, #ff0000); + background-image: -moz-linear-gradient(top, #f42323, #ff0000); + background-image: -ms-linear-gradient(top, #f42323, #ff0000); + background-image: -o-linear-gradient(top, #f42323, #ff0000); + background-image: linear-gradient(top, #f42323, #ff0000); + } + + .green span { + background-color: #a5df41; + background-image: -webkit-gradient(linear, left top, left bottom, from(#a5df41), to(#4ca916)); + background-image: -webkit-linear-gradient(top, #a5df41, #4ca916); + background-image: -moz-linear-gradient(top, #a5df41, #4ca916); + background-image: -ms-linear-gradient(top, #a5df41, #4ca916); + background-image: -o-linear-gradient(top, #a5df41, #4ca916); + background-image: linear-gradient(top, #a5df41, #4ca916); + } + + /*---------------------------*/ + + .stripes span { + -webkit-background-size: 30px 30px; + -moz-background-size: 30px 30px; + background-size: 30px 30px; + background-image: -webkit-gradient(linear, left top, right bottom, + color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent), + color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)), + color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent), + to(transparent)); + background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, + transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, + transparent 75%, transparent); + + -webkit-animation: animate-stripes 3s linear infinite; + -moz-animation: animate-stripes 3s linear infinite; + } + + @-webkit-keyframes animate-stripes { + 0% {background-position: 0 0;} 100% {background-position: 60px 0;} + } + + + @-moz-keyframes animate-stripes { + 0% {background-position: 0 0;} 100% {background-position: 60px 0;} + } + + /*---------------------------*/ + + .shine span { + position: relative; + } + + .shine span::after { + content: ''; + opacity: 0; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #fff; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + + -webkit-animation: animate-shine 2s ease-out infinite; + -moz-animation: animate-shine 2s ease-out infinite; + } + + @-webkit-keyframes animate-shine { + 0% {opacity: 0; width: 0;} + 50% {opacity: .5;} + 100% {opacity: 0; width: 95%;} + } + + + @-moz-keyframes animate-shine { + 0% {opacity: 0; width: 0;} + 50% {opacity: .5;} + 100% {opacity: 0; width: 95%;} + } + .glow span { + -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset; + -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset; + box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset; + + -webkit-animation: animate-glow 1s ease-out infinite; + -moz-animation: animate-glow 1s ease-out infinite; + } + + @-webkit-keyframes animate-glow { + 0% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;} + 50% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;} + 100% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;} + } + + @-moz-keyframes animate-glow { + 0% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;} + 50% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;} + 100% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;} + } + + diff --git a/templates/themes/donate/donate.html b/templates/themes/donate/donate.html index 551eea62..27f16747 100644 --- a/templates/themes/donate/donate.html +++ b/templates/themes/donate/donate.html @@ -7,167 +7,8 @@ + {% if config.font_awesome %}{% endif %} -
    {{ boardlist.top }}
    @@ -181,7 +22,7 @@

    Thanks for donating

    -

    The server costs $55 per month. If you buy stickers we get about 45-55% of whatever you spend. Historical donation records to the former owner are ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. If you don't want to buy stickers, but want to donate something else please either ask in /q/ or contact the Lainchan administration on IRC at #lainchan on Freenode. +

    The server costs {{ settings.monthlyamount }} per month. If you buy stickers we get about 45-55% of whatever you spend. Historical donation records to the former owner are ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. If you don't want to buy stickers, but want to donate something else please either ask in /q/ or contact the Lainchan administration on IRC at #lainchan on Freenode.

    Buy stickers here @@ -189,16 +30,16 @@

    Monthly Funding Progress Bar

    -

    Cost per month $55

    +

    Cost per month {{ settings.monthlyamount }}

    -

    Funds from stickers $37.75

    +

    Funds from stickers {{ settings.currentamount }}

    -
    - +
    -
    $-19.25
    +
    {{ settings.currentprogress }}
    diff --git a/templates/themes/donate/info.php b/templates/themes/donate/info.php index fa3f649b..2b618e89 100644 --- a/templates/themes/donate/info.php +++ b/templates/themes/donate/info.php @@ -17,7 +17,38 @@ $theme = array( array('title' => 'File', 'name' => 'file', 'type' => 'text', - 'default' => 'donate.html')), + 'default' => 'donate.html'), + + array('title' => 'Monthly Amount', + 'name' => 'monthlyamount', + 'type' => 'text', + 'default' => '$55'), + + array('title' => 'Current Amount', + 'name' => 'currentamount', + 'type' => 'text', + 'default' => '$0'), + + array('title' => 'Current Progress', + 'name' => 'currentprogress', + 'type' => 'text', + 'default' => '$0'), + + array('title' => 'Progress Bar CSS class', + 'name' => 'progressbarcssclass', + 'type' => 'text', + 'default' => 'progress-bar red glow'), + + array('title' => 'Progress Bar CSS left', + 'name' => 'progressbarcssleft', + 'type' => 'text', + 'default' => '36'), + + array('title' => 'Progress Bar Text CSS left', + 'name' => 'progressbartextcssleft', + 'type' => 'text', + 'default' => '135'), + ), 'build_function' => 'donate_build'); ?> diff --git a/templates/themes/irc/info.php b/templates/themes/irc/info.php index 8b31b011..59ff4bd6 100644 --- a/templates/themes/irc/info.php +++ b/templates/themes/irc/info.php @@ -17,7 +17,12 @@ $theme = array( array('title' => 'File', 'name' => 'file', 'type' => 'text', - 'default' => 'irc.html')), + 'default' => 'irc.html'), + + array('title' => 'Channel', + 'name' => 'channel', + 'type' => 'text', + 'default' => 'lainchan')), 'build_function' => 'irc_build'); ?> diff --git a/templates/themes/irc/irc.html b/templates/themes/irc/irc.html index 2828b6e0..1766f426 100644 --- a/templates/themes/irc/irc.html +++ b/templates/themes/irc/irc.html @@ -22,8 +22,8 @@
    -

    Web Client - Point your own clients to #lainchan on irc.freenode.net.

    - +

    Web Client - Point your own clients to #{{ settings.channel }} on irc.freenode.net.

    +
    diff --git a/templates/themes/irc/radio.html b/templates/themes/irc/radio.html deleted file mode 100644 index 7f84134b..00000000 --- a/templates/themes/irc/radio.html +++ /dev/null @@ -1,29 +0,0 @@ -{% filter remove_whitespace %} - - - - - {{ settings.title }} - - - - - - -
    - {{ boardlist.top }} -
    - -
    -

    {{ settings.title }}

    -
    {{ settings.subtitle }}
    -
    - - -
    -

    Web Client - Point your own clients to #lainchan on irc.freenode.net.

    - -
    - - -{% endfilter %} diff --git a/templates/themes/radio/info.php b/templates/themes/radio/info.php index d6679733..2ae31fbd 100644 --- a/templates/themes/radio/info.php +++ b/templates/themes/radio/info.php @@ -17,7 +17,12 @@ $theme = array( array('title' => 'File', 'name' => 'file', 'type' => 'text', - 'default' => 'radio.html')), + 'default' => 'radio.html'), + + array('title' => 'Radio Status URL', + 'name' => 'radiostatus', + 'type' => 'text', + 'default' => '/radio_assets/status.xsl')), 'build_function' => 'radio_build'); -?> \ No newline at end of file +?> diff --git a/templates/themes/radio/radio.html b/templates/themes/radio/radio.html index b19d703a..3e16430e 100644 --- a/templates/themes/radio/radio.html +++ b/templates/themes/radio/radio.html @@ -16,7 +16,7 @@ $(document).ready(function(){ }); function check_status(){ -$.get("/radio_assets/status.xsl", function(data){ +$.get("{{ settings.radiostatus }}", function(data){ var el = $( '
    ' ); el.html(data); var sd = el.find(".streamdata"); -- cgit v1.3 From c0d1f60752f9a9c2ff6c2516cd7edd946fd3a441 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 8 Oct 2016 00:47:55 +0900 Subject: Add other donation fields to donate theme / extension --- templates/themes/donate/donate.html | 4 +++- templates/themes/donate/info.php | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/themes/donate/donate.html b/templates/themes/donate/donate.html index 27f16747..1ecf008e 100644 --- a/templates/themes/donate/donate.html +++ b/templates/themes/donate/donate.html @@ -32,7 +32,9 @@

    Cost per month {{ settings.monthlyamount }}

    -

    Funds from stickers {{ settings.currentamount }}

    +

    Funds from stickers {{ settings.stickeramount }}

    + +

    Funds from other donations {{ settings.otheramount }}

    diff --git a/templates/themes/donate/info.php b/templates/themes/donate/info.php index 2b618e89..6fa57cd6 100644 --- a/templates/themes/donate/info.php +++ b/templates/themes/donate/info.php @@ -24,8 +24,13 @@ $theme = array( 'type' => 'text', 'default' => '$55'), - array('title' => 'Current Amount', - 'name' => 'currentamount', + array('title' => 'Current Sticker Amount', + 'name' => 'stickeramount', + 'type' => 'text', + 'default' => '$0'), + + array('title' => 'Current Other Donations Amount', + 'name' => 'otheramount', 'type' => 'text', 'default' => '$0'), -- cgit v1.3 From 379fe63fba2bd74584a4af0a209022207974c66c Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 8 Oct 2016 00:48:55 +0900 Subject: Add enable per board feature and only include new threads feature for RSS theme / extension --- templates/themes/rss/info.php | 14 +++++ templates/themes/rss/rss.xml | 2 +- templates/themes/rss/theme.php | 114 +++++++++++++++++++++-------------------- 3 files changed, 74 insertions(+), 56 deletions(-) (limited to 'templates') diff --git a/templates/themes/rss/info.php b/templates/themes/rss/info.php index 14b39eb9..4da43bf0 100755 --- a/templates/themes/rss/info.php +++ b/templates/themes/rss/info.php @@ -48,6 +48,20 @@ 'comment' => '(eg. "http://test.com")' ); + $theme['config'][] = Array( + 'title' => 'Show Threads Only', + 'name' => 'show_threads_only', + 'type' => 'text', + 'default' => 'false', + ); + + $theme['config'][] = Array( + 'title' => 'Enable Per Board', + 'name' => 'enable_per_board', + 'type' => 'text', + 'default' => 'false', + ); + // Unique function name for building everything $theme['build_function'] = 'rss_recentposts_build'; $theme['install_callback'] = 'rss_recentposts_install'; diff --git a/templates/themes/rss/rss.xml b/templates/themes/rss/rss.xml index 30fdb473..6bf34113 100644 --- a/templates/themes/rss/rss.xml +++ b/templates/themes/rss/rss.xml @@ -11,7 +11,7 @@ {{ settings.base_url }}{{ config.root }}{{ settings.html }} {% for post in recent_posts %} - {{ post.board_name }} + <![CDATA[ {{ post.board_name }} ]]> diff --git a/templates/themes/rss/theme.php b/templates/themes/rss/theme.php index 33c1b210..d0a80f51 100755 --- a/templates/themes/rss/theme.php +++ b/templates/themes/rss/theme.php @@ -16,52 +16,91 @@ // Wrap functions in a class so they don't interfere with normal Tinyboard operations class RSSRecentPosts { public function build($action, $settings) { - global $config, $_theme; + global $config, $_theme,$board; - /*if ($action == 'all') { - copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); - }*/ $this->excluded = explode(' ', $settings['exclude']); - - if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . $settings['xml'], $this->homepage($settings)); + if ($settings['show_threads_only'] == 'true'){ + if ($action == 'all' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . $settings['xml'], $this->site_rsspage($settings)); + } + else { + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . $settings['xml'], $this->site_rsspage($settings)); + } + + if ($settings['enable_per_board'] == 'true'){ + $boards = listBoards(); + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + + openBoard($_board['uri']); + if ($settings['show_threads_only'] == 'true'){ + if ($action == 'all' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . 'debug.xml', $board['dir']); + file_write($config['dir']['home'] . $board['dir'] . $settings['xml'], $this->board_rsspage($settings,$_board)); + } + else { + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . $board['dir'] . $settings['xml'], $this->board_rsspage($settings,$_board)); + } + } + + } } // Build news page - public function homepage($settings) { + public function site_rsspage($settings) { global $config, $board; - //$recent_images = Array(); $recent_posts = Array(); - //$stats = Array(); $boards = listBoards(); - /*$query = ''; + $query = ''; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; - $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']); + if ($settings['show_threads_only'] == 'true'){ + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` is null UNION ALL ", $_board['uri'], $_board['uri']); + } + else { + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']); + } } - $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query); + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query); $query = query($query) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; - $post['src'] = $config['uri_thumb'] . $post['thumb']; + $post['snippet'] = pm_snippet($post['body'], 30); + $post['board_name'] = $board['name']; - //$recent_images[] = $post; - }*/ + $recent_posts[] = $post; + } + + + return Element('themes/rss/rss.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'recent_posts' => $recent_posts, + )); + } + + // Build news page + public function board_rsspage($settings,$_board) { + global $config, $board; + $recent_posts = Array(); $query = ''; - foreach ($boards as &$_board) { - if (in_array($_board['uri'], $this->excluded)) - continue; + if ($settings['show_threads_only'] == 'true'){ + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` is null UNION ALL ", $_board['uri'], $_board['uri']); + } + else { $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']); } $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query); @@ -77,46 +116,11 @@ $recent_posts[] = $post; } - // Total posts - /*$query = 'SELECT SUM(`top`) FROM ('; - foreach ($boards as &$_board) { - if (in_array($_board['uri'], $this->excluded)) - continue; - $query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']); - } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); - $query = query($query) or error(db_error());*/ - //$stats['total_posts'] = number_format($query->fetchColumn()); - - // Unique IPs - /*$query = 'SELECT COUNT(DISTINCT(`ip`)) FROM ('; - foreach ($boards as &$_board) { - if (in_array($_board['uri'], $this->excluded)) - continue; - $query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']); - } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); - $query = query($query) or error(db_error()); - //$stats['unique_posters'] = number_format($query->fetchColumn());*/ - - // Active content - /*$query = 'SELECT SUM(`filesize`) FROM ('; - foreach ($boards as &$_board) { - if (in_array($_board['uri'], $this->excluded)) - continue; - $query .= sprintf("SELECT `filesize` FROM ``posts_%s`` UNION ALL ", $_board['uri']); - } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); - $query = query($query) or error(db_error()); - //$stats['active_content'] = $query->fetchColumn();*/ return Element('themes/rss/rss.xml', Array( 'settings' => $settings, 'config' => $config, - //'boardlist' => createBoardlist(), - //'recent_images' => $recent_images, 'recent_posts' => $recent_posts, - //'stats' => $stats )); } }; -- cgit v1.3 From 2abb80ba296908be3d4480ff32e5eda3822881a6 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 8 Oct 2016 01:47:53 +0900 Subject: Remove debugging from RSS extension --- templates/themes/rss/theme.php | 1 - 1 file changed, 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/rss/theme.php b/templates/themes/rss/theme.php index d0a80f51..eb833ec8 100755 --- a/templates/themes/rss/theme.php +++ b/templates/themes/rss/theme.php @@ -38,7 +38,6 @@ openBoard($_board['uri']); if ($settings['show_threads_only'] == 'true'){ if ($action == 'all' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . 'debug.xml', $board['dir']); file_write($config['dir']['home'] . $board['dir'] . $settings['xml'], $this->board_rsspage($settings,$_board)); } else { -- cgit v1.3 From fa01d816b3b2d9dfb4f6b37435d1a6fd3cbf76f7 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 8 Oct 2016 15:29:06 +0900 Subject: Add stream theme / extension to Lainchan --- templates/themes/stream/info.php | 74 +++++++++++++++++++++++++++++++ templates/themes/stream/stream.html | 84 ++++++++++++++++++++++++++++++++++++ templates/themes/stream/theme.php | 34 +++++++++++++++ templates/themes/stream/thumb.png | Bin 0 -> 7872 bytes 4 files changed, 192 insertions(+) create mode 100644 templates/themes/stream/info.php create mode 100644 templates/themes/stream/stream.html create mode 100644 templates/themes/stream/theme.php create mode 100644 templates/themes/stream/thumb.png (limited to 'templates') diff --git a/templates/themes/stream/info.php b/templates/themes/stream/info.php new file mode 100644 index 00000000..169cbe46 --- /dev/null +++ b/templates/themes/stream/info.php @@ -0,0 +1,74 @@ + 'Site title', + 'name' => 'title', + 'type' => 'text' + ); + + $theme['config'][] = Array( + 'title' => 'Slogan', + 'name' => 'subtitle', + 'type' => 'text', + 'comment' => '(optional)' + ); + + $theme['config'][] = Array( + 'title' => 'File', + 'name' => 'file', + 'type' => 'text', + 'default' => 'stream.html', + 'comment' => '(eg. "stream.html")' + ); + $theme['config'][] = Array( + 'title' => 'OGV stream URL', + 'name' => 'ogvurl', + 'type' => 'text', + 'default' => 'https://lainchan.org/radio_assets/lainstream.ogg') + ); + $theme['config'][] = Array( + 'title' => 'RTMP stream URL', + 'name' => 'rtmpurl', + 'type' => 'text', + 'default' => 'rtmp://lainchan.org/live/&stream') + ); + + $theme['config'][] = Array( + 'title' => 'OGV Status URL', + 'name' => 'ogvstatus', + 'type' => 'text', + 'default' => '/radio_assets/status.xsl') + ); + + $theme['config'][] = Array( + 'title' => 'RTMP Status URL', + 'name' => 'rtmpstatus', + 'type' => 'text', + 'default' => '/live/status?app=live&name=stream') + ); + $theme['config'][] = Array( + 'title' => 'RTMP Viewers URL', + 'name' => 'rtmpviewers', + 'type' => 'text', + 'default' => '/live/subs?app=live&name=stream') + ); + + + // Unique function name for building everything + $theme['build_function'] = 'stream_build'; + $theme['install_callback'] = 'stream_install'; + if (!function_exists('stream_install')) { + function stream_install($settings) { + } + } + diff --git a/templates/themes/stream/stream.html b/templates/themes/stream/stream.html new file mode 100644 index 00000000..cf952366 --- /dev/null +++ b/templates/themes/stream/stream.html @@ -0,0 +1,84 @@ +{% filter remove_whitespace %} + + + + + + + {{ settings.title }} + {% if config.meta_keywords %}{% endif %} + + {% if config.url_favicon %}{% endif %} + + + {% if config.font_awesome %}{% endif %} + + + + + +
    + {{ boardlist.top }} +
    +
    +

    {{ settings.title }}

    +
    {{ settings.subtitle }}
    +
    + +
    + + +
    +

    Now Streaming RTMP unknown

    +

    Now Streaming OGV unknown

    +

    Current RTMP viewers: unknown

    +

    Current OGV viewers: unknown

    +
    +

    Raw stream URLs for Mplayer, mpv, VLC, etc:

    +

    RTMP : {{ setings.rtmpurl }}

    +

    OGV : {{ setings.ogvurl }}

    +

    +
    + +
    + +
    +
    +

    - Tinyboard + + vichan {{ config.version }} - +
    Tinyboard Copyright © 2010-2014 Tinyboard Development Group +
    vichan Copyright © 2012-2015 vichan-devel

    +
    + + + +{% endfilter %} diff --git a/templates/themes/stream/theme.php b/templates/themes/stream/theme.php new file mode 100644 index 00000000..6d11a0dc --- /dev/null +++ b/templates/themes/stream/theme.php @@ -0,0 +1,34 @@ + $settings, + 'config' => $config, + 'boardlist' => createBoardlist(), + )); + } + }; + +?> diff --git a/templates/themes/stream/thumb.png b/templates/themes/stream/thumb.png new file mode 100644 index 00000000..d0c3c771 Binary files /dev/null and b/templates/themes/stream/thumb.png differ -- cgit v1.3 From bd3cc259810fa664abd09de0d94e4d0dc70648e8 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 10 Dec 2016 18:15:11 +0900 Subject: Add JSON API to Ukko Overboard Theme --- templates/themes/ukko/theme.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index ee2707bf..a3f30dd4 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -15,6 +15,10 @@ if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); + if ($config['api']['enabled']) { + $jsonFilename = $settings['uri'] . '/0.json'; + file_unlink($jsonFilename); + } } elseif ($action == 'rebuild') { file_write($settings['uri'] . '/index.html', $ukko->build()); @@ -48,6 +52,9 @@ $count = 0; $threads = array(); + if ($config['api']['enabled']) { + $apithreads = array(); + } while($post = $query->fetch()) { if(!isset($threads[$post['board']])) { @@ -89,6 +96,9 @@ $thread->posts = array_reverse($thread->posts); $body .= '

    /' . $post['board'] . '/

    '; $body .= $thread->build(true); + if ($config['api']['enabled']) { + array_push($apithreads,$thread); + } } else { $page = 'index'; if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { @@ -102,7 +112,15 @@ $body .= ''; $body .= ''; - + + // json api + if ($config['api']['enabled']) { + require_once __DIR__. '/../../../inc/api.php'; + $api = new Api(); + $jsonFilename = $board['dir'] . '0.json'; + $json = json_encode($api->translatePage($apithreads)); + file_write($jsonFilename, $json); + } return Element('index.html', array( 'config' => $config, 'board' => $board, -- cgit v1.3 From 1c7c6458316daaed5b233e1c125a7aa2f853425e Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 10 Dec 2016 18:18:27 +0900 Subject: Adding separate videojs RTMP URL configuration variable to stream theme --- templates/themes/stream/info.php | 16 +++++++++++----- templates/themes/stream/stream.html | 18 +++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'templates') diff --git a/templates/themes/stream/info.php b/templates/themes/stream/info.php index 169cbe46..081b29ca 100644 --- a/templates/themes/stream/info.php +++ b/templates/themes/stream/info.php @@ -34,33 +34,39 @@ 'title' => 'OGV stream URL', 'name' => 'ogvurl', 'type' => 'text', - 'default' => 'https://lainchan.org/radio_assets/lainstream.ogg') + 'default' => 'https://lainchan.org/radio_assets/lainstream.ogg' ); $theme['config'][] = Array( 'title' => 'RTMP stream URL', 'name' => 'rtmpurl', 'type' => 'text', - 'default' => 'rtmp://lainchan.org/live/&stream') + 'default' => 'rtmp://lainchan.org/live/stream' + ); + $theme['config'][] = Array( + 'title' => 'RTMP Video.JS stream URL', + 'name' => 'rtmpvideojsurl', + 'type' => 'text', + 'default' => 'rtmp://lainchan.org/live/&stream' ); $theme['config'][] = Array( 'title' => 'OGV Status URL', 'name' => 'ogvstatus', 'type' => 'text', - 'default' => '/radio_assets/status.xsl') + 'default' => '/radio_assets/status.xsl' ); $theme['config'][] = Array( 'title' => 'RTMP Status URL', 'name' => 'rtmpstatus', 'type' => 'text', - 'default' => '/live/status?app=live&name=stream') + 'default' => '/live/status?app=live&name=stream' ); $theme['config'][] = Array( 'title' => 'RTMP Viewers URL', 'name' => 'rtmpviewers', 'type' => 'text', - 'default' => '/live/subs?app=live&name=stream') + 'default' => '/live/subs?app=live&name=stream' ); diff --git a/templates/themes/stream/stream.html b/templates/themes/stream/stream.html index cf952366..dc2ed26d 100644 --- a/templates/themes/stream/stream.html +++ b/templates/themes/stream/stream.html @@ -12,6 +12,9 @@ {% if config.font_awesome %}{% endif %} + + {{ settings.title }} ( /{{ board }}/ ) {% include 'header.html' %} @@ -41,7 +42,7 @@
    - +

    {% for post in recent_posts %} diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 24cdcbb8..3ef974c3 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -15,7 +15,7 @@ // - post-thread (a thread has been made) if ($action === 'all') { foreach ($boards as $board) { - $b = new Catalog(); + $b = new Catalog($settings); $action = generation_strategy("sb_catalog", array($board)); if ($action == 'delete') { @@ -27,7 +27,7 @@ } } } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) { - $b = new Catalog(); + $b = new Catalog($settings); $action = generation_strategy("sb_catalog", array($board)); if ($action == 'delete') { @@ -148,10 +148,13 @@ /** * Build and save the HTML of the catalog for the given board */ - public function build($board_name) { - if (!openBoard($board_name)) { - error(sprintf(_("Board %s doesn't exist"), $post['board'])); - } + public function build($settings, $board_name) { + global $config, $board; + if ($board['uri'] != $board_name) { + if (!openBoard($board_name)) { + error(sprintf(_("Board %s doesn't exist"), $board_name)); + } + } if (array_key_exists($board_name, $this->threadsCache)) { $threads = $this->threadsCache[$board_name]; -- cgit v1.3 From b89fe3046bfbc0d7db8e7e8773e92c0536417450 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 10 Dec 2016 18:39:18 +0900 Subject: Fix board filter listing in the search form --- templates/search_form.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/search_form.html b/templates/search_form.html index 4c8bd077..095968de 100644 --- a/templates/search_form.html +++ b/templates/search_form.html @@ -6,8 +6,13 @@ -- cgit v1.3 From 2c9fbb5770495a209872642fb3169d8568e4181e Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 10 Dec 2016 18:40:11 +0900 Subject: Updated maximum file size on rules page --- templates/rules.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/rules.html b/templates/rules.html index 76fb6a5f..3cc064c2 100644 --- a/templates/rules.html +++ b/templates/rules.html @@ -24,7 +24,7 @@
  • Mods usually ask each other for opinions before doing anything. We hate having to ban someone.
  • Just relax and try to have fun. Jokes are always welcome.
  • Visit a board you've never been to. Try out /random/.
  • -
  • Max file size is 35 mb.
  • +
  • Max file size is 25 mb.
  • PDF, ePub, and webm are supported across the boards.
  • We ALWAYS need contributors to our board software, located on github
  • Dice rolling: posting in the email field with the form "dice XdY+/-Z" will result in X Y-sided dice rolled and summed, with the modifier Z added, the result is displayed at the top of the post body.
  • -- cgit v1.3 From ceb8df370caeba48219530bf5deb5e6a06e56648 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sun, 11 Dec 2016 08:04:18 +0900 Subject: Fix copyright on page templates --- templates/generic_page.html | 11 +++++++---- templates/page.html | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'templates') diff --git a/templates/generic_page.html b/templates/generic_page.html index 6d2f28c3..cc076106 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -38,10 +38,13 @@ {% endfor %} {{ btn.next }}
    {{ boardlist.bottom }}
    -

    - Tinyboard + - vichan {{ config.version }} - -
    Tinyboard Copyright © 2010-2014 Tinyboard Development Group -
    vichan Copyright © 2012-2016 vichan-devel

    +

    - Tinyboard + + vichan + + lainchan {{ config.version }} - +
    Tinyboard Copyright © 2010-2014 Tinyboard Development Group +
    vichan Copyright © 2012-2016 vichan-devel +
    lainchan Copyright © 2014-2016 lainchan Administration

    + {% for footer in config.footer %}

    {{ footer }}

    {% endfor %}