in response to
dancingyel's
s2haven post.
set tags_aware = true;
set text_meta_location = "Current Location:";
set text_meta_mood = "Current Mood:";
set text_meta_music = "Current Music:";
function CommentInfo::print_readlink() {
var string img_url = "";
var int img_width = 0;
var int img_height = 0;
var bool img_count = false;
if($.show_readlink) {
var Page p = get_page();
var string url = $.read_url;
var string text = get_plural_phrase($.count, "text_read_comments" + ($p.view == "friends" ? "_friends" : ""));
if($.screened) {
$text = $text + " " + $*text_month_screened_comments;
}
if($url != "") {
"""
""";
}
if($img_url != "") {
if($img_count) {
print $.count;
}
"""
""";
} else {
print $text;
}
if($url != "") {
"""""";
}
}
}
function CommentInfo::print_postlink() {
var string img_url = "";
var int img_width = 0;
var int img_height = 0;
if($.show_postlink) {
var Page p = get_page();
var string url = $.post_url;
var string text = get_plural_phrase(0, "text_post_comment" + ($p.view == "friends" ? "_friends" : ""));
if($.maxcomments) {
$url = "";
$text = $*text_max_comments;
}
if($url != "") {
"""
""";
}
if($img_url != "") {
"""
""";
} else {
print $text;
}
if($url != "") {
"""""";
}
}
}
function CommentInfo::print() {
var string text_comment_divider = " | ";
if($.show_readlink) {
$this->print_readlink();
if($.show_postlink) {
print $text_comment_divider;
}
}
if($.show_postlink) {
$this->print_postlink();
print $text_comment_divider;
}
}
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
# if you need data specific to the meta to be in these strings you'll have to set those individually down further
# one example is provided with meta_label_open
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
# in this layout, each piece of meta gets its own class
$meta_label_open = """
""";
# 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);
}
# in this layout, each piece of meta gets its own class
$meta_label_open = """
""";
# 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"
# in this layout, each piece of meta gets its own class
$meta_label_open = """
""";
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 Entry::print_linkbar() {
var string link_seperator = " | "; # seperator for links
# 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{"mem_add" } = "";
$link_image{"edit_entry" } = "";
$link_image{"edit_tags" } = "";
$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 print_entry(Page p, Entry e, Color bgcolor, Color fgcolor, bool viewing_thread) {
var string entry = "";
var bool have_meta = (size ($e.metadata) > 0);
var bool have_tags = ($*tags_aware and (size ($e.tags) > 0));
# Named anchor to link from page summary
$entry = $entry + """""";
$entry = $entry + """
""";
var string subject = $e.subject != "" ? $e.subject : $*text_nosubject;
var string time = $e.time->time_format();
$entry = $entry + """$e.security_icon $subject @ $time
""";
$entry = $entry + """
""";
# build poster info
if(
(
$p.view == "friends" or
(not $e.poster->equals($e.journal)) or
($*show_entry_userpic and defined $e.userpic)
)
) {
if ($p.view == "friends") {
if (defined $e.userpic) {
$entry = $entry + """
""";
}
if (not $e.poster->equals($e.journal)) {
$entry = $entry + $e.poster->as_string() + ", posting in ";
}
$entry = $entry + $e.journal->as_string() + ":
";
} elseif (not $e.poster->equals($e.journal)) {
if (defined $e.userpic) {
$entry = $entry + """
""";
}
$entry = $entry + $e.poster->as_string() + ":
";
} elseif (defined $e.userpic) {
$entry = $entry + """
""";
}
}
# print what we've got and clear it
print $entry;
$entry = "";
# print metadata
$e->print_metadata();
# if we have meta or tags, add a line break
if ($have_meta or $have_tags) {
$entry = "$entry
";
}
# print what we've got and clear it
print $entry;
$entry = "";
# if we're not viewing a thread, print entry text
if (not $viewing_thread) {
$e->print_text();
}
# add some more blank lines
$entry = $entry + """
""";
$entry = $entry + "";
# Comments
$entry = $entry + """
""";
# print what we've got and clear it
print $entry;
$entry = "";
$e.comments->print();
$e->print_linkbar();
# close entry div
$entry = $entry + "";
$entry = $entry + "";
# print what we've got and clear it
print $entry;
$entry = "";
}