in response to
1101's
comment in
vincel's
s2styles post.
layout previews.
# set commands
# add custom boxes
# add tags, alter metadata printing
# function overrides
# fix width of reply form
# add unique id's to days
# fix date header on day page
# add custom boxes
# fix/alter entry linkbar
# fix/alter comment linkbar
# alter metadata printing
# fix printing of poster info
# alter metadata printing
# fix/alter entry linkbar
# if screened comments, show readlink
# remove border from yearweeks
# make yearmonth headers look like day view headers
# make monthday headers look like day view headers
# add multiform to entrypage
# add subject icon to comments
# add multiform check to comments
# fix/alter comment linkbar
# fix tags page view title
# add my spiffy tags page with day view-like headers
# add custom box
set sidebar_primary = [
[ "userprofile", "", "0", "1" ],
[ "viewlinks", "" ],
[ "calendar" ],
[ "syndicate", "Syndicate" ],
[ "links", "Links" ],
[ "customtext", "", "", ""],
[ "poweredby" ],
];
# add tags, alter mood/music cuz i removed printing of the : in Entry::print_metadata();
set tags_aware = true;
set text_meta_location = "Current Location:";
set text_meta_mood = "Current Mood:";
set text_meta_music = "Current Music:";
function Page::print_custom_head() {
"""
""";
}
function DayPage::print_body() {
# give each day a unique id
# add date-header class to date header
if ($.has_entries) {
var string id = $.date->date_format("day%%yyyy%%%%mm%%%%dd%%");
"""
""";
print $.date->date_format("long");
"""
""";
foreach var Entry e ($.entries) {
$this->print_entry($e);
}
"""
""";
} else {
"""
$*text_noentries_day
""";
}
"""
$*text_day_prev |
$*text_day_next """;
}
function print_module_customtext(string title, string text, string titlelink_url) {
var Page p = get_page();
open_module("customA", "Frank A", "
http://www.livejournal.com/site/goat.bml");
"""""";
close_module();
open_module("customB", "Frank B", "
http://www.livejournal.com/site/goat.bml");
"""""";
close_module();
}
function Entry::print_linkbar() {
var string link_seperator = """ | """; # same as var string sep in Page::print_entry()
# add 's to sep to force them spaces
# initialize array/hashes
var string[] link_keyseq = [""];
var string{} link_url = {"" => ""};
var string{} link_caption = {"" => ""};
var string{} link_image = {"" => ""};
var string print = ""; # var for printing
var Page p = get_page(); # page handle to determine interentry
var bool show_interentry = ($p.view == "entry" or $p.view == "reply"); # if entry/reply view, show interentry
var int keyseq_index = 0; # set index point for new link_keyseq array
if($show_interentry) {
# if show interentry, put previous entry link first
$link_keyseq[$keyseq_index++] = "nav_prev";
# get previous entry link information
var Link prev = $this->get_link("nav_prev");
$link_url{"nav_prev"} = $prev.url;
$link_caption{"nav_prev"} = $prev.caption;
$link_image{"nav_prev"} = $prev.icon.url;
# get next entry link information
var Link next = $this->get_link("nav_next");
$link_url{"nav_next"} = $next.url;
$link_caption{"nav_next"} = $next.caption;
$link_image{"nav_next"} = $next.icon.url;
}
# gather current linkbar
foreach var string link_key ($.link_keyseq) {
var Link link = $this->get_link($link_key);
$link_url{$link_key} = $link.url;
$link_caption{$link_key} = $link.caption;
$link_image{$link_key} = $link.icon.url;
$link_keyseq[$keyseq_index++] = $link_key; # add this to new link_keyseq array
}
if($show_interentry) {
# if show interentry, put next entry link last
$link_keyseq[$keyseq_index++] = "nav_next";
}
#################################################################################################################
# by now, the above hashes should look something like: #
# #
# If interentry: #
# Previous Entry: #
# $link_url{"nav_prev"} =
http://www.livejournal.com/go.bml?journal=exampleusername&itemid=256&dir=prev #
# $link_caption{"nav_prev"} = Previous Entry #
# $link_image{"nav_prev"} =
http://stat.livejournal.com/img/btn_prev.gif #
# #
# Edit Entry: #
# $link_url{"edit_entry"} =
http://www.livejournal.com/editjournal.bml?journal=exampleusername&itemid=256 #
# $link_caption{"edit_entry"} = Edit Entry #
# $link_image{"edit_entry"} =
http://stat.livejournal.com/img/btn_edit.gif #
# #
# Edit Tags: #
# $link_url{"edit_tags"} =
http://www.livejournal.com/edittags.bml?journal=exampleusername&itemid=256 #
# $link_caption{"edit_tags"} = Edit Tags #
# $link_image{"edit_tags"} =
http://stat.livejournal.com/img/btn_edittags.gif #
# #
# Add to Memories: #
# $link_url{"mem_add"} =
http://www.livejournal.com/tools/memadd.bml?journal=exampleusername&itemid=256 #
# $link_caption{"mem_add"} = Add to Memories #
# $link_image{"mem_add"} =
http://stat.livejournal.com/img/btn_memories.gif #
# #
# If interentry: #
# Next Entry: #
# $link_url{"nav_next"} =
http://www.livejournal.com/go.bml?journal=exampleusername&itemid=256&dir=next #
# $link_caption{"nav_next"} = Next Entry #
# $link_image{"nav_next"} =
http://stat.livejournal.com/img/btn_next.gif #
#################################################################################################################
# disable images
$link_image{"nav_prev" } = "";
$link_image{"edit_entry" } = "";
$link_image{"edit_tags" } = "";
$link_image{"mem_add" } = "";
$link_image{"tell_friend"} = "";
$link_image{"nav_next" } = "";
# loop thru linkbar and add links to print var
foreach var string link_key ($link_keyseq) {
# if we can do performed action, url will be present
if($link_url{$link_key} != "") {
$print = $print + """
""";
# if image url available, use it
if($link_image{$link_key} != "") {
$print = $print + """
""";
} else {
# else, just use text
$print = $print + "$link_caption{$link_key}";
}
# add a seperator
$print = $print + "$link_seperator";
}
}
# hack off last seperator
$print = $print->substr(0, $print->length() - $link_seperator->length());
# we're done! let's print it!
print $print;
}
function Comment::print_linkbar() {
var string link_seperator = """ | """; # same as var string sep in Page::print_entry()
# add 's to sep to force them spaces
# initialize array/hashes
var string[] link_keyseq = [""];
var string{} link_url = {"" => ""};
var string{} link_caption = {"" => ""};
var string{} link_image = {"" => ""};
var string print = ""; # var for printing
var int keyseq_index = 0; # set index point for new link_keyseq array
# gather current linkbar
foreach var string link_key ($.link_keyseq) {
var Link link = $this->get_link($link_key);
$link_url{$link_key} = $link.url;
$link_caption{$link_key} = $link.caption;
$link_image{$link_key} = $link.icon.url;
$link_keyseq[$keyseq_index++] = $link_key; # add this to new link_keyseq array
}
#####################################################################################################################################
# by now, the above hashes should look something like: #
# #
# Delete Comment: #
# $link_url{"delete_comment"} =
http://www.livejournal.com/delcomment.bml?journal=exampleusername&id=256 #
# $link_caption{"delete_comment"} = Delete #
# $link_image{"delete_comment"} =
http://stat.livejournal.com/img/btn_del.gif #
# #
# If not frozen: #
# Freeze Comment: #
# $link_url{"freeze_thread"} =
http://www.livejournal.com/talkscreen.bml?mode=freeze&journal=exampleusername&talkid=256 #
# $link_caption{"freeze_thread"} = Freeze #
# $link_image{"freeze_thread"} =
http://stat.livejournal.com/img/btn_freeze.gif #
# #
# If frozen: #
# Unfreeze Comment: #
# $link_url{"unfreeze_thread"} =
http://www.livejournal.com/talkscreen.bml?mode=unfreeze&journal=exampleusername&talkid=256 #
# $link_caption{"unfreeze_thread"} = Unfreeze #
# $link_image{"unfreeze_thread"} =
http://stat.livejournal.com/img/btn_unfreeze.gif #
# #
# If not screened: #
# Screen Comment: #
# $link_url{"screen_comment"} =
http://www.livejournal.com/talkscreen.bml?mode=screen&journal=exampleusername&talkid=256 #
# $link_caption{"screen_comment"} = Screen #
# $link_image{"screen_comment"} =
http://stat.livejournal.com/img/btn_scr.gif #
# #
# If screened: #
# Unscreen Comment: #
# $link_url{"unscreen_comment"} =
http://www.livejournal.com/talkscreen.bml?mode=unfreeze&journal=exampleusername&talkid=256 #
# $link_caption{"unscreen_comment"} = Unscreen #
# $link_image{"unscreen_comment"} =
http://stat.livejournal.com/img/btn_unscr.gif #
#####################################################################################################################################
# disable images
$link_image{"delete_comment" } = "";
$link_image{"freeze_thread" } = "";
$link_image{"unfreeze_thread" } = "";
$link_image{"screen_comment" } = "";
$link_image{"unscreen_comment"} = "";
# loop thru linkbar and add links to print var
foreach var string link_key ($link_keyseq) {
# if we can do performed action, url will be present
if($link_url{$link_key} != "") {
$print = $print + """
""";
# if image url available, use it
if($link_image{$link_key} != "") {
$print = $print + """
""";
} else {
# else, just use text
$print = $print + "$link_caption{$link_key}";
}
# add a seperator
$print = $print + "$link_seperator";
}
}
# hack off last seperator
$print = $print->substr(0, $print->length() - $link_seperator->length());
# we're done! let's print it!
print $print;
}
function Entry::print_metadata() {
var string tags_header = "Current Tags"; # text for tags header, "Current Tags"
var string tags_joiner = ":"; # text for tags joiner, ":"
var string tags_sep = ", "; # text for tags separator, ", "
var bool show_edit_tags_link = false; # set to true if you want edit tags link as tags header
var string currents_open = """
"""; # html for opening of currents container
var string currents_close = """
"""; # html for closing of currents container
var bool loc_after_mood = false; # set to true to print location after mood
var bool vanilla_loc = false; # set to true to delinkify location
var string meta_label_open = """"""; # html for opening of metadata label
var string meta_label_close = """ """; # html for closing of metadata label
var string meta_val_open = ""; # html for opening of metadata value
var string meta_val_close = """
"""; # html for closing of metadata value
var Link edit_tags = $this->get_link("edit_tags"); # helper var to see if remote user can edit tags
if ((size $.metadata > 0) or ((size $.tags > 0) and ($*tags_aware))){
if($.metadata{"mood"} == "" and $loc_after_mood) {
# if we're printing loc after mood but we have no mood, set loc_after_mood to false
$loc_after_mood = false;
}
var string currents = ""; # make var for printing
$currents = $currents_open; # add opening of currents container
foreach var string k ($.metadata){ # step thru metadata
var string text = $k; # set text to key
var string val = $.metadata{$k}; # get val
if ($k == "mood"){ # if mood, set text to mood property
$text = $*text_meta_mood;
if (defined $.mood_icon){ # if we have a mood icon, add it
var Image i = $.mood_icon;
$val = """
$val""";
}
}
elseif ($k == "music") { # if music, set text to music property
$text = $*text_meta_music;
} elseif ($k == "location") { # if location, set text to loc variable
$text = $*text_meta_location;
if($vanilla_loc) { # if vanilla loc, striphtml() it
$val = striphtml($val);
}
}
if(not ($k == "location" and $loc_after_mood)) {
# if we're doing loc right now and printing loc after mood, skip it
# if we're doing loc right now and we're not printing loc after mood, print it now
# if we're not doing loc right now, print this piece of meta
# add the meta
$currents = $currents + """$meta_label_open$text$meta_label_close$meta_val_open$val$meta_val_close""";
}
if($k == "mood" and $loc_after_mood) {
# if we just now did the mood and we're printing loc after mood, print the loc
$k = "location"; # set meta key to "location"
$text = $*text_meta_location; # set text to loc variable
$val = $.metadata{$k}; # get val
# if we have a loc, do stuff
if($val != "") {
# if vanilla loc, striphtml() it
if($vanilla_loc) {
$val = striphtml($val);
}
# add the meta
$currents = $currents + """$meta_label_open$text$meta_label_close$meta_val_open$val$meta_val_close""";
}
}
}
if ((size $.tags > 0) and $*tags_aware) {
var string k = "tags"; # set key to "tags"
var int tcount = 0; # set counter for tags
if($edit_tags.url != "" and $show_edit_tags_link) { # if remote user can edit tags, let's give them a link
$tags_header = """
$tags_header""";
}
# add text, open val container
$currents = $currents + """$meta_label_open$tags_header$tags_joiner$meta_label_close$meta_val_open""";
# build tag list
foreach var Tag t ($.tags) {
$currents = $currents + """
$t.name""";
$tcount++;
# if we haven't hit the last tag, add a separator
if ($tcount != size $.tags) { $currents = $currents + $tags_sep; }
}
# close val container
$currents = $currents + $meta_val_close;
}
# close currents container
$currents = $currents + $currents_close;
# print currents
println "$currents";
}
}
function Page::print_entry(Entry e) {
var string subject = $e.subject != "" ? $e.subject : """$*text_nosubject""";
"
\n";
"""
$subject
""";
"""
""";
var bool showuserpic = $*opt_userpic_main;
if ($.view == "friends") { $showuserpic = $*opt_userpic_friends; }
if ($.view == "entry") { $showuserpic = $*opt_userpic_entrypage; }
if ($showuserpic and defined $e.userpic) {
"""
$e.userpic""";
}
"""
""";
$e->print_metadata();
$e->print_text();
"""
""";
# add 's to sep to force them spaces
var string sep = """ | """;
var bool showtime = $*opt_showtime;
var bool showdate = not $*opt_datehead;
var bool showposter = false;
if ($.view == "friends") { $showposter = true; $showtime = true; }
if ($.view == "day") { $showdate = false; }
if ($.view == "entry" or $.view == "reply") { $showdate = true; }
if (not $e.poster->equals($e.journal)) { $showposter = true; }
"""
""";
if (defined $e.security_icon) {
print """$e.security_icon """;
}
if ($showdate or $showtime or $showposter) {
# add a
here instead of a seperator
# linkbar is too long to not do so
print lang_posted_by_date_and_time($e, $e.poster, $e.journal, $e.time, $showposter, $showdate, $showtime) + "
";
}
"""
$*text_permalink$sep""";
$e->print_linkbar();
if ($.view != "reply") {
if ($e.comments.enabled) {
" $sep "; $e.comments->print_postlink();
}
}
if ($.view != "entry") {
if (($e.comments.count > 0) or $e.comments.screened) {
" $sep "; $e.comments->print_readlink();
if($e.comments.screened) {
" w/ screened";
}
}
}
"""
""";
}
function YearWeek::print() {
"""
""";
if ($.pre_empty > 0) {
"""
\n""";
}
foreach var YearDay d ($.days) {
"""
$d.day""";
if ($d.num_entries > 0) {
"""
$d.num_entries""";
}
"""
""";
}
if ($.post_empty > 0) {
"""
""";
}
"""
""";
}
function YearPage::print_month(YearMonth m) {
if (not $m.has_entries) { return; }
var string id = "anchor$m.month";
var string title = $m->month_format();
var string url = $m.url;
"""
""";
print """
$title""";
"""
""";
"""
""";
foreach var int d (weekdays()) {
"""
$*lang_dayname_short[$d]
""";
}
"""
""";
foreach var YearWeek w ($m.weeks) {
$w->print();
}
"""
""";
}
function MonthPage::print_body {
var string id = "";
var string text = "";
var string url = "";
"""
""";
foreach var MonthDay d ($.days) {
if ($d.has_entries) {
$id = $d.date->date_format("anchor%%yyyy%%%%mm%%%%dd%%");
$text = lang_ordinal($d.day);
$url = $d.url;
"""
$text """;
$d->print_subjectlist();
"""
""";
}
}
}
function EntryPage::print_body() {
# let's toss in the multiform stuff
$this->print_entry($.entry);
if ($this.multiform_on) {
$this->print_multiform_start();
}
"""
$*text_comments
""";
foreach var Comment c ($.comments) {
$this->print_comment($c);
}
"""
""";
if ($this.multiform_on) {
$this->print_multiform_actionline();
$this->print_multiform_end();
}
}
function EntryPage::print_comment(Comment e) {
if (not $e.full) {
# Collapsed mode
"
\n";
"""
""";
var string subject = $e.subject;
if ($subject == "") { $subject = $*text_nosubject; }
"""
$subject - """;
print lang_posted_by_date_and_time($e, $e.poster, $e.journal, $e.time, true, true, true) + "
";
"""
""";
return;
}
"
\n";
if ($e.subject != "") {
"""
$e.subject
""";
}
if ($*opt_userpic_comments and defined $e.userpic) {
"""
$e.userpic""";
}
"""
""";
$e->print_text();
"""
""";
# add 's to sep to force them spaces
var string sep = """ | """;
# add subject icon, just like security icon in entries
if (defined $e.subject_icon) {
print """$e.subject_icon """;
}
print lang_posted_by_date_and_time($e, $e.poster, $e.journal, $e.time, true, true, true) + "
";
# let's toss in the mass action select box after a seperator
if ($.multiform_on) {
"""$sep$*text_multiform_check """;
$e->print_multiform_check();
}
# add a
here instead of a seperator
# linkbar is too long to not do so
"
";
"
$*text_permalink";
# better support for reply/parent/thread links
# re-order links
var string parent = $e.parent_url != "" ? """$sep
$*text_comment_parent""" : "";
var string thread = $e.thread_url != "" ? """$sep
$*text_comment_thread""" : "";
var string reply = " $sep " + (((not $e.frozen) and ($e.reply_url != "")) ? """
$*text_comment_reply""" : $*text_comment_frozen);
"$parent$thread$reply";
# add delete/[un]screen/[un]freeze links, kick to next line as to decrease accidental deletion/etc of comments
"
";
$e->print_linkbar();
"";
if (size($e.replies) > 0) {
println """
""";
foreach var Comment c ($e.replies) {
$this->print_comment($c);
}
println "";
}
"";
}
function TagsPage::view_title() : string {
return "Tags Page";
}
function TagsPage::print_body() {
var string text = "Visible Tags";
"""
$text
""";
var string content = "";
var string[] security_order = ["public"];
var int security_index = 1;
if(viewer_is_owner()) {
$security_order[$security_index++] = "private";
$security_order[$security_index++] = "group";
}
if(viewer_logged_in()) {
$security_order[$security_index++] = "friends";
}
var int colspan = viewer_is_owner() ? 3 : 2;
var string{} security_labels = {
"public" => """
""",
"private" => """
""",
"friends" => """
""",
"group" => """
"""
};
var string{} security_headers = {
"public" => "Public",
"private" => "Private",
"friends" => "Protected",
"group" => "Group"
};
$content = $content + """\n\n Tag \n""" + (viewer_is_owner() ? """ Total \n""" : "");
foreach var string security($security_order) {
$content = $content + """ $security_headers{$security} \n""";
}
$content = $content + "\n";
foreach var TagDetail td ($.tags) {
var int security_count = 0;
var int group_count = $td.use_count;
var string uses = (viewer_is_owner() ? ("""$td.use_count""") : "");
foreach var string security($security_order) {
$security_count = $security != "group" ? $td.security_counts{$security} : $group_count;
$uses = $uses + """$security_count""";
$group_count = $group_count - $security_count;
}
$content = $content + """$security_labels{$td.visibility}
$td.name$uses\n""";
}
$content = $content + "";
print $content;
"""
""";
}