Merge remote-tracking branch 'upstream/master' into vichan-merge

This commit is contained in:
Simon McFarlane 2015-05-26 23:31:47 -07:00
commit 4b40f69a4e
223 changed files with 65256 additions and 2969 deletions

15
templates/fileboard.html Normal file
View file

@ -0,0 +1,15 @@
<table class='fileboard'>
<tr>
<th>&nbsp; <!-- checkbox -->
<th>{% trans %}No.{% endtrans %}
<th>{% trans %}Name{% endtrans %}
<th>{% trans %}File{% endtrans %}
<th>{% trans %}Tag{% endtrans %}
<th>{% trans %}Subject{% endtrans %}
<th>{% trans %}Size{% endtrans %}
<th>{% trans %}Date{% endtrans %}
<th>{% trans %}Replies{% endtrans %}
<th>&nbsp; <!-- reply -->
</tr>
{{ body }}
</table>

View file

@ -39,7 +39,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
<script type="text/javascript">{% raw %}

View file

@ -67,12 +67,12 @@
{{ config.ad.bottom }}
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">
- <a href="http://tinyboard.org/">Tinyboard</a> + <a href="https://int.vichan.net/devel/">vichan</a> + <a href="https://github.com/lainchan/lainchan">lainchan</a> {{ config.version }} -<br>
<a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group<br/>
<a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel<br/>
<a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2015 lainchan Administration
</p>
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> +
<a href='https://github.com/lainchan/lainchan'>lainchan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2015 lainchan Administration</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
@ -93,7 +93,7 @@
<script type="text/javascript">{% raw %}
ready();
{% endraw %}</script>
</body>
</html>

View file

@ -22,6 +22,76 @@ 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')
};
function alert(a) {
var handler, div;
var close = function() {
handler.fadeOut(400, function() { handler.remove(); });
return false;
};
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
$("<div id='alert_background'></div>").click(close).appendTo(handler);
div = $("<div id='alert_div'></div>").appendTo(handler);
$("<a id='alert_close' href='javascript:void(0)'><i class='fa fa-times'></i></div>")
.click(close).appendTo(div);
$("<div id='alert_message'></div>").html(a).appendTo(div);
$("<button class='button alert_button'>"+_("OK")+"</button>").click(close).appendTo(div);
handler.fadeIn(400);
}
var saved = {};
@ -94,6 +164,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) {
@ -172,6 +243,7 @@ function highlightReply(id) {
var post = document.getElementById('reply_'+id);
if (post)
post.className += ' highlighted';
window.location.hash = id;
}
return true;
}
@ -200,7 +272,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) {
@ -225,6 +297,15 @@ function citeReply(id, with_link) {
textarea.value += '>>' + id + '\n';
}
if (typeof $ != 'undefined') {
var select = document.getSelection().toString();
if (select) {
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';
}
}
$(window).trigger('cite', [id, with_link]);
$(textarea).change();
}

View file

@ -1,104 +1,41 @@
{% if bans|count == 0 %}
<p style="text-align:center" class="unimportant">({% trans 'There are no active bans.' %})</p>
{% else %}
<form action="?/bans" method="post">
<input type="hidden" name="token" value="{{ token }}">
<table class="mod" style="width:100%">
<tr>
<th>{% trans 'IP address/mask' %}</th>
<th>{% trans 'Reason' %}</th>
<th>{% trans 'Board' %}</th>
<th>{% trans 'Set' %}</th>
<th>{% trans 'Duration' %}</th>
<th>{% trans 'Expires' %}</th>
<th>{% trans 'Seen' %}</th>
<th>{% trans 'Staff' %}</th>
</tr>
{% for ban in bans %}
<tr{% if ban.expires != 0 and ban.expires < time() %} style="text-decoration:line-through"{% endif %}>
<td style="white-space: nowrap">
<input type="checkbox" name="ban_{{ ban.id }}">
{% if ban.single_addr %}
<a href="?/IP/{{ ban.mask }}">{{ ban.mask }}</a>
{% else %}
{{ ban.mask }}
{% endif %}
</td>
<td>
{% if ban.reason %}
{{ ban.reason }}
{% else %}
-
{% endif %}
</td>
<td style="white-space: nowrap">
{% if ban.board %}
{{ config.board_abbreviation|sprintf(ban.board) }}
{% else %}
<em>{% trans 'all boards' %}</em>
{% endif %}
</td>
<td style="white-space: nowrap">
<span title="{{ ban.created|date(config.post_date) }}">
{{ ban.created|ago }} ago
</span>
</td>
<td style="white-space: nowrap">
{% if ban.expires == 0 %}
-
{% else %}
{{ (ban.expires - ban.created + time()) | until }}
{% endif %}
</td>
<td style="white-space: nowrap">
{% if ban.expires == 0 %}
<em>{% trans 'never' %}</em>
{% else %}
{{ ban.expires|date(config.post_date) }}
{% if ban.expires > time() %}
<small>(in {{ ban.expires|until }})</small>
{% endif %}
{% endif %}
</td>
<td>
{% if ban.seen %}
{% trans 'Yes' %}
{% else %}
{% trans 'No' %}
{% endif %}
</td>
<td>
{% if ban.username %}
{% if mod|hasPermission(config.mod.view_banstaff) %}
<a href="?/new_PM/{{ ban.username|e }}">{{ ban.username|e }}</a>
{% else %}
{% if mod|hasPermission(config.mod.view_banquestionmark) %}
<em>?</em>
{% else %}
{% endif %}
{% endif %}
{% elseif ban.creator == -1 %}
<em>system</em>
{% else %}
<em>{% trans 'deleted?' %}</em>
{% endif %}
</td>
</tr>
{% endfor %}
<script src='main.js'></script>
<script src='js/jquery.min.js'></script>
<script src='js/mobile-style.js'></script>
<script src='js/strftime.min.js'></script>
<script src='js/longtable/longtable.js'></script>
<script src='js/mod/ban-list.js'></script>
<link rel='stylesheet' href='stylesheets/longtable/longtable.css'>
<link rel='stylesheet' href='stylesheets/mod/ban-list.css'>
<form action="?/bans" method="post" class="banform">
{% if token %}
<input type="hidden" name="token" value="{{ token }}">
{% endif %}
<div class='banlist-opts'>
<div class='checkboxes'>
{% if mod and mod.boards[0] != '*' %}
<label><input type="checkbox" id="only_mine"> {% trans %}Show only bans from boards I moderate{% endtrans %}</label>
{% endif %}
<label><input type="checkbox" id="only_not_expired"> {% trans %}Show only active bans{% endtrans %}</label>
</div>
<div class='buttons'>
<input type="text" id="search" placeholder="{% trans %}Search{% endtrans %}">
{% if mod %}
<input type="submit" name="unban" id="unban" value="{% trans 'Unban selected' %}">
{% endif %}
</div>
<br class='clear'>
</div>
<table class="mod" style="width:100%" id="banlist">
</table>
<p style="text-align:center">
<input type="submit" name="unban" value="{% trans 'Unban selected' %}">
</p>
</form>
{% if token_json %}
<script>$(function(){ banlist_init("{{ token_json }}", {{ boards }}); });</script>
{% else %}
<script>$(function(){ banlist_init("{{ uri_json }}", {{ boards }}, true); });</script>
{% endif %}
{% if count > bans|count %}
<p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.modlog_page) %}
<a href="?/bans/{{ i + 1 }}">[{{ i + 1 }}]</a>
{% endfor %}
</p>
{% endif %}

View file

@ -155,9 +155,9 @@
<legend>Update</legend>
<ul>
<li>
A newer version of Tinyboard
A newer version of vichan
(<strong>v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}</strong>) is available!
See <a href="http://tinyboard.org">http://tinyboard.org/</a> for upgrade instructions.
See <a href="https://engine.vichan.net">https://engine.vichan.net/</a> for upgrade instructions.
</li>
</ul>
</fieldset>

View file

@ -63,7 +63,7 @@
{% else %}
{% set thread = post.id %}
{% endif %}
<a href="?/{{ post.board ~ '/' ~ config.dir.res}}{{ config.file_page|sprintf(thread) }}#{{ post.id }}">
<a href="?/{{ post.board ~ '/' ~ config.dir.res}}{{ link_for(post) }}#{{ post.id }}">
{{ post.id }}
</a>
</td>

View file

@ -195,7 +195,7 @@
{% else %}
{% set thread = post.id %}
{% endif %}
<a href="?/{{ post.board ~ '/' ~ config.dir.res}}{{ config.file_page|sprintf(thread) }}#{{ post.id }}">
<a href="?/{{ post.board ~ '/' ~ config.dir.res}}{{ link_for(post) }}#{{ post.id }}">
{{ post.id }}
</a>
</td>
@ -265,4 +265,4 @@
<a href="?/search/{{ search_type }}/{{ search_query_escaped }}/{{ i + 1 }}">[{{ i + 1 }}]</a>
{% endfor %}
</p>
{% endif %}
{% endif %}

View file

@ -25,7 +25,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>

View file

@ -8,7 +8,7 @@
<a href="http://regex.info/exif.cgi?url={{ config.domain }}{{ config.uri_img }}{{ file.file }}" target="_blank">Exif</a>
{% endif %}
{% if config.image_identification_google %}
<a href="https://www.google.com/searchbyimage?image_url={{ config.domain }}{{ config.uri_img }}{{ file.file }}" target="_blank">Google</a>
<a href="https://www.google.com/searchbyimage?image_url={{ config.domain|url_encode }}{{ config.uri_img|url_encode }}{{ file.file|url_encode }}" target="_blank">Google</a>
{% endif %}
{% if config.image_identification_iqdb %}
<a href="http://iqdb.org/?url={{ config.domain }}{{ config.uri_img }}{{ file.file }}" target="_blank">iqdb</a>

View file

@ -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 #}
<a class="email" href="mailto:{{ post.email }}">
{% endif %}

View file

@ -1,7 +1,7 @@
{% if config.poster_ids %}
{% if post.thread %}
ID: {{ post.ip|poster_id(post.thread) }}
ID: <span class="poster_id">{{ post.ip|poster_id(post.thread) }}</span>
{% else %}
ID: {{ post.ip|poster_id(post.id) }}
ID: <span class="poster_id">{{ post.ip|poster_id(post.id) }}</span>
{% endif %}
{% endif %}

View file

@ -95,13 +95,27 @@
</td>
</tr>
{% endif %}
{% if config.allowed_tags and not id %}
<tr>
<th>{% trans %}Tag{% endtrans %}</th>
<td>
<select name="tag">
{% for id, tag in config.allowed_tags %}
<option value="{{ id|e }}">{{ tag|e }}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
<tr id="upload">
<th>
{% trans %}File{% endtrans %}
</th>
<td>
<input type="file" name="file" id="upload_file">
{% if config.spoiler_images %} <div id="spoilercontainer"><input id="spoiler" name="spoiler" type="checkbox"> <label for="spoiler">{% trans %}Spoiler?{% endtrans %}</label></div>{% endif %}
<script type="text/javascript">if (typeof init_file_selector !== 'undefined') init_file_selector({{ config.max_images }});</script>
{% if config.allow_upload_by_url %}
<div style="float:none;text-align:left" id="upload_url">
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:
@ -147,14 +161,9 @@
<th>
{% trans %}Password{% endtrans %}
{{ antibot.html() }}
<!-- Chrome, you suck so hard with your autofill mechanism -->
<!-- I tried N different tricks, this sucks most, but only this one -->
<!-- disables autofill successfully -->
<input type='text' style='display: none'>
<input type='password' style='display: none'>
</th>
<td>
<input type="password" name="password" value="" size="12" maxlength="18" autocomplete="off">
<input type="text" name="password" value="" size="12" maxlength="18" autocomplete="off">
<span class="unimportant">{% trans %}(For file deletion.){% endtrans %}</span>
{{ antibot.html() }}
</td>

View file

@ -5,7 +5,7 @@
{% if not index %}<a id="{{ post.id }}" class="post_anchor"></a>{% endif %}
{% include 'post/fileinfo.html' %}
<div class="post op" {%if post.num_files > 1%}style='clear:both'{%endif%}><p class="intro">
<div class="post op" id="op_{{ post.id }}" {%if post.num_files > 1%}style='clear:both'{%endif%}><p class="intro">
<input type="checkbox" class="delete" name="delete_{{ post.id }}" id="delete_{{ post.id }}" />
<label for="delete_{{ post.id }}">
{% include 'post/subject.html' %}
@ -15,8 +15,8 @@
{% include 'post/time.html' %}
</label>
{% include 'post/poster_id.html' %}&nbsp;
<a class="post_no" id="post_no_{{ post.id }}" onclick="highlightReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('', config.file_page50) }}{% else %}{{ post.link }}{% endif %}">No.</a>
<a class="post_no" onclick="citeReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('q', config.file_page50) }}{% else %}{{ post.link('q') }}{% endif %}">{{ post.id }}</a>
<a class="post_no" id="post_no_{{ post.id }}" onclick="highlightReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('', '50') }}{% else %}{{ post.link }}{% endif %}">No.</a>
<a class="post_no" onclick="citeReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('q', '50') }}{% else %}{{ post.link('q') }}{% endif %}">{{ post.id }}</a>
{% if post.sticky %}
{% if config.font_awesome %}
<i class="fa fa-thumb-tack"></i>
@ -39,14 +39,14 @@
{% endif %}
{% endif %}
{% if index %}
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ config.file_page|sprintf(post.id) }}">[{% trans %}Reply{% endtrans %}]</a>
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}Reply{% endtrans %}]</a>
{% endif %}
{% if isnoko50 %}
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ config.file_page|sprintf(post.id) }}">[{% trans %}View All{% endtrans %}]</a>
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}View All{% endtrans %}]</a>
{% endif %}
{% if hasnoko50 and not isnoko50 %}
{% set lastcount = config.noko50_count %}
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ config.file_page50|sprintf(post.id) }}">[{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}]</a>
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post, true) }}">[{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}]</a>
{% endif %}
{% include 'post/post_controls.html' %}
</p>

View file

@ -0,0 +1,42 @@
{% filter remove_whitespace %}
{# tabs and new lines will be ignored #}
{# we are intentionally breaking the thread_ID convention: the jses need to handle this case differently #}
<tr id="filethread_{{ post.id }}" class="intro" data-board="{{ board.uri }}">
<td><input type="checkbox" class="delete" name="delete_{{ post.id }}" id="delete_{{ post.id }}" />
<td><a class="post_no" onclick="citeReply({{ post.id }})" href="{{ post.link('q') }}">{{ post.id }}</a>
<td>{% include 'post/name.html' %}
{% include 'post/flag.html' %}
<td>[<a href="{{ config.uri_img }}{{ post.files[0].file }}">{{ post.files[0].filename|e|bidi_cleanup }}</a>]
<td>{% if post.modifiers['tag'] %}[{{ post.modifiers['tag']|e }}]{% endif %}
<td>{% include 'post/subject.html' %}
{% if post.sticky %}
{% if config.font_awesome %}
<i class="fa fa-thumb-tack"></i>
{% else %}
<img class="icon" title="Sticky" src="{{ config.image_sticky }}" alt="Sticky" />
{% endif %}
{% endif %}
{% if post.locked %}
{% if config.font_awesome %}
<i class="fa fa-lock"></i>
{% else %}
<img class="icon" title="Locked" src="{{ config.image_locked }}" alt="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 %}
<i class="fa fa-anchor"></i>
{% else %}
<img class="icon" title="Bumplocked" src="{{ config.image_bumplocked }}" alt="Bumplocked" />
{% endif %}
{% endif %}
<td>{{ post.files[0].size|filesize }}
<td>{% include 'post/time.html' %}
<td>{{ post.omitted }}
<td>{% include 'post/post_controls.html' %}
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}Reply{% endtrans %}]</a>
</tr>
{% endfilter %}

View file

@ -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)),

View file

@ -44,7 +44,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>

View file

@ -50,45 +50,53 @@
data-bump="{{ post.bump }}"
data-time="{{ post.time }}"
>
<div class="thread grid-li grid-size-small">
<a href="{{post.link}}">
{% if post.youtube %}
<img src="http://img.youtube.com/vi/{{ post.youtube }}/0.jpg"
{% else %}
<img src="{{post.file}}"
{% endif %}
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')}}">
</a>
<div class="replies">
<strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong>
{% if post.subject %}
<p class="intro">
<span class="subject">
{{ post.subject|e }}
</span>
</p>
{% else %}
<br />
{% endif %}
{{ post.body }}
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
<div class="thread grid-li grid-size-small">
<a href="{{post.link}}">
{% if post.youtube %}
<img src="//img.youtube.com/vi/{{ post.youtube }}/0.jpg"
{% else %}
<img src="{{post.file}}"
{% endif %}
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')}}">
</a>
<div class="replies">
<strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong>
{% if post.subject %}
<p class="intro">
<span class="subject">
{{ post.subject|e }}
</span>
</p>
{% else %}
<br />
{% endif %}
{{ post.body }}
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
<hr/>
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
<script type="text/javascript">
<script type="text/javascript">{% raw %}
var styles = {
{% endraw %}
{% for name, uri in config.stylesheets %}{% raw %}'{% endraw %}{{ name|addslashes }}{% raw %}' : '{% endraw %}/stylesheets/{{ uri|addslashes }}{% raw %}',
{% endraw %}{% endfor %}{% raw %}
}; onready(init);
{% endraw %}</script>
<script type="text/javascript">{% raw %}
ready();
</script>
{% endraw %}</script>
</body>
</html>
{% endfilter %}

View file

@ -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();
@ -42,35 +57,37 @@
$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)) {
$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;

View file

@ -35,7 +35,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>

View file

@ -34,7 +34,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>

View file

@ -0,0 +1,33 @@
<?php
$theme = Array();
// Theme name
$theme['name'] = 'Public Banlist';
// Description (you can use Tinyboard markup here)
$theme['description'] =
'Shows a public list of bans, that were issued on all boards. Basically, this theme
copies the banlist interface from moderation panel.';
$theme['version'] = 'v0.1';
// Theme configuration
$theme['config'] = Array();
$theme['config'][] = Array(
'title' => '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';
?>

View file

@ -0,0 +1,56 @@
<?php
require 'info.php';
function pbanlist_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)
// - boards (board list changed)
// - bans (ban list changed)
PBanlist::build($action, $settings);
}
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
class PBanlist {
public static function build($action, $settings) {
global $config;
if ($action == 'all')
file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings));
if ($action == 'all' || $action == 'bans')
file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings));
}
public static function gen_json($settings) {
ob_start();
Bans::stream_json(false, true, true, array());
$out = ob_get_contents();
ob_end_clean();
return $out;
}
// Build homepage
public static function homepage($settings) {
global $config;
return Element('page.html', array(
'config' => $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'],
))
));
}
};
?>

View file

@ -61,7 +61,7 @@
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>

View file

@ -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
@ -62,7 +68,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 +98,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
@ -124,15 +130,21 @@
$query = query($query) or error(db_error());
$stats['unique_posters'] = number_format($query->fetchColumn());
/*$query = 'SELECT SUM(`filesize`) FROM (';
// Active content
$query = 'SELECT DISTINCT(`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) {
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,

View file

@ -9,11 +9,11 @@
{% for board, thread_list in threads %}
{% for thread in thread_list %}
<url>
<loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ (config.file_page | format(thread.thread_id)) }}</loc>
<loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }}</loc>
<lastmod>{{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}</lastmod>
<changefreq>{{ settings.changefreq }}</changefreq>
</url>
{% endfor %}
{% endfor %}
</urlset>
{% endfilter %}
{% endfilter %}

View file

@ -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
}
}
}
$boards = explode(' ', $settings['boards']);
$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());
$threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC);
if ($config['smart_build']) {
file_unlink($settings['path']);
}
else {
$boards = explode(' ', $settings['boards']);
$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);
}
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,
)));
}
}

View file

@ -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()));
}
}

View file

@ -2,11 +2,21 @@
require 'info.php';
function ukko_build($action, $settings) {
global $config;
$ukko = new ukko();
$ukko->settings = $settings;
file_write($settings['uri'] . '/index.html', $ukko->build());
file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array()));
if (! ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')) {
return;
}
if ($config['smart_build']) {
file_unlink($settings['uri'] . '/index.html');
}
else {
file_write($settings['uri'] . '/index.html', $ukko->build());
}
}
class ukko {

View file

@ -48,12 +48,12 @@
<footer>
{% include 'badges.html' %}
<p class="unimportant" style="margin-top:20px;text-align:center;">
- <a href="http://tinyboard.org/">Tinyboard</a> + <a href="https://int.vichan.net/devel/">vichan</a> + <a href="https://github.com/lainchan/lainchan">lainchan</a> {{ config.version }} -<br>
<a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group<br/>
<a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel<br/>
<a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2015 lainchan Administration
</p>
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> +
<a href='https://github.com/lainchan/lainchan'>lainchan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2015 lainchan Administration</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
<div class="bar bottom">