frameset theme: transition to twig, plus more configurable

This commit is contained in:
Michael Save 2012-02-14 21:02:06 +11:00
parent bac326a365
commit cdfd67c87a
5 changed files with 134 additions and 88 deletions

View File

@ -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>

View File

@ -2,19 +2,19 @@
$theme = Array();
// Theme name
$theme['name'] = 'Frameset (alpha)';
$theme['name'] = 'Frameset';
// Description (you can use Tinyboard markup here)
$theme['description'] =
'Use a basic frameset layout, with a list of boards and pages on a sidebar to the left of the page.
Users never have to leave the homepage; they can do all their browsing from the one page.';
$theme['version'] = 'v0.0.1';
$theme['version'] = 'v0.1';
// Theme configuration
$theme['config'] = Array();
$theme['config'][] = Array(
'title' => 'Title',
'title' => 'Site title',
'name' => 'title',
'type' => 'text'
);
@ -22,7 +22,32 @@ Users never have to leave the homepage; they can do all their browsing from the
$theme['config'][] = Array(
'title' => 'Slogan',
'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

View File

@ -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"> &mdash; 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 &copy; 2010-2012 Tinyboard Development Group</p>
</body>
</html>
{% endfilter %}

View File

@ -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 %}

View File

@ -16,13 +16,13 @@
global $config;
if($action == 'all')
file_write($config['dir']['home'] . $config['file_index'], Frameset::homepage($settings));
file_write($config['dir']['home'] . $settings['file_main'], Frameset::homepage($settings));
if($action == 'all' || $action == 'boards')
file_write($config['dir']['home'] . 'sidebar.html', Frameset::sidebar($settings));
file_write($config['dir']['home'] . $settings['file_sidebar'], Frameset::sidebar($settings));
if($action == 'all' || $action == 'news')
file_write($config['dir']['home'] . 'news.html', Frameset::news($settings));
file_write($config['dir']['home'] . $settings['file_news'], Frameset::news($settings));
}
// Build homepage
@ -30,61 +30,21 @@
global $config;
// HTML5
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>'
. '</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>';
return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings));
}
// Build news page
public static function news($settings) {
global $config;
// HTML5
$body = '<!DOCTYPE html><html>'
. '<head>'
. '<link rel="stylesheet" media="screen" href="' . $config['url_stylesheet'] . '"/>'
. '<title>News</title>'
. '</head><body>';
$body .= '<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());
if($query->rowCount() == 0) {
$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"> &mdash; by ' .
$news['name'] .
' at ' .
strftime($config['post_date'], $news['time']) .
'</span></h2><p>' . $news['body'] . '</p></div>';
}
}
$news = $query->fetchAll(PDO::FETCH_ASSOC);
// Finish page
$body .= '</body></html>';
return Element('themes/frameset/news.html', Array(
'settings' => $settings,
'config' => $config,
'news' => $news
));
return $body;
}
@ -93,39 +53,11 @@
public static function sidebar($settings) {
global $config, $board;
$body = '<!DOCTYPE html><html>'
. '<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>' .
'<li><a class="system" href="news.html">[News]</a></li>' .
'</ul></fieldset>';
$body .= '<fieldset><legend>Boards</legend><ul>';
$boards = listBoards();
foreach($boards as &$_board) {
openBoard($_board['uri']);
$body .= '<li><a href="' .
sprintf($config['board_path'], $board['uri']) .
'">' . $board['name'] . '</a></li>';
}
$body .= '</ul></fieldset>';
// Finish page
$body .= '</body></html>';
return Element('themes/frameset/sidebar.html', Array(
'settings' => $settings,
'config' => $config,
'boards' => listBoards()
));
return $body;
}