Merge /srv/http

This commit is contained in:
8chan 2014-12-14 11:29:50 +00:00
commit 1b2ef21b8c
14 changed files with 71 additions and 35 deletions

View File

@ -1,7 +0,0 @@
<?php
require_once 'inc/functions.php';
checkBan();
print "<!doctype html><html><head><meta charset='utf-8'><title>"._("Banned?")."</title></head><body>";
print "<h1>"._("You are not banned.")."</h1>";
print "</body></html>";
?>

View File

@ -8,7 +8,7 @@ header("Expires: 0");
function get_custom_banner(&$b) { function get_custom_banner(&$b) {
# Validate the board name # Validate the board name
if (!(isset($b) && preg_match('/^[a-z0-9]{1,30}$/', $b))) if (!(isset($b) && preg_match('/^[a-z0-9+]{1,30}$/', $b)))
return null; return null;
# Check if directory exists # Check if directory exists

18
faq.php
View File

@ -65,9 +65,9 @@ $body = <<<EOT
</ul> </ul>
<h2>How are featured boards chosen?</h2> <h2>How are featured boards chosen?</h2>
<p>Top fifteen boards excluding /meta/, /b/ and /int/.</p> <p>Top fifteen boards excluding /meta/, /b/ and /pol/.</p>
<h2>Who owns /meta/, /b/, and /int/?</h2> <h2>Who owns /meta/ and /b/?</h2>
<p>No one, so they are <em>de facto</em> property of the administration.</p> <p>No one, so they are <em>de facto</em> property of the administration.</p>
<h2>Where's the mobile app?</h2> <h2>Where's the mobile app?</h2>
@ -76,12 +76,22 @@ $body = <<<EOT
<p>I don't provide support for this app, ask the developer of it if you have a problem with it.</p> <p>I don't provide support for this app, ask the developer of it if you have a problem with it.</p>
<h2>Where's the archive?</h2> <h2>Where's the archive?</h2>
<p>There isn't one yet and there will never be an official archive.</p> <p><s>There isn't one yet and there will never be an official archive.</s></p>
<p>Given that archives are inevitable and will be created anyway via <a href="https://archive.today">archive.today</a>, Google cache, and anyone who installs Asagi, I'm softening my stance on this. Currently, 8archive.moe provides our archive, and I may set up an official one. <strong>All archives officially partnered with us will be opt-in by our board owners, not opt-out. Archives who archive boards that have not opted in will be considered pirate archives, and legal action may be taken.</strong></p>
<h2>I got an email from an @8chan.co email address, is that you?</h2>
<p>8chan.co uses <a href="https://cock.li">cock.li</a> to manage our domain's email. cock.li allows anyone to create an email account @8chan.co.</p>
<p>That said, we have quite a few official 8chan.co email addresses. They are:</p>
<ul>
<li>admin at 8chan dot co</li>
<li>dmca at 8chan dot co</li>
<li>claim at 8chan dot co</li>
</ul>
<h2>How do I donate?</h2> <h2>How do I donate?</h2>
<p>Donations can be sent to 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C (Bitcoin) or LUPgSCJt3iGeJXUETVhmnbQ89Riaq1yjZm (Litecoin).</p> <p>Donations can be sent to 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C (Bitcoin) or LUPgSCJt3iGeJXUETVhmnbQ89Riaq1yjZm (Litecoin).</p>
<p>I am also a big fan of Monero (XMR). You can send XMR to our <a href="http://openalias.org">OpenAlias</a> in the simplewallet client, or simply send to 49dBJhGhYFxJEfydS6hH6GRyg1W4cDgupdNVtw7j1WtcUY7xPXwNLw6fUVay644viaCcEhMFG1Z7SjjxRXEFDdNWJdvH9kS.</p>
<p>You may also donate monthly via Patreon at <a href="http://www.patreon.com/user?u=162165">http://www.patreon.com/user?u=162165</a>. <p>You may also donate monthly via Patreon at <a href="http://www.patreon.com/user?u=162165">http://www.patreon.com/user?u=162165</a>.
<h2>Are you really a cripple?</h2> <h2>Are you really a cripple?</h2>
<p>Yes.</p> <p>Yes.</p>

View File

@ -22,6 +22,7 @@
$config['mod']['clean_global'] = GLOBALVOLUNTEER; $config['mod']['clean_global'] = GLOBALVOLUNTEER;
$config['mod']['view_notes'] = DISABLED; $config['mod']['view_notes'] = DISABLED;
$config['mod']['create_notes'] = DISABLED; $config['mod']['create_notes'] = DISABLED;
$config['mod']['edit_config'] = DISABLED;
$config['mod']['debug_recent'] = ADMIN; $config['mod']['debug_recent'] = ADMIN;
$config['mod']['debug_antispam'] = ADMIN; $config['mod']['debug_antispam'] = ADMIN;
$config['mod']['noticeboard_post'] = ADMIN; $config['mod']['noticeboard_post'] = ADMIN;
@ -155,14 +156,16 @@
error(sprintf($config['error']['required'], 'username')); error(sprintf($config['error']['required'], 'username'));
if ($_POST['password'] == '') if ($_POST['password'] == '')
error(sprintf($config['error']['required'], 'password')); error(sprintf($config['error']['required'], 'password'));
if (!preg_match('/^[a-zA-Z0-9._]{1,30}$/', $_POST['username']))
error(_('Invalid username'));
if ($count > 10) { if ($count > 10) {
error(_('Too many board volunteers!')); error(_('Too many board volunteers!'));
} }
foreach ($volunteers as $i => $v) { foreach ($volunteers as $i => $v) {
if ($_POST['username'] == $v['username']) { if (strtolower($_POST['username']) == strtolower($v['username'])) {
error(_('Refusing to create a volunteer with the same username as an existing one.')); error(_('Refusing to create a volunteer with the same username as an existing one.'));
} }
} }

View File

@ -1083,6 +1083,7 @@
$config['error']['youaremuted'] = _('You are muted! Expires in %d seconds.'); $config['error']['youaremuted'] = _('You are muted! Expires in %d seconds.');
$config['error']['dnsbl'] = _('Your IP address is listed in %s.'); $config['error']['dnsbl'] = _('Your IP address is listed in %s.');
$config['error']['toomanylinks'] = _('Too many links; flood detected.'); $config['error']['toomanylinks'] = _('Too many links; flood detected.');
$config['error']['notenoughlinks'] = _('OPs are required to have at least %d links on this board.');
$config['error']['toomanycites'] = _('Too many cites; post discarded.'); $config['error']['toomanycites'] = _('Too many cites; post discarded.');
$config['error']['toomanycross'] = _('Too many cross-board links; post discarded.'); $config['error']['toomanycross'] = _('Too many cross-board links; post discarded.');
$config['error']['nodelete'] = _('You didn\'t select anything to delete.'); $config['error']['nodelete'] = _('You didn\'t select anything to delete.');
@ -1680,7 +1681,7 @@
// Regex for board URIs. Don't add "`" character or any Unicode that MySQL can't handle. 58 characters // Regex for board URIs. Don't add "`" character or any Unicode that MySQL can't handle. 58 characters
// is the absolute maximum, because MySQL cannot handle table names greater than 64 characters. // is the absolute maximum, because MySQL cannot handle table names greater than 64 characters.
$config['board_regex'] = '[0-9a-zA-Z$_\x{0080}-\x{FFFF}]{1,58}'; $config['board_regex'] = '[0-9a-zA-Z\+$_\x{0080}-\x{FFFF}]{1,58}';
// Youtube.js embed HTML code // Youtube.js embed HTML code
$config['youtube_js_html'] = '<div class="video-container" data-video="$1" data-params="&$2&$3">'. $config['youtube_js_html'] = '<div class="video-container" data-video="$1" data-params="&$2&$3">'.

View File

@ -432,7 +432,8 @@ function setupBoard($array) {
$board = array( $board = array(
'uri' => $array['uri'], 'uri' => $array['uri'],
'title' => $array['title'], 'title' => $array['title'],
'subtitle' => $array['subtitle'] 'subtitle' => $array['subtitle'],
'indexed' => $array['indexed']
); );
// older versions // older versions
@ -1703,7 +1704,7 @@ function extract_modifiers($body) {
return $modifiers; return $modifiers;
} }
function markup(&$body, $track_cites = false) { function markup(&$body, $track_cites = false, $op = false) {
global $board, $config, $markup_urls; global $board, $config, $markup_urls;
$modifiers = extract_modifiers($body); $modifiers = extract_modifiers($body);
@ -1741,6 +1742,9 @@ function markup(&$body, $track_cites = false) {
if ($num_links > $config['max_links']) if ($num_links > $config['max_links'])
error($config['error']['toomanylinks']); error($config['error']['toomanylinks']);
if ($num_links < $config['min_links'] && $op)
error(sprintf($config['error']['notenoughlinks'], $config['min_links']));
} }
if ($config['markup_repair_tidy']) if ($config['markup_repair_tidy'])

View File

@ -74,7 +74,7 @@
$config['mod']['capcode'][MOD] = array('Board Owner'); $config['mod']['capcode'][MOD] = array('Board Owner');
$config['mod']['capcode'][GLOBALVOLUNTEER] = array('Global Volunteer'); $config['mod']['capcode'][GLOBALVOLUNTEER] = array('Global Volunteer');
$config['custom_capcode']['Admin'] = array( $config['custom_capcode']['Admin'] = array(
'<span class="capcode" style="color:blue;font-weight:bold"> <i class="fa fa-wheelchair"></i> %s</span>', '<span class="capcode" title="This post is written by the global 8chan.co administrator."> <i class="fa fa-wheelchair" style="color:blue;"></i> <span style="color:red">8chan.co Administrator</span></span>',
); );
//$config['mod']['view_banlist'] = GLOBALVOLUNTEER; //$config['mod']['view_banlist'] = GLOBALVOLUNTEER;
$config['mod']['recent_reports'] = 65535; $config['mod']['recent_reports'] = 65535;
@ -91,6 +91,7 @@
//$config['default_stylesheet'] = array('Notsuba', 'notsuba.css'); //$config['default_stylesheet'] = array('Notsuba', 'notsuba.css');
$config['additional_javascript'][] = 'js/jquery.min.js'; $config['additional_javascript'][] = 'js/jquery.min.js';
$config['additional_javascript'][] = 'js/jquery.mixitup.min.js'; $config['additional_javascript'][] = 'js/jquery.mixitup.min.js';
$config['additional_javascript'][] = 'js/jquery-ui.custom.min.js';
$config['additional_javascript'][] = 'js/catalog.js'; $config['additional_javascript'][] = 'js/catalog.js';
$config['additional_javascript'][] = 'js/captcha.js'; $config['additional_javascript'][] = 'js/captcha.js';
$config['additional_javascript'][] = 'js/jquery.tablesorter.min.js'; $config['additional_javascript'][] = 'js/jquery.tablesorter.min.js';
@ -150,8 +151,9 @@
$config['markup'][] = array("/\[spoiler\](.+?)\[\/spoiler\]/", "<span class=\"spoiler\">\$1</span>"); $config['markup'][] = array("/\[spoiler\](.+?)\[\/spoiler\]/", "<span class=\"spoiler\">\$1</span>");
$config['markup'][] = array("/~~(.+?)~~/", "<s>\$1</s>"); $config['markup'][] = array("/~~(.+?)~~/", "<s>\$1</s>");
$config['markup'][] = array("/__(.+?)__/", "<u>\$1</u>"); $config['markup'][] = array("/__(.+?)__/", "<u>\$1</u>");
$config['markup'][] = array("/###([^\s']+)###/", "<a href='/boards.html#\$1'>###\$1###</a>");
$config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-ban" title="Public ban list"></i>' => '/bans.html', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta'), array('<i class="fa fa-twitter" title="Twitter"></i>'=>'https://twitter.com/infinitechan')); $config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-ban" title="Public ban list"></i>' => '/bans.html', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'news+'), array('<i class="fa fa-twitter" title="Twitter"></i>'=>'https://twitter.com/infinitechan'));
//$config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array('<i class="fa fa-twitter" title="Twitter"></i>'=>'https://twitter.com/infinitechan')); //$config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array('<i class="fa fa-twitter" title="Twitter"></i>'=>'https://twitter.com/infinitechan'));
$config['footer'][] = 'All posts on 8chan.co are the responsibility of the individual poster and not the administration of 8chan.co, pursuant to 47 U.S.C. &sect; 230.'; $config['footer'][] = 'All posts on 8chan.co are the responsibility of the individual poster and not the administration of 8chan.co, pursuant to 47 U.S.C. &sect; 230.';
@ -195,6 +197,9 @@
$config['gzip_static'] = false; $config['gzip_static'] = false;
$config['hash_masked_ip'] = true; $config['hash_masked_ip'] = true;
$config['force_subject_op'] = false;
$config['min_links'] = 0;
$config['min_body'] = 0;
// 8chan specific mod pages // 8chan specific mod pages
require '8chan-mod-pages.php'; require '8chan-mod-pages.php';

View File

@ -633,7 +633,7 @@ function mod_news($page_no = 1) {
rebuildThemes('news'); rebuildThemes('news');
header('Location: ?/news#' . $pdo->lastInsertId(), true, $config['redirect_http']); header('Location: ?/edit_news#' . $pdo->lastInsertId(), true, $config['redirect_http']);
} }
$query = prepare("SELECT * FROM ``news`` ORDER BY `id` DESC LIMIT :offset, :limit"); $query = prepare("SELECT * FROM ``news`` ORDER BY `id` DESC LIMIT :offset, :limit");
@ -646,14 +646,14 @@ function mod_news($page_no = 1) {
error($config['error']['404']); error($config['error']['404']);
foreach ($news as &$entry) { foreach ($news as &$entry) {
$entry['delete_token'] = make_secure_link_token('news/delete/' . $entry['id']); $entry['delete_token'] = make_secure_link_token('edit_news/delete/' . $entry['id']);
} }
$query = prepare("SELECT COUNT(*) FROM ``news``"); $query = prepare("SELECT COUNT(*) FROM ``news``");
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
$count = $query->fetchColumn(); $count = $query->fetchColumn();
mod_page(_('News'), 'mod/news.html', array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('news'))); mod_page(_('News'), 'mod/news.html', array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('edit_news')));
} }
function mod_news_delete($id) { function mod_news_delete($id) {
@ -668,7 +668,7 @@ function mod_news_delete($id) {
modLog('Deleted a news entry'); modLog('Deleted a news entry');
header('Location: ?/news', true, $config['redirect_http']); header('Location: ?/edit_news', true, $config['redirect_http']);
} }
function mod_log($page_no = 1) { function mod_log($page_no = 1) {

View File

@ -4,7 +4,7 @@ window.boards = new Array();
function handle_boards(data) { function handle_boards(data) {
$.each(data, function(k, v) { $.each(data, function(k, v) {
if (v.uri != 'meta' && v.uri != 'b') { if (v.uri != 'meta' && v.uri != 'b') {
boards.push('<a href="/'+v.uri+(window.active_page === 'catalog' ? '/catalog.html' : '')+'">'+v.uri+'</a>'); boards.push('<a href="/'+v.uri+(window.active_page === 'catalog' ? '/catalog.html' : '/index.html')+'">'+v.uri+'</a>');
} }
}) })

View File

@ -42,9 +42,9 @@ $pages = array(
'/log/(\d+)' => 'log', // modlog '/log/(\d+)' => 'log', // modlog
'/log:([^/]+)' => 'user_log', // modlog '/log:([^/]+)' => 'user_log', // modlog
'/log:([^/]+)/(\d+)' => 'user_log', // modlog '/log:([^/]+)/(\d+)' => 'user_log', // modlog
'/news' => 'secure_POST news', // view news '/edit_news' => 'secure_POST news', // view news
'/news/(\d+)' => 'secure_POST news', // view news '/edit_news/(\d+)' => 'secure_POST news', // view news
'/news/delete/(\d+)' => 'secure news_delete', // delete from news '/edit_news/delete/(\d+)' => 'secure news_delete', // delete from news
'/noticeboard' => 'secure_POST noticeboard', // view noticeboard '/noticeboard' => 'secure_POST noticeboard', // view noticeboard
'/noticeboard/(\d+)' => 'secure_POST noticeboard', // view noticeboard '/noticeboard/(\d+)' => 'secure_POST noticeboard', // view noticeboard

View File

@ -394,11 +394,19 @@ elseif (isset($_POST['post'])) {
$post['has_file'] = (!isset($post['embed']) && (($post['op'] && !isset($post['no_longer_require_an_image_for_op']) && $config['force_image_op']) || !empty($_FILES['file']['name']))); $post['has_file'] = (!isset($post['embed']) && (($post['op'] && !isset($post['no_longer_require_an_image_for_op']) && $config['force_image_op']) || !empty($_FILES['file']['name'])));
if (!($post['has_file'] || isset($post['embed'])) || (($post['op'] && $config['force_body_op']) || (!$post['op'] && $config['force_body']))) { if (!($post['has_file'] || isset($post['embed'])) || (($post['op'] && $config['force_body_op']) || (!$post['op'] && $config['force_body']))) {
$stripped_whitespace = preg_replace('/[\s]/u', '', $post['body']); // http://stackoverflow.com/a/4167053
$stripped_whitespace = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $post['body']);
if ($stripped_whitespace == '') { if ($stripped_whitespace == '') {
error($config['error']['tooshort_body']); error($config['error']['tooshort_body']);
} }
} }
if ($config['force_subject_op'] && $post['op']) {
$stripped_whitespace = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $post['subject']);
if ($stripped_whitespace == '') {
error(_('It is required to enter a subject when starting a new thread on this board.'));
}
}
if (!$post['op']) { if (!$post['op']) {
// Check if thread is locked // Check if thread is locked
@ -523,6 +531,8 @@ elseif (isset($_POST['post'])) {
error(sprintf($config['error']['toolong'], 'subject')); error(sprintf($config['error']['toolong'], 'subject'));
if (!$mod && mb_strlen($post['body']) > $config['max_body']) if (!$mod && mb_strlen($post['body']) > $config['max_body'])
error($config['error']['toolong_body']); error($config['error']['toolong_body']);
if (mb_strlen($post['body']) < $config['min_body'] && $post['op'])
error(_(sprintf('OP must be at least %d chars on this board.', $config['min_body'])));
if (mb_strlen($post['password']) > 20) if (mb_strlen($post['password']) > 20)
error(sprintf($config['error']['toolong'], 'password')); error(sprintf($config['error']['toolong'], 'password'));
@ -588,7 +598,7 @@ elseif (isset($_POST['post'])) {
} }
} }
$post['tracked_cites'] = markup($post['body'], true); $post['tracked_cites'] = markup($post['body'], true, $post['op']);

View File

@ -18,7 +18,7 @@
{{ boardlist.top }} {{ boardlist.top }}
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %} {% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
{% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}?board={{ board.uri }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %} {% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}?board={{ board.uri|url_encode }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %}
<header> <header>
<h1>{{ board.url }} - {{ board.title|e }}</h1> <h1>{{ board.url }} - {{ board.title|e }}</h1>

View File

@ -188,7 +188,7 @@ function changeStyle(styleName, link) {
{% endraw %} {% endraw %}
function init_stylechooser() { function init_stylechooser() {
var matches = document.URL.match(/\/(\w+)\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page50|replace({'+': '\\+', '%d': '\\d+', '.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.catalog_link|replace({'.': '\\.'}) }})/); var matches = document.URL.match(/\/([0-9a-zA-Z\+$_\u0080-\uFFFF]{1,58})\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page50|replace({'+': '\\+', '%d': '\\d+', '.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.catalog_link|replace({'.': '\\.'}) }})/);
var newElement = document.createElement('div'); var newElement = document.createElement('div');
newElement.className = 'styles'; newElement.className = 'styles';
@ -255,9 +255,10 @@ function get_cookie(cookie_name) {
} }
function highlightReply(id) { function highlightReply(id) {
if (typeof window.event != "undefined" && event.which == 2) { if (typeof window.event != "undefined") {
// don't highlight on middle click // don't highlight on middle click
return true; if (event.which == 2) return true;
window.event.preventDefault();
} }
var divs = document.getElementsByTagName('div'); var divs = document.getElementsByTagName('div');
@ -268,9 +269,18 @@ function highlightReply(id) {
} }
if (id) { if (id) {
var post = document.getElementById('reply_'+id); var post = document.getElementById('reply_'+id);
if (post) if (post) {
post.className += ' highlighted'; post.className += ' highlighted';
window.location.hash = id; window.location.hash = id;
// Better offset to keep in mind new hovering boardlist
var post_top = post.getBoundingClientRect().top;
var body_top = document.body.getBoundingClientRect().top;
var boardlist_height = document.getElementsByClassName('boardlist')[0].getBoundingClientRect().height;
var offset = (post_top - body_top) - boardlist_height;
window.scrollTo(0, offset);
}
} }
return true; return true;
} }

View File

@ -13,7 +13,7 @@
<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}"> <body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }} {{ boardlist.top }}
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %} {% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
{% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}?board={{ board.uri }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %} {% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}?board={{ board.uri|url_encode }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %}
<header> <header>
<h1>{{ board.url }} - {{ board.title|e }}</h1> <h1>{{ board.url }} - {{ board.title|e }}</h1>
<div class="subtitle"> <div class="subtitle">