Danbooru2 theme

This commit is contained in:
Daniel Oaks 2013-06-19 20:09:22 +01:00 committed by Shish
parent c64a43eb2b
commit 06dd72fe66
12 changed files with 1126 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<?php
class CustomAdminPageTheme extends AdminPageTheme {
public function display_page() {
global $page;
$page->disable_left();
parent::display_page($page);
}
}
?>

View file

@ -0,0 +1,124 @@
<?php
class CustomCommentListTheme extends CommentListTheme {
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
global $config, $page, $user;
$page->disable_left();
// parts for the whole page
$prev = $page_number - 1;
$next = $page_number + 1;
$h_prev = ($page_number <= 1) ? "Prev" :
"<a href='".make_link("comment/list/$prev")."'>Prev</a>";
$h_index = "<a href='".make_link()."'>Index</a>";
$h_next = ($page_number >= $total_pages) ? "Next" :
"<a href='".make_link("comment/list/$next")."'>Next</a>";
$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 = "&nbsp;&nbsp;&nbsp;";
$un = $image->get_owner()->name;
$t = "";
foreach($image->get_tag_array() as $tag) {
$u_tag = url_escape($tag);
$t .= "<a href='".make_link("post/list/$u_tag/1")."'>".html_escape($tag)."</a> ";
}
$p = autodate($image->posted);
$r = class_exists("Ratings") ? "<b>Rating</b> ".Ratings::rating_to_human($image->rating) : "";
$comment_html = "<b>Date</b> $p $s <b>User</b> $un $s $r<br><b>Tags</b> $t<p>&nbsp;";
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
$hidden = $comment_count - $comment_limit;
$comment_html .= "<p>showing $comment_limit of $comment_count comments</p>";
$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 .= "<a href='".make_link("post/view/".$image->id)."'>Add Comment</a>";
}
}
}
$html = "
<table><tr>
<td style='width: 220px;'>$thumb_html</td>
<td style='text-align: left;'>$comment_html</td>
</tr></table>
";
$page->add_block(new Block("&nbsp;", $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 = "<a class='username' href='".make_link("user/$h_name")."'>$h_name</a>";
$h_del = $user->can("delete_comment") ?
' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '.
'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : '';
$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>&gt;&gt;&gt;</a>\n" : "";
if($trim) {
return "<p class='comment'>$h_userlink $h_del<br/>$h_posted<br/>$h_comment</p>";
}
else {
return "
<table class='comment'><tr>
<td class='meta'>$h_userlink<br/>$h_posted$h_del</td>
<td>$h_comment</td>
</tr></table>
";
}
}
}
?>

View file

@ -0,0 +1,9 @@
<?php
class CustomPage extends Page {
var $left_enabled = true;
public function disable_left() {
$this->left_enabled = false;
}
}
?>

View file

@ -0,0 +1,14 @@
<?php
class CustomExtManagerTheme extends ExtManagerTheme {
public function display_table(Page $page, /*array*/ $extensions, /*bool*/ $editable) {
$page->disable_left();
parent::display_table($page, $extensions, $editable);
}
public function display_doc(Page $page, ExtensionInfo $info) {
$page->disable_left();
parent::display_doc($page, $info);
}
}
?>

View file

@ -0,0 +1,60 @@
<?php
class CustomIndexTheme extends IndexTheme {
public function display_page(Page $page, $images) {
global $config;
if(count($this->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 = "
<p><form action='$h_search_link' method='GET'>
<input name='search' type='text' value='$h_search_string' class='autocomplete_tags' placeholder='' style='width:75%'/>
<input type='submit' value='Go' style='width:20%'>
<input type='hidden' name='q' value='/post/list'>
</form>
<div id='search_completions'></div>";
return $h_search;
}
protected function build_table($images, $query) {
$table = "<div class='shm-image-list'>";
foreach($images as $image) {
$table .= "\t<span class=\"thumb\">" . $this->build_thumb_html($image, $query) . "</span>\n";
}
$table .= "</div>";
return $table;
}
}
?>

View file

@ -0,0 +1,295 @@
<?php
/**
* Name: Danbooru 2 Theme
* Author: Bzchan <bzchan@animemahou.com>, updated by Daniel Oaks <danneh@danneh.net>
* 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 <http://seemslegit.com>
//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 = "&nbsp;";
}
$main_block_html .= $block->get_html(false);
break;
default:
print "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$debug = get_debug_info();
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
if(empty($this->subheading)) {
$subheading = "";
}
else {
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
}
$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 &raquo;", 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 .= "<li><a href='".make_link('user_admin/create')."'>Sign up</a></li>";
// $custom_sublinks .= "<li><a href='".make_link('')."'>Reset Password</a></li>";
// $custom_sublinks .= "<li><a href='".make_link('')."'>Login Reminder</a></li>";
} else {
$custom_sublinks .= "<li><a href='".make_link('user_admin/logout')."'>Sign out</a></li>";
}
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 .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>";}
$custom_sublinks .= "<li><a href='".make_link('post/list')."'>Listing</a></li>";
if(class_exists("Favorites")){ $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>";}
if(class_exists("RSS_Images")){ $custom_sublinks .= "<li><a href='".make_link('rss/images')."'>Feed</a></li>";}
if(class_exists("RandomImage")){ $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random</a></li>";}
$custom_sublinks .= "<li><a href='".make_link('upload')."'>Upload</a></li>";
if($hw){ $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>";
}else{ $custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>";}
break;
case "comment":
$custom_sublinks .= "<li><a href='".make_link('comment/list')."'>All</a></li>";
$custom_sublinks .= "<li><a href='".make_link("ext_doc/comment")."'>Help</a></li>";
break;
case "pool":
$custom_sublinks .= "<li><a href='".make_link('pool/list')."'>List</a></li>";
$custom_sublinks .= "<li><a href='".make_link("pool/new")."'>Create</a></li>";
$custom_sublinks .= "<li><a href='".make_link("pool/updated")."'>Changes</a></li>";
$custom_sublinks .= "<li><a href='".make_link("ext_doc/pools")."'>Help</a></li>";
break;
case "wiki":
$custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>";
$custom_sublinks .= "<li><a href='".make_link("wiki/rules")."'>Rules</a></li>";
$custom_sublinks .= "<li><a href='".make_link("ext_doc/wiki")."'>Help</a></li>";
break;
case "tags":
case "alias":
$custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>";
$custom_sublinks .= "<li><a href='".make_link('tags/alphabetic')."'>Alphabetic</a></li>";
$custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</a></li>";
$custom_sublinks .= "<li><a href='".make_link('tags/categories')."'>Categories</a></li>";
$custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</a></li>";
$custom_sublinks .= "<li><a href='".make_link("ext_doc/tag_edit")."'>Help</a></li>";
break;
case "admin":
case "ext_manager":
case "setup":
if($user->is_admin()) {
$custom_sublinks .= "<li><a href='".make_link('ext_manager')."'>Extension Manager</a></li>";
$custom_sublinks .= "<li><a href='".make_link('setup')."'>Board Config</a></li>";
$custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Alias Editor</a></li>";
} else {
$custom_sublinks .= "<li>I think you might be lost</li>";
}
break;
}
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
//if($this->heading==$site_name)$this->heading = '';
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
// bzchan: prepare main title link
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
if($page->left_enabled) {
$left = "<nav>$left_block_html</nav>";
$withleft = "withleft";
}
else {
$left = "";
$withleft = "noleft";
}
$flash = get_prefixed_cookie("flash_message");
$flash_html = "";
if($flash) {
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
set_prefixed_cookie("flash_message", "", -1, "/");
}
print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title>{$page->title}</title>
$header_html
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
</head>
<body>
<header>
$title_link
<ul id="navbar" class="flat-list">
$custom_links
</ul>
<ul id="subnavbar" class="flat-list">
$custom_sublinks
</ul>
</header>
$subheading
$sub_block_html
$left
<article class="$withleft">
$flash_html
$main_block_html
</article>
<footer><div>
Running Shimmie &ndash;
Images &copy; their respective owners &ndash;
<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
<a href="http://www.shishnet.org/">Shish</a> &amp;
<a href="https://github.com/shish/shimmie2/contributors">The Team</a>
2007-2012,
based on the Danbooru concept<br />
$debug
$contact
</div></footer>
</body>
</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<count($pages_matched);$i++) {
if($url == $pages_matched[$i]) {
$html = "<li class='current-page'><a href='$link'>$desc</a></li>";
}
}
if(is_null($html)) {$html = "<li><a class='tab' href='$link'>$desc</a></li>";}
return $html;
}
}
?>

348
themes/danbooru2/style.css Normal file
View file

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

View file

@ -0,0 +1,9 @@
<?php
class CustomTagListTheme extends TagListTheme {
public function display_page(Page $page) {
$page->disable_left();
parent::display_page($page);
}
}
?>

View file

@ -0,0 +1,73 @@
<?php
class Themelet extends BaseThemelet {
public function build_thumb_html(Image $image, $query=null) {
global $config;
$h_view_link = make_link("post/view/{$image->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 "<a href='$h_view_link' class='shm-thumb' data-tags='$h_tags' data-post-id='$i_id'><img title='$h_tip' alt='$h_tip' ".
"width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link' /></a>";
}
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 "<a href='$link'>$name</a>";
}
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
$paginator = "";
if($page == $current_page) $paginator .= "<b>$page</b>";
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, "&lt;&lt;");
$next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, "&gt;&gt;");
$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 "<div id='paginator'>$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html</div>";
}
}
?>

View file

@ -0,0 +1,14 @@
<?php
class CustomUploadTheme extends UploadTheme {
public function display_block(Page $page) {
// this theme links to /upload
// $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
}
public function display_page(Page $page) {
$page->disable_left();
parent::display_page($page);
}
}
?>

View file

@ -0,0 +1,102 @@
<?php
class CustomUserPageTheme extends UserPageTheme {
public function display_login_page(Page $page) {
global $config;
$page->set_title("Login");
$page->set_heading("Login");
$page->disable_left();
$html = "
<form action='".make_link("user_admin/login")."' method='POST'>
<table summary='Login Form'>
<tr>
<td width='70'><label for='user'>Name</label></td>
<td width='70'><input id='user' type='text' name='user'></td>
</tr>
<tr>
<td><label for='pass'>Password</label></td>
<td><input id='pass' type='password' name='pass'></td>
</tr>
<tr><td colspan='2'><input type='submit' value='Log In'></td></tr>
</table>
</form>
";
if($config->get_bool("login_signup_enabled")) {
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>";
}
$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 .= "<li><a href='{$part["link"]}'>{$part["name"]}</a>";
}
$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 = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";
if(empty($tac)) {$html = "";}
else {$html = "<p>$tac</p>";}
$html .= "
<form action='".make_link("user_admin/create")."' method='POST'>
<table style='width: 300px;'>
<tr><td>Name</td><td><input type='text' name='name'></td></tr>
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
<tr><td>Email (Optional)</td><td><input type='text' name='email'></td></tr>
$reca;
<tr><td colspan='2'><input type='Submit' value='Create Account'></td></tr>
</table>
</form>
";
$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 = "<table id='ip-history' style='width: 400px;'>";
$html .= "<tr><td>Uploaded from: ";
foreach($uploads as $ip => $count) {
$html .= "<br>$ip ($count)";
}
$html .= "</td><td>Commented from:";
foreach($comments as $ip => $count) {
$html .= "<br>$ip ($count)";
}
$html .= "</td></tr>";
$html .= "<tr><td colspan='2'>(Most recent at top)</td></tr></table>";
$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);
}
}
?>

View file

@ -0,0 +1,67 @@
<?php
class CustomViewImageTheme extends ViewImageTheme {
public function display_page(Image $image, $editor_parts) {
global $page;
$page->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 = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>";
$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}
<br>Uploader: $h_ownerlink
<br>Date: $h_date
<br>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 .= "<br>Source: <a href='$h_source'>link</a>";
}
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 .= "<br>Rating: $h_rating";
}
}
return $html;
}
protected function build_navigation(Image $image) {
//$h_pin = $this->build_pin($image);
$h_search = "
<form action='".make_link()."' method='GET'>
<input name='search' type='text' style='width:75%'>
<input type='submit' value='Go' style='width:20%'>
<input type='hidden' name='q' value='/post/list'>
<input type='submit' value='Find' style='display: none;'>
</form>
";
return "$h_search";
}
}
?>