On second thought, let's not. I think we can get the 'new' theme working better.

This commit is contained in:
Daniel Saunders 2017-10-29 01:06:23 -04:00
parent 9af6a136e7
commit 5ba68d8793
6 changed files with 2 additions and 570 deletions

View File

@ -46,8 +46,8 @@
$categories = $config['categories'];
foreach ($categories as &$boards) {
foreach ($boards as &$_board) {
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

View File

@ -1,103 +0,0 @@
{% filter remove_whitespace %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ settings.title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %}
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}" />
<link rel="stylesheet" media="screen" href="{{ config.root }}{{ settings.css }}" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
var onready_callbacks = [];
function onready(fnc) {
onready_callbacks.push(fnc);
}
function ready() {
for (var i = 0; i < onready_callbacks.length; i++) {
onready_callbacks[i]();
}
}
</script>
<script type="text/javascript" src="/js/post-hover.js"></script>
<script type="text/javascript" src="/js/sidebar.js"></script>
</head>
<body>
<header>
<h1><img class="banner logo" src="/static/logo.png" alt="{{ settings.title }}" /></h1>
<div class="subtitle">{% if settings.subtitle %}{{ settings.subtitle }}{% endif %}</div>
</header>
<div class="ban boards">
<h2>Boards</h2>
<p>
{% for category, boards in categories %}
<div class="category">
<h3>{{ category }}{% if loop.last %} <span class="unimportant" style="color:red;">(+18)</span>{% endif %}</h3>
{% for board in boards %}
<a href="{{ board.uri }}">{{ board.title|e }}</a>
{% endfor %}
</div>
{% endfor %}
</p>
<br class="clear" />
</div>
<div class="box-wrap">
<div class="box left">
<h2>Recent Images</h2>
<ul>
{% for post in recent_images %}
<li>
<a class="preview" href="{{ post.link }}">
<img src="{{ post.src }}" style="width:{{ post.thumbwidth }}px;height:{{ post.thumbheight }}px" alt="">
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="box right">
<h2>Latest Posts</h2>
<ul>
{% for post in recent_posts %}
<li>
<strong>{{ post.board_name }}</strong>:
<a class="preview" href="{{ post.link }}">
{{ post.snippet }}
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="box right">
<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>
<nav>
<div class="navigation">
<a href="{{ config.root }}{{ settings.file_main }}" class="selected">Home</a>
<a href="{{ config.root }}{{ settings.file_news }}">News</a>
<a href="http://qchat.rizon.net?channels=awsumchan">IRC</a>
</div>
</nav>
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2012 Tinyboard Development Group</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
<script type="text/javascript">{% raw %}
ready();
{% endraw %}</script>
</body>
</html>
{% endfilter %}

View File

@ -1,86 +0,0 @@
<?php
$theme = array();
$theme['name'] = 'Sharp';
$theme['description'] = 'A special theme for AwsumChan';
$theme['version'] = 'v0.1';
$theme['config'] = array();
$theme['config'][] = array(
'title' => 'Title',
'name' => 'title',
'type' => 'text',
'default' => 'AwsumChan'
);
$theme['config'][] = Array(
'title' => 'Slogan',
'name' => 'subtitle',
'type' => 'text',
'comment' => '(optional)'
);
$theme['config'][] = array(
'title' => 'Excluded boards',
'name' => 'exclude',
'type' => 'text',
'comment' => '(space seperated)'
);
$theme['config'][] = array(
'title' => '# of recent images',
'name' => 'limit_images',
'type' => 'text',
'default' => '3',
'comment' => '(maximum images to display)'
);
$theme['config'][] = array(
'title' => '# of recent posts',
'name' => 'limit_posts',
'type' => 'text',
'default' => '30',
'comment' => '(maximum posts to display)'
);
$theme['config'][] = array(
'title' => 'Main HTML file',
'name' => 'file_main',
'type' => 'text',
'default' => $config['file_index'],
'comment' => '(eg. "index.html")'
);
$theme['config'][] = array(
'title' => 'News file',
'name' => 'file_news',
'type' => 'text',
'default' => 'news.html',
'comment' => '(eg. "news.html")'
);
$theme['config'][] = array(
'title' => 'CSS file',
'name' => 'css',
'type' => 'text',
'default' => 'site.css',
'comment' => '(eg. "site.css")'
);
$theme['build_function'] = 'sharp_build';
$theme['install_callback'] = 'sharp_install';
if (!function_exists('sharp_install')) {
function sharp_install($settings) {
global $config;
if (!isset($config['categories'])) {
return array(false, '<h2>Prerequisites not met!</h2>' .
'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.');
}
if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0)
return array(false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.');
if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0)
return array(false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.');
}
}

View File

@ -1,71 +0,0 @@
{% filter remove_whitespace %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ settings.title }} - News</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %}
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}" />
<link rel="stylesheet" media="screen" href="{{ config.root }}{{ settings.css }}" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
var onready_callbacks = [];
function onready(fnc) {
onready_callbacks.push(fnc);
}
function ready() {
for (var i = 0; i < onready_callbacks.length; i++) {
onready_callbacks[i]();
}
}
</script>
<script type="text/javascript" src="/js/sidebar.js"></script>
</head>
<body>
<header>
<h1><img class="banner logo" src="/static/logo.png" alt="{{ settings.title }}"/></h1>
<div class="subtitle">{% if settings.subtitle %}{{ settings.subtitle }}{% endif %}</div>
</header>
{% if news|count == 0 %}
<div class="ban">
<p style="text-align:center" class="unimportant">(No news to show.)</p>
</div>
{% else %}
{% for entry in news %}
<div class="ban">
<h2 id="{{ entry.id }}">
<small class="unimportant">
<a href="#{{ entry.id }}">#</a>
</small>
{% if entry.subject %}
{{ entry.subject }}
{% else %}
<em>no subject</em>
{% endif %}
<span class="unimportant"> &mdash; by {{ entry.name }} at {{ entry.time|date(config.post_date) }}</span>
</h2>
<p>{{ entry.body }}</p>
</div>
{% endfor %}
{% endif %}
<nav>
<div class="navigation">
<a href="{{ config.root }}{{ settings.file_main }}">Home</a>
<a href="{{ config.root }}{{ settings.file_news }}" class="selected">News</a>
<a href="http://qchat.rizon.net?channels=awsumchan">IRC</a>
</div>
</nav>
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2012 Tinyboard Development Group</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
</body>
</html>
{% endfilter %}

View File

@ -1,163 +0,0 @@
.box-wrap {
max-width: 700px;
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: #efe;
color: #060;
border: 1px solid #060;
float: left;
-webkit-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
}
.box.right {
background: #eef;
color: #006;
border: 1px solid #006;
float: right;
-webkit-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
}
.box h2 {
padding: 3px 7px;
font-size: 12pt;
}
.box.left h2 {
background: #9C6;
color: #060;
}
.box.right h2 {
background: #59A;
color: white;
}
.box img {
float: none;
margin: 10px auto;
}
header h1 {
background: url('/static/logo_bg.gif') left center no-repeat;
height: 125px;
margin-bottom: -40px;
margin-left: auto;
margin-right: auto;
padding-bottom: 18px;
padding-left: 16px;
padding-top: 34px;
text-align: text-bottom;
width: 478px;
}
img.banner.logo {
border-width: 0;
}
div.ban {
-webkit-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
}
div.ban.boards {
border: 1px solid #CCC;
}
div.ban.boards h2 {
background-color: #DDD;
color: #36362E;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.7);
}
div.ban.boards p {
overflow: hidden;
padding: 0 5px;
display: inline-block;
}
div.category {
width: 190px;
margin-bottom: 20px;
margin-top: 15px;
margin-left: 20px;
margin-right: 20px;
float: left;
}
div.category a {
display: block;
color: #28759c;
text-decoration: none;
}
div.category a:link:hover, div.category a:link:active {
font-weight: bold;
}
div.category h3 {
margin: 5px;
font-size: 16px;
color: #36362E;
text-shadow: 1px 1px 0 rgba(255, 255, 255, 1);
}
div.navigation {
width: 660px;
margin: 30px auto 0 auto;
border-top: 1px solid #ccc;
overflow: hidden;
padding: 0 20px 3px 20px;
}
div.navigation a {
border: 1px solid #ccc;
border-top: 0;
border-left: 0;
padding: 5px 10px;
display: block;
float: left;
color: #28759c;
text-decoration: none;
background: #F6F6F6;
}
div.navigation a:first-child {
border-left: 1px solid #ccc;
}
div.navigation a.selected {
margin: -1px 0 0 0;
padding: 6px 15px;
background: rgba(255,255,255, 0.6);
border-bottom: 1px solid #ccc;
-webkit-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.1);
}
div[id*="post-hover-"] {
color: #000;
}
div[id*="post-hover-"] img {
float: left;
margin: 5px;
}

View File

@ -1,145 +0,0 @@
<?php
require 'info.php';
function sharp_build($action, $settings) {
$b = new Sharp();
$b->build($action, $settings);
}
class Sharp {
private $excluded;
public function build($action, $settings) {
global $config;
if ($action == 'all') copy('templates/themes/sharp/site.css', $config['dir']['home'] . $settings['css']);
$this->excluded = explode(' ', $settings['exclude']);
if ($action == 'all' || $action == 'boards' || $action == 'post') file_write($config['dir']['home'] . $settings['file_main'], $this->homepage($settings));
if ($action == 'all' || $action == 'news') file_write($config['dir']['home'] . $settings['file_news'], Sharp::news($settings));
}
public function homepage($settings) {
global $config, $board;
$categories = $config['categories'];
$query = '';
$recent_images = array();
$recent_posts = array();
$stats = array();
foreach ($categories as &$_boards) {
foreach ($_boards as &$_board) {
$title = boardTitle($_board);
if (!$title) $title = $_board;
$_board = array('title' => $title, 'uri' => sprintf($config['board_path'], $_board));
}
}
$boards = listBoards();
foreach ($boards as &$_board) {
if (in_array($_board['uri'], $this->excluded)) continue;
$query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']);
}
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query);
$query = query($query) or error(db_error());
while ($post = $query->fetch()) {
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['src'] = $config['uri_thumb'] . $post['thumb'];
$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` WHERE `body` <> '' 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()) {
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['snippet'] = pm_snippet($post['body'], 30);
$post['board_name'] = $board['name'];
$recent_posts[] = $post;
}
$query = 'SELECT SUM(`top`) AS `count` 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());
$res = $query->fetch();
$stats['total_posts'] = number_format($res['count']);
$query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` 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());
$res = $query->fetch();
$stats['unique_posters'] = number_format($res['count']);
$query = 'SELECT SUM(`filesize`) AS `count` 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 = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
$query = query($query) or error(db_error());
$res = $query->fetch();
$stats['active_content'] = $res['count'];
return Element('themes/sharp/index.html', array(
'settings' => $settings,
'config' => $config,
'categories' => $categories,
'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
'stats' => $stats
));
}
public static function news($settings) {
global $config;
$query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error());
$news = $query->fetchAll(PDO::FETCH_ASSOC);
return Element('themes/sharp/news.html', array(
'settings' => $settings,
'config' => $config,
'news' => $news
));
}
}
?>