new theme

This commit is contained in:
Shish 2009-07-23 02:32:45 +01:00
parent a601c5b9ed
commit b30ed5b375
8 changed files with 581 additions and 0 deletions

BIN
themes/warm/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

View File

@ -0,0 +1,51 @@
<?php
class CustomCommentListTheme extends CommentListTheme {
public function add_comment_list(Page $page, Image $image, $comments, $position, $with_postbox) {
$html = "<div style='text-align: left'>";
$html .= "<div style='float: left; margin-right: 16px;'>" . $this->build_thumb_html($image) . "</div>";
$html .= "<div style='margin-left: 228px;'>" . $this->comments_to_html($comments) . "</div>";
$html .= "</div>";
if($with_postbox) {
$html .= "<div style='clear:both;'>".($this->build_postbox($image->id))."</div>";
}
else {
// $html .= "<div style='clear:both;'><p><small>You need to create an account before you can comment</small></p></div>";
$html .= "<div style='clear:both;'><p>&nbsp;</p></div>";
}
$page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position));
}
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_userlink = "<a href='".make_link("user/$h_name")."'>$h_name</a>";
$stripped_nonl = str_replace("\n", "\\n", $tfe->stripped);
$stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
$h_dellink = $user->is_admin() ?
"<br>($h_poster_ip, <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" : "";
return "
<div class='rr'>
<div class='rrtop'><div></div></div>
<div class='rrcontent'>
<div class='comment'>$h_userlink: $h_comment $h_imagelink $h_dellink</div>
</div>
<div class='rrbot'><div></div></div>
</div>";
}
}
?>

View File

@ -0,0 +1,144 @@
<?php
/**
* A class to turn a Page data structure into a blob of HTML
*/
class Layout {
/**
* turns the Page into HTML
*/
public function display_page(Page $page) {
global $config;
$theme_name = $config->get_string('theme', 'default');
$data_href = get_base_href();
$contact_link = $config->get_string('contact_link');
$version = "Shimmie-".VERSION;
$header_html = "";
foreach($page->headers as $line) {
$header_html .= "\t\t$line\n";
}
$left_block_html = "";
$main_block_html = "";
$head_block_html = "";
foreach($page->blocks as $block) {
switch($block->section) {
case "left":
$left_block_html .= $this->block_to_html($block, true, "left");
break;
case "head":
$head_block_html .= "<td width='250'><small>".$this->block_to_html($block, false, "head")."</small></td>";
break;
case "main":
$main_block_html .= $this->block_to_html($block, false, "main");
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='$contact_link'>Contact</a>";
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
$wrapper = "";
if(strlen($page->heading) > 100) {
$wrapper = ' style="height: 3em; overflow: auto;"';
}
print <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>{$page->title}</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
<link rel="stylesheet" href="$data_href/themes/$theme_name/menuh.css" type="text/css">
$header_html
</head>
<body>
<table id="header" class="bgtop" width="100%" height="113px">
<tr>
<td><center>
<h1><a href="/">{$page->heading}</a></h1>
<p>[Navigation links go here]
</center></td>
$head_block_html
</tr>
</table>
<div id="nav">$left_block_html</div>
<div id="body">$main_block_html</div>
<div id="footer">
Images &copy; their respective owners,
<a href="http://code.shishnet.org/shimmie2/">$version</a> &copy;
<a href="http://www.shishnet.org/">Shish</a> 2007-2009,
based on the Danbooru concept.
$debug
$contact
</div>
</body>
</html>
EOD;
}
/**
* A handy function which does exactly what it says in the method name
*/
private function block_to_html($block, $hidable=false, $salt="") {
$h = $block->header;
$b = $block->body;
$html = "";
$i = str_replace(' ', '_', $h) . $salt;
if($hidable) $html .= "
<script><!--
$(document).ready(function() {
$(\"#$i-toggle\").click(function() {
$(\"#$i\").slideToggle(\"slow\", function() {
if($(\"#$i\").is(\":hidden\")) {
$.cookie(\"$i-hidden\", 'true', {path: '/'});
}
else {
$.cookie(\"$i-hidden\", 'false', {path: '/'});
}
});
});
if($.cookie(\"$i-hidden\") == 'true') {
$(\"#$i\").hide();
}
});
//--></script>
";
if(!is_null($h)) $html .= "
<div class='hrr' id='$i-toggle'>
<div class='hrrtop'><div></div></div>
<div class='hrrcontent'><h3>$h</h3></div>
<div class='hrrbot'><div></div></div>
</div>
";
if(!is_null($b)) {
if(strpos($b, "rrcontent")) {
$html .= "<div class='blockbody' id='$i'>$b</div>";
}
else {
$html .= "
<div class='rr' id='$i'>
<div class='rrtop'><div></div></div>
<div class='rrcontent'><div class='blockbody'>$b</div></div>
<div class='rrbot'><div></div></div>
</div>
";
}
}
return $html;
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
/**
* A customised version of the Setup theme
*/
class CustomSetupTheme extends SetupTheme {
/**
* Turn a SetupBlock into HTML... with rounded corners.
*/
protected function sb_to_html(SetupBlock $block) {
return "
<div class='rr setupblock'>
<div class='rrtop'><div></div></div>
<div class='rrcontent'><b>{$block->header}</b><br>{$block->body}</div>
<div class='rrbot'><div></div></div>
</div>
";
}
}
?>

226
themes/warm/style.css Normal file
View File

@ -0,0 +1,226 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 things common to all pages *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
BODY {
background: url(bg.png);
font-family: "Arial", sans-serif;
font-size: 14px;
margin: 0px;
}
#header {
border-bottom: 1px solid #B89F7C;
margin-top: 0px;
margin-bottom: 16px;
padding: 8px;
background: #FCD9A9;
text-align: center;
}
H1 {
font-size: 5em;
margin: 0px;
padding: 0px;
}
H1 A {
color: black;
}
H3 {
text-align: center;
margin: 0px;
}
THEAD {
font-weight: bold;
}
TD {
vertical-align: top;
text-align: center;
}
CODE {
background: #DEDEDE;
font-size: 0.8em;
}
#subtitle {
width: 256px;
font-size: 0.75em;
margin: auto;
margin-top: -16px;
text-align: center;
border: 1px solid black;
border-top: none;
background: #DDD;
}
#body SELECT {width: 150px;}
TD>INPUT[type="submit"] {width: 100%;}
TD>INPUT[type="text"] {width: 100%;}
TD>INPUT[type="password"] {width: 100%;}
TD>SELECT {width: 100%;}
TABLE.zebra {border-spacing: 0px; border: 1px solid #B89F7C; }
TABLE.zebra TD, TABLE.zebra TH {vertical-align: middle; padding: 4px;}
TABLE.zebra THEAD TD, TABLE.zebra THEAD TH {border-bottom: 2px solid #B89F7C;}
TABLE.zebra TFOOT TD, TABLE.zebra TFOOT TH {border-top: 2px solid #B89F7C;}
TABLE.zebra TD {border-top: 1px solid #B89F7C;}
TABLE.zebra TR.odd {background: #FCD9A9;}
TABLE.zebra TR.even {background: #DABC92;}
#footer {
clear: both;
padding: 8px;
font-size: 0.7em;
text-align: center;
border-top: 1px solid #B89F7C;
background: #FCD9A9;
}
*[onclick] {cursor: pointer;}
IMG {border: none;}
FORM {margin: 0px;}
A {color: #665844; text-decoration: none; font-weight: bold;}
A:hover {color: #665844; text-decoration: underline;}
A:visited {color: #665844; text-decoration: none}
A:active {color: #665844; text-decoration: underline;}
BLOCKQUOTE {
border: 1px solid black;
padding: 8px;
background: #DDD;
}
UL {
text-align: left;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the navigation bar, and all its blocks *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#nav {
width: 250px;
float: left;
text-align: center;
margin-left: 16px;
}
#nav .blockbody {
font-size: 0.85em;
text-align: center;
}
#nav TABLE {
width: 150px;
}
#nav TD {
vertical-align: middle;
}
#nav INPUT {
width: 100%;
padding: 0px;
}
#nav SELECT {
width: 100%;
padding: 0px;
}
#comments P {
text-align: left;
width: 150px;
max-width: 150px;
overflow: hidden;
}
.comment {
text-align: left;
}
.more:after {
content: " >>>";
}
.tag_count:before {
content: "(";
}
.tag_count:after {
content: ")";
}
.paginator {
clear: both;
padding: 4px;
margin-bottom: 32px;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the main part of each page *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#body {
margin-left: 276px;
margin-right: 16px;
text-align: center;
height: 1%;
}
#body TABLE {
width: 90%;
margin: auto;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* specific page types *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#pagelist {
margin-top: 32px;
}
#tagmap A {
padding: 8px 4px 8px 4px;
}
.rr {text-align: left; background: #FCD9A9; margin: 8px; border: 1px solid #B89F7C;}
.rrtop, .rrtop div, .rrbot, .rrbot div {height: 8px; width: 100%;}
.rrcontent {margin: 0px 8px; text-align: center;}
.hrr {text-align: left; background: #DABC92; margin: 8px; border: 1px solid #B89F7C;}
.hrrtop, .hrrtop div, .hrrbot, .hrrbot div {height: 8px; width: 100%;}
.hrrcontent {margin: 0px 8px;}
.setupblock {
text-align: center;
margin: 16px;
width: 350px;
}
.setupblock TEXTAREA {
width: 300px;
font-size: 0.75em;
}
.helpable {
border-bottom: 1px dashed gray;
}
.ok {
background: #AFA;
}
.bad {
background: #FAA;
}
#nav .thumbblock {
float: none;
height: auto;
}
#nav .thumb {
margin-bottom: 0px;
}
.thumbblock {
width: 220px;
height: 220px;
display: inline-block;
float: left;
}
.thumb {
display: inline-block;
text-align: center;
margin-bottom: 32px;
}

View File

@ -0,0 +1,103 @@
<?php
/**
* A collection of common functions for theme parts
*/
class Themelet {
/**
* Generic error message display
*/
public function display_error(Page $page, $title, $message) {
$page->set_title($title);
$page->set_heading($title);
$page->add_block(new NavBlock());
$page->add_block(new Block("Error", $message));
}
/**
* A specific, common error message
*/
public function display_permission_denied(Page $page) {
header("HTTP/1.0 403 Permission Denied");
$this->display_error($page, "Permission Denied", "You do not have permission to access this page");
}
/**
* Generic thumbnail code; returns HTML rather than adding
* a block since thumbs tend to go inside blocks...
*/
public function build_thumb_html(Image $image, $query=null) {
global $config;
$i_id = int_escape($image->id);
$h_view_link = make_link("post/view/$i_id", $query);
$h_tip = html_escape($image->get_tooltip());
$h_image_link = $image->get_image_link();
$h_thumb_link = $image->get_thumb_link();
$tsize = get_thumbnail_size($image->width, $image->height);
return "
<div class='thumbblock'>
<div class='rr thumb'>
<div class='rrtop'><div></div></div>
<div class='rrcontent'>
<a href='$h_view_link' style='position: relative; display: block; height: {$tsize[1]}px; width: {$tsize[0]}px;'>
<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'>
</a>
</div>
<div class='rrbot'><div></div></div>
</div>
</div>
";
}
/**
* Add a generic paginator
*/
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>";
$paginator .= $this->gen_page_link($base_url, $query, $page, $name);
if($page == $current_page) $paginator .= "</b>";
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 <= 1 || $total_pages <= 1);
$at_end = ($current_page >= $total_pages);
$first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First");
$prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev");
$random_html = $this->gen_page_link($base_url, $query, $rand, "Random");
$next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next");
$last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last");
$start = $current_page-5 > 1 ? $current_page-5 : 1;
$end = $start+10 < $total_pages ? $start+10 : $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);
return "<p class='paginator'>$first_html | $prev_html | $random_html | $next_html | $last_html".
"<br>&lt;&lt; $pages_html &gt;&gt;</p><!-- rrcontent -->";
}
}
?>

View File

@ -0,0 +1,12 @@
<?php
class CustomUploadTheme extends UploadTheme {
public function display_block(Page $page) {
$page->add_block(new Block("Upload", $this->build_upload_block(), "head", 20));
}
public function display_full(Page $page) {
$page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "head", 20));
}
}
?>

View File

@ -0,0 +1,26 @@
<?php
class CustomUserPageTheme extends UserPageTheme {
public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name);
$html = join("\n | ", $parts);
$page->add_block(new Block("Logged in as $h_name", $html, "head", 90));
}
public function display_login_block(Page $page) {
global $config;
$html = "
<form action='".make_link("user_admin/login")."' method='POST'>
<table summary='Login Form' align='center'>
<tr><td width='70'>Name</td><td width='70'><input type='text' name='user'></td></tr>
<tr><td>Password</td><td><input type='password' name='pass'></td></tr>
<tr><td colspan='2'><input type='submit' name='gobu' 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, "head", 90));
}
}
?>