layerinfo "type" = "layout";
layerinfo "name" = "Dear Diary...";
layerinfo "author_name" = "Martin Atkins";
layerinfo "redist_uniq" = "deardiary/layout";
layerinfo "previews" = "deardiary/preview.jpg";

## Customization Props

propgroup colors {
    property Color clr_page_bg {
        des = "Main Page Background Color";
    }
    property Color clr_page_fg {
        des = "Main Page Foreground Color";
    }
    property Color clr_title_bg {
        des = "Title Background Color";
    }
    property Color clr_title_fg {
        des = "Title Text Color";
    }
    property Color clr_title_pattern {
        des = "Color of Title Background Pattern";
        note = "This color will only be used if a pattern is selected.";
    }
    property Color clr_title_separator {
        des = "Color of Line Under Title";
    }
    property Color clr_sidebar_bg {
        des = "Sidebar Background Color";
    }
    property Color clr_sidebar_fg {
        des = "Sidebar Text Color";
    }
    property Color clr_link_normal {
        des = "Normal Link Color";
    }
    property Color clr_link_visited {
        des = "Visited Link Color";
    }

    set clr_page_bg = "#F8EEFA";
    set clr_page_fg = "#000000";
    set clr_title_bg = "#8B04B2";
    set clr_title_fg = "#ffffff";
    set clr_title_pattern = "#D891F5";
    set clr_title_separator = "#000000";
    set clr_sidebar_bg = "#D891F5";
    set clr_sidebar_fg = "#ffffff";
    set clr_link_normal = "#D891F5";
    set clr_link_visited = "#B375CD";
}

propgroup appearance {
    property string title_pattern {
        des = "Pattern to use in the title bar";
        note = "You can choose the color of the pattern on the colors page.";
        values = "letters.png|Letters|explosion.png|Explosion|nature.png|Nature|camouflage.png|Camouflage|ramblings.png|Ramblings|clouds.png|Clouds|futuristic.png|Futuristic|bubbles.png|Circles|bubblewrap.png|Bubble Wrap|wires.png|Wires|urban.png|Urban||None";
    }
    set title_pattern = "camouflage.png";

    property bool title_separator {
        des = "Show line under title bar";
    }
    set title_separator = true;

    property string{}{} font_sizes {
        des = "A bunch of font size settings";
        noui = 1;
    }
    set font_sizes = {
        "tiny" => {
            "body" => "10px",
            "pagetitle" => "25px",
            "pagesubtitle" => "14px",
            "dayhead" => "14px",
            "entryhead" => "12px",
        },
        "small" => {
            "body" => "12px",
            "pagetitle" => "25px",
            "pagesubtitle" => "14px",
            "dayhead" => "16px",
            "entryhead" => "14px",
        },
        "medium" => {
            "body" => "14px",
            "pagetitle" => "25px",
            "pagesubtitle" => "14px",
            "dayhead" => "18px",
            "entryhead" => "16px",
        },
        "large" => {
            "body" => "16px",
            "pagetitle" => "25px",
            "pagesubtitle" => "14px",
            "dayhead" => "20px",
            "entryhead" => "18px",
        },
        "huge" => {
            "body" => "18px",
            "pagetitle" => "25px",
            "pagesubtitle" => "14px",
            "dayhead" => "22px",
            "entryhead" => "20px",
        },
    };

    property string font_body {
        des = "Font Family For Normal Text";
        note = "Specify a list of acceptable fonts in order of preference, most preferred first.";
    }
    set font_body = "\"Garamond\", \"Palatino\", \"Palatino Linotype\", serif";

    property string font_sidebar {
        des = "Font Family For Sidebar";
        note = "Specify a list of acceptable fonts in order of preference, most preferred first.";
    }
    set font_sidebar = "\"Tahoma\", \"Georgia\", \"Helvetica\", \"Arial\", sans-serif";

    property string font_title {
        des = "Font Family For Title";
        note = "Specify a list of acceptable fonts in order of preference, most preferred first.";
    }
    set font_title = "\"Tahoma\", \"Georgia\", \"Helvetica\", \"Arial\", sans-serif";

    property string font_headings {
        des = "Font Family For Headings";
        note = "Specify a list of acceptable fonts in order of preference, most preferred first.";
    }
    set font_headings = "\"Garamond\", \"Palatino\", \"Palatino Linotype\", serif";

    property string font_size_keyword {
        des = "Text Size";
        values = "tiny|Tiny|small|Small|medium|Medium|large|Large|huge|Huge";
    }
    set font_size_keyword = "medium";
}

propgroup options {
    property bool opt_use_friendcolors {
        des = "Use friend colors on friends page";
        noui = 1; # The support for this isn't brilliant
    }
    set opt_use_friendcolors = false;

    property bool opt_hide_userpics {
        des = "Hide user picture icons on entries";
        note = "The pictures will still be shown on the Friends view";
    }
    set opt_hide_userpics = true;

    property use lang_fmt_date_short;
    property use lang_fmt_date_long;
    property use lang_fmt_time_short;

    property use page_recent_items;
    property use page_friends_items;

    property use use_shared_pic;
    property use view_entry_disabled;

    # This layout has quite a hefty stylesheet, so let's
    # make it external to avoid loading it over and over.
    set external_stylesheet = true;
}
propgroup options = "Options";

## I18n Props

propgroup text {
    property use text_view_recent;
    property use text_view_archive;
    property use text_view_friends;
    property use text_view_userinfo;

    property string i18n_paraphernalia_journalinfo {
        des = "Journal Info Heading";
    }
    property string i18n_paraphernalia_viewsel {
        des = "View Selection Heading";
        noui = 1;
    }
    property string i18n_paraphernalia_links {
        des = "Link List Heading";
        noui = 1;
    }
    property string i18n_paraphernalia_recent_navigation {
        des = "RecentPage Navigation Heading";
        noui = 1;
    }
    property string i18n_paraphernalia_year_navigation {
        des = "YearPage Navigation Heading";
        noui = 1;
    }
    property string i18n_paraphernalia_entry_navigation {
        des = "EntryPage Navigation Heading";
        noui = 1;
    }
    property string i18n_paraphernalia_day_navigation {
        des = "DayPage Navigation Heading";
        noui = 1;
    }
    set i18n_paraphernalia_journalinfo = "Journal Info";
    set i18n_paraphernalia_viewsel = "View";
    set i18n_paraphernalia_links = "Links";
    set i18n_paraphernalia_recent_navigation = "Navigation";
    set i18n_paraphernalia_year_navigation = "Year";
    set i18n_paraphernalia_entry_navigation = "Entry";
    set i18n_paraphernalia_day_navigation = "Navigation";

    property string i18n_journalinfo_name {
        des = "Journal Name Caption";
        noui = 1;
    }
    property string i18n_journalinfo_website {
        des = "Journal Name Caption";
        noui = 1;
    }
    set i18n_journalinfo_name = "Name";
    set i18n_journalinfo_website = "Website";

    property use text_post_comment;
    property use text_read_comments;
    property use text_post_comment_friends;
    property use text_read_comments_friends;
    property use text_website_default_name;
}
propgroup text = "Text";

function prop_init() {
    # A vague attempt at sanity-checking the font properties. Not
    # foolproof, of course, but this is about as good as it gets in S2.
    if ($*font_body->contains(";")) { $*font_body = "serif"; }
    if ($*font_sidebar->contains(";")) { $*font_sidebar = "sans-serif"; }
    if ($*font_title->contains(";")) { $*font_title = "sans-serif"; }
    if ($*font_headings->contains(";")) { $*font_headings = "serif"; }
}

function pretty_styles() "Pretty stuff that's completely dispensible" {

    var int top = ($*title_separator ? 79 : 75);
    var string{} size = $*font_sizes{$*font_size_keyword};

"""

body {
    background: $*clr_sidebar_bg;
    color: $*clr_sidebar_fg;
    margin: 0;
    padding: 0;
    border: 0;
    font-family: $*font_body;
    width: 100%;
    height: 100%;
}
body, td, table, th, tr {
    font-size: $size{"body"};
}

#main a:link {
    color: $*clr_link_normal;
}
#main a:visited {
    color: $*clr_link_visited;
}
.pbox a {
    color: $*clr_sidebar_fg;
}

#title {
    color: $*clr_title_fg;
    background-color: $*clr_title_bg;
""";
if ($*title_pattern != "") {
"""
    background-image: url("""+palimg_tint("deardiary/titleimages/$*title_pattern", $*clr_title_bg, $*clr_title_pattern)+""");
    background-repeat: no-repeat;
    background-position: top right;
""";
}
if ($*title_separator) {
"""
    border-bottom: 4px solid $*clr_title_separator;
""";
}
"""
    width: 100%;
    font-family: $*font_title;
    height: 75px;
    overflow: hidden;
}
#title h1 {
    font-size: $size{"pagetitle"};
    font-weight: bold;
    margin: 0;
    padding-top: 20px;
    padding-left: 8px;
    white-space: no-wrap;
}
#title #journal_subtitle {
    font-size: $size{"pagesubtitle"};
    font-weight: bold;
    margin: 0;
    padding-left: 8px;
    white-space: no-wrap;
}

#paraphernalia {
    position: absolute;
    left: 0;
    top: ${top}px;
    width: 200px;
    font-family: $*font_sidebar;
}
#paraphernalia h2 {
    font-size: $size{"body"};
    font-weight: bold;
    text-align: left;
    margin-top: 16px;
    margin-bottom: 8px;
}
#paraphernalia .pbox {
    margin-left: 8px;
    margin-right: 8px;
}
#journalinfouserpic {
    text-align: center;
}
.pboxcontent {
    margin-left: 8px;
    margin-right: 8px;
}
.pbox dt {
    font-weight: normal;
    margin-top: 4px;
}
.pbox dd {
    padding: 0;
    margin-left: 24px;
}
.pbox ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.pbox ul ul {
    margin-left: 24px;
}
.pbox li {
    margin: 0;
    padding: 0;
}
.pbox li.current {
    font-weight: bold;
}
.pbox p {
    margin: 8px 0;
}

#main {
    position: absolute;
    /*left: 20%;*/
    left: 200px;
    top: ${top}px;
    right: 0;
    margin: 0;
    background-color: $*clr_page_bg;
    color: $*clr_page_fg;
    min-height: 150%;
    padding: 0 10px 0 0;
}
* html #main {
    width: expression((document.body.clientWidth - document.getElementById('paraphernalia').clientWidth - 10)+"px");
    height: expression((document.body.clientHeight)+"px");
}

.day h2 {
    font-size: $size{"dayhead"};
    font-weight: bold;
    padding: 0 0 5px 10px;
    background-image: url("""+palimg_tint("deardiary/headinggrad.png", $*clr_page_bg, $*clr_sidebar_bg)+""");
    background-position: bottom left;
    background-repeat: no-repeat;
    margin: 16px 0 8px 0;
    font-family: $*font_headings;
}

.entry {
    margin: 32px 16px 32px 26px;
}
.entryheader {
    font-size: $size{"entryhead"};
}
.entryheader .entrytimestampdate {
    display: none;
}

.comments .entry {
    margin-left: 0;
    margin-bottom: 8px;
}

.calendarmonth {
    width: 60%;
    margin-right: auto;
    margin-left: auto;
    border-collapse: collapse;
    margin-bottom: 2em;
}
.calendarmonth td, .calendarmonth th {
    padding: 0.5em;
    margin: 0;
}
.calendarmonthlink {
    text-align: center;
}
.calendarmonthheader h2 {
    font-size: $size{"entryhead"};
    margin: 0;
}

.page_month #main form, .page_month #main dl {
    margin: 8px;
}

#server_sig {
    display: none;
}

""";
}

function necessary_styles() "Styles which are likely to be needed whatever stylesheet is in use" {
"""
.entry {
margin-bottom: 2em;
clear: both;
}

.entry .entryheader {
font-weight: bold;
text-align: left;
}

.entry .entryheader h3 {
font-size: 1em;
margin: 0;
padding: 0;
}

.entryheader .entryicon {
float: right;
margin-right: 1em;
}

.entryheader .entryuserpic {
float: right;
margin-top: 2em;
clear: both;
display: block;
padding: 0.5em;
""";
if ($*opt_hide_userpics) {
"""
display: none;
}
.page_friends .entryheader .entryuserpic {
display: block;
""";
}

"""
}

.entryheader .entryposter {
display: inline;
float:left;
margin-right: 1em;
}
.entryheader .entryposter:after {
content: ": ";
}
.entryposter img, .collapsed_entry img {
height: 14px;
width: 10px;
}

.entryheader .entrytimestamp {
display: inline;
}

.entrylinkbarpre, .entrylinkbarpost {
display: none;
}
.page_entry .entrylinkbarpre, .page_reply .entrylinkbarpre {
display: block;
float: right;
}

.entry .entrycontent {
margin: 8px;
}

.entrymeta {
list-style: none;
padding: 0;
margin: 0 0 0.5em 0;
display: block;
}
.entrymeta .entrymetacaption {
font-weight: bold;
}
.entrymeta li {
white-space: no-wrap;
}

.entry .entryfooter {
clear: both;
margin: 0;
}

.entryfooter .entrycmdlinks {
list-style: none;
vertical-align: middle;
margin: 0; padding: 0em;
white-space: no-wrap;
text-align: left;
}
.entryfooter .entrycmdlinks:before {
content: "(";
}
.entryfooter .entrycmdlinks:after {
content: ")";
}

.entrycmdlinks li {
display: inline;
}
* html .entrycmdlinks li {
margin-left: 1em;
}
.entrycmdlinks li:before {
content: " - ";
}
.entrycmdlinks li:first-child:before {
content: "";
}

.comments {
    list-style: none;
    padding: 0;
    margin-left: 50px;
}
.comments .comments {
    margin-left: 25px;
}
.comments > li {
    margin: 0;
    padding: 0;
}
.calendardaynum { text-align: right; }
.calendardaycount { text-align: center; }
.calendarday {
width: 14%;
}
.itemrange {
    list-style: none;
    padding: 0;
    margin: 0.5em;
    text-align: center;
}
.itemrange li {
    display: inline;
    margin: 0 0.25em;
}
.itemrange li a:before, .itemrange li.current:before {
    content: "[";
}
.itemrange li a:after, .itemrange li.current:after {
    content: "]";
}
""";
}
function custom_styles() "User layers can override this to add extra CSS to the stylesheet" {}

## Everything after this point should be common to all Cascadadelic layouts

function UserLite::lay_as_string() : string {
    var Image uiimg = userinfoicon($this);
    var string dir = $.journal_type == "C" ? "community" : "users";
    return "<span class='ljuser_$.username' style='white-space:nowrap;'><a href='$*SITEROOT/userinfo.bml?user=$.username'><img src='$uiimg.url' alt='[info]' width='$uiimg.width' height='$uiimg.height' style='vertical-align:bottom;border:0;' /></a><a href='$*SITEROOT/$dir/$.username/'><b>$.username</b></a></span>";
}

function print_stylesheet() {
    necessary_styles();
    pretty_styles();
    custom_styles();
}

function paraphernalia_box_open(string id, string title) "Open a paraphenalia box" {
    "<div class=\"pbox\"";
    if ($id != "") {
        " id=\"$id\"";
    }
    ">";
    if ($title != "") {
        """<h2>$title</h2>""";
    }
    """<div class="pboxcontent">\n""";
}
function paraphernalia_box_close(string id, string title) "Close a paraphenalia box" {
    """</div></div>\n""";
}

function Page::lay_print_heading() {
    print "<h1>$.global_title</h1>";
    if ($.view == "recent" and $.global_subtitle != "") {
        print """<div id="journal_subtitle">$.global_subtitle</div>""";
    }
    else {
        print """<div id="journal_subtitle">"""+$this->view_title()+"""</div>""";
    }
}
function Page::lay_print_journalinfo() {
    paraphernalia_box_open("journalinfo",$*i18n_paraphernalia_journalinfo);
    if (defined $.journal.default_pic) {
        println """<div id="journalinfouserpic">$.journal.default_pic</div>""";
    }
    println "<dl>";
    println "<dt>$*i18n_journalinfo_name</dt><dd>$.journal.name</dd>";
    if ($.journal.website_url != "") {
        var string website = $.journal.website_name != "" ? $.journal.website_name : $*text_website_default_name;
        println """<dt>$*i18n_journalinfo_website</dt><dd><a href="$.journal.website_url">$website</a></dd>""";
    }
    println "</dl>";
    paraphernalia_box_close("journalinfo",$*i18n_paraphernalia_journalinfo);
}
function Page::lay_print_viewsel() {
    paraphernalia_box_open("viewsel",$*i18n_paraphernalia_viewsel);
    "<ul>\n";
    foreach var string vl ($.views_order) {
        if ($vl == $.view) {
            print "<li class=\"current\">"+lang_viewname($vl)+"</li>\n";
        } else {
            print "<li><a href=\""+ehtml($.view_url{$vl})+"\">"+lang_viewname($vl)+"</a></li>\n";
        }
    }
    "</ul>\n";
    paraphernalia_box_close("viewsel",$*i18n_paraphernalia_viewsel);
}
function Page::lay_print_userlinks() {
    if (size $.linklist <= 0) {
        return;
    }
    paraphernalia_box_open("userlinks",$*i18n_paraphernalia_links);
    $this->print_linklist();
    paraphernalia_box_close("userlinks",$*i18n_paraphernalia_links);
}
function Page::lay_print_viewspec() {}
function Page::lay_print_viewspec_after() {}
function Page::lay_print_custom_paraphernalia() "User layers can override this to add extra paraphernalia" {}

function Page::lay_print_paraphernalia() "User layers can override this to change what appears in the paraphernalia section" {
    $this->lay_print_journalinfo();
    $this->lay_print_viewsel();
    $this->lay_print_viewspec();
    $this->lay_print_custom_paraphernalia();
    $this->lay_print_userlinks();
}

function lang_posting_in(UserLite poster, UserLite journal) : string "Return the string 'poster posting in journal'; I18n layers should override this." {
    return $poster->lay_as_string()+" posting in "+$journal->lay_as_string();
}

function EntryLite::lay_print_icon() {}
function EntryLite::lay_print_metadata() {}
function EntryLite::lay_print_cmdlinks() {}
function EntryLite::lay_print_poster() {
    if (defined $.poster) {
        print """<div class="entryposter">$.poster</div>""";
    }
    else {
        print """<div class="entryposter">$*text_poster_anonymous</div>""";
    }
}
function Entry::lay_print_poster() {
    var Page p = get_page();
    if ($p.view == "recent" and $.poster->equals($.journal)) {
        return;
    }
    if ($p.view == "friends") {
        print """<div class="entryposter">""";
        if (not $.poster->equals($.journal)) {
            print lang_posting_in($.poster, $.journal);
        }
        else {
            print $.poster->lay_as_string();
        }
        print """</div>""";
    }
    else {
        print """<div class="entryposter">"""+$.poster->lay_as_string()+"""</div>""";
    }
}

function Entry::lay_print_icon() {
    if ($.security != "") {
        """<div class="entryicon">""";
        print $.security_icon->as_string("[$.security]");
        "</div>";
    }
}
function Comment::lay_print_icon() {
    if (defined $.subject_icon) {
        """<div class="entryicon">""";
        print $.subject_icon->as_string("");
        "</div>";
    }
}

function Entry::lay_print_metadata() {
    if ($.metadata{"music"} == "" and $.metadata{"mood"} == "") {return;}
    println """<ul class="entrymeta">""";
    if ($.metadata{"music"} != "") {
        println """<li><span class="entrymetacaption">Current Music:</span> $.metadata{"music"}</li>""";
    }
    if ($.metadata{"mood"} != "") {
        print """<li><span class="entrymetacaption">Current Mood:</span> """;
        if (defined $.mood_icon) {
            print $.mood_icon->as_string() + " ";
        }
        println """$.metadata{"mood"}</li>""";
    }
    println """</ul>""";
}
function Comment::lay_print_metadata() {
    if ($.metadata{"poster_ip"} != "") {
        println """<ul class="entrymeta">""";
        println """<li><b>Poster IP Address:</b> $.metadata{"poster_ip"}</li>""";
        println """</ul>""";
    }
}

function Entry::lay_print_cmdlinks() {
    println """<ul class="entrycmdlinks">""";
    if ($.comments.enabled) {
        if ($.comments.count != 0) {
            println "<li>"; $.comments->print_readlink(); "</li>";
        }
        println "<li>"; $.comments->print_postlink(); "</li>";
    }
    println """</ul>""";
}

function Comment::lay_print_cmdlinks() {
    println """<ul class="entrycmdlinks">""";
    if ($.reply_url != "") {
        println """<li><a href="$.reply_url">$*text_comment_reply</a></li>""";
    }
    if ($.parent_url != "") {
        println """<li><a href="$.parent_url">$*text_comment_parent</a></li>""";
    }
    if ($.thread_url != "") {
        println """<li><a href="$.thread_url">$*text_comment_thread</a></li>""";
    }
    println """</ul>""";
}

function Page::lay_print_entrylite(EntryLite e) {
"""<div class="entry">
<div class="entryheader">
<h3 class="entrysubject">$e.subject</h3>""";
    $e->lay_print_poster();
"""<div class="entrytimestamp">
<span class="entrytimestampdate">"""+$e.time->date_format("short")+"""</span>
<span class="entrytimestamptime">"""+$e.time->time_format()+"""</span>
</div>""";

$e->lay_print_icon();
"""<div class="entrylinkbarpre">"""; $e->print_linkbar(); """</div>
""";
    if (defined $e.userpic) {
        """<div class="entryuserpic">$e.userpic</div>""";
    }
"""</div>

<div class="entrycontent">
$e.text
</div>

<div class="entryfooter">

"""; $e->lay_print_metadata(); """
<div class="entrylinkbarpost">"""; $e->print_linkbar(); """</div>
"""; $e->lay_print_cmdlinks(); """

</div>

</div>""";
}
function Page::print_entry(Entry e) {
    $this->lay_print_entrylite($e);
}
function EntryPage::print_comment(Comment c) {
    if ($c.full) {
        $this->lay_print_entrylite($c);
    }
    else {
        var string subject = ($c.subject ? $c.subject : "<i>(no subject)</i>");
        """<div class="collapsed_entry"><a href="$c.permalink_url">$subject</a> - $c.poster</div>""";
    }
}

function Page::lay_print_viewspec_head() {}
function FriendsPage::lay_print_viewspec_head() {
    if (not $*opt_use_friendcolors) { return; }
    println """<style type="text/css">""";
    foreach var string f ($.friends) {
        println ".ljuser_$f { background: $.friends{$f}.bgcolor none; color: $.friends{$f}.fgcolor; padding: 0 0.25em;}";
    }
    println """</style>""";
}

function Page::print() {
   """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>"""+$this->title()+"""</title>
""";
    if ($*external_stylesheet) {
        println """<link rel="stylesheet" href="$.stylesheet_url" type="text/css" />""";
    }
    else {
        println """<style type="text/css">""";
        print_stylesheet();
        println """</style>""";
    }
    $this->print_head();
    $this->lay_print_viewspec_head();
"""
</head>

<body class="page_$.view">

<div id="pagecontainer">

<div id="title">
"""; $this->lay_print_heading(); """
</div>

<div id="paraphernalia">
"""; $this->lay_print_paraphernalia(); """
</div>

<div id="main">
"""; $this->print_body(); """
</div>

"""; $this->lay_print_viewspec_after(); """

<div id="server_sig">"""; server_sig(); """</div>

</div>

</body>
</html>""";

}

## Some general page stuff

function Page::print_linklist() {
    if (size $.linklist <= 0) {
        return;
    }

    var bool section_open = false;

    println "<ul>";
    foreach var UserLink l ($.linklist) {
        if ($l.title) {
            if ($l.is_heading) {
                if ($section_open) {
                    println "</ul></li>";
                }
                println """<li><span style="font-weight: bold;">$l.title</span>\n<ul>""";
                $section_open = true;
            } else {
                println """<li><a href="$l.url">$l.title</a></li>""";
            }
        }
    }
    if ($section_open) {
        println "</ul></li>";
    }
    println "</ul>";
}


## RecentPage Stuff
function lang_skipped_back(RecentNav nav) : string
"Return short text saying how many entries have been skipped back. i18n layers should override this."
{
    return "Skipped Back $nav.skip";
}

function lang_adjacent_skip(RecentNav nav, bool next) : string
"Return either 'Previous N' or 'Next N' depending on the value of the 'next' parameter"
{
    if ($next) {
        return "Next $nav.forward_count";
    }
    else {
        return "Previous $nav.backward_count";
    }
}

function RecentPage::lay_print_viewspec() {
    if ($.nav.backward_url != "" or $.nav.forward_url != "") {
        paraphernalia_box_open("recentnav",$*i18n_paraphernalia_recent_navigation);
        if ($.nav.skip > 0) {
            println "<p>"+lang_skipped_back($.nav)+"</p>";
        }
        println """<ul>""";
        if ($.nav.backward_url) {
            println """<li><a href="$.nav.backward_url">"""+lang_adjacent_skip($.nav,false)+"""</a></li>""";
        }
        if ($.nav.forward_url) {
            println """<li><a href="$.nav.forward_url">"""+lang_adjacent_skip($.nav,true)+"""</a></li>""";
        }
        println "</ul>";
        paraphernalia_box_close("recentnav",$*i18n_paraphernalia_recent_navigation);
    }
}

function RecentPage::print_body() {
    foreach var Entry e ($.entries) {
        if ($e.new_day) {
            """<div class="day" id="day"""+$e.time->date_format("%%yyyy%%%%mm%%%%dd%%")+"\">\n";
            println "<h2>"+$e.time->date_format("long")+"</h2>";
        }
        # Print the entry
        $this->print_entry($e);
        if ($e.end_day) {
            "</div>";
        }
    }
}


## YearPage Stuff
function YearPage::lay_print_viewspec() {
    paraphernalia_box_open("yearnav",$*i18n_paraphernalia_year_navigation);
    $this->print_year_links();
    paraphernalia_box_close("yearnav",$*i18n_paraphernalia_year_navigation);
}
function YearPage::print_body {
    println """<div id="calendarmonthcontainer">""";
    foreach var YearMonth m ($.months) {
        $this->print_month($m);
    }
    println "</div>";
}
function YearPage::print_year_links() {
    """<ul class="viewspecnavbar">\n""";
    foreach var YearYear y ($.years) {
        if ($y.displayed) {
            """<li class="current">$y.year</li>\n""";
        } else {
            """<li><a href="$y.url">$y.year</a></li>\n""";
        }
    }
    """</ul>\n""";
}
function YearPage::print_month(YearMonth m) {
    if (not $m.has_entries) { return; }
    """<table class="calendarmonth">\n
       <tr><th colspan="7" class="calendarmonthheader">""";
    print "<h2>"+$m->month_format()+"</h2>\n";
    """</th></tr><tr>\n""";
    foreach var int d (weekdays()) {
        "<th>"+$*lang_dayname_short[$d]+"</th>\n";
    }
    "</tr>\n";
    foreach var YearWeek w ($m.weeks) {
        $w->print();
    }
    """<tr><td colspan="7" class="calendarmonthlink">
        <a href="$m.url">$*text_view_month</a></td></tr>\n""";
    "</table>";
}
function YearWeek::print() {
   """<tr valign="top" style="height: 3em;">\n""";
   if ($.pre_empty > 0) {
      """<td class="emptyday" colspan="$.pre_empty">&nbsp;</td>\n""";
   }
   foreach var YearDay d ($.days) {
       """<td class="calendarday">\n""";
       """<div class="calendardaynum">$d.day</div>\n""";
       if ($d.num_entries > 0) {
           """<div class="calendardaycount"><a href="$d.url">$d.num_entries</a></div>\n""";
       }
       """</td>\n""";
   }
   if ($.post_empty > 0) {
      """<td colspan="$.post_empty">&nbsp;</td>\n""";
   }
   "</tr>";
}

# EntryPage and ReplyPage stuff
function EntryPage::lay_print_pager() {
    if ($.comment_pages.all_subitems_displayed) { return; }
    print "<ul class=\"itemrange\">";
    foreach var int i (1 .. $.comment_pages.total) {
        if ($i == $.comment_pages.current) {
            print "<li class=\"current\">$i</li>";
        }
        else {
            print "<li><a href=\""+$.comment_pages->url_of($i)+"\">$i</a></li>";
        }
    }
    print "</ul>";
}
function EntryPage::print_body() {
    $this->lay_print_entrylite($.entry);
    $this->lay_print_pager();
    $this->print_comments($.comments);
    $this->lay_print_pager();
}
function ReplyPage::print_body() {
    $this->lay_print_entrylite($.replyto);
    """<div id="commentform">""";
    $.form->print();
    """</div>""";
}

function EntryPage::print_comments (Comment[] cs) {
    if (size $cs == 0) { return; }
    """<ul class="comments">\n""";
    foreach var Comment c ($cs) {
        var int indent = ($c.depth - 1) * 25;
        print "<li>";
        $this->print_comment($c);
        $this->print_comments($c.replies);
        println "</li>";
    }
    """</ul>""";
}

# DayPage stuff

function DayPage::lay_print_viewspec() {
    paraphernalia_box_open("daynav",$*i18n_paraphernalia_day_navigation);
    println """<ul>""";
    if ($.prev_url) {
        println """<li><a href="$.prev_url">"""+$.prev_date->date_format()+"""</a></li>""";
    }
    if ($.next_url) {
        println """<li><a href="$.next_url">"""+$.next_date->date_format()+"""</a></li>""";
    }
    println "</ul>";
    paraphernalia_box_close("daynav",$*i18n_paraphernalia_day_navigation);
}
function DayPage::print_body() {
    "<div class=\"day\" id=\""+$.date->date_format("%%yyyy%%%%mm%%%%dd%%")+"\">\n<h2>";
    print $.date->date_format("long");
    "</h2>\n";
    if ($.has_entries) {

        foreach var Entry e ($.entries) {
            $this->print_entry($e);
        }

        "</div>";
    } else {
        """<div class="entry"><div class="entryheader">&nbsp;</div>\n""";
        """<div class="entrycontent"><p>$*text_noentries_day</p></div>\n""";
        """<div class="entryfooter">&nbsp;</div></div>\n""";
    }

}

function print_theme_preview() {
        var int top = ($*title_separator ? 79 : 75);
"""<div style='width: 600px; background: $*clr_sidebar_bg; color: $*clr_sidebar_fg; margin: 0; padding: 0; border: 2px inset; font-family: $*font_body; font-size: 12px;'>
<div style='color: $*clr_title_fg; background-color: $*clr_title_bg; background-image: url("""+palimg_tint("deardiary/titleimages/$*title_pattern", $*clr_title_bg, $*clr_title_pattern)+"""); background-repeat: no-repeat;
            background-position: top right; border-bottom: """+($*title_separator ? "4px solid $*clr_title_separator" : "0")+"""; width: 100%; font-family: $*font_title; height: 75px; overflow: hidden;'>

<h1 style="font-size: 25px; font-weight: bold; margin: 0; padding-top: 20px; padding-left: 8px; white-space: no-wrap;">Frank's LiveJournal</h1>
<div style="font-size: 14px; font-weight: bold; margin: 0; padding-left: 8px; white-space: no-wrap;">Because goats are cool</div>

</div>

<div style='float: left; width: 150px; font-family: $*font_sidebar;'>
<div style='margin-left: 8px; margin-right: 8px;'>
<h2 style="font-size: 12px; font-weight: bold; text-align: left; margin-top: 16px; margin-bottom: 8px;">Sidebar Stuff</h2>
<div style='margin-left: 8px; margin-right: 8px;'>

<p>Blah blah blah</p>

</div>
</div>
</div>

<div style="float: right; width: 440px; background-color: $*clr_page_bg; color: $*clr_page_fg; min-height: 150%; padding: 0 10px 0 0;">

<h2 style='font-size: 16px; font-weight: bold; padding: 0 0 5px 10px; background-image: url("""+palimg_tint("deardiary/headinggrad.png", $*clr_page_bg, $*clr_sidebar_bg)+""");
           background-position: bottom right; background-repeat: no-repeat; margin: 16px 0 8px 0; font-family: $*font_headings'>
Tuenesday 34th Augurary 2615
</h2>

<div style="margin: 32px 16px 32px 26px;">
<div style="font-size: 14px;">
Flobidob Blib Blob Blib
</div>
<p>Praesent id diam ut eros convallis eleifend. Quisque rhoncus, purus a lobortis pellentesque, est erat condimentum elit,
fringilla aliquet diam neque ut leo. Vivamus faucibus magna id magna sollicitudin venenatis. Cras dolor. Vivamus nec
risus. Morbi vitae erat vel ipsum posuere tristique. <span style="color: $*clr_link_normal; text-decoration: underline;">Mauris tincidunt</span>, sem sit amet vulputate dignissim, diam est
adipiscing urna, ut sollicitudin mi dui ultrices quam. Cras in nibh ut nisl ultrices ultrices. Cras turpis massa,
rhoncus sed, dapibus id, iaculis et, mauris. Suspendisse in wisi. Duis at nibh. In laoreet purus id lacus. Ut
nulla est, venenatis eget, auctor sed, pretium a, diam.</p>

</div>

</div>

</div>

<div style="clear: both;">&nbsp;</div>
""";
}