mirror of
https://github.com/Circlepuller/Tinyboard.git
synced 2025-01-16 21:08:30 +01:00
Moved AwsumChan theme to its own repository
This commit is contained in:
parent
0552e5b50d
commit
0c4dac71a0
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -1,4 +1,7 @@
|
||||
[submodule "js/wPaint"]
|
||||
path = js/wPaint
|
||||
url = https://github.com/vichan-devel/wPaint.git
|
||||
branch = master
|
||||
branch = master
|
||||
[submodule "templates/themes/awsumchan"]
|
||||
path = templates/themes/awsumchan
|
||||
url = https://github.com/AwsumChan/AwsumChan-Theme.git
|
||||
|
1
templates/themes/awsumchan
Submodule
1
templates/themes/awsumchan
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit aee9b12d6efd816eeb9bfda85f8a219189879760
|
@ -1,17 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="{{ config.locale }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{% include "header.html" with {"nojavascript": true} %}
|
||||
<style>
|
||||
iframe{border:none;margin:0;padding:0;height:99%;position:absolute}
|
||||
iframe#sidebar{left:0;top:0;width:15%}
|
||||
iframe#main{border-left:1px solid black;left:15%;top:0;width:85%}
|
||||
</style>
|
||||
<title>{{ settings.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="{{ settings.file_sidebar }}" id="sidebar" name="sidebar"></iframe>
|
||||
<iframe src="{{ settings.file_index }}" id="main" name="main"></iframe>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
@ -1,99 +0,0 @@
|
||||
{% filter remove_whitespace %}
|
||||
<!doctype html>
|
||||
<html lang="{{ config.locale }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{% include 'header.html' %}
|
||||
<link rel="stylesheet" media="screen" href="{{ config.root }}{{ settings.file_css }}">
|
||||
<title>{{ settings.title }}</title>
|
||||
</head>
|
||||
<body class="{% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
|
||||
<header>
|
||||
<h1>
|
||||
<img class="banner logo" src="{{ config.root }}{{ settings.file_logo }}" alt="{{ settings.title }}">
|
||||
</h1>
|
||||
<div class="subtitle">{{ settings.subtitle }}</div>
|
||||
</header>
|
||||
|
||||
<div class="ban">
|
||||
{% if news|length == 0 %}
|
||||
<p style="text-align:center" class="unimportant">(No news to show.)</p>
|
||||
{% else %}
|
||||
{% for entry in news %}
|
||||
<h2 id="{{ entry.id }}">
|
||||
{% if entry.subject %}
|
||||
{{ entry.subject }}
|
||||
{% else %}
|
||||
<em>no subject</em>
|
||||
{% endif %}
|
||||
<span class="unimportant"> — by {{ entry.name }} at {{ entry.time|date(config.post_date, config.timezone) }}</span>
|
||||
</h2>
|
||||
<p>{{ entry.body }}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="ban boards">
|
||||
{% for category, boards in categories %}
|
||||
<div class="category">
|
||||
<h2>{{ category }}</h2>
|
||||
<ul>
|
||||
{% for board in boards %}
|
||||
<li>
|
||||
<a href="{{ board.uri }}">{{ board.title|e }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="box-wrap">
|
||||
<div class="left-column">
|
||||
<div class="box">
|
||||
<h2>Recent Images</h2>
|
||||
<ul>
|
||||
{% for post in recent_images %}
|
||||
<li>
|
||||
<a href="{{ post.link }}" data-thread="{{ post.thread }}">
|
||||
<img src="{{ post.src }}" style="width:{{ post.thumbwidth }}px;height:{{ post.thumbheight }}px" alt="">
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-column">
|
||||
<div class="box">
|
||||
<h2>Latest Posts</h2>
|
||||
<ul>
|
||||
{% for post in recent_posts %}
|
||||
<li>
|
||||
<strong>{{ post.board_name }}</strong>:
|
||||
<a href="{{ post.link }}" data-thread="{{ post.thread }}">
|
||||
{{ post.snippet }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="box">
|
||||
<h2>Stats</h2>
|
||||
<ul>
|
||||
<li>Total posts: {{ stats.total_posts }}</li>
|
||||
<li>Unique posters: {{ stats.unique_posters }}</li>
|
||||
<li>Active content: {{ stats.active_content|filesize }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
<footer>
|
||||
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by Tinyboard {{ config.version }}
|
||||
<br>Tinyboard Copyright © 2010-2019 Tinyboard Development Group
|
||||
<br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
@ -1,135 +0,0 @@
|
||||
<?php
|
||||
$theme = [];
|
||||
|
||||
// Theme name
|
||||
$theme['name'] = 'AwsumChan';
|
||||
// Description (you can use Tinyboard markup here)
|
||||
$theme['description'] = 'A combination of the RecentPosts and Basic themes, made specially for AwsumChan.';
|
||||
$theme['version'] = 'v1.2';
|
||||
|
||||
// Theme configuration
|
||||
$theme['config'] = [];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Site Title',
|
||||
'name' => 'title',
|
||||
'type' => 'text'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Slogan',
|
||||
'name' => 'subtitle',
|
||||
'type' => 'text',
|
||||
'comment' => '(optional)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => '# of recent entries',
|
||||
'name' => 'no_recent',
|
||||
'type' => 'text',
|
||||
'default' => 0,
|
||||
'size' => 3,
|
||||
'comment' => '(number of recent news entries to display; "0" is infinite)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Excluded boards',
|
||||
'name' => 'exclude',
|
||||
'type' => 'text',
|
||||
'comment' => '(space seperated)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => '# of recent images',
|
||||
'name' => 'limit_images',
|
||||
'type' => 'text',
|
||||
'default' => '3',
|
||||
'comment' => '(maximum images to display)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => '# of recent posts',
|
||||
'name' => 'limit_posts',
|
||||
'type' => 'text',
|
||||
'default' => '30',
|
||||
'comment' => '(maximum posts to display)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Index file',
|
||||
'name' => 'file_index',
|
||||
'type' => 'text',
|
||||
'default' => 'index.html',
|
||||
'comment' => '(eg. "index.html")'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'CSS file',
|
||||
'name' => 'file_css',
|
||||
'type' => 'text',
|
||||
'default' => 'recent.css',
|
||||
'comment' => '(eg. "recent.css")'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Logo file',
|
||||
'name' => 'file_logo',
|
||||
'type' => 'text',
|
||||
'default' => 'logo.png',
|
||||
'comment' => '(optional, leave blank to disable)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Favicon file',
|
||||
'name' => 'file_favicon',
|
||||
'type' => 'text',
|
||||
'default' => 'favicon.ico',
|
||||
'comment' => '(optional, leave blank to disable)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Frames file',
|
||||
'name' => 'file_frames',
|
||||
'type' => 'text',
|
||||
'default' => 'frames.html',
|
||||
'comment' => '(optional, required if using frames - leave blank to disable)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'Sidebar file',
|
||||
'name' => 'file_sidebar',
|
||||
'type' => 'text',
|
||||
'default' => 'sidebar.html',
|
||||
'comment' => '(optional, required if using frames - leave blank to disable)'
|
||||
];
|
||||
|
||||
// This one's a bit of an odd one
|
||||
$theme['config'][] = [
|
||||
'title' => 'YouTube video playlist',
|
||||
'name' => 'playlist',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'comment' => '(optional, play a YouTube playlist in the sidebar - leave blank to disable)'
|
||||
];
|
||||
|
||||
$theme['config'][] = [
|
||||
'title' => 'CSS stylesheet name',
|
||||
'name' => 'basecss',
|
||||
'type' => 'text',
|
||||
'default' => 'recent.css',
|
||||
'comment' => '(eg. "recent.css" - see templates/themes/awsumchan for details)'
|
||||
];
|
||||
|
||||
// Unique function name for building everything
|
||||
$theme['build_function'] = 'awsumchan_build';
|
||||
$theme['install_callback'] = 'awsumchan_install';
|
||||
|
||||
if (!function_exists('awsumchan_install')) {
|
||||
function awsumchan_install($settings) {
|
||||
if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0)
|
||||
return [false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.'];
|
||||
if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0)
|
||||
return [false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.'];
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 919 KiB |
@ -1,93 +0,0 @@
|
||||
.box-wrap {
|
||||
max-width: 700px;
|
||||
min-width: 332px;
|
||||
margin: 0 auto;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
}
|
||||
.left-column {
|
||||
align-self: flex-start;
|
||||
}
|
||||
.right-column {
|
||||
margin-left: auto;
|
||||
}
|
||||
.box {
|
||||
background: white;
|
||||
border: 1px solid #98E;
|
||||
width: 330px;
|
||||
margin: 30px 0;
|
||||
margin-top: 0;
|
||||
padding: 0;
|
||||
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
|
||||
flex: 1;
|
||||
}
|
||||
.box ul {
|
||||
padding: 2px 15px;
|
||||
}
|
||||
.box ul li {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
.left-column .box {
|
||||
background: #efe;
|
||||
color: #060;
|
||||
border: 1px solid #060;
|
||||
float: left;
|
||||
}
|
||||
.right-column .box {
|
||||
background: #eef;
|
||||
color: #006;
|
||||
border: 1px solid #006;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.box h2 {
|
||||
padding: 3px 7px;
|
||||
font-size: 12pt;
|
||||
}
|
||||
.left-column .box h2 {
|
||||
background: #9C6;
|
||||
color: #060;
|
||||
}
|
||||
.right-column .box h2 {
|
||||
background: #59A;
|
||||
color: white;
|
||||
}
|
||||
.box img {
|
||||
float: none;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
img.banner.logo {
|
||||
border-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
div.ban.boards {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
div.category {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div.category:not(:first-child) {
|
||||
border-left: 1px solid #CCC;
|
||||
}
|
||||
|
||||
div.category ul {
|
||||
padding: 0;
|
||||
margin: 20px 20px;
|
||||
margin-top: 15px;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
div.category a:link, div.category a:visited {
|
||||
color: #28759C;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
div.category a:hover, div.category a:active {
|
||||
font-weight: bold;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
body {
|
||||
color: #CCCCCC;
|
||||
background: #1E1E1E;
|
||||
}
|
||||
|
||||
header div.subtitle, h1 {
|
||||
color: #CCCCCC;
|
||||
}
|
||||
|
||||
a:link, a:visited, p.intro a.email span.name {
|
||||
color: #CCCCCC;
|
||||
text-decoration: underline;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
a:link:hover, a:visited:hover {
|
||||
color: #FF0000;
|
||||
font-family: sans-serif;
|
||||
text-decoration: underline overline;
|
||||
}
|
||||
|
||||
.box-wrap {
|
||||
max-width: 670px;
|
||||
min-width: 332px;
|
||||
margin: 30px auto;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
}
|
||||
.box {
|
||||
background: white;
|
||||
border: 1px solid #98E;
|
||||
width: 330px;
|
||||
margin: 8px 0;
|
||||
padding: 0;
|
||||
}
|
||||
.box ul {
|
||||
padding: 2px 15px;
|
||||
}
|
||||
.box ul li {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
.box.left {
|
||||
background: #333333;
|
||||
color: #CCCCCC;
|
||||
border: #555555 1px solid;
|
||||
float: left;
|
||||
}
|
||||
.box.right {
|
||||
background: #333333;
|
||||
color: #CCCCCC;
|
||||
border: #555555 1px solid;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.box h2 {
|
||||
padding: 3px 7px;
|
||||
font-size: 12pt;
|
||||
border: #555555 1px solid;
|
||||
}
|
||||
.box.left h2 {
|
||||
background: #333333;
|
||||
color: #CCCCCC;
|
||||
border: #555555 1px solid;
|
||||
}
|
||||
.box.right h2 {
|
||||
background: #333333;
|
||||
color: #CCCCCC;
|
||||
border: #555555 1px solid;
|
||||
}
|
||||
.box img {
|
||||
float: none;
|
||||
margin: 10px auto;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
.box-wrap {
|
||||
max-width: 670px;
|
||||
min-width: 332px;
|
||||
margin: 30px auto;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
}
|
||||
.box {
|
||||
background: white;
|
||||
border: 1px solid #98E;
|
||||
width: 330px;
|
||||
margin: 8px 0;
|
||||
padding: 0;
|
||||
}
|
||||
.box ul {
|
||||
padding: 2px 15px;
|
||||
}
|
||||
.box ul li {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
.box.left {
|
||||
background: #FDF6AF;
|
||||
color: #9E914F;
|
||||
border: 1px solid #9E914F;
|
||||
float: left;
|
||||
}
|
||||
.box.right {
|
||||
background: #F2DCE5;
|
||||
color: #525;
|
||||
border: 1px solid #CA759E;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.box h2 {
|
||||
padding: 3px 7px;
|
||||
font-size: 12pt;
|
||||
}
|
||||
.box img {
|
||||
float: none;
|
||||
margin: 10px auto;
|
||||
}
|
||||
.box.left h2 {
|
||||
background: #FEE78F;
|
||||
color: #9E914F;
|
||||
}
|
||||
.box.right h2 {
|
||||
background: #EB81B4;
|
||||
color: #F8F8F8;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #F7F8F9;
|
||||
}
|
||||
header div.subtitle, h1 {
|
||||
color: #888A8C;
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
{% filter remove_whitespace %}
|
||||
<!doctype html>
|
||||
<html lang="{{ config.locale }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{% include "header.html" with {"nojavascript": true} %}
|
||||
<style>
|
||||
fieldset{margin:10px 0}
|
||||
legend{width:100%;margin-left:-15px;background:#DDD;border:1px solid #CCC;color:#36362E;font-weight:bold;padding:4px 15px 5px 5px;text-shadow:1px 1px 1px rgba(255, 255, 255, 0.7)}
|
||||
ul{margin:0;padding:0}
|
||||
li{list-style:none;padding:0 4px;margin: 0 4px}
|
||||
li a.system{font-weight:bold}
|
||||
#player{width:100%;height:100%}
|
||||
</style>
|
||||
{% if settings.playlist %}
|
||||
{% verbatim %}
|
||||
<script>
|
||||
let tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
|
||||
let first = document.getElementsByTagName('script')[0];
|
||||
first.parentNode.insertBefore(tag, first);
|
||||
|
||||
var player;
|
||||
|
||||
/* Play a psuedo-random video depending on the day */
|
||||
function dailyRandom(s)
|
||||
{
|
||||
let n = new Date();
|
||||
if (!(s > 0))
|
||||
s = '' + n.getFullYear() + n.getDate() + n.getMonth();
|
||||
let x = Math.sin(s++) * 10000;
|
||||
return x - Math.floor(x);
|
||||
}
|
||||
|
||||
function onYouTubeIframeAPIReady()
|
||||
{
|
||||
player = new YT.Player('player', {
|
||||
height: 480,
|
||||
width: 640,
|
||||
events: {
|
||||
onReady: onPlayerReady,
|
||||
onStateChange: (event) => {
|
||||
if (event.data === YT.PlayerState.ENDED) /* Ended */
|
||||
player.stopVideo();
|
||||
}
|
||||
},
|
||||
playerVars: {
|
||||
listType: 'playlist',
|
||||
list: '{% endverbatim %}{{ settings.playlist }}{% verbatim %}',
|
||||
autoplay: 0,
|
||||
rel: 0,
|
||||
controls: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onPlayerReady(event)
|
||||
{
|
||||
let idx = Math.round(dailyRandom() * player.getPlaylist().length);
|
||||
|
||||
setTimeout(() => {
|
||||
player.playVideoAt(idx);
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
{% endverbatim %}
|
||||
{% endif %}
|
||||
<title>{{ settings.title }}</title>
|
||||
<base target="main"/>
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<legend>{{ settings.title }}</legend>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="system" href="{{ settings.file_index }}">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
{% for category, boards in categories %}
|
||||
<fieldset>
|
||||
<legend>
|
||||
{{ category }}
|
||||
</legend>
|
||||
{% for board in boards %}
|
||||
<li>
|
||||
<a href="{{ board.uri }}">{{ board.title|e }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
|
||||
{% for category, links in config.custom_categories %}
|
||||
<fieldset>
|
||||
<legend>
|
||||
{{ category }}
|
||||
</legend>
|
||||
{% for title, uri in links %}
|
||||
<li>
|
||||
<a href="{{ uri }}">{{ title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
|
||||
{% if settings.playlist %}
|
||||
<div id="player"></div>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
{% endfilter %}
|
@ -1,232 +0,0 @@
|
||||
<?php
|
||||
require 'info.php';
|
||||
|
||||
function awsumchan_build($action, $settings, $board) {
|
||||
// Possible values for $action:
|
||||
// - all (rebuild everything, initialization)
|
||||
// - news (news has been updated)
|
||||
// - boards (board list changed)
|
||||
// - post (a post has been made)
|
||||
// - post-thread (a thread has been made)
|
||||
// - post-delete (a post has been deleted)
|
||||
|
||||
$b = new AwsumChan();
|
||||
$b->build($action, $settings);
|
||||
}
|
||||
|
||||
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
||||
class AwsumChan {
|
||||
public function build($action, $settings) {
|
||||
global $config, $_theme;
|
||||
|
||||
$frames_enabled = ($settings['file_frames'] !== '' && $settings['file_sidebar'] !== '');
|
||||
|
||||
if ($action === 'all') {
|
||||
copy('templates/themes/awsumchan/' . $settings['basecss'], $config['dir']['home'] . $settings['file_css']);
|
||||
|
||||
if ($settings['file_logo'] !== '')
|
||||
copy('templates/themes/awsumchan/logo.png', $config['dir']['home'] . $settings['file_logo']);
|
||||
|
||||
if ($settings['file_favicon'] !== '')
|
||||
copy('templates/themes/awsumchan/icon.ico', $config['dir']['home'] . $settings['file_favicon']);
|
||||
}
|
||||
|
||||
if ($frames_enabled) {
|
||||
switch ($action) {
|
||||
case 'all':
|
||||
file_write($config['dir']['home'] . $settings['file_frames'], $this->frames($settings));
|
||||
case 'boards':
|
||||
file_write($config['dir']['home'] . $settings['file_sidebar'], $this->sidebar($settings));
|
||||
}
|
||||
}
|
||||
|
||||
$this->excluded = explode(' ', $settings['exclude']);
|
||||
|
||||
if ($action === 'all' || $action === 'news' || $action === 'boards' || $action === 'post' || $action === 'post-thread' || $action === 'post-delete')
|
||||
file_write($config['dir']['home'] . $settings['file_index'], $this->homepage($settings));
|
||||
}
|
||||
|
||||
// Build news page
|
||||
public function homepage($settings) {
|
||||
global $config, $board;
|
||||
|
||||
$settings['no_recent'] = (int)$settings['no_recent'];
|
||||
|
||||
$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 = ['title' => $title, 'uri' => sprintf($config['board_path'], $_board)];
|
||||
}
|
||||
}
|
||||
|
||||
$recent_images = [];
|
||||
$recent_posts = [];
|
||||
$stats = [];
|
||||
|
||||
$boards = listBoards();
|
||||
|
||||
$query = '';
|
||||
foreach ($boards as &$_board) {
|
||||
if (in_array($_board['uri'], $this->excluded))
|
||||
continue;
|
||||
$query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `files` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']);
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query);
|
||||
|
||||
if ($query == '') {
|
||||
error(_("Can't build the AwsumChan theme, because there are no boards to be fetched."));
|
||||
}
|
||||
|
||||
$query = query($query) or error(db_error());
|
||||
|
||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
openBoard($post['board']);
|
||||
|
||||
if (isset($post['files']))
|
||||
$files = json_decode($post['files']);
|
||||
|
||||
if ($files[0]->file == 'deleted' || $files[0]->thumb == 'file') continue;
|
||||
|
||||
// board settings won't be available in the template file, so generate links now
|
||||
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res']
|
||||
. link_for($post) . '#' . $post['id'];
|
||||
|
||||
if ($files) {
|
||||
if ($files[0]->thumb == 'spoiler') {
|
||||
$tn_size = @getimagesize($config['spoiler_image']);
|
||||
$post['src'] = $config['spoiler_image'];
|
||||
$post['thumbwidth'] = $tn_size[0];
|
||||
$post['thumbheight'] = $tn_size[1];
|
||||
}
|
||||
else {
|
||||
$post['src'] = $config['uri_thumb'] . $files[0]->thumb;
|
||||
$post['thumbwidth'] = $files[0]->thumbwidth;
|
||||
$post['thumbheight'] = $files[0]->thumbheight;
|
||||
}
|
||||
}
|
||||
|
||||
$recent_images[] = $post;
|
||||
}
|
||||
|
||||
|
||||
$query = '';
|
||||
foreach ($boards as &$_board) {
|
||||
if (in_array($_board['uri'], $this->excluded))
|
||||
continue;
|
||||
$query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']);
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query);
|
||||
$query = query($query) or error(db_error());
|
||||
|
||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
openBoard($post['board']);
|
||||
|
||||
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id'];
|
||||
if ($post['body'] != "")
|
||||
$post['snippet'] = pm_snippet($post['body'], 30);
|
||||
else
|
||||
$post['snippet'] = "<em>" . _("(no comment)") . "</em>";
|
||||
$post['board_name'] = $board['name'];
|
||||
|
||||
$recent_posts[] = $post;
|
||||
}
|
||||
|
||||
// Total posts
|
||||
$query = 'SELECT SUM(`top`) FROM (';
|
||||
foreach ($boards as &$_board) {
|
||||
if (in_array($_board['uri'], $this->excluded))
|
||||
continue;
|
||||
$query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
|
||||
$query = query($query) or error(db_error());
|
||||
$stats['total_posts'] = number_format($query->fetchColumn());
|
||||
|
||||
// Unique IPs
|
||||
$query = 'SELECT COUNT(DISTINCT(`ip`)) FROM (';
|
||||
foreach ($boards as &$_board) {
|
||||
if (in_array($_board['uri'], $this->excluded))
|
||||
continue;
|
||||
$query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
|
||||
$query = query($query) or error(db_error());
|
||||
$stats['unique_posters'] = number_format($query->fetchColumn());
|
||||
|
||||
// Active content
|
||||
$query = 'SELECT DISTINCT(`files`) FROM (';
|
||||
foreach ($boards as &$_board) {
|
||||
if (in_array($_board['uri'], $this->excluded))
|
||||
continue;
|
||||
$query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query);
|
||||
$query = query($query) or error(db_error());
|
||||
$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/awsumchan/index.html', [
|
||||
'settings' => $settings,
|
||||
'config' => $config,
|
||||
'mod' => false,
|
||||
'boardlist' => createBoardlist(),
|
||||
'news' => $news,
|
||||
'categories' => $categories,
|
||||
'recent_images' => $recent_images,
|
||||
'recent_posts' => $recent_posts,
|
||||
'stats' => $stats
|
||||
]);
|
||||
}
|
||||
|
||||
public function frames($settings)
|
||||
{
|
||||
global $config;
|
||||
|
||||
return Element('themes/awsumchan/frames.html', [
|
||||
'config' => $config,
|
||||
'settings' => $settings
|
||||
]);
|
||||
}
|
||||
|
||||
public function sidebar($settings)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$categories = $config['categories'];
|
||||
|
||||
foreach ($categories as &$_boards) {
|
||||
foreach ($_boards as &$_board) {
|
||||
$title = boardTitle($_board);
|
||||
|
||||
if (!$title)
|
||||
$title = $_board;
|
||||
|
||||
$_board = [
|
||||
'title' => $title,
|
||||
'uri' => sprintf($config['board_path'], $_board)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return Element('themes/awsumchan/sidebar.html', [
|
||||
'settings' => $settings,
|
||||
'config' => $config,
|
||||
'categories' => $categories
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Loading…
x
Reference in New Issue
Block a user