From a25e5f7839fa68fe464bbb0d5fe112b9d13a3c76 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 24 Sep 2014 03:21:32 +0200 Subject: additional measurements for catalog, so it does not throw errors; should fix vichan-devel#84 --- templates/themes/catalog/theme.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'templates') diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 357870e4..9ba2d27a 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -49,28 +49,30 @@ $post['youtube'] = $matches[2]; } - if (isset($post['files'])) { + if (isset($post['files']) && $post['files']) { $files = json_decode($post['files']); - if ($files[0]->file == 'deleted') { - if (count($files) > 1) { - foreach ($files as $file) { - if (($file == $files[0]) || ($file->file == 'deleted')) continue; - $post['file'] = $config['uri_thumb'] . $file->thumb; - } + if ($files[0]) { + if ($files[0]->file == 'deleted') { + if (count($files) > 1) { + foreach ($files as $file) { + if (($file == $files[0]) || ($file->file == 'deleted')) continue; + $post['file'] = $config['uri_thumb'] . $file->thumb; + } - if (empty($post['file'])) $post['file'] = $config['image_deleted']; + if (empty($post['file'])) $post['file'] = $config['image_deleted']; + } + else { + $post['file'] = $config['image_deleted']; + } + } + else if($files[0]->thumb == 'spoiler') { + $post['file'] = '/' . $config['spoiler_image']; } else { - $post['file'] = $config['image_deleted']; + $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } } - else if($files[0]->thumb == 'spoiler') { - $post['file'] = '/' . $config['spoiler_image']; - } - else { - $post['file'] = $config['uri_thumb'] . $files[0]->thumb; - } } if (empty($post['image_count'])) $post['image_count'] = 0; -- cgit v1.3 From 45dd9e637f94d3e0b4c8c1f02a378fff4f199afd Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 16:54:19 -0700 Subject: Added scrolling threads with up and down keys For 8chan X. Redone so it's in js folder. @KillerWhale321 --- templates/index.html | 2 ++ 1 file changed, 2 insertions(+) (limited to 'templates') diff --git a/templates/index.html b/templates/index.html index 52328675..105d1584 100644 --- a/templates/index.html +++ b/templates/index.html @@ -86,5 +86,7 @@ + + -- cgit v1.3 From e81d016ffac5a5e7f73a9aafe35a221397b51a51 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 19 Apr 2014 20:02:39 +0000 Subject: Attempt to fix scroll to anchor issue --- templates/main.js | 1 + 1 file changed, 1 insertion(+) (limited to 'templates') diff --git a/templates/main.js b/templates/main.js index 97f1135f..9286d201 100644 --- a/templates/main.js +++ b/templates/main.js @@ -154,6 +154,7 @@ function highlightReply(id) { var post = document.getElementById('reply_'+id); if (post) post.className += ' highlighted'; + window.location.hash = id; } return true; } -- cgit v1.3 From cb7b7d070cad4286c998579d4cd263b9979535ef Mon Sep 17 00:00:00 2001 From: 8chan Date: Fri, 26 Sep 2014 23:53:52 +0000 Subject: threadscroll was in template for no reason --- templates/index.html | 1 - 1 file changed, 1 deletion(-) (limited to 'templates') diff --git a/templates/index.html b/templates/index.html index 105d1584..8c4c278d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -87,6 +87,5 @@ ready(); {% endraw %} - -- cgit v1.3 From 296e4fd5fa2510623a9680df4fa37ddf0bd6485a Mon Sep 17 00:00:00 2001 From: kaf Date: Wed, 1 Oct 2014 10:40:51 +0000 Subject: Added an option to hide sages --- inc/config.php | 3 +++ templates/post/name.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index e2cc2ebd..93fc7687 100644 --- a/inc/config.php +++ b/inc/config.php @@ -529,6 +529,9 @@ // When true, users are instead presented a selectbox for email. Contains, blank, noko and sage. $config['field_email_selectbox'] = false; + // When true, the sage won't be displayed + $config['hide_sage'] = false; + // Attach country flags to posts. $config['country_flags'] = false; diff --git a/templates/post/name.html b/templates/post/name.html index 009b234d..13c676c7 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 %} +{% if post.email|length > 0 and (config.hide_sage!=true or post.email!='sage') %} {# start email #} Tinyboard Copyright © 2010-2014 Tinyboard Development Group
vichan Copyright © 2012-2014 vichan-devel

- + + + {% endfilter %} -- cgit v1.3 From 1edaea309b115bbbd17ab121f719cc9bba191c3e Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 30 Sep 2014 14:45:02 +0900 Subject: quote selected text on cite --- templates/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'templates') diff --git a/templates/main.js b/templates/main.js index 9286d201..960aac86 100644 --- a/templates/main.js +++ b/templates/main.js @@ -208,6 +208,15 @@ function citeReply(id, with_link) { textarea.value += '>>' + id + '\n'; } if (typeof $ != 'undefined') { + var select = document.getSelection().toString(); + if (select) { + var body = $('#reply_' + id).find('div.body'); // TODO: support for OPs + var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this + if (index > -1) { + textarea.value += '>' + select + '\n'; + } + } + $(window).trigger('cite', [id, with_link]); $(textarea).change(); } -- cgit v1.3 From 62b7e02050be1c9c9e561aea360da191177f344f Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 30 Sep 2014 15:24:12 +0900 Subject: give OPs IDs --- templates/main.js | 2 +- templates/post_thread.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/main.js b/templates/main.js index 960aac86..52f38e69 100644 --- a/templates/main.js +++ b/templates/main.js @@ -210,7 +210,7 @@ function citeReply(id, with_link) { if (typeof $ != 'undefined') { var select = document.getSelection().toString(); if (select) { - var body = $('#reply_' + id).find('div.body'); // TODO: support for OPs + var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this if (index > -1) { textarea.value += '>' + select + '\n'; diff --git a/templates/post_thread.html b/templates/post_thread.html index aa0f1f78..08b4c4c1 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -5,7 +5,7 @@ {% if not index %}{% endif %} {% include 'post/fileinfo.html' %} -
1%}style='clear:both'{%endif%}>

+

1%}style='clear:both'{%endif%}>

"+add+"
"; } + + if (f.reason) return add + f.reason + suf; + else return add + "-" + suf; + } }, + board: {name: _("Board"), width: "60px", fmt: function(f) { + if (f.board) return "/"+f.board+"/"; + else return ""+_("all")+""; + } }, + created: {name: _("Set"), width: "100px", fmt: function(f) { + return ago(f.created) + _(" ago"); // in AGO form + } }, + // duration? + expires: {name: _("Expires"), width: "235px", fmt: function(f) { + if (!f.expires || f.expires == 0) return ""+_("never")+""; + return strftime(window.post_date, new Date((f.expires|0)*1000), datelocale) + + ((f.expires < time()) ? "" : " "+_("in ")+until(f.expires|0)+""); + } }, + username: {name: _("Staff"), width: "100px", fmt: function(f) { + var pre='',suf='',un=f.username; + if (inMod && f.username && f.username != '?') { + pre = ""; + suf = ""; + } + if (!f.username) { + un = ""+_("system")+""; + } + return pre + un + suf; + } } + }, {}, t); + + $("#select-all").click(function(e) { + var $this = $(this); + $("input.unban").prop("checked", $this.prop("checked")); + lt.get_data().forEach(function(v) { v.access && (selected[v.id] = $this.prop("checked")); }); + e.stopPropagation(); + }); + + var filter = function(e) { + if ($("#only_mine").prop("checked") && ($.inArray(e.board, my_boards) === -1)) return false; + if ($("#only_not_expired").prop("checked") && e.expires && e.expires != 0 && e.expires < time()) return false; + if ($("#search").val()) { + var terms = $("#search").val().split(" "); + + var fields = ["mask", "reason", "board", "staff", "message"]; + + var ret_false = false; + terms.forEach(function(t) { + var fs = fields; + + var re = /^(mask|reason|board|staff|message):/, ma; + if (ma = t.match(re)) { + fs = [ma[1]]; + t = t.replace(re, ""); + } + + var found = false + fs.forEach(function(f) { + if (e[f] && e[f].indexOf(t) !== -1) { + found = true; + } + }); + if (!found) ret_false = true; + }); + + if (ret_false) return false; + } + + return true; + }; + + $("#only_mine, #only_not_expired, #search").on("click input", function() { + lt.set_filter(filter); + }); + lt.set_filter(filter); + + $(".banform").on("submit", function() { return false; }); + + $("#unban").on("click", function() { + $(".banform .hiddens").remove(); + $("").appendTo(".banform"); + + $.each(selected, function(e) { + $("").appendTo(".banform"); + }); + + $(".banform").off("submit").submit(); + }); + + if (device_type == 'desktop') { + // Stick topbar + var stick_on = $(".banlist-opts").offset().top; + var state = true; + $(window).on("scroll resize", function() { + if ($(window).scrollTop() > stick_on && state == true) { + $("body").css("margin-top", $(".banlist-opts").height()); + $(".banlist-opts").addClass("boardlist top").detach().prependTo("body"); + $("#banlist tr:not(.row)").addClass("tblhead").detach().appendTo(".banlist-opts"); + state = !state; + } + else if ($(window).scrollTop() < stick_on && state == false) { + $("body").css("margin-top", "auto"); + $(".banlist-opts").removeClass("boardlist top").detach().prependTo(".banform"); + $(".tblhead").detach().prependTo("#banlist"); + state = !state; + } + }); + } + }); +} diff --git a/mod.php b/mod.php index 5428e84d..384eec88 100644 --- a/mod.php +++ b/mod.php @@ -62,7 +62,7 @@ $pages = array( '/ban' => 'secure_POST ban', // new ban '/bans' => 'secure_POST bans', // ban list - '/bans/(\d+)' => 'secure_POST bans', // ban list + '/bans.json' => 'secure bans_json', // ban list JSON '/ban-appeals' => 'secure_POST ban_appeals', // view ban appeals '/recent/(\d+)' => 'recent_posts', // view recent posts diff --git a/templates/main.js b/templates/main.js index 52f38e69..ed25f7d9 100644 --- a/templates/main.js +++ b/templates/main.js @@ -22,6 +22,53 @@ function fmt(s,a) { return s.replace(/\{([0-9]+)\}/g, function(x) { return a[x[1]]; }); } +function until($timestamp) { + var $difference = $timestamp - Date.now()/1000|0, $num; + switch(true){ + case ($difference < 60): + return "" + $difference + ' ' + _('second(s)'); + case ($difference < 3600): //60*60 = 3600 + return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)'); + case ($difference < 86400): //60*60*24 = 86400 + return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)'); + case ($difference < 604800): //60*60*24*7 = 604800 + return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)'); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)'); + default: + return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)'); + } +} + +function ago($timestamp) { + var $difference = (Date.now()/1000|0) - $timestamp, $num; + switch(true){ + case ($difference < 60) : + return "" + $difference + ' ' + _('second(s)'); + case ($difference < 3600): //60*60 = 3600 + return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)'); + case ($difference < 86400): //60*60*24 = 86400 + return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)'); + case ($difference < 604800): //60*60*24*7 = 604800 + return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)'); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)'); + default: + return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)'); + } +} + +var datelocale = + { days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')] + , shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")] + , months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')] + , shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')] + , AM: _('AM') + , PM: _('PM') + , am: _('am') + , pm: _('pm') + }; + var saved = {}; diff --git a/templates/mod/ban_list.html b/templates/mod/ban_list.html index 97c02029..0c67f269 100644 --- a/templates/mod/ban_list.html +++ b/templates/mod/ban_list.html @@ -1,104 +1,41 @@ -{% if bans|count == 0 %} -

({% trans 'There are no active bans.' %})

-{% else %} -
- - - - - - - - - - - - - {% for ban in bans %} - - - - - - - - - - - {% endfor %} + + + + + + + + + + + {% if token %} + + {% endif %} +
+
+ {% if mod and mod.boards[0] != '*' %} + + {% endif %} + +
+
+ + {% if mod %} + + {% endif %} +
+ +
+
+ +
{% trans 'IP address/mask' %}{% trans 'Reason' %}{% trans 'Board' %}{% trans 'Set' %}{% trans 'Duration' %}{% trans 'Expires' %}{% trans 'Seen' %}{% trans 'Staff' %}
- - {% if ban.single_addr %} - {{ ban.mask }} - {% else %} - {{ ban.mask }} - {% endif %} - - {% if ban.reason %} - {{ ban.reason }} - {% else %} - - - {% endif %} - - {% if ban.board %} - {{ config.board_abbreviation|sprintf(ban.board) }} - {% else %} - {% trans 'all boards' %} - {% endif %} - - - {{ ban.created|ago }} ago - - - {% if ban.expires == 0 %} - - - {% else %} - {{ (ban.expires - ban.created + time()) | until }} - {% endif %} - - {% if ban.expires == 0 %} - {% trans 'never' %} - {% else %} - {{ ban.expires|date(config.post_date) }} - {% if ban.expires > time() %} - (in {{ ban.expires|until }}) - {% endif %} - {% endif %} - - {% if ban.seen %} - {% trans 'Yes' %} - {% else %} - {% trans 'No' %} - {% endif %} - - {% if ban.username %} - {% if mod|hasPermission(config.mod.view_banstaff) %} - {{ ban.username|e }} - {% else %} - {% if mod|hasPermission(config.mod.view_banquestionmark) %} - ? - {% else %} - - {% endif %} - {% endif %} - {% elseif ban.creator == -1 %} - system - {% else %} - {% trans 'deleted?' %} - {% endif %} -
+ + -

- -

+{% if token_json %} + +{% else %} + {% endif %} - -{% if count > bans|count %} -

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

-{% endif %} - diff --git a/templates/themes/public_banlist/info.php b/templates/themes/public_banlist/info.php new file mode 100644 index 00000000..006ac38e --- /dev/null +++ b/templates/themes/public_banlist/info.php @@ -0,0 +1,33 @@ + 'JSON feed file', + 'name' => 'file_json', + 'type' => 'text', + 'default' => 'bans.json', + 'comment' => '(eg. "bans.json")' + ); + + $theme['config'][] = Array( + 'title' => 'Main HTML file', + 'name' => 'file_bans', + 'type' => 'text', + 'default' => 'bans.html', + 'comment' => '(eg. "bans.html")' + ); + + // Unique function name for building everything + $theme['build_function'] = 'pbanlist_build'; +?> diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php new file mode 100644 index 00000000..b64b8d9e --- /dev/null +++ b/templates/themes/public_banlist/theme.php @@ -0,0 +1,56 @@ + $config, + 'mod' => false, + 'hide_dashboard_link' => true, + 'title' => _("Ban list"), + 'subtitle' => "", + 'nojavascript' => true, + 'body' => Element('mod/ban_list.html', array( + 'mod' => false, + 'boards' => "[]", + 'token' => false, + 'token_json' => false, + 'uri_json' => $config['dir']['home'] . $settings['file_json'], + )) + )); + } + }; + +?> diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index b2624ed7..058fc77b 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -4,7 +4,11 @@ function ukko_build($action, $settings) { $ukko = new ukko(); $ukko->settings = $settings; - + + if (! ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')) { + return; + } + file_write($settings['uri'] . '/index.html', $ukko->build()); file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } -- cgit v1.3 From 7719ad3e8148af407a72d92f2d157c7d29601689 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 9 Oct 2014 01:26:34 +0200 Subject: minor bugfix @ banlist --- templates/themes/public_banlist/theme.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'templates') diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php index b64b8d9e..68037aec 100644 --- a/templates/themes/public_banlist/theme.php +++ b/templates/themes/public_banlist/theme.php @@ -24,6 +24,8 @@ } public static function gen_json($settings) { + global $config, $mod; + ob_start(); Bans::stream_json(false, false, !hasPermission($config['mod']['view_banstaff']), $mod['boards']); $out = ob_get_contents(); -- cgit v1.3 From 948695e73cf086bfa59cda0e4cd2822853b77f3b Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 9 Oct 2014 01:49:29 +0200 Subject: lel, this one will do --- templates/themes/public_banlist/theme.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php index 68037aec..f2b65839 100644 --- a/templates/themes/public_banlist/theme.php +++ b/templates/themes/public_banlist/theme.php @@ -24,10 +24,8 @@ } public static function gen_json($settings) { - global $config, $mod; - ob_start(); - Bans::stream_json(false, false, !hasPermission($config['mod']['view_banstaff']), $mod['boards']); + Bans::stream_json(false, true, true, array()); $out = ob_get_contents(); ob_end_clean(); return $out; -- cgit v1.3 From b55ebcd0ef002c86df714a3c857746832f010bc7 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 18 Oct 2014 22:43:35 +0200 Subject: custom alert: now alert will be able to display custom HTML --- stylesheets/caffe.css | 2 +- stylesheets/dark.css | 2 +- stylesheets/dark_roach.css | 2 +- stylesheets/futaba+vichan.css | 2 +- stylesheets/futaba-light.css | 2 +- stylesheets/futaba.css | 2 +- stylesheets/roach.css | 2 +- stylesheets/style.css | 27 ++++++++++++++++++++++----- stylesheets/yotsuba.css | 2 +- templates/main.js | 23 +++++++++++++++++++++++ 10 files changed, 53 insertions(+), 13 deletions(-) (limited to 'templates') diff --git a/stylesheets/caffe.css b/stylesheets/caffe.css index 7e2c5879..aee4d5ab 100644 --- a/stylesheets/caffe.css +++ b/stylesheets/caffe.css @@ -382,7 +382,7 @@ font-size: 9pt; } /* options.js */ -#options_div { +#options_div, #alert_div { background: #a47a6b url('img/caffe_reply.png') repeat center; border: solid 1px #a47a6b; -moz-border-radius: 5px; diff --git a/stylesheets/dark.css b/stylesheets/dark.css index 7d81f56d..7fc4e199 100644 --- a/stylesheets/dark.css +++ b/stylesheets/dark.css @@ -181,7 +181,7 @@ div.report { } /* options.js */ -#options_div { +#options_div, #alert_div { background: #333333; } .options_tab_icon { diff --git a/stylesheets/dark_roach.css b/stylesheets/dark_roach.css index 1831fd91..7d123c6d 100644 --- a/stylesheets/dark_roach.css +++ b/stylesheets/dark_roach.css @@ -471,7 +471,7 @@ input[type="submit"]:hover } /* options.js */ -#options_div { +#options_div, #alert_div { background: #333333; } .options_tab_icon { diff --git a/stylesheets/futaba+vichan.css b/stylesheets/futaba+vichan.css index 607cf49c..5f7d742b 100644 --- a/stylesheets/futaba+vichan.css +++ b/stylesheets/futaba+vichan.css @@ -101,7 +101,7 @@ div.boardlist.bottom { } /* options.js */ -#options_div { +#options_div, #alert_div { background: rgb(240, 224, 214); } .options_tab_icon { diff --git a/stylesheets/futaba-light.css b/stylesheets/futaba-light.css index ecc5da83..fc67709f 100644 --- a/stylesheets/futaba-light.css +++ b/stylesheets/futaba-light.css @@ -98,7 +98,7 @@ table.modlog tr th { } /* options.js */ -#options_div { +#options_div, #alert_div { background: rgb(240, 224, 214); } diff --git a/stylesheets/futaba.css b/stylesheets/futaba.css index c9cefb85..02c38351 100644 --- a/stylesheets/futaba.css +++ b/stylesheets/futaba.css @@ -86,7 +86,7 @@ table.modlog tr th { } /* options.js */ -#options_div { +#options_div, #alert_div { background: rgb(240, 224, 214); } .options_tab_icon { diff --git a/stylesheets/roach.css b/stylesheets/roach.css index 945559be..99aa6125 100644 --- a/stylesheets/roach.css +++ b/stylesheets/roach.css @@ -256,7 +256,7 @@ border-top: 1px solid #835B36 !important; } /* options.js */ -#options_div { +#options_div, #alert_div { background: white; } diff --git a/stylesheets/style.css b/stylesheets/style.css index ac6a2c11..e0ce08c5 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -786,7 +786,7 @@ div.thread:hover { text-align: center; } -#options_handler { +#options_handler, #alert_handler { position: fixed; top: 0px; left: 0px; @@ -798,7 +798,7 @@ div.thread:hover { z-index: 9900; } -#options_background { +#options_background, #alert_background { background: black; opacity: 0.5; position: absolute; @@ -811,21 +811,38 @@ div.thread:hover { z-index: -1; } -#options_div { +#options_div, #alert_div { background-color: #d6daf0; border: 1px solid black; display: inline-block; position: relative; margin-top: 20px; +} + +#options_div { width: 600px; height: 300px; } +#alert_div { + width: 500px; +} + +#alert_message { + text-align: center; + margin: 13px; + font-size: 110%; +} + +.alert_button { + margin-bottom: 13px; +} + #options_div textarea { max-width: 100%; } -#options_close { +#options_close, #alert_close { top: 0px; right: 0px; position: absolute; @@ -878,7 +895,7 @@ div.thread:hover { margin-bottom: 5px; } -.mobile-style #options_div { +.mobile-style #options_div, .mobile-style #alert_div { display: block; width: 100%; height: 100%; diff --git a/stylesheets/yotsuba.css b/stylesheets/yotsuba.css index 845a5f67..8997b696 100644 --- a/stylesheets/yotsuba.css +++ b/stylesheets/yotsuba.css @@ -59,7 +59,7 @@ table.modlog tr th { } /* options.js */ -#options_div { +#options_div, #alert_div { background: #f0e0d6; } diff --git a/templates/main.js b/templates/main.js index ed25f7d9..ead852fe 100644 --- a/templates/main.js +++ b/templates/main.js @@ -69,6 +69,29 @@ var datelocale = , pm: _('pm') }; + +function alert(a) { + var handler, div; + var close = function() { + handler.fadeOut(400, function() { handler.remove(); }); + return false; + }; + + handler = $("
").hide().appendTo('body'); + + $("
").click(close).appendTo(handler); + + div = $("
").appendTo(handler); + $("
") + .click(close).appendTo(div); + + $("
").html(a).appendTo(div); + + $("").click(close).appendTo(div); + + handler.fadeIn(400); +} + var saved = {}; -- cgit v1.3 From a550c63f9c896ddba236d9136998a858c233b492 Mon Sep 17 00:00:00 2001 From: 8chan Date: Fri, 23 Jan 2015 02:29:55 -0800 Subject: SECURITY / XSS : Stop XSS in post subjects displayed in catalog git blame says czaks forgot an |e in catalog.html, this means that anyone posting a new thread with HTML in the subject field or name field can arbitrarily insert it into the page. Conflicts: templates/themes/catalog/catalog.html --- templates/themes/catalog/catalog.html | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 72cb8698..aef6c139 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -52,14 +52,22 @@ {% else %} + id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}">
-

- - R: {{ post.reply_count }} / I: {{ post.image_count }}
- {{ post.body }} -
-

+
+ R: {{ post.reply_count }} / I: {{ post.image_count }} + {% if post.subject %} +

+ + {{ post.subject|e }} + +

+ {% else %} +
+ {% endif %} + + {{ post.body }} +
{% endfor %} -- cgit v1.3 From bdb6001f3f7e93e0b9655c0491bbef6f1df8a5fa Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 12:48:59 +0100 Subject: support for slugified links; may introduce a few bugs --- inc/config.php | 7 +- inc/display.php | 4 +- inc/functions.php | 92 +++++++++++++++++++++++-- inc/lib/Twig/Extensions/Extension/Tinyboard.php | 3 +- inc/mod/pages.php | 18 ++--- install.php | 6 +- mod.php | 5 ++ post.php | 19 +++-- templates/main.js | 1 + templates/mod/debug/recent_posts.html | 2 +- templates/mod/search_results.html | 4 +- templates/post_reply.html | 4 +- templates/post_thread.html | 10 +-- templates/posts.sql | 1 + templates/themes/catalog/theme.php | 2 +- templates/themes/recent/theme.php | 4 +- templates/themes/sitemap/sitemap.xml | 4 +- templates/themes/sitemap/theme.php | 2 +- 18 files changed, 145 insertions(+), 43 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index edbe7b2a..ac4acaa4 100644 --- a/inc/config.php +++ b/inc/config.php @@ -566,6 +566,9 @@ // Allow dice rolling: an email field of the form "dice XdY+/-Z" will result in X Y-sided dice rolled and summed, // with the modifier Z added, with the result displayed at the top of the post body. $config['allow_roll'] = false; + + // Use semantic URLs for threads, like /b/res/12345/daily-programming-thread.html + $config['slugify'] = false; /* * ==================== @@ -1118,8 +1121,10 @@ // Location of files. $config['file_index'] = 'index.html'; - $config['file_page'] = '%d.html'; + $config['file_page'] = '%d.html'; // NB: page is both an index page and a thread $config['file_page50'] = '%d+50.html'; + $config['file_page_slug'] = '%d-%s.html'; + $config['file_page50_slug'] = '%d-%s+50.html'; $config['file_mod'] = 'mod.php'; $config['file_post'] = 'post.php'; $config['file_script'] = 'main.js'; diff --git a/inc/display.php b/inc/display.php index 1a78e19b..65525ab9 100644 --- a/inc/display.php +++ b/inc/display.php @@ -383,7 +383,7 @@ class Post { public function link($pre = '', $page = false) { global $config, $board; - return $this->root . $board['dir'] . $config['dir']['res'] . sprintf(($page ? $page : $config['file_page']), $this->thread) . '#' . $pre . $this->id; + return $this->root . $board['dir'] . $config['dir']['res'] . link_for((array)$this, $page == '50') . '#' . $pre . $this->id; } public function build($index=false) { @@ -438,7 +438,7 @@ class Thread { public function link($pre = '', $page = false) { global $config, $board; - return $this->root . $board['dir'] . $config['dir']['res'] . sprintf(($page ? $page : $config['file_page']), $this->id) . '#' . $pre . $this->id; + return $this->root . $board['dir'] . $config['dir']['res'] . link_for((array)$this, $page == '50') . '#' . $pre . $this->id; } public function add(Post $post) { $this->posts[] = $post; diff --git a/inc/functions.php b/inc/functions.php index 25362a62..79d06f5c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -150,7 +150,9 @@ function loadConfig() { preg_quote($config['dir']['res'], '/') . '(' . str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . '|' . - str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . + str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . '|' . + str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '/')) . '|' . + str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) . ')' . '|' . preg_quote($config['file_mod'], '/') . '\?\/.+' . @@ -912,7 +914,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)", $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, 0, :embed, :slug)", $board['uri'])); // Basic stuff if (!empty($post['subject'])) { @@ -981,6 +983,10 @@ function post(array $post) { $query->bindValue(':filehash', null, PDO::PARAM_NULL); } + if ($post['op']) { + $query->bindValue(':slug', slugify($post)); + } + if (!$query->execute()) { undoImage($post); error(db_error($query)); @@ -1094,8 +1100,8 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { if (!$post['thread']) { // Delete thread HTML page - file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id'])); - file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $post['id'])); + file_unlink($board['dir'] . $config['dir']['res'] . link_for($post) ); + file_unlink($board['dir'] . $config['dir']['res'] . link_for($post, true) ); // noko50 file_unlink($board['dir'] . $config['dir']['res'] . sprintf('%d.json', $post['id'])); $antispam_query = prepare('DELETE FROM ``antispam`` WHERE `board` = :board AND `thread` = :thread'); @@ -2067,12 +2073,12 @@ function buildThread($id, $return = false, $mod = false) { if ($return) { return $body; } else { - $noko50fn = $board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id); + $noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true); if ($hasnoko50 || file_exists($noko50fn)) { buildThread50($id, $return, $mod, $thread, $antibot); } - file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body); + file_write($board['dir'] . $config['dir']['res'] . link_for($thread), $body); } } @@ -2152,7 +2158,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti if ($return) { return $body; } else { - file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id), $body); + file_write($board['dir'] . $config['dir']['res'] . link_for($thread, true), $body); } } @@ -2421,3 +2427,75 @@ function diceRoller($post) { } } } + +function slugify($post) { + $slug = ""; + + if (isset($post['thread']) && $post['thread']) + $slug = $post['thread']; + elseif (isset ($post['body_nomarkup']) && $post['body_nomarkup']) + $slug = $post['body_nomarkup']; + elseif (isset ($post['body']) && $post['body']) + $slug = strip_html($post['body']); + + // Fix UTF-8 first + $slug = mb_convert_encoding($slug, "UTF-8", "UTF-8"); + + // Transliterate local characters like ü, I wonder how would it work for weird alphabets :^) + $slug = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $slug); + + // Downcase everything + $slug = strtolower($slug); + + // Strip bad characters, alphanumerics should suffice + $slug = preg_replace('/[^a-zA-Z0-9]/', '-', $slug); + + // Replace multiple dashes with single ones + $slug = preg_replace('/-+/', '-', $slug); + + // Strip dashes at the beginning and at the end + $slug = preg_replace('/^-|-$/', '', $slug); + + // Slug should be 200 characters long, at max + $slug = substr($slug, 0, 200); + + // Slug is now ready + return $slug; +} + +function link_for($post, $page50 = false, $foreignlink = false, $thread = false) { + global $config, $board; + + $post = (array)$post; + + // Where do we need to look for OP? + $b = $foreignlink ? $foreignlink : $board; + + $id = (isset($post['thread']) && $post['thread']) ? $post['thread'] : $post['id']; + + $slug = false; + + if ($config['slugify'] && isset($post['thread']) && $post['thread']) { + if (!$thread) { + // Oh fuck, we'd better optimize it ASAP + + $query = prepare(sprintf("SELECT `slug` FROM ``posts_%s`` WHERE `id` = :id", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + $thread = $query->fetch(PDO::FETCH_ASSOC); + } + $slug = $thread['slug']; + } + elseif ($config['slugify']) { + $slug = $post['slug']; + } + + + if ( $page50 && $slug) $tpl = $config['file_page50_slug']; + else if (!$page50 && $slug) $tpl = $config['file_page_slug']; + else if ( $page50 && !$slug) $tpl = $config['file_page50']; + else if (!$page50 && !$slug) $tpl = $config['file_page']; + + return sprintf($tpl, $id, $slug); +} diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 81276147..028db438 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -45,7 +45,8 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'), new Twig_SimpleFunction('ratio', 'twig_ratio_function'), new Twig_SimpleFunction('secure_link_confirm', 'twig_secure_link_confirm'), - new Twig_SimpleFunction('secure_link', 'twig_secure_link') + new Twig_SimpleFunction('secure_link', 'twig_secure_link'), + new Twig_SimpleFunction('link_for', 'link_for') ); } diff --git a/inc/mod/pages.php b/inc/mod/pages.php index c7722763..79d1bf51 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1161,7 +1161,7 @@ function mod_move_reply($originBoard, $postID) { $post = $query->fetch(PDO::FETCH_ASSOC); // redirect - header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $newID) . '#' . $newID, true, $config['redirect_http']); + header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($post) . '#' . $newID, true, $config['redirect_http']); } else { @@ -1322,6 +1322,8 @@ function mod_move($originBoard, $postID) { // trigger themes rebuildThemes('post', $targetBoard); + $newboard = $board; + // return to original board openBoard($originBoard); @@ -1332,7 +1334,7 @@ function mod_move($originBoard, $postID) { $query->execute() or error(db_error($query)); // leave a reply, linking to the new thread - $post = array( + $spost = array( 'mod' => true, 'subject' => '', 'email' => '', @@ -1346,23 +1348,23 @@ function mod_move($originBoard, $postID) { 'op' => false ); - $post['body'] = $post['body_nomarkup'] = sprintf($config['mod']['shadow_mesage'], '>>>/' . $targetBoard . '/' . $newID); + $spost['body'] = $spost['body_nomarkup'] = sprintf($config['mod']['shadow_mesage'], '>>>/' . $targetBoard . '/' . $newID); - markup($post['body']); + markup($spost['body']); - $botID = post($post); + $botID = post($spost); buildThread($postID); buildIndex(); - header('Location: ?/' . sprintf($config['board_path'], $originBoard) . $config['dir']['res'] .sprintf($config['file_page'], $postID) . + header('Location: ?/' . sprintf($config['board_path'], $originBoard) . $config['dir']['res'] . link_for($post, false, $newboard) . '#' . $botID, true, $config['redirect_http']); } else { deletePost($postID); buildIndex(); openBoard($targetBoard); - header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . sprintf($config['file_page'], $newID), true, $config['redirect_http']); + header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($post, false, $newboard), true, $config['redirect_http']); } } @@ -1494,7 +1496,7 @@ function mod_edit_post($board, $edit_raw_html, $postID) { rebuildThemes('post', $board); - header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']); + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . link_for($post) . '#' . $postID, true, $config['redirect_http']); } else { if ($config['minify_html']) { $post['body_nomarkup'] = str_replace("\n", ' ', utf8tohtml($post['body_nomarkup'])); diff --git a/install.php b/install.php index 2e050eee..95caf8ec 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 384eec88..e06d5db6 100644 --- a/mod.php +++ b/mod.php @@ -105,6 +105,11 @@ $pages = array( str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '!')) => 'view_thread50', '/(\%b)/' . preg_quote($config['dir']['res'], '!') . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_thread', + + '/(\%b)/' . preg_quote($config['dir']['res'], '!') . + str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '!')) => 'view_thread50', + '/(\%b)/' . preg_quote($config['dir']['res'], '!') . + str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '!')) => 'view_thread', ); diff --git a/post.php b/post.php index d33c8150..93592590 100644 --- a/post.php +++ b/post.php @@ -85,7 +85,7 @@ if (isset($_POST['delete'])) { } _syslog(LOG_INFO, 'Deleted post: ' . - '/' . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $id) . ($post['thread'] ? '#' . $id : '') + '/' . $board['dir'] . $config['dir']['res'] . link_for($post) . ($post['thread'] ? '#' . $id : '') ); } } @@ -142,7 +142,7 @@ if (isset($_POST['delete'])) { if ($config['syslog']) _syslog(LOG_INFO, 'Reported post: ' . - '/' . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $thread ? $thread : $id) . ($thread ? '#' . $id : '') . + '/' . $board['dir'] . $config['dir']['res'] . link_for($post) . ($thread ? '#' . $id : '') . ' for "' . $reason . '"' ); $query = prepare("INSERT INTO ``reports`` VALUES (NULL, :time, :ip, :board, :post, :reason)"); @@ -250,7 +250,7 @@ if (isset($_POST['delete'])) { //Check if thread exists if (!$post['op']) { - $query = prepare(sprintf("SELECT `sticky`,`locked`,`sage` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri'])); + $query = prepare(sprintf("SELECT `sticky`,`locked`,`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()); @@ -259,6 +259,9 @@ if (isset($_POST['delete'])) { error($config['error']['nonexistant']); } } + else { + $thread = false; + } // Check for an embed field @@ -782,6 +785,7 @@ if (isset($_POST['delete'])) { $post = (object)$post; $post->files = array_map(function($a) { return (object)$a; }, $post->files); + $error = event('post', $post); $post->files = array_map(function($a) { return (array)$a; }, $post->files); @@ -845,19 +849,20 @@ if (isset($_POST['delete'])) { if ($noko) { $redirect = $root . $board['dir'] . $config['dir']['res'] . - sprintf($config['file_page'], $post['op'] ? $id:$post['thread']) . (!$post['op'] ? '#' . $id : ''); + link_for($post, false, false, $thread) . (!$post['op'] ? '#' . $id : ''); if (!$post['op'] && isset($_SERVER['HTTP_REFERER'])) { $regex = array( 'board' => str_replace('%s', '(\w{1,8})', preg_quote($config['board_path'], '/')), 'page' => str_replace('%d', '(\d+)', preg_quote($config['file_page'], '/')), - 'page50' => str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '/')), + 'page50' => '(' . str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '/')) . '|' . + str_replace(array('%d', '%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) . ')', 'res' => preg_quote($config['dir']['res'], '/'), ); if (preg_match('/\/' . $regex['board'] . $regex['res'] . $regex['page50'] . '([?&].*)?$/', $_SERVER['HTTP_REFERER'])) { $redirect = $root . $board['dir'] . $config['dir']['res'] . - sprintf($config['file_page50'], $post['op'] ? $id:$post['thread']) . (!$post['op'] ? '#' . $id : ''); + link_for($post, true, false, $thread) . (!$post['op'] ? '#' . $id : ''); } } } else { @@ -867,7 +872,7 @@ if (isset($_POST['delete'])) { if ($config['syslog']) _syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] . - sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : '')); + link_for($post) . (!$post['op'] ? '#' . $id : '')); if (!$post['mod']) header('X-Associated-Content: "' . $redirect . '"'); diff --git a/templates/main.js b/templates/main.js index ead852fe..e948fd82 100644 --- a/templates/main.js +++ b/templates/main.js @@ -146,6 +146,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) { diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html index e4eb4f3a..ce4cffc4 100644 --- a/templates/mod/debug/recent_posts.html +++ b/templates/mod/debug/recent_posts.html @@ -63,7 +63,7 @@ {% else %} {% set thread = post.id %} {% endif %} - + {{ post.id }} diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index 0d3c2a10..186ee5db 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -195,7 +195,7 @@ {% else %} {% set thread = post.id %} {% endif %} - + {{ post.id }} @@ -265,4 +265,4 @@ [{{ i + 1 }}] {% endfor %}

-{% endif %} \ No newline at end of file +{% endif %} diff --git a/templates/post_reply.html b/templates/post_reply.html index e7343230..451ff1b9 100644 --- a/templates/post_reply.html +++ b/templates/post_reply.html @@ -12,8 +12,8 @@ {% include 'post/time.html' %} {% include 'post/poster_id.html' %}  - No. - {{ post.id }} + No. + {{ post.id }}

{% include 'post/fileinfo.html' %} {% include 'post/post_controls.html' %} diff --git a/templates/post_thread.html b/templates/post_thread.html index 08b4c4c1..61146491 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -15,8 +15,8 @@ {% include 'post/time.html' %} {% include 'post/poster_id.html' %}  - No. - {{ post.id }} + No. + {{ post.id }} {% if post.sticky %} {% if config.font_awesome %} @@ -39,14 +39,14 @@ {% endif %} {% endif %} {% if index %} - [{% trans %}Reply{% endtrans %}] + [{% trans %}Reply{% endtrans %}] {% endif %} {% if isnoko50 %} - [{% trans %}View All{% endtrans %}] + [{% trans %}View All{% endtrans %}] {% endif %} {% if hasnoko50 and not isnoko50 %} {% set lastcount = config.noko50_count %} - [{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}] + [{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}] {% endif %} {% include 'post/post_controls.html' %}

diff --git a/templates/posts.sql b/templates/posts.sql index 9a47c6ad..6b2249ef 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -19,6 +19,7 @@ CREATE TABLE IF NOT EXISTS ``posts_{{ board }}`` ( `locked` int(1) NOT NULL, `sage` int(1) NOT NULL, `embed` text, + `slug` varchar(256) DEFAULT NULL, UNIQUE KEY `id` (`id`), KEY `thread_id` (`thread`,`id`), KEY `filehash` (`filehash`(40)), diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 9ba2d27a..b3b7caf7 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -42,7 +42,7 @@ $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])); + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post)); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index b1153477..2ea6a7b9 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -62,7 +62,7 @@ // 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']; + . link_for($post) . '#' . $post['id']; if ($files) { if ($files[0]->thumb == 'spoiler') { @@ -92,7 +92,7 @@ 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['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id']; if ($post['body'] != "") $post['snippet'] = pm_snippet($post['body'], 30); else diff --git a/templates/themes/sitemap/sitemap.xml b/templates/themes/sitemap/sitemap.xml index 733da607..95dfdd26 100644 --- a/templates/themes/sitemap/sitemap.xml +++ b/templates/themes/sitemap/sitemap.xml @@ -9,11 +9,11 @@ {% for board, thread_list in threads %} {% for thread in thread_list %} - {{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ (config.file_page | format(thread.thread_id)) }} + {{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }} {{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }} {{ settings.changefreq }} {% endfor %} {% endfor %} -{% endfilter %} \ No newline at end of file +{% endfilter %} diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 3e048dd5..1cebcdb6 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -26,7 +26,7 @@ $threads = array(); foreach ($boards as $board) { - $query = query(sprintf("SELECT `id` AS `thread_id`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $query = query(sprintf("SELECT `id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); } -- cgit v1.3 From 7d92a05bd8b283a79764e8ed5435661b9a8b27f2 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:23:40 +0100 Subject: ... --- templates/themes/catalog/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index b3b7caf7..f8f1146e 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -42,7 +42,7 @@ $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post)); + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { -- cgit v1.3 From 4aa1d387f8a90d33207d28afc637958759e2ce6e Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:34:02 +0100 Subject: ... --- templates/themes/sitemap/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 1cebcdb6..41a7f304 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -26,7 +26,7 @@ $threads = array(); foreach ($boards as $board) { - $query = query(sprintf("SELECT `id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); } -- cgit v1.3 From d6e91ec62f0364c0ea430bd872c5eec3c7169bdb Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Thu, 19 Mar 2015 19:35:28 -0400 Subject: Added space after Google image search link --- templates/post/image_identification.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/post/image_identification.html b/templates/post/image_identification.html index fa2f30b3..cd37b901 100644 --- a/templates/post/image_identification.html +++ b/templates/post/image_identification.html @@ -8,7 +8,7 @@ Exif {% endif %} {% if config.image_identification_google %} - Google + Google {% endif %} {% if config.image_identification_iqdb %} iqdb -- cgit v1.3 From 1283e51ca50c9085a0f1b763fa4928c91b7c8e69 Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Thu, 19 Mar 2015 21:49:57 -0400 Subject: Fixed and re-enabled active content stat for recent theme --- templates/themes/recent/theme.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 2ea6a7b9..9307c6a9 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -125,15 +125,18 @@ $stats['unique_posters'] = number_format($query->fetchColumn()); // Active content - /*$query = 'SELECT SUM(`filesize`) FROM ('; + $query = 'SELECT `files` 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 .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']); } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query); $query = query($query) or error(db_error()); - $stats['active_content'] = $query->fetchColumn();*/ + $files = $query->fetchAll(); + $stats['active_content'] = 0; + foreach ($files as &$file) + $stats['active_content'] += intval(preg_replace('/.*"size":([0-9]*).*/', '$1', $file[0])); return Element('themes/recent/recent.html', Array( 'settings' => $settings, -- cgit v1.3 From 034b288a1317a940c3a5722c6d2864d1ea08f5db Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Fri, 20 Mar 2015 09:47:40 -0400 Subject: Fixed to work with multiple images --- templates/themes/recent/theme.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 9307c6a9..ce64c80e 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -125,7 +125,7 @@ $stats['unique_posters'] = number_format($query->fetchColumn()); // Active content - $query = 'SELECT `files` FROM ('; + $query = 'SELECT DISTINCT(`files`) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; @@ -135,8 +135,10 @@ $query = query($query) or error(db_error()); $files = $query->fetchAll(); $stats['active_content'] = 0; - foreach ($files as &$file) - $stats['active_content'] += intval(preg_replace('/.*"size":([0-9]*).*/', '$1', $file[0])); + foreach ($files as &$file) { + preg_match_all('/"size":([0-9]*)/', $file[0], $matches); + $stats['active_content'] += array_sum($matches[1]); + } return Element('themes/recent/recent.html', Array( 'settings' => $settings, -- cgit v1.3 From 81afc17b671e16cd95923c1b2461509a5fc4aa81 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 00:35:13 +0100 Subject: image identification: url encode --- templates/post/image_identification.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/post/image_identification.html b/templates/post/image_identification.html index fa2f30b3..408a338c 100644 --- a/templates/post/image_identification.html +++ b/templates/post/image_identification.html @@ -8,7 +8,7 @@ Exif {% endif %} {% if config.image_identification_google %} - Google + Google {% endif %} {% if config.image_identification_iqdb %} iqdb -- cgit v1.3 From 3bd7f94861e9a2a8b9a7f8f972f04eb6eaa45453 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 18:44:47 +0800 Subject: Fallback for browsers that disables javascript Conflicts: stylesheets/style.css templates/post_form.html --- js/file-selector.js | 3 +- stylesheets/style.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ templates/post_form.html | 8 +++++ 3 files changed, 91 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/js/file-selector.js b/js/file-selector.js index c820db48..ddae2d09 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -140,7 +140,8 @@ var dropHandlers = { } }; -$('.dropzone').css('user-select', 'none') // let jquery add browser specific prefix +$('#upload input[type=file]').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); diff --git a/stylesheets/style.css b/stylesheets/style.css index e0ce08c5..56140561 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -959,3 +959,84 @@ span.pln { cursor: pointer; } +#youtube-size input { + width: 50px; +} + +/* File selector */ +.dropzone { + color: #000; + cursor: default; + margin: auto; + padding: 0px 4px; + text-align: center; + min-height: 50px; + max-height: 140px; + transition: 0.2s; + background-color: rgba(200, 200, 200, 0.5); + overflow-y: auto; +} +.dropzone-wrap { + width: 100%; +} +.dropzone .file-hint { + color: rgba(0, 0, 0, 0.5); + cursor: pointer; + position: relative; + margin-bottom: 5px; + padding: 10px 0px; + top: 5px; + transition: 0.2s; + border: 2px dashed rgba(125, 125, 125, 0.4); +} +.file-hint:hover, .dropzone.dragover .file-hint { + color: rgba(0, 0, 0, 1); + border-color: rgba(125, 125, 125, 0.8); +} +.dropzone.dragover { + background-color: rgba(200, 200, 200, 1); +} +.dropzone .file-thumbs { + text-align: left; + width: 100%; +} +.dropzone .tmb-container { + padding: 3px; + overflow-x: hidden; + white-space: nowrap; +} +.dropzone .file-tmb { + height: 40px; + width: 70px; + cursor: pointer; + display: inline-block; + text-align: center; + background-color: rgba(187, 187, 187, 0.5); + background-size: cover; + background-position: center; +} +.dropzone .file-tmb span { + font-weight: 600; + position: relative; + top: 13px; +} +.dropzone .tmb-filename { + display: inline-block; + vertical-align: bottom; + bottom: 12px; + position: relative; + margin-left: 5px; +} +.dropzone .remove-btn { + cursor: pointer; + color: rgba(125, 125, 125, 0.5); + display: inline-block; + vertical-align: bottom; + bottom: 10px; + position: relative; + margin-right: 5px; + font-size: 20px +} +.dropzone .remove-btn:hover { + color: rgba(125, 125, 125, 1); +} diff --git a/templates/post_form.html b/templates/post_form.html index 1846adb5..9596ee6b 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -98,6 +98,14 @@ + + + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 0005f11098890ad76c1b9963792cd686493649a9 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 21:35:58 +0800 Subject: initialize file selector soon as it's loaded Conflicts: templates/post_form.html --- js/file-selector.js | 44 +++++++++++++++++++------------------------- templates/post_form.html | 2 ++ 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'templates') diff --git a/js/file-selector.js b/js/file-selector.js index ddae2d09..b4589706 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -5,34 +5,29 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/file-selector.js'; */ +function init_file_selector() { -if (active_page == 'index' || active_page == 'thread') { $(document).ready(function () { + // add options panel item + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); -// add options panel item -if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); - - if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); -} + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); // disabled by user, or incompatible browser. -// fallback to old -if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) { - $('.dropzone-wrap').remove(); - $('#upload_file').show(); - +if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) return; -} // multipost not enabled if (typeof max_images == 'undefined') { @@ -40,6 +35,8 @@ if (typeof max_images == 'undefined') { } var files = []; +$('#upload_file').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { if (files.length == max_images) @@ -140,8 +137,6 @@ var dropHandlers = { } }; -$('#upload input[type=file]').hide(); // hide the original file selector -$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); @@ -184,5 +179,4 @@ $(document).on('paste', function (e) { } }); -}); } diff --git a/templates/post_form.html b/templates/post_form.html index 9596ee6b..809230f0 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -106,6 +106,8 @@
+ + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 6e84a25f9a882bc4c2cbd1e376416ac34ca9943b Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 08:53:57 +0800 Subject: Adds keyboard focus to file selector --- js/file-selector.js | 10 +++++++++- templates/post_form.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/js/file-selector.js b/js/file-selector.js index e5451f1a..dbe8ea82 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -135,13 +135,21 @@ var dropHandlers = { $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { + e.stopPropagation(); + var file = $(e.target).parent().data('file-ref'); getThumbElement(file).remove(); removeFile(file); }); -$(document).on('click', '.dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { + e.stopPropagation(); + + // accept mosue click or Enter + if (e.which != 1 || e.which != 13) + return; + var $fileSelector = $(''); $fileSelector.on('change', function (e) { diff --git a/templates/post_form.html b/templates/post_form.html index 809230f0..7cdcc7d3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -100,7 +100,7 @@ - + {% if config.allow_upload_by_url %}
-- cgit v1.3 From 765dea599bd010bc00a3a40df58953b239ec0e9d Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 06:50:05 +0200 Subject: trivial fixes to file-selector.js --- js/file-selector.js | 11 ++++++++++- js/upload-selection.js | 2 ++ templates/post_form.html | 7 ------- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'templates') diff --git a/js/file-selector.js b/js/file-selector.js index fc9c83e2..6aad9382 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -34,8 +34,16 @@ if (typeof max_images == 'undefined') { var max_images = 1; } +$(''+ +'
').prependTo('#upload td'); + var files = []; -$('#upload_file').hide(); // hide the original file selector +$('#upload_file').remove(); // remove the original file selector $('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { @@ -83,6 +91,7 @@ $(document).on('ajax_before_post', function (e, formData) { for (var i=0; i 0) key += i + 1; + if (typeof files[i] === 'undefined') break; formData.append(key, files[i]); } }); diff --git a/js/upload-selection.js b/js/upload-selection.js index e2032748..b342a134 100644 --- a/js/upload-selection.js +++ b/js/upload-selection.js @@ -25,6 +25,7 @@ $(function(){ $("#upload_url").hide(); $("#upload_embed").hide(); $(".add_image").hide(); + $(".dropzone-wrap").hide(); $('[id^=upload_file]').each(function(i, v) { $(v).val(''); @@ -40,6 +41,7 @@ $(function(){ enable_file = function() { disable_all(); $("#upload").show(); + $(".dropzone-wrap").show(); $(".file_separator").show(); $("[id^=upload_file]").show(); $(".add_image").show(); diff --git a/templates/post_form.html b/templates/post_form.html index 00390daf..d6a77452 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -99,13 +99,6 @@ - - {% if config.allow_upload_by_url %} -- cgit v1.3 From 745bdc2b6cf5af863a7ae86f5b95b14746f5f2e4 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:01:51 +0200 Subject: password is text nao, fuck you chrome --- templates/post_form.html | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'templates') diff --git a/templates/post_form.html b/templates/post_form.html index d6a77452..d2e644b3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -146,14 +146,9 @@ {% trans %}Password{% endtrans %} {{ antibot.html() }} - - - - - - + {% trans %}(For file deletion.){% endtrans %} {{ antibot.html() }} -- cgit v1.3 From 960053af750a9e8ce196a3855c9fbee69f9ec0ba Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:48:03 +0200 Subject: catalog: fix for embed youtube on https --- 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 aef6c139..acf538f0 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -48,7 +48,7 @@
{% if post.youtube %} - Date: Wed, 1 Apr 2015 19:37:06 +0200 Subject: main.js vs new file uploader --- templates/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/main.js b/templates/main.js index e948fd82..59a632d7 100644 --- a/templates/main.js +++ b/templates/main.js @@ -254,7 +254,7 @@ function dopost(form) { saved[document.location] = form.elements['body'].value; sessionStorage.body = JSON.stringify(saved); - return form.elements['body'].value != "" || form.elements['file'].value != "" || (form.elements.file_url && form.elements['file_url'].value != ""); + return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != ""); } function citeReply(id, with_link) { -- cgit v1.3 From 61d2729a40e8249fef8b3c0c584a9b5f7ae0777c Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:54:28 +0200 Subject: themes can use smart_build now --- templates/themes/catalog/theme.php | 23 +++++++++++++++++++---- templates/themes/recent/theme.php | 10 ++++++++-- templates/themes/ukko/theme.php | 10 +++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index f8f1146e..34b28e48 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -16,11 +16,22 @@ if ($action == 'all') { foreach ($boards as $board) { $b = new Catalog(); - $b->build($settings, $board); + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $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(); - $b->build($settings, $board); + + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $b->build($settings, $board); + } } } @@ -28,8 +39,12 @@ class Catalog { public function build($settings, $board_name) { global $config, $board; - - openBoard($board_name); + + if ($board['uri'] != $board_name) { + if (!openBoard($board_name)) { + error(sprintf(_("Board %s doesn't exist"), $board_name)); + } + } $recent_images = array(); $recent_posts = array(); diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ce64c80e..f44e2529 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -24,8 +24,14 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $settings['html']); + } + else { + file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + } + } } // Build news page diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 058fc77b..e1fa0a3f 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -2,6 +2,8 @@ require 'info.php'; function ukko_build($action, $settings) { + global $config; + $ukko = new ukko(); $ukko->settings = $settings; @@ -9,7 +11,13 @@ return; } - file_write($settings['uri'] . '/index.html', $ukko->build()); + if ($config['smart_build']) { + file_unlink($settings['uri'] . '/index.html'); + } + else { + file_write($settings['uri'] . '/index.html', $ukko->build()); + } + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } -- cgit v1.3 From e2731113404bda42ee506e29b6927165b7576f61 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 3 Apr 2015 05:57:39 +0200 Subject: sitemap theme for smart_build --- smart_build.php | 9 ++++++++ templates/themes/sitemap/theme.php | 47 ++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 20 deletions(-) (limited to 'templates') diff --git a/smart_build.php b/smart_build.php index fb467233..43734e4f 100644 --- a/smart_build.php +++ b/smart_build.php @@ -105,6 +105,11 @@ function sb_recent() { return true; } +function sb_sitemap() { + rebuildTheme("sitemap", "all"); + return true; +} + $entrypoints = array(); $entrypoints['/%b/'] = 'sb_board'; @@ -130,6 +135,7 @@ $entrypoints['/*/'] = 'sb_ukko'; $entrypoints['/*/index.html'] = 'sb_ukko'; $entrypoints['/recent.html'] = 'sb_recent'; $entrypoints['/%b/catalog.html'] = 'sb_catalog'; +$entrypoints['/sitemap.xml'] = 'sb_sitemap'; $reached = false; @@ -185,6 +191,9 @@ if ($reached) { elseif (preg_match('/\.js$/', $request)) { header("Content-Type", "text/javascript; charset=utf-8"); } + elseif (preg_match('/\.xml$/', $request)) { + header("Content-Type", "application/xml"); + } else { header("Content-Type", "text/html; charset=utf-8"); } diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 41a7f304..52779d53 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -10,30 +10,37 @@ // - boards (board list changed) // - post (a post has been made) // - thread (a thread has been made) + + if ($action != 'all') { + if ($action != 'post-thread' && $action != 'post-delete') + return; - if ($action != 'post-thread' && $action != 'post-delete') - return; - - if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { - if ($last_gen = @filemtime($settings['path'])) { - if (time() - $last_gen < (int)$settings['regen_time']) - return; // Too soon + if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { + if ($last_gen = @filemtime($settings['path'])) { + if (time() - $last_gen < (int)$settings['regen_time']) + return; // Too soon + } } } + + if ($config['smart_build']) { + file_unlink($settings['path']); + } + else { + $boards = explode(' ', $settings['boards']); - $boards = explode(' ', $settings['boards']); - - $threads = array(); + $threads = array(); - foreach ($boards as $board) { - $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); - $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); - } + foreach ($boards as $board) { + $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); + } - file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'threads' => $threads, - 'boards' => $boards, - ))); + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'threads' => $threads, + 'boards' => $boards, + ))); + } } -- cgit v1.3 From 1f9e36868e82fe563028f8c35aaee3c9ba21fa23 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:20:59 +0200 Subject: ukko: small optimization: move js creation to install time --- templates/themes/ukko/info.php | 1 + templates/themes/ukko/theme.php | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/themes/ukko/info.php b/templates/themes/ukko/info.php index 45a687fc..9a0a53e6 100644 --- a/templates/themes/ukko/info.php +++ b/templates/themes/ukko/info.php @@ -49,6 +49,7 @@ function ukko_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } } diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index e1fa0a3f..d6fc303c 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -17,8 +17,6 @@ else { file_write($settings['uri'] . '/index.html', $ukko->build()); } - - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } class ukko { -- cgit v1.3 From 4060bf10eda3b17513907332890575566cf6e890 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 12 Apr 2015 03:17:12 +0200 Subject: update copyright years & vichan website --- README.md | 4 ++-- templates/generic_page.html | 2 +- templates/index.html | 2 +- templates/page.html | 2 +- templates/themes/basic/index.html | 2 +- templates/themes/catalog/catalog.html | 2 +- templates/themes/categories/news.html | 2 +- templates/themes/frameset/news.html | 2 +- templates/themes/recent/recent.html | 2 +- templates/thread.html | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/README.md b/README.md index e47dd597..c3383b32 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ vichan is a fork of (now defunc'd) [Tinyboard](http://github.com/savetheinternet a great imageboard package, actively building on it and adding a lot of features and other improvements. -Support and announcements: https://int.vichan.net/devel/ +Support and announcements: https://engine.vichan.net/ Requirements ------------ @@ -90,7 +90,7 @@ links may be helpful for you as well: Donations --------- Do you like our work? You can motivate us financially to do better ;) -* Bitcoin: [![tip for next commit](http://tip4commit.com/projects/708.svg)](http://tip4commit.com/projects/708) +* Bitcoin: 1GjZEdLaTQ8JWVFGZW921Yv4x59f9oiZME You can also ask us to develop some feature specially for you <3. Join our IRC channel and ask for a quote (there are a few of us, who work with the codebase diff --git a/templates/generic_page.html b/templates/generic_page.html index 0fe1f9c5..965cbc2c 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -39,7 +39,7 @@

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

+
vichan Copyright © 2012-2015 vichan-devel

{% for footer in config.footer %}

{{ footer }}

{% endfor %}