Out with the old and in with the new.. I guess?

This commit is contained in:
Daniel Saunders 2018-11-01 21:12:26 -04:00
parent 02abee7304
commit 209ba201b6
23 changed files with 87 additions and 126 deletions

View File

@ -952,24 +952,18 @@
$config['font_awesome_css'] = 'stylesheets/font-awesome/css/font-awesome.min.css';
/*
* For lack of a better name, “boardlinks” are those sets of navigational links that appear at the top
* and bottom of board pages. They can be a list of links to boards and/or other pages such as status
* blogs and social network profiles/pages.
*
* "Groups" in the boardlinks are marked with square brackets. Tinyboard allows for infinite recursion
* with groups. Each array() in $config['boards'] represents a new square bracket group.
* Tinyboard allows the creation of a menu for boards and other links you may want on your site.
* Categories are used for organizing your menu items into sections.
*/
// $config['boards'] = array(
// array('a', 'b'),
// array('c', 'd', 'e', 'f', 'g'),
// array('h', 'i', 'j'),
// array('k', array('l', 'm')),
// array('status' => 'http://status.example.org/')
// );
// Whether or not to put brackets around the whole board list
$config['boardlist_wrap_bracket'] = false;
// $config['menu'] = [
// 'Japan' => ['a', 'd', 'h', 'm'],
// 'General' => ['b', 'f', 'k'],
// 'Site' => [
// 'news' => 'https://example.org/news',
// 'status' => 'https://status.example.org'
// ]
// ];
// Show page navigation links at the top as well.
$config['page_nav_top'] = false;
@ -977,11 +971,6 @@
// Show "Catalog" link in page navigation. Use with the Catalog theme. Set to false to disable.
$config['catalog_link'] = 'catalog.html';
// Board categories. Only used in the "Categories" theme.
// $config['categories'] = array(
// 'Group Name' => array('a', 'b', 'c'),
// 'Another Group' => array('d')
// );
// Optional for the Categories theme. This is an array of name => (title, url) groups for categories
// with non-board links.
// $config['custom_categories'] = array(

View File

@ -19,56 +19,38 @@ function format_bytes($size) {
return round($size, 2).$units[$i];
}
function doBoardListPart($list, $root, &$boards) {
function createMenu($mod=false) {
global $config;
$body = '';
foreach ($list as $key => $board) {
if (is_array($board))
$body .= ' <span class="sub" data-description="' . $key . '">[' . doBoardListPart($board, $root, $boards) . ']</span> ';
else {
if (gettype($key) == 'string') {
$body .= ' <a href="' . $board . '">' . $key . '</a> /';
} else {
$title = '';
if (isset ($boards[$board])) {
$title = ' title="'.$boards[$board].'"';
}
$body .= ' <a href="' . $root . $board . '/' . $config['file_index'] . '"'.$title.'>' . $board . '</a> /';
}
}
}
$body = preg_replace('/\/$/', '', $body);
return $body;
}
function createBoardlist($mod=false) {
global $config;
if (!isset($config['boards'])) return array('top'=>'','bottom'=>'');
$xboards = listBoards();
$boards = array();
$boards = [];
$menu = [];
foreach ($xboards as $val) {
$boards[$val['uri']] = $val['title'];
}
$body = doBoardListPart($config['boards'], $mod?'?/':$config['root'], $boards);
foreach ($config['menu'] as $category => $items) {
$menu[$category] = [];
if ($config['boardlist_wrap_bracket'] && !preg_match('/\] $/', $body))
$body = '[' . $body . ']';
foreach ($items as $title => $uri) {
if (gettype($title) != 'string' && array_key_exists($uri, $boards)) {
$menu[$category][] = [
'title' => $boards[$uri],
'uri' => ($mod ? '?/' : $config['root']) . $uri . '/' . $config['file_index'],
'is_board' => true
];
} else {
$menu[$category][] = [
'title' => $title,
'uri' => $uri,
'is_board' => false
];
}
}
}
$body = trim($body);
// Message compact-boardlist.js faster, so that page looks less ugly during loading
$top = "<script type='text/javascript'>if (typeof do_boardlist != 'undefined') do_boardlist();</script>";
return array(
'top' => '<div class="boardlist">' . $body . '</div>' . $top,
'bottom' => '<div class="boardlist bottom">' . $body . '</div>'
);
return $menu;
}
function error($message, $priority = true, $debug_stuff = false) {

View File

@ -886,7 +886,7 @@ function displayBan($ban) {
Element('page.html', array(
'title' => _('Banned!'),
'config' => $config,
'boardlist' => createBoardlist(isset($mod) ? $mod : false),
'menu' => createMenu(isset($mod) ? $mod : false),
'body' => Element('banned.html', array(
'config' => $config,
'ban' => $ban,
@ -1428,7 +1428,7 @@ function index($page, $mod=false, $brief = false) {
'body' => $body,
'post_url' => $config['post_url'],
'config' => $config,
'boardlist' => createBoardlist($mod),
'menu' => createMenu($mod),
'threads' => $threads,
);
}
@ -2270,7 +2270,7 @@ function buildThread($id, $return = false, $mod = false) {
'hasnoko50' => $hasnoko50,
'isnoko50' => false,
'antibot' => $antibot,
'boardlist' => createBoardlist($mod),
'menu' => createMenu($mod),
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
));
@ -2373,7 +2373,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
'hasnoko50' => $hasnoko50,
'isnoko50' => true,
'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)),
'boardlist' => createBoardlist($mod),
'menu' => createMenu($mod),
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
));

View File

@ -15,7 +15,7 @@ function mod_page($title, $template, $args, $subtitle = false) {
'hide_dashboard_link' => $template == 'mod/dashboard.html',
'title' => $title,
'subtitle' => $subtitle,
'boardlist' => createBoardlist($mod),
'menu' => createMenu($mod),
'body' => Element($template,
array_merge(
array('config' => $config, 'mod' => $mod),

View File

@ -7,7 +7,7 @@
{% endblock %}
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
{% 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="banner" src="{{ config.url_banner }}" {% 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>
@ -34,7 +34,7 @@
<div class="pages">{{ btn.prev }} {% for page in pages %}
[<a {% if page.selected %}class="selected"{% endif %}{% if not page.selected %}href="{{ page.link }}"{% endif %}>{{ page.num }}</a>]{% if loop.last %} {% endif %}
{% endfor %} {{ btn.next }}</div>
{{ boardlist.bottom }}
{% include "menu.html" with {"bottom": true} %}
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
@ -42,8 +42,8 @@
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
<script type="text/javascript">{% verbatim %}
{% verbatim %}<script type="text/javascript">
ready();
{% endverbatim %}</script>
</script>{% endverbatim %}
</body>
</html>

View File

@ -17,7 +17,7 @@
<title>{{ board.url }} - {{ board.title|e }}</title>
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} active-{% if not no_post_form %}index{% else %}ukko{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
{% 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 }}" {% 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 %}
@ -84,7 +84,7 @@
{% endif %}
</div>
{{ boardlist.bottom }}
{% include "menu.html" with {"bottom": true} %}
{{ config.ad.bottom }}

11
templates/menu.html Normal file
View File

@ -0,0 +1,11 @@
<div class="boardlist{% if bottom %} bottom{% endif %}">
{% for category, items in menu %}
<span class="sub" data-description="{{ category }}">[
{% for item in items %}
<a href="{{ item.uri }}"{% if item.is_board %} title="{{ item.title }}"{% endif %}>{% if item.is_board %}{{ item.uri }}{% else %}{{ item.title }}{% endif %}</a>
{% if not loop.last %}/{% endif %}
{% endfor %}
]</span>
{% endfor %}
</div>
{% if not bottom %}<script type='text/javascript'>if (typeof do_boardlist != 'undefined') do_boardlist();</script>{% endif %}

View File

@ -9,7 +9,7 @@
<title>{{ title }}</title>
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} active-page" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
{% 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 %}
<header>

View File

@ -40,7 +40,7 @@
</div>
<div class="ban boards">
{% for category, boards in categories %}
{% for category, items in menu %}
<div class="category">
<h2>{{ category }}</h2>
<ul>

View File

@ -44,17 +44,6 @@
$query = query("SELECT * FROM ``news`` ORDER BY `time` DESC" . ($settings['no_recent'] ? ' LIMIT ' . $settings['no_recent'] : '')) or error(db_error());
$news = $query->fetchAll(PDO::FETCH_ASSOC);
$categories = $config['categories'];
foreach ($categories as &$_boards) {
foreach ($_boards as &$_board) {
$title = boardTitle($_board);
if (!$title)
$title = $_board; // board doesn't exist, but for some reason you want to display it anyway
$_board = ['title' => $title, 'uri' => sprintf($config['board_path'], $_board)];
}
}
$recent_images = [];
$recent_posts = [];
$stats = [];
@ -168,9 +157,8 @@
return Element('themes/awsumchan/index.html', [
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
'menu' => createMenu(),
'news' => $news,
'categories' => $categories,
'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
'stats' => $stats

View File

@ -12,7 +12,7 @@
{% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %}
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
<header>
<h1>{{ settings.title }}</h1>
<div class="subtitle">{{ settings.subtitle }}</div>

View File

@ -31,7 +31,7 @@
return Element('themes/basic/index.html', Array(
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
'menu' => createMenu(),
'news' => $news
));
}

View File

@ -11,7 +11,7 @@
<title>{{ board }} - Catalog</title>
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} theme-catalog active-catalog" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
<header>
<h1>{{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1>
<div class="subtitle">{{ settings.subtitle }}</div>
@ -78,17 +78,17 @@
<br>Tinyboard Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
</footer>
<script type="text/javascript">{% verbatim %}
{% verbatim %}<script type="text/javascript">
var styles = {
{% endverbatim %}
{% for name, uri in config.stylesheets %}{% verbatim %}'{% endverbatim %}{{ name|addslashes }}{% verbatim %}' : '{% endverbatim %}/stylesheets/{{ uri|addslashes }}{% verbatim %}',
{% endverbatim %}{% endfor %}{% verbatim %}
}; onready(init);
{% endverbatim %}</script>
</script>{% endverbatim %}
<script type="text/javascript">{% verbatim %}
{% verbatim %}<script type="text/javascript">
ready();
{% endverbatim %}</script>
</script>{% endverbatim %}
</body>
</html>
{% endfilter %}

View File

@ -112,7 +112,7 @@
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array(
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
'menu' => createMenu(),
'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
'stats' => $stats,

View File

@ -58,9 +58,9 @@ Requires $config[\'categories\'].';
function categories_install($settings) {
global $config;
if (!isset($config['categories'])) {
if (!isset($config['menu'])) {
return Array(false, '<h2>Prerequisites not met!</h2>' .
'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.');
'This theme requires $config[\'menu\'] to be set.');
}
}
}

View File

@ -7,7 +7,7 @@
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"/>
</head>
<body>
{{ boardlist.top }}
{% include "menu.html" %}
<header>
<h1>{{ settings.title }}</h1>
<div class="subtitle">{{ settings.subtitle }}</div>

View File

@ -24,15 +24,17 @@
</ul>
</fieldset>
{% for category, boards in categories %}
{% for category, items in menu %}
<fieldset>
<legend>
{{ category }}
</legend>
{% for board in boards %}
<li>
<a href="{{ board.uri }}">{{ board.title|e }}</a>
</li>
{% for item in items %}
{% if item.is_board %}
<li>
<a href="{{ item.uri }}">{{ item.title|e }}</a>
</li>
{% endif %}
{% endfor %}
</fieldset>
{% endfor %}

View File

@ -43,29 +43,18 @@
'settings' => $settings,
'config' => $config,
'news' => $news,
'boardlist' => createBoardlist(false)
'menu' => createMenu(false)
));
}
// Build sidebar
public static function sidebar($settings) {
global $config, $board;
$categories = $config['categories'];
foreach ($categories as &$boards) {
foreach ($boards as &$board) {
$title = boardTitle($board);
if (!$title)
$title = $board; // board doesn't exist, but for some reason you want to display it anyway
$board = Array('title' => $title, 'uri' => sprintf($config['board_path'], $board));
}
}
global $config;
return Element('themes/categories/sidebar.html', Array(
'settings' => $settings,
'config' => $config,
'categories' => $categories
'menu' => $menu
));
}
};

View File

@ -12,7 +12,7 @@
{% include 'header.html' %}
</head>
<body>
{{ boardlist.top }}
{% include "menu.html" %}
<header>
<h1>{{ settings.title }}</h1>
<div class="subtitle">{{ settings.subtitle }}</div>

View File

@ -152,7 +152,7 @@
return Element('themes/recent/recent.html', Array(
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
'menu' => createMenu(),
'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
'stats' => $stats

View File

@ -113,7 +113,7 @@
return Element('themes/rss/rss.xml', Array(
'settings' => $settings,
'config' => $config,
//'boardlist' => createBoardlist(),
//'menu' => createMenu(),
//'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
//'stats' => $stats

View File

@ -107,7 +107,7 @@
'no_post_form' => true,
'body' => $body,
'mod' => $mod,
'boardlist' => createBoardlist($mod),
'menu' => createMenu($mod),
));
}

View File

@ -24,7 +24,7 @@
<title>{{ board.url }} - {{ meta_subject }}</title>
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} active-thread" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% include "menu.html" %}
<a name="top"></a>
{% 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 }}" {% 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 %}
@ -78,7 +78,7 @@
</form>
<a name="bottom"></a>
{{ boardlist.bottom }}
{% include "menu.html" with {"bottom": true} %}
{{ config.ad.bottom }}
@ -89,8 +89,8 @@
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
<script type="text/javascript">{% verbatim %}
{% verbatim %}<script type="text/javascript">
ready();
{% endverbatim %}</script>
</script>{% endverbatim %}
</body>
</html>