[theme] - [generator] - [k1ified print_entry() (v2.0)]

Jan 04, 2006 21:48


function Page::print_custom_head() {
"""

""";
}

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

# 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 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 = $.comments.enabled ? $link_seperator: ""; # 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 #
#################################################################################################################

$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 Page::print_entry (Entry e) {
var Color bgcolor = "#ffffff";
var Color fgcolor = "#000000";

if($this isa FriendsPage) {
var FriendsPage fp = $this as FriendsPage;
var Friend f = $fp.friends{$e.journal.username};
$bgcolor = $f.bgcolor;
$fgcolor = $f.fgcolor;
}

print_entry($this, $e, $bgcolor, $fgcolor, false);
}

function print_entry (Page p, Entry e, Color bgcolor, Color fgcolor, bool hide_text) {
var bool show_recent_userpics = true;
var bool show_friends_userpics = true;
var bool show_day_userpics = true;
var bool show_entry_userpics = true;
var bool show_reply_userpics = true;

var bool show_userpic = defined $e.userpic and
(
($p.view == "recent" and $show_recent_userpics) or
($p.view == "friends" and $show_friends_userpics) or
($p.view == "day" and $show_day_userpics) or
($p.view == "entry" and $show_entry_userpics) or
($p.view == "reply" and $show_reply_userpics)
);
var bool show_poster = ($p.view == "friends") or (not $e.poster->equals($e.journal));
var bool show_journal = ($p.view == "friends") and (not $e.poster->equals($e.journal));
var string subject = $e.subject != "" ? $e.subject : """$*text_nosubject""";
var string datetime = $e.time->date_format("med")+"|" + $e.time->time_format() + "";

"""

""";

if ($e.security != "") {
$subject = "$e.security_icon $subject";
}

"""$subject
[$datetime]

""";

if ($show_userpic or $show_poster or $show_journal) {
"""

""";
if($show_userpic) {
print "$e.userpic
";
}
if($show_journal) {
var string journal_base = $e.journal->base_url();
"""
$e.journal.username
""";
}
if($show_poster) {
var string poster_base = $e.poster->base_url();
"""
[ $e.poster.username]""";
}
}
"""

""";

if (not $hide_text) {
"""
""";
$e->print_metadata();
$e->print_text();
"""""";
}
"""

$*text_permalink

"""; $e.comments->print(); $e->print_linkbar(); "";
"""

""";

} # print_entry(Page,Entry,Color,Color,bool)

function EntryPage::print_body() {

$this->print_entry($.entry);

if ($.entry.comments.enabled and $.comment_pages.total_subitems > 0) {
$this->print_multiform_start();
"""

Comments:

""";

$.comment_pages->print();

set_handler("unscreen_comment_#", [
[ "style_bgcolor", "cmtbar#", "$*comment_bar_one_bgcolor", ],
[ "style_color", "cmtbar#", "$*comment_bar_one_fgcolor", ],
]);
set_handler("screen_comment_#", [
[ "style_bgcolor", "cmtbar#", "$*comment_bar_screened_bgcolor", ],
[ "style_color", "cmtbar#", "$*comment_bar_screened_fgcolor", ],
]);

$this->print_comments($.comments);
$.comment_pages->print();
"""

""";

if ($this.multiform_on) {
"""

Mass Action:

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

""";
$this->print_multiform_end();
}
}
}

function print_entry, class entry, function print_linkbar, function print_body, function print_metadata, class page, class entrypage, function print_custom_head, layout generator

Previous post Next post
Up