diff --git a/themes/danbooru2/admin.theme.php b/themes/danbooru2/admin.theme.php
new file mode 100644
index 00000000..b08d12c3
--- /dev/null
+++ b/themes/danbooru2/admin.theme.php
@@ -0,0 +1,11 @@
+disable_left();
+ parent::display_page($page);
+ }
+}
+
+?>
diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php
new file mode 100644
index 00000000..f9fcdfca
--- /dev/null
+++ b/themes/danbooru2/comment.theme.php
@@ -0,0 +1,124 @@
+disable_left();
+
+ // parts for the whole page
+ $prev = $page_number - 1;
+ $next = $page_number + 1;
+
+ $h_prev = ($page_number <= 1) ? "Prev" :
+ "Prev ";
+ $h_index = "Index ";
+ $h_next = ($page_number >= $total_pages) ? "Next" :
+ "Next ";
+
+ $nav = "$h_prev | $h_index | $h_next";
+
+ $page->set_title("Comments");
+ $page->set_heading("Comments");
+ $page->add_block(new Block("Navigation", $nav, "left"));
+ $this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
+
+ // parts for each image
+ $position = 10;
+
+ $comment_captcha = $config->get_bool('comment_captcha');
+ $comment_limit = $config->get_int("comment_list_count", 10);
+
+ foreach($images as $pair) {
+ $image = $pair[0];
+ $comments = $pair[1];
+
+ $thumb_html = $this->build_thumb_html($image);
+
+ $s = " ";
+ $un = $image->get_owner()->name;
+ $t = "";
+ foreach($image->get_tag_array() as $tag) {
+ $u_tag = url_escape($tag);
+ $t .= "".html_escape($tag)." ";
+ }
+ $p = autodate($image->posted);
+
+ $r = class_exists("Ratings") ? "Rating ".Ratings::rating_to_human($image->rating) : "";
+ $comment_html = "Date $p $s User $un $s $rTags $t
";
+
+ $comment_count = count($comments);
+ if($comment_limit > 0 && $comment_count > $comment_limit) {
+ $hidden = $comment_count - $comment_limit;
+ $comment_html .= "
showing $comment_limit of $comment_count comments
";
+ $comments = array_slice($comments, -$comment_limit);
+ }
+ foreach($comments as $comment) {
+ $comment_html .= $this->comment_to_html($comment);
+ }
+ if($can_post) {
+ if(!$user->is_anonymous()) {
+ $comment_html .= $this->build_postbox($image->id);
+ }
+ else {
+ if(!$comment_captcha) {
+ $comment_html .= $this->build_postbox($image->id);
+ }
+ else {
+ $comment_html .= "Add Comment ";
+ }
+ }
+ }
+
+ $html = "
+
+ $thumb_html
+ $comment_html
+
+ ";
+
+
+ $page->add_block(new Block(" ", $html, "main", $position++));
+ }
+ }
+
+ public function display_recent_comments($comments) {
+ // no recent comments in this theme
+ }
+
+
+ protected function comment_to_html($comment, $trim=false) {
+ global $user;
+
+ $tfe = new TextFormattingEvent($comment->comment);
+ send_event($tfe);
+
+ $i_uid = int_escape($comment->owner_id);
+ $h_name = html_escape($comment->owner_name);
+ $h_poster_ip = html_escape($comment->poster_ip);
+ $h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
+ $i_comment_id = int_escape($comment->comment_id);
+ $i_image_id = int_escape($comment->image_id);
+ $h_posted = autodate($comment->posted);
+
+ $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50));
+ $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
+ $h_userlink = "$h_name ";
+ $h_del = $user->can("delete_comment") ?
+ ' - Del ' : '';
+ $h_imagelink = $trim ? ">>> \n" : "";
+ if($trim) {
+ return "";
+ }
+ else {
+ return "
+
+ ";
+ }
+ }
+}
+?>
diff --git a/themes/danbooru2/custompage.class.php b/themes/danbooru2/custompage.class.php
new file mode 100644
index 00000000..1e71720b
--- /dev/null
+++ b/themes/danbooru2/custompage.class.php
@@ -0,0 +1,9 @@
+left_enabled = false;
+ }
+}
+?>
diff --git a/themes/danbooru2/ext_manager.theme.php b/themes/danbooru2/ext_manager.theme.php
new file mode 100644
index 00000000..67449dcf
--- /dev/null
+++ b/themes/danbooru2/ext_manager.theme.php
@@ -0,0 +1,14 @@
+disable_left();
+ parent::display_table($page, $extensions, $editable);
+ }
+ public function display_doc(Page $page, ExtensionInfo $info) {
+ $page->disable_left();
+ parent::display_doc($page, $info);
+ }
+}
+
+?>
diff --git a/themes/danbooru2/index.theme.php b/themes/danbooru2/index.theme.php
new file mode 100644
index 00000000..429bd0fe
--- /dev/null
+++ b/themes/danbooru2/index.theme.php
@@ -0,0 +1,60 @@
+search_terms) == 0) {
+ $query = null;
+ $page_title = $config->get_string('title');
+ }
+ else {
+ $search_string = implode(' ', $this->search_terms);
+ $query = url_escape($search_string);
+ $page_title = html_escape($search_string);
+ }
+
+ $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms);
+ $page->set_title($page_title);
+ $page->set_heading($page_title);
+ $page->add_block(new Block("Search", $nav, "left", 0));
+ if(count($images) > 0) {
+ if($query) {
+ $page->add_block(new Block("Images", $this->build_table($images, "search=$query"), "main", 10));
+ $this->display_paginator($page, "post/list/$query", null, $this->page_number, $this->total_pages);
+ }
+ else {
+ $page->add_block(new Block("Images", $this->build_table($images, null), "main", 10));
+ $this->display_paginator($page, "post/list", null, $this->page_number, $this->total_pages);
+ }
+ }
+ else {
+ $page->add_block(new Block("No Images Found", "No images were found to match the search criteria"));
+ }
+ }
+
+
+ protected function build_navigation($page_number, $total_pages, $search_terms) {
+ $h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
+ $h_search_link = make_link();
+ $h_search = "
+
+
";
+
+ return $h_search;
+ }
+
+ protected function build_table($images, $query) {
+ $table = "";
+ foreach($images as $image) {
+ $table .= "\t" . $this->build_thumb_html($image, $query) . " \n";
+ }
+ $table .= "
";
+ return $table;
+ }
+}
+?>
diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php
new file mode 100644
index 00000000..e39c6623
--- /dev/null
+++ b/themes/danbooru2/layout.class.php
@@ -0,0 +1,295 @@
+, updated by Daniel Oaks
+* Link: http://trac.shishnet.org/shimmie2/
+* License: GPLv2
+* Description: This is a simple theme changing the css to make shimme
+* look more like danbooru as well as adding a custom links
+* bar and title to the top of every page.
+*/
+//Small changes added by zshall
+//Changed CSS and layout to make shimmie look even more like danbooru
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+Danbooru 2 Theme - Notes (Bzchan)
+
+Files: default.php, style.css
+
+How to use a theme
+- Copy the danbooru2 folder with all its contained files into the "themes"
+ directory in your shimmie installation.
+- Log into your shimmie and change the Theme in the Board Config to your
+ desired theme.
+
+Changes in this theme include
+- Adding and editing various elements in the style.css file.
+- $site_name and $front_name retreival from config added.
+- $custom_link and $title_link preparation just before html is outputed.
+- Altered outputed html to include the custom links and removed heading
+ from being displayed (subheading is still displayed)
+- Note that only the sidebar has been left aligned. Could not properly
+ left align the main block because blocks without headers currently do
+ not have ids on there div elements. (this was a problem because
+ paginator block must be centered and everything else left aligned)
+
+Tips
+- You can change custom links to point to whatever pages you want as well as adding
+ more custom links.
+- The main title link points to the Front Page set in your Board Config options.
+- The text of the main title is the Title set in your Board Config options.
+- Themes make no changes to your database or main code files so you can switch
+ back and forward to other themes all you like.
+
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+class Layout {
+ public function display_page($page) {
+ global $config, $user;
+
+ $theme_name = $config->get_string('theme');
+ $base_href = $config->get_string('base_href');
+ $data_href = get_base_href();
+ $contact_link = $config->get_string('contact_link');
+
+
+ $header_html = "";
+ ksort($page->html_headers);
+ foreach($page->html_headers as $line) {
+ $header_html .= "\t\t$line\n";
+ }
+
+ $left_block_html = "";
+ $user_block_html = "";
+ $main_block_html = "";
+ $sub_block_html = "";
+
+ foreach($page->blocks as $block) {
+ switch($block->section) {
+ case "left":
+ $left_block_html .= $block->get_html(true);
+ break;
+ case "user":
+ $user_block_html .= $block->body; // $this->block_to_html($block, true);
+ break;
+ case "subheading":
+ $sub_block_html .= $block->body; // $this->block_to_html($block, true);
+ break;
+ case "main":
+ if($block->header == "Images") {
+ $block->header = " ";
+ }
+ $main_block_html .= $block->get_html(false);
+ break;
+ default:
+ print "error: {$block->header} using an unknown section ({$block->section})";
+ break;
+ }
+ }
+
+ $debug = get_debug_info();
+
+ $contact = empty($contact_link) ? "" : "Contact ";
+
+ if(empty($this->subheading)) {
+ $subheading = "";
+ }
+ else {
+ $subheading = "
{$this->subheading}
";
+ }
+
+ $site_name = $config->get_string('title'); // bzchan: change from normal default to get title for top of page
+ $main_page = $config->get_string('main_page'); // bzchan: change from normal default to get main page for top of page
+
+ // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
+ $custom_links = "";
+ if($user->is_anonymous()) {
+ $custom_links .= $this->navlinks(make_link('user_admin/login'), "Sign in", array("user", "user_admin", "setup", "admin"));
+ }
+ else {
+ $custom_links .= $this->navlinks(make_link('user'), "My Account", array("user", "user_admin"));
+ }
+ if($user->is_admin()) {
+ $custom_links .= $this->navlinks(make_link('admin'), "Admin", array("admin", "ext_manager", "setup"));
+ }
+ $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "upload", "", "random_image"));
+ $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
+ $custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags", "alias"));
+ if(class_exists("Pools")) {
+ $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", array("pool"));
+ }
+ if(class_exists("Wiki")) {
+ $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki"));
+ $custom_links .= $this->navlinks(make_link('wiki/more'), "More »", array("wiki/more"));
+ }
+
+ $custom_sublinks = "";
+ // hack
+ global $user;
+ $username = url_escape($user->name);
+ // hack
+ $qp = explode("/", ltrim(@$_GET["q"], "/"));
+ $hw = class_exists("Wiki");
+ // php sucks
+ switch($qp[0]) {
+ default:
+ case "ext_doc":
+ $custom_sublinks .= $user_block_html;
+ break;
+ case "user":
+ case "user_admin":
+ if($user->is_anonymous()) {
+ $custom_sublinks .= "Sign up ";
+ // $custom_sublinks .= "Reset Password ";
+ // $custom_sublinks .= "Login Reminder ";
+ } else {
+ $custom_sublinks .= "Sign out ";
+ }
+ break;
+ case "":
+ # FIXME: this assumes that the front page is
+ # post/list; in 99% of case it will either be
+ # post/list or home, and in the latter case
+ # the subnav links aren't shown, but it would
+ # be nice to be correct
+ case "random_image":
+ case "post":
+ case "upload":
+ if(class_exists("NumericScore")){ $custom_sublinks .= "Popular by Day /Month /Year ";}
+ $custom_sublinks .= "Listing ";
+ if(class_exists("Favorites")){ $custom_sublinks .= "My Favorites ";}
+ if(class_exists("RSS_Images")){ $custom_sublinks .= "Feed ";}
+ if(class_exists("RandomImage")){ $custom_sublinks .= "Random ";}
+ $custom_sublinks .= "Upload ";
+ if($hw){ $custom_sublinks .= "Help ";
+ }else{ $custom_sublinks .= "Help ";}
+ break;
+ case "comment":
+ $custom_sublinks .= "All ";
+ $custom_sublinks .= "Help ";
+ break;
+ case "pool":
+ $custom_sublinks .= "List ";
+ $custom_sublinks .= "Create ";
+ $custom_sublinks .= "Changes ";
+ $custom_sublinks .= "Help ";
+ break;
+ case "wiki":
+ $custom_sublinks .= "Index ";
+ $custom_sublinks .= "Rules ";
+ $custom_sublinks .= "Help ";
+ break;
+ case "tags":
+ case "alias":
+ $custom_sublinks .= "Map ";
+ $custom_sublinks .= "Alphabetic ";
+ $custom_sublinks .= "Popularity ";
+ $custom_sublinks .= "Categories ";
+ $custom_sublinks .= "Aliases ";
+ $custom_sublinks .= "Help ";
+ break;
+ case "admin":
+ case "ext_manager":
+ case "setup":
+ if($user->is_admin()) {
+ $custom_sublinks .= "Extension Manager ";
+ $custom_sublinks .= "Board Config ";
+ $custom_sublinks .= "Alias Editor ";
+ } else {
+ $custom_sublinks .= "I think you might be lost ";
+ }
+ break;
+ }
+
+
+ // bzchan: failed attempt to add heading after title_link (failure was it looked bad)
+ //if($this->heading==$site_name)$this->heading = '';
+ //$title_link = "";
+
+ // bzchan: prepare main title link
+ $title_link = "";
+
+ if($page->left_enabled) {
+ $left = "$left_block_html ";
+ $withleft = "withleft";
+ }
+ else {
+ $left = "";
+ $withleft = "noleft";
+ }
+
+ $flash = get_prefixed_cookie("flash_message");
+ $flash_html = "";
+ if($flash) {
+ $flash_html = "".nl2br(html_escape($flash))." [X] ";
+ set_prefixed_cookie("flash_message", "", -1, "/");
+ }
+
+ print <<
+
+
+
+
+
+ {$page->title}
+$header_html
+
+
+
+
+
+ $subheading
+ $sub_block_html
+ $left
+
+ $flash_html
+ $main_block_html
+
+
+
+
+EOD;
+ }
+
+ private function navlinks($link, $desc, $pages_matched) {
+ /**
+ * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
+ */
+ $html = null;
+ $url = $_GET['q'];
+
+ $re1='.*?';
+ $re2='((?:[a-z][a-z_]+))';
+
+ if ($c=preg_match_all ("/".$re1.$re2."/is", $url, $matches)) {
+ $url=$matches[1][0];
+ }
+
+ for($i=0;$i$desc ";
+ }
+ }
+ if(is_null($html)) {$html = "$desc ";}
+ return $html;
+ }
+}
+?>
diff --git a/themes/danbooru2/style.css b/themes/danbooru2/style.css
new file mode 100644
index 00000000..efa39edf
--- /dev/null
+++ b/themes/danbooru2/style.css
@@ -0,0 +1,348 @@
+.noleft{
+padding-left:2rem;
+}
+HEADER {
+margin-bottom:0.9rem;
+}
+HEADER #site-title {
+padding:0.6rem 2rem 0.25rem;
+}
+HEADER ul#navbar, HEADER ul#subnavbar {
+font-family:Verdana,Helvetica,sans-serif;
+font-size:110%;
+}
+HEADER ul#navbar {
+margin:0;
+padding:0 1rem 0 2rem;
+}
+HEADER ul#navbar li {
+display:inline-block;
+margin:0 0.15rem;
+padding:0.4rem 0.6rem;
+}
+HEADER ul#navbar li:first-child {
+margin-left: -0.6rem;
+}
+HEADER ul#navbar li:first-child a {
+color: #FF3333;
+font-weight: bold;
+}
+HEADER ul#navbar li.current-page {
+background-color:#EEEEFF;
+border-radius:0.2rem 0.2rem 0 0;
+}
+HEADER ul#navbar li.current-page a {
+font-weight:bold;
+}
+HEADER ul#subnavbar {
+margin:0 0 0.5rem;
+padding:0 1rem 0 2rem;
+background-color:#EEEEFF;
+}
+HEADER ul#subnavbar li {
+display:inline-block;
+margin:0 0.15rem;
+padding:0.4rem 0.6rem;
+}
+HEADER ul#subnavbar li:first-child {
+margin-left: -0.6rem;
+}
+body {
+background-color:#FFFFFF;
+font-weight:normal;
+font-style:normal;
+font-variant:normal;
+font-size-adjust:none;
+font-stretch:normal;
+font-size:80%;
+line-height:normal;
+-x-system-font:none;
+}
+h1 {
+margin-top:0;
+margin-bottom:0;
+padding:0.3rem;
+font-size:2.2rem;
+}
+h1 a {
+color:black;
+}
+h3 {
+margin-top:0;
+margin-bottom:0;
+padding:0.2rem 0.2rem 0.2rem 0;
+font-size:1rem;
+}
+h4 {
+font-size:1.4rem;
+}
+h5 {
+font-size:1.2rem;
+}
+table.zebra {border-spacing: 0;border-collapse: collapse;}
+table.zebra > tbody > tr:hover {background: #FFD;}
+table.zebra th { padding-right: 0.4rem;color: #171BB3;}
+table.zebra td {margin: 0;padding-right: 0.6rem;border: 1px dotted #EEE;}
+table.zebra th {margin: 0;text-align: left;}
+thead {
+font-weight:bold;
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+}
+td {
+vertical-align:top;
+}
+#subtitle {
+margin:auto;
+width:256px;
+border-top:medium none;
+text-align:center;
+font-size:0.75em;
+}
+FOOTER {
+clear:both;
+border-top:solid 1px #E7E7F7;
+margin-top:1rem;
+text-align:center;
+color:#555555;
+font-size:0.8rem;
+}
+FOOTER > DIV {
+margin: 1rem 2rem;
+}
+form {
+margin:0;
+}
+a {
+text-decoration:none;
+}
+a:hover {
+text-decoration:underline;
+}
+NAV {
+float:left;
+padding:0 1rem 0.2rem 2rem;
+width:11.5rem;
+text-align:left;
+}
+NAV section + section {
+margin-top:1rem;
+}
+NAV table {
+width:15rem;
+}
+NAV td {
+vertical-align:middle;
+}
+NAV input {
+padding:0;
+width:100%;
+}
+NAV select {
+padding:0;
+width:100%;
+}
+NAV h3 {
+text-align:left;
+}
+#comments p {
+overflow:hidden;
+max-width:150px;
+width:15rem;
+text-align:left;
+}
+.tag_count {
+display:inline-block;
+margin-left:0.4rem;
+color:#AAAAAA;
+}
+.more {
+content:"More â";
+}
+.comment {
+margin-bottom:8px;
+}
+.comment .meta {
+width: 15rem;
+color: gray;
+}
+.comment TD {
+text-align: left;
+}
+.withleft {
+margin-left:14.5rem;
+}
+div#paginator {
+display:block;
+clear:both;
+padding:2em 0 1em;
+text-align:center;
+font-weight:bold;
+font-size:1em;
+}
+.paginator {
+margin:16px;
+text-align:center;
+}
+div#paginator b {
+margin:3px;
+padding:4px 8px;
+}
+div#paginator a {
+margin:3px;
+padding:4px 8px;
+border:1px solid #EEEEEE;
+}
+div#paginator a:hover {
+border:1px solid #EEEEEE;
+background:blue none repeat scroll 0 0;
+color:white;
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+}
+span.thumb {
+display:inline-block;
+float:left;
+width:220px;
+height:220px;
+text-align:center;
+}
+#pagelist {
+margin-top:32px;
+}
+#large_upload_form {
+width:600px;
+}
+.setupblock, .tagcategoryblock {
+margin:0.6rem 1rem 0.6rem 0;
+padding:0.5rem 0.6rem 0.7rem;
+width:18rem;
+border:1px solid #AAAAAA;
+border-radius:0.25rem;
+display:inline-block;
+}
+.tagcategoryblock table {
+width:100%;
+border-spacing:0;
+}
+.tagcategoryblock input, .tagcategoryblock span {
+width:100%;
+height:100%;
+}
+.tagcategoryblock td:first-child {
+padding:0.3rem 0.7rem 0.4rem 0;
+text-align:right;
+width:40%;
+}
+.tagcategoryblock td:last-child {
+width:60%;
+}
+.tagcategoryblock td:last-child span {
+padding:0.24rem 0.7rem 0.5rem 0;
+display:block;
+}
+.tagcategoryblock button {
+width:100%;
+margin-top:0.4rem;
+padding:0.2rem 0.6rem;
+}
+.helpable {
+border-bottom:1px dashed gray;
+}
+.ok {
+background:#AAFFAA none repeat scroll 0 0;
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+}
+.bad {
+background:#FFAAAA none repeat scroll 0 0;
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+}
+.comment .username {
+font-weight:bold;
+font-size:1.5em;
+}
+HEADER {
+text-align:left;
+}
+HEADER h1 {
+text-align:left;
+}
+* {
+margin:0;
+padding:0;
+font-family:Tahoma,Verdana,Helvetica,sans-serif;
+}
+a:link {
+color:#006FFA;
+text-decoration:none;
+}
+a:visited {
+color:#006FFA;
+text-decoration:none;
+}
+a:hover {
+color:#33CFFF;
+text-decoration:none;
+}
+a:active {
+color:#006FFA;
+text-decoration:none;
+}
+ul.flat-list {
+display:block;
+margin:0;
+padding:0;
+}
+ul.flat-list * {
+display:inline;
+text-align:left;
+}
+ul.flat-list li {
+margin:0 1.3em 0 0;
+list-style-type:none;
+text-align:left;
+font-weight:bold;
+}
+ul.flat-list li a {
+font-weight:normal;
+}
+#tips {
+margin-left:16px;
+}
+#blotter1 {
+position: relative;
+margin-right:16px;
+margin-left:16px;
+font-size: 90%;
+}
+#blotter2 {
+margin-right:16px;
+margin-left:16px;
+font-size: 90%;
+}
+#flash {
+background:#FDF5D9;
+border:1px solid #FCEEC1;
+margin:1rem 0;
+padding:1rem;
+text-align:center;
+border-radius:0.5rem;
+}
+ARTICLE {
+margin-right:1rem;
+}
+ARTICLE section + section {
+margin-top:1rem;
+}
+form + form {
+margin-top:0.5rem;
+}
+#Imagemain h3 {
+display:none;
+}
diff --git a/themes/danbooru2/tag_list.theme.php b/themes/danbooru2/tag_list.theme.php
new file mode 100644
index 00000000..3c168380
--- /dev/null
+++ b/themes/danbooru2/tag_list.theme.php
@@ -0,0 +1,9 @@
+disable_left();
+ parent::display_page($page);
+ }
+}
+?>
diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php
new file mode 100644
index 00000000..6ef57ee8
--- /dev/null
+++ b/themes/danbooru2/themelet.class.php
@@ -0,0 +1,73 @@
+id}", $query);
+ $h_thumb_link = $image->get_thumb_link();
+ $h_tip = html_escape($image->get_tooltip());
+ $i_id = int_escape($image->id);
+ $h_tags = strtolower($image->get_tag_list());
+
+ // If file is flash or svg then sets thumbnail to max size.
+ if($image->ext == 'swf' || $image->ext == 'svg') {
+ $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height'));
+ }
+ else{
+ $tsize = get_thumbnail_size($image->width, $image->height);
+ }
+
+ return " ";
+ }
+
+
+ public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
+ if($total_pages == 0) $total_pages = 1;
+ $body = $this->build_paginator($page_number, $total_pages, $base, $query);
+ $page->add_block(new Block(null, $body, "main", 90));
+ }
+
+ private function gen_page_link($base_url, $query, $page, $name) {
+ $link = make_link("$base_url/$page", $query);
+ return "$name ";
+ }
+
+ private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
+ $paginator = "";
+ if($page == $current_page) $paginator .= "$page ";
+ else $paginator .= $this->gen_page_link($base_url, $query, $page, $name);
+ return $paginator;
+ }
+
+ private function build_paginator($current_page, $total_pages, $base_url, $query) {
+ $next = $current_page + 1;
+ $prev = $current_page - 1;
+ $rand = rand(1, $total_pages);
+
+ $at_start = ($current_page <= 3 || $total_pages <= 3);
+ $at_end = ($current_page >= $total_pages -2);
+
+ $first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1");
+ $prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<");
+ $next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>");
+ $last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages");
+
+ $start = $current_page-2 > 1 ? $current_page-2 : 1;
+ $end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages;
+
+ $pages = array();
+ foreach(range($start, $end) as $i) {
+ $pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, $i);
+ }
+ $pages_html = implode(" ", $pages);
+
+ if(strlen($first_html) > 0) $pdots = "...";
+ else $pdots = "";
+
+ if(strlen($last_html) > 0) $ndots = "...";
+ else $ndots = "";
+
+ return "$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html
";
+ }
+}
+?>
diff --git a/themes/danbooru2/upload.theme.php b/themes/danbooru2/upload.theme.php
new file mode 100644
index 00000000..7e5f75bf
--- /dev/null
+++ b/themes/danbooru2/upload.theme.php
@@ -0,0 +1,14 @@
+add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
+ }
+
+ public function display_page(Page $page) {
+ $page->disable_left();
+ parent::display_page($page);
+ }
+}
+?>
diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php
new file mode 100644
index 00000000..ca62caa8
--- /dev/null
+++ b/themes/danbooru2/user.theme.php
@@ -0,0 +1,102 @@
+set_title("Login");
+ $page->set_heading("Login");
+ $page->disable_left();
+ $html = "
+
+ ";
+ if($config->get_bool("login_signup_enabled")) {
+ $html .= "Create Account ";
+ }
+ $page->add_block(new Block("Login", $html, "main", 90));
+ }
+
+ public function display_user_links(Page $page, User $user, $parts) {
+ // no block in this theme
+ }
+ public function display_login_block(Page $page) {
+ // no block in this theme
+ }
+
+ public function display_user_block(Page $page, User $user, $parts) {
+ $h_name = html_escape($user->name);
+ $html = "";
+ $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile");
+ foreach($parts as $part) {
+ if(in_array($part["name"], $blocked)) continue;
+ $html .= "{$part["name"]} ";
+ }
+ $page->add_block(new Block("User Links", $html, "user", 90));
+ }
+
+ public function display_signup_page(Page $page) {
+ global $config;
+ $tac = $config->get_string("login_tac", "");
+
+ $tfe = new TextFormattingEvent($tac);
+ send_event($tfe);
+ $tac = $tfe->formatted;
+
+ $reca = "".captcha_get_html()." ";
+
+ if(empty($tac)) {$html = "";}
+ else {$html = "$tac
";}
+
+ $html .= "
+
+ ";
+
+ $page->set_title("Create Account");
+ $page->set_heading("Create Account");
+ $page->disable_left();
+ $page->add_block(new Block("Signup", $html));
+ }
+
+ public function display_ip_list(Page $page, $uploads, $comments) {
+ $html = "";
+ $html .= "Uploaded from: ";
+ foreach($uploads as $ip => $count) {
+ $html .= " $ip ($count)";
+ }
+ $html .= " Commented from:";
+ foreach($comments as $ip => $count) {
+ $html .= " $ip ($count)";
+ }
+ $html .= " ";
+ $html .= "(Most recent at top)
";
+
+ $page->add_block(new Block("IPs", $html));
+ }
+
+ public function display_user_page(User $duser, $stats) {
+ global $page;
+ $page->disable_left();
+ parent::display_user_page($duser, $stats);
+ }
+}
+?>
diff --git a/themes/danbooru2/view.theme.php b/themes/danbooru2/view.theme.php
new file mode 100644
index 00000000..11956fc9
--- /dev/null
+++ b/themes/danbooru2/view.theme.php
@@ -0,0 +1,67 @@
+set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
+ $page->set_heading(html_escape($image->get_tag_list()));
+ $page->add_block(new Block("Search", $this->build_navigation($image), "left", 0));
+ $page->add_block(new Block("Information", $this->build_information($image), "left", 15));
+ $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 15));
+ }
+
+ private function build_information(Image $image) {
+ $h_owner = html_escape($image->get_owner()->name);
+ $h_ownerlink = "$h_owner ";
+ $h_ip = html_escape($image->owner_ip);
+ $h_date = autodate($image->posted);
+ $h_filesize = to_shorthand_int($image->filesize);
+
+ global $user;
+ if($user->can("view_ip")) {
+ $h_ownerlink .= " ($h_ip)";
+ }
+
+ $html = "
+ ID: {$image->id}
+ Uploader: $h_ownerlink
+ Date: $h_date
+ Size: $h_filesize ({$image->width}x{$image->height})
+ ";
+
+ if(!is_null($image->source)) {
+ $h_source = html_escape($image->source);
+ if(substr($image->source, 0, 7) != "http://") {
+ $h_source = "http://" . $h_source;
+ }
+ $html .= " Source: link ";
+ }
+
+ if(class_exists("Ratings")) {
+ if($image->rating == null || $image->rating == "u"){
+ $image->rating = "u";
+ }
+ if(class_exists("Ratings")) {
+ $h_rating = Ratings::rating_to_human($image->rating);
+ $html .= " Rating: $h_rating";
+ }
+ }
+
+ return $html;
+ }
+
+ protected function build_navigation(Image $image) {
+ //$h_pin = $this->build_pin($image);
+ $h_search = "
+
+ ";
+
+ return "$h_search";
+ }
+}
+?>