categories theme v0.3
This commit is contained in:
parent
de2238d55c
commit
5ea4de048a
|
@ -0,0 +1,16 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}">
|
||||||
|
<style type="text/css">
|
||||||
|
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_news }}" id="main" name="main"></iframe>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -7,14 +7,14 @@
|
||||||
$theme['description'] =
|
$theme['description'] =
|
||||||
'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame.
|
'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame.
|
||||||
|
|
||||||
Requires $config[\'boards\'] and $config[\'categories\'].';
|
Requires $config[\'categories\'].';
|
||||||
$theme['version'] = 'v0.2.1';
|
$theme['version'] = 'v0.2.2';
|
||||||
|
|
||||||
// Theme configuration
|
// Theme configuration
|
||||||
$theme['config'] = Array();
|
$theme['config'] = Array();
|
||||||
|
|
||||||
$theme['config'][] = Array(
|
$theme['config'][] = Array(
|
||||||
'title' => 'Title',
|
'title' => 'Site title',
|
||||||
'name' => 'title',
|
'name' => 'title',
|
||||||
'type' => 'text'
|
'type' => 'text'
|
||||||
);
|
);
|
||||||
|
@ -22,18 +22,43 @@ Requires $config[\'boards\'] and $config[\'categories\'].';
|
||||||
$theme['config'][] = Array(
|
$theme['config'][] = Array(
|
||||||
'title' => 'Slogan',
|
'title' => 'Slogan',
|
||||||
'name' => 'subtitle',
|
'name' => 'subtitle',
|
||||||
'type' => 'text'
|
'type' => 'text',
|
||||||
|
'comment' => '(optional)'
|
||||||
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Main HTML file',
|
||||||
|
'name' => 'file_main',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => $config['file_index'],
|
||||||
|
'comment' => '(eg. "index.html")'
|
||||||
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Sidebar file',
|
||||||
|
'name' => 'file_sidebar',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => 'sidebar.html',
|
||||||
|
'comment' => '(eg. "sidebar.html")'
|
||||||
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'News file',
|
||||||
|
'name' => 'file_news',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => 'news.html',
|
||||||
|
'comment' => '(eg. "news.html")'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Unique function name for building everything
|
// Unique function name for building everything
|
||||||
$theme['build_function'] = 'categories_build';
|
$theme['build_function'] = 'categories_build';
|
||||||
|
|
||||||
$theme['install_callback'] = 'categories_install';
|
$theme['install_callback'] = 'categories_install';
|
||||||
|
|
||||||
if(!function_exists('categories_install')) {
|
if(!function_exists('categories_install')) {
|
||||||
function categories_install($settings) {
|
function categories_install($settings) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if(!isset($config['boards']) || !isset($config['categories'])) {
|
if(!isset($config['categories'])) {
|
||||||
return Array(false, '<h2>Prerequisites not met!</h2>' .
|
return Array(false, '<h2>Prerequisites not met!</h2>' .
|
||||||
'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.');
|
'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
{% filter remove_whitespace %}
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ settings.title }}</title>
|
||||||
|
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{ settings.title }}</h1>
|
||||||
|
<div class="title">{{ settings.subtitle }}</div>
|
||||||
|
|
||||||
|
<div class="ban">
|
||||||
|
{% if news|count == 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) }}</span>
|
||||||
|
</h2>
|
||||||
|
<p>{{ entry.body }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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 © 2010-2012 Tinyboard Development Group</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{% endfilter %}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{% filter remove_whitespace %}
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ settings.title }}</title>
|
||||||
|
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"/>
|
||||||
|
<style type="text/css">
|
||||||
|
fieldset{margin:10px 0}
|
||||||
|
legend{width:100%;margin-left:-15px;background:#98E;border:1px solid white;color:white;font-weight:bold;padding:5px 5px}
|
||||||
|
ul{margin:0;padding:0}
|
||||||
|
li{list-style:none;padding:0 4px;margin: 0 4px}
|
||||||
|
li a.system{font-weight:bold}
|
||||||
|
</style>
|
||||||
|
<base target="main"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ settings.title }}</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a class="system" href="{{ settings.file_news }}">[News]</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Boards</legend>
|
||||||
|
<ul>
|
||||||
|
{% for board in boards %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ config.board_path|sprintf(board.uri) }}">
|
||||||
|
{{ board.title }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{% endfilter %}
|
|
@ -16,142 +16,56 @@
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if($action == 'all')
|
if($action == 'all')
|
||||||
file_write($config['dir']['home'] . $config['file_index'], Categories::homepage($settings));
|
file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings));
|
||||||
|
|
||||||
if($action == 'all' || $action == 'boards')
|
if($action == 'all' || $action == 'boards')
|
||||||
file_write($config['dir']['home'] . 'sidebar.html', Categories::sidebar($settings));
|
file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings));
|
||||||
|
|
||||||
if($action == 'all' || $action == 'news')
|
if($action == 'all' || $action == 'news')
|
||||||
file_write($config['dir']['home'] . 'news.html', Categories::news($settings));
|
file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build homepage
|
// Build homepage
|
||||||
public static function homepage($settings) {
|
public static function homepage($settings) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// HTML5
|
return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings));
|
||||||
return '<!DOCTYPE html><html>'
|
|
||||||
. '<head>'
|
|
||||||
. '<link rel="stylesheet" media="screen" href="' . $config['url_stylesheet'] . '"/>'
|
|
||||||
. '<style type="text/css">'
|
|
||||||
. '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>'
|
|
||||||
. '<script type="text/javascript">'
|
|
||||||
. 'function removeFrames() {'
|
|
||||||
. 'window.location = document.getElementById("main").contentWindow.location.href'
|
|
||||||
. '}'
|
|
||||||
. '</script>'
|
|
||||||
. '</head><body>'
|
|
||||||
// Sidebar
|
|
||||||
. '<iframe src="sidebar.html" id="sidebar" name="sidebar"></iframe>'
|
|
||||||
// Main
|
|
||||||
. '<iframe src="news.html" id="main" name="main"></iframe>'
|
|
||||||
// Finish page
|
|
||||||
. '</body></html>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build news page
|
// Build news page
|
||||||
public static function news($settings) {
|
public static function news($settings) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// HTML5
|
|
||||||
$body = '<!DOCTYPE html><html>'
|
|
||||||
. '<head>'
|
|
||||||
. '<link rel="stylesheet" media="screen" href="' . $config['url_stylesheet'] . '"/>'
|
|
||||||
. '<title>News</title>'
|
|
||||||
. '</head><body>';
|
|
||||||
|
|
||||||
$boardlist = createBoardlist();
|
|
||||||
|
|
||||||
$body .= $boardlist['top']
|
|
||||||
|
|
||||||
. '<h1>' . $settings['title'] . '</h1>'
|
|
||||||
. '<div class="title">' . ($settings['subtitle'] ? utf8tohtml($settings['subtitle']) : '') . '</div>';
|
|
||||||
|
|
||||||
$query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error());
|
$query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error());
|
||||||
if($query->rowCount() == 0) {
|
$news = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$body .= '<p style="text-align:center" class="unimportant">(No news to show.)</p>';
|
|
||||||
} else {
|
|
||||||
// List news
|
|
||||||
while($news = $query->fetch()) {
|
|
||||||
$body .= '<div class="ban">' .
|
|
||||||
'<h2 id="' . $news['id'] . '">' .
|
|
||||||
($news['subject'] ?
|
|
||||||
$news['subject']
|
|
||||||
:
|
|
||||||
'<em>no subject</em>'
|
|
||||||
) .
|
|
||||||
'<span class="unimportant"> — by ' .
|
|
||||||
$news['name'] .
|
|
||||||
' at ' .
|
|
||||||
strftime($config['post_date'], $news['time']) .
|
|
||||||
'</span></h2><p>' . $news['body'] . '</p></div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish page
|
return Element('themes/frameset/news.html', Array(
|
||||||
$body .= '</body></html>';
|
'settings' => $settings,
|
||||||
|
'config' => $config,
|
||||||
return $body;
|
'news' => $news
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build sidebar
|
// Build sidebar
|
||||||
public static function sidebar($settings) {
|
public static function sidebar($settings) {
|
||||||
global $config, $board;
|
global $config, $board;
|
||||||
|
|
||||||
$body = '<!DOCTYPE html><html>'
|
$categories = $config['categories'];
|
||||||
. '<head>'
|
|
||||||
. '<link rel="stylesheet" media="screen" href="' . $config['url_stylesheet'] . '"/>'
|
|
||||||
. '<style type="text/css">'
|
|
||||||
. 'fieldset{margin:10px 0}'
|
|
||||||
. 'legend{width:100%;margin-left:-15px;background:#98E;border:1px solid white;color:white;font-weight:bold;padding:5px 5px}'
|
|
||||||
. 'ul{margin:0;padding:0}'
|
|
||||||
. 'li{list-style:none;padding:0 4px;margin: 0 4px}'
|
|
||||||
. 'li a.system{font-weight:bold}'
|
|
||||||
. '</style>'
|
|
||||||
. '<base target="main" />'
|
|
||||||
. '<title>' . $settings['title'] . '</title>'
|
|
||||||
. '</head><body>';
|
|
||||||
|
|
||||||
$body .= '<fieldset><legend>' . $settings['title'] . '</legend><ul>' .
|
foreach($categories as &$boards) {
|
||||||
'<li><a class="system" href="news.html">[News]</a></li>' .
|
foreach($boards as &$board) {
|
||||||
'<li><a class="system" href="javascript:parent.removeFrames()">[Remove Frames]</a></li>' .
|
$title = boardTitle($board);
|
||||||
'</ul></fieldset>';
|
if(!$title)
|
||||||
|
$title = $board; // board doesn't exist, but for some reason you want to display it anyway
|
||||||
if(isset($config['categories'])) {
|
$board = Array('title' => $title, 'uri' => sprintf($config['board_path'], $board));
|
||||||
for($cat = 0; $cat < count($config['categories']); $cat++) {
|
|
||||||
$body .= '<fieldset><legend>' . $config['categories'][$cat] . '</legend><ul>';
|
|
||||||
|
|
||||||
foreach($config['boards'][$cat] as &$board) {
|
|
||||||
$body .= '<li><a href="' .
|
|
||||||
sprintf($config['board_path'], $board) .
|
|
||||||
'">' . boardTitle($board) . '</a></li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$body .= '</ul></fieldset>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($config['custom_categories'])) {
|
return Element('themes/frameset/sidebar.html', Array(
|
||||||
foreach($config['custom_categories'] as $name => &$group) {
|
'settings' => $settings,
|
||||||
$body .= '<fieldset><legend>' . $name . '</legend><ul>';
|
'config' => $config,
|
||||||
|
'categories' => $categories
|
||||||
foreach($group as $title => &$url) {
|
));
|
||||||
$body .= '<li><a href="' . $url .
|
|
||||||
'">' . $title . '</a></li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$body .= '</ul></fieldset>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish page
|
|
||||||
$body .= '</body></html>';
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue