From cdfd67c87a6177101f920acbdd33b94d00a13fda Mon Sep 17 00:00:00 2001 From: Michael Save Date: Tue, 14 Feb 2012 21:02:06 +1100 Subject: [PATCH] frameset theme: transition to twig, plus more configurable --- templates/themes/frameset/frames.html | 16 +++++ templates/themes/frameset/info.php | 35 +++++++-- templates/themes/frameset/news.html | 33 +++++++++ templates/themes/frameset/sidebar.html | 40 +++++++++++ templates/themes/frameset/theme.php | 98 ++++---------------------- 5 files changed, 134 insertions(+), 88 deletions(-) create mode 100644 templates/themes/frameset/frames.html create mode 100644 templates/themes/frameset/news.html create mode 100644 templates/themes/frameset/sidebar.html diff --git a/templates/themes/frameset/frames.html b/templates/themes/frameset/frames.html new file mode 100644 index 00000000..d1d23aaa --- /dev/null +++ b/templates/themes/frameset/frames.html @@ -0,0 +1,16 @@ + + + + + + {{ settings.title }} + + + + + + diff --git a/templates/themes/frameset/info.php b/templates/themes/frameset/info.php index ad42fc91..8cff78a9 100644 --- a/templates/themes/frameset/info.php +++ b/templates/themes/frameset/info.php @@ -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,9 +22,34 @@ 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 $theme['build_function'] = 'frameset_build'; -?> \ No newline at end of file +?> diff --git a/templates/themes/frameset/news.html b/templates/themes/frameset/news.html new file mode 100644 index 00000000..538eb945 --- /dev/null +++ b/templates/themes/frameset/news.html @@ -0,0 +1,33 @@ +{% filter remove_whitespace %} + + + + {{ settings.title }} + + + +

{{ settings.title }}

+
{{ settings.subtitle }}
+ +
+ {% if news|count == 0 %} +

(No news to show.)

+ {% else %} + {% for entry in news %} +

+ {% if entry.subject %} + {{ entry.subject }} + {% else %} + no subject + {% endif %} + — by {{ entry.name }} at {{ entry.time|date(config.post_date) }} +

+

{{ entry.body }}

+ {% endfor %} + {% endif %} +
+ +

Powered by Tinyboard {{ config.version }} | Tinyboard Copyright © 2010-2012 Tinyboard Development Group

+ + +{% endfilter %} diff --git a/templates/themes/frameset/sidebar.html b/templates/themes/frameset/sidebar.html new file mode 100644 index 00000000..171e4e93 --- /dev/null +++ b/templates/themes/frameset/sidebar.html @@ -0,0 +1,40 @@ +{% filter remove_whitespace %} + + + + {{ settings.title }} + + + + + +
+ {{ settings.title }} + +
+ +
+ Boards + +
+ + +{% endfilter %} diff --git a/templates/themes/frameset/theme.php b/templates/themes/frameset/theme.php index 7eac4b99..08db7d1d 100644 --- a/templates/themes/frameset/theme.php +++ b/templates/themes/frameset/theme.php @@ -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 '' - . '' - . '' - . '' - . '' . $settings['title'] . '' - . '' - // Sidebar - . '' - // Main - . '' - // Finish page - . ''; + return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings)); } // Build news page public static function news($settings) { global $config; - // HTML5 - $body = '' - . '' - . '' - . 'News' - . ''; - - $body .= '

' . $settings['title'] . '

' - . '
' . ($settings['subtitle'] ? utf8tohtml($settings['subtitle']) : '') . '
'; - $query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error()); - if($query->rowCount() == 0) { - $body .= '

(No news to show.)

'; - } else { - // List news - while($news = $query->fetch()) { - $body .= '
' . - '

' . - ($news['subject'] ? - $news['subject'] - : - 'no subject' - ) . - ' — by ' . - $news['name'] . - ' at ' . - strftime($config['post_date'], $news['time']) . - '

' . $news['body'] . '

'; - } - } + $news = $query->fetchAll(PDO::FETCH_ASSOC); - // Finish page - $body .= ''; + 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 = '' - . '' - . '' - . '' - . '' - . '' . $settings['title'] . '' - . ''; - - $body .= '
' . $settings['title'] . '
'; - - - $body .= '
Boards
'; - - // Finish page - $body .= ''; + return Element('themes/frameset/sidebar.html', Array( + 'settings' => $settings, + 'config' => $config, + 'boards' => listBoards() + )); return $body; }