?

Log in

No account? Create an account
[theme] - [generator] - [k1ified print_entry() (v2.0)] - S2 Layers [entries|archive|friends|userinfo]
S2 Layers

[ website | advanced customization ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| how to post tags page ]
[affiliated communities| fblayers ]

[theme] - [generator] - [k1ified print_entry() (v2.0)] [Jan. 4th, 2006|09:48 pm]
S2 Layers

s2layers

[kunzite1]
[Tags|, , , , , , , , ]

function Page::print_custom_head() {
"""
<style type="text/css">
td.comments {
  white-space: nowrap;
}
</style>
""";
}

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       = """<table cellspacing="0" cellpadding="0" border="0" summary="">"""; # html for opening of currents container
  var string currents_close      = """</table><br />"""; # 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     = """<tr><td class="meta">[</td><td class="meta" align="right"><b>"""; # html for opening of metadata label
  var string meta_label_close    = """</b></td><td class="meta" align="center">|</td>"""; # html for closing of metadata label
  var string meta_val_open       = """<td class="meta">"""; # html for opening of metadata value
  var string meta_val_close      = """</td><td class="meta">]</td></tr>"""; # 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        = """<img src="$i.url" width="$i.width" height="$i.height" align="middle" alt="$val" title="$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 = """<a href="$edit_tags.url">$tags_header</a>""";
      }

      # 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 + """<a rel="tag" href="$t.url">$t.name</a>""";
        $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 + """<a href="$link_url{$link_key}">""";
      # if image url available, use it
      if($link_image{$link_key} != "") {
        $print = $print + """<img src="$link_image{$link_key}" alt="$link_caption{$link_key}" title="$link_caption{$link_key}" border="0" />""";
      } else {
        # else, just use text
        $print = $print + "$link_caption{$link_key}";
      }
      # add a seperator
      $print = $print + "</a>$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 : """<i class="nosubject">$*text_nosubject</i>""";
  var string datetime              = $e.time->date_format("med")+"|<b>" + $e.time->time_format() + "</b>";

  """
  <table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
    <tr align="left">
      <td bgcolor="$*stronger_back" align="center">
        <table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
          <tr align="left">
            <td>
              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td class="caption">""";

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

  """$subject</td>
                  <td align="right" class="index">[$datetime]</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr align="left">
          <td colspan="2" bgcolor="$*entry_back">""";

  if ($show_userpic or $show_poster or $show_journal) {
    """
            <table cellpadding="1" align="right" cellspacing="0" border="0" summary="">
              <tr align="left">
                <td bgcolor="$*stronger_back">
                  <table cellpadding="2" align="center" cellspacing="0" border="0" summary="">
                    <tr align="left">
                      <td bgcolor="$bgcolor" align="center">""";
    if($show_userpic) {
      print "$e.userpic<br />";
    }
    if($show_journal) {
      var string journal_base = $e.journal->base_url();
      """
                       <a href="$journal_base/" style="color: $fgcolor;">$e.journal.username</a><br />""";
    }
    if($show_poster) {
      var string poster_base = $e.poster->base_url();
      """
                       [<a href="$poster_base/" style="color: $fgcolor;">$e.poster.username</a>]""";
    }
  }
  """
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>""";

  if (not $hide_text) {
    """<div class="entrytext">""";
    $e->print_metadata();
    $e->print_text();
    """</div>""";
  }
  """
          </td>
        </tr>
        <tr bgcolor="$*weak_back">
          <td>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                <td align="left" class="comments">
                  <a href="$e.permalink_url">$*text_permalink</a>
                </td>
                <td align="right" class="comments">"""; $e.comments->print(); $e->print_linkbar(); "</td>";
  """
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table><p>""";

} # 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();
    """
    <table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
      <tr align="left">
        <td bgcolor="$*stronger_back" align="center">
          <table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
            <tr align="left">
              <td class="caption" colspan="2">Comments:</td>
            </tr>
            <tr align="left">
              <td colspan="2" bgcolor="$*entry_back">""";

    $.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();
    """
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table><p>""";

    if ($this.multiform_on) {
      """
    <table width="$*box_width" cellpadding="2" cellspacing="0" border="0" summary="" class="entrybox">
      <tr align="left">
        <td bgcolor="$*stronger_back" align="center">
          <table width="100%" cellpadding="5" cellspacing="0" border="0" summary="">
            <tr align="left">
              <td class="caption" colspan="2">Mass Action:</td>
            </tr>
            <tr align="left">
              <td colspan="2" bgcolor="$*entry_back">""";
      $this->print_multiform_actionline();
      """
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table><p>""";
      $this->print_multiform_end();
    }
  }
}
linkReply

Comments:
From: ghostno
2006-01-05 08:02 am (UTC)
Very cool! Only one thing, the border around the user picture changes when you go into the entry proper. It has a white border on recent entries but red when you go into the actual entry.

(And I still don't know how to make my entry text smaller :P though that's more because I'm me.)

Excellent otherwise :D
(Reply) (Thread)
[User Picture]From: kunzite1
2006-01-05 08:10 am (UTC)

added EntryPage::print_body().

add some css to Page::print_custom_head() using the div.entrytext selector to isolate the entry text.
(Reply) (Parent) (Thread)
From: ghostno
2006-01-05 08:30 pm (UTC)
Hmmm.

I'm currently fiddling with it. How do you change the text for 'Edit Tags', 'Edit Entry', and 'Add To Memories'?

(I'm also searching the community memories.)
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-01-05 09:10 pm (UTC)

see the $link_image{"string"} stuffs in Entry::print_linkbar()?

add stuffs like:
$link_caption{"edit_entry"} = "Edit";
(Reply) (Parent) (Thread)
From: ghostno
2006-01-06 12:50 am (UTC)
Yays, I've tweaked it :) Success!

Only a few questions though.

I've made a practice post so you can see the layout of it.

1. The font size in the entry is bigger than the font everywhere else, how can I make it the same size as the links?

2. How do I make the title of the post permanently capitals (can that be done)?

3. How do I get rid of the title of the post appearing at the top of the page every time I go into a link? (I already have the title in the entry I don't need it at the top of the page.)
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-01-06 08:53 am (UTC)

1. add the following to Page::print_custom_head():
.entrytext {
  font-size: 8pt;
}
2. add the following to Page::print_custom_head():
.caption {
  text-transform: uppercase;
}
3. add the following to the end of the layer:
function EntryPage::title() : string {
  return $.global_title != "" ? $.global_title : $.journal.name;
}
(Reply) (Parent) (Thread)
From: ghostno
2006-01-06 08:04 pm (UTC)
Outstanding!

Only one more thing (I hope). How do I remove the 'LINKS' caption (the white one)? It seems kind or redundant to have it say 'links' twice - the black text better matches the header.
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-01-06 08:19 pm (UTC)

grab the code for Page::print_linklist from the generator source code, put it into your layer, compile, remove the first instance of <b>Links</b>.
(Reply) (Parent) (Thread)
From: ghostno
2006-01-06 10:43 pm (UTC)
Did it, to grand result... only to discover that the comments, month (I managed to fix the calendar text by guess work) revert back to that horrible large text, and the comment captions don't stay in capitals.

I tried copying part of the code from the source code but I must have picked the wrong part as it didn't make any difference - help! (I hope this isn't harrassment, btw.)
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-01-06 10:52 pm (UTC)

might just need a css hack to do the font-size stuffs:
body, td {
  font-size: 8pt;
}
(Reply) (Parent) (Thread)
From: ghostno
2006-01-06 11:32 pm (UTC)
Oh no, that's done it - it now looks a million times better - THANK YOU :)

I (cross-fingers) hope this is the last thing. How do I get the comment titles in caps? Is that possible.
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-01-06 11:36 pm (UTC)

should be:
table.entrybox tr td table tr td div div table tr td h3 {
  text-transform: uppercase;
}
(Reply) (Parent) (Thread)
From: girlboheme
2006-08-12 10:30 pm (UTC)
This is wonderful. But I can't take the user pic out of the recent entries page.

I also wanted to use the option of having the mood theme icon in front of the meta, so I took the one you made for boxer and stuck it in. It works great but when I put false for the userpics on recent entries page, it skews the meta across the top.

Is it possible to have this without a recent entry user pic as well as mood theme icon to the left of meta?

Thanks for your help and your wonderful code :)

(Reply) (Thread)
[User Picture]From: kunzite1
2006-08-13 03:42 am (UTC)
the following should do it with no problems:
var bool   show_recent_userpics  = false;
provided that the other code you used isn't hosed.
(Reply) (Parent) (Thread)
From: girlboheme
2006-08-13 05:01 am (UTC)
well, I used your code from the boxer set for putting the mood icon before the meta data.

This is what it looks like when I change it to false, which was my problem:


  


So, I guess, what I am wondering is how can I contain that box in the table? I couldn't use the generator code for placing the mood icon in front of the meta because there isn't one and I've not got the experience to write my own. I tried. And I had hoped that since the boxer one worked with the icon there, that it would also work with the icon taken out. But it doesn't.

Thanks. If you need my code, here it is:
http://www.modelhommes-forum.com/lj/codes.txt
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-08-13 05:22 am (UTC)
since my LJ access is limited, i'd appreciated it if you went to component_help and found the "make layer code viewable" link on the right side and followed those instructions about your layer code. thanks!
(Reply) (Parent) (Thread)
From: girlboheme
2006-08-13 05:26 am (UTC)
Wow, thanks, I didn't know how to do that. Very helpful.

This should be my layer number: 7057229
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-08-15 07:02 am (UTC)

(Reply) (Parent) (Thread)
From: soup_nazi
2007-04-06 05:15 pm (UTC)
Is there any way that I can remove the "track this" image and replace it with text?

(Reply) (Thread)
[User Picture]From: kunzite1
2007-04-06 05:18 pm (UTC)
try the following:
  $link_image{"nav_prev"   }      = "";
  $link_image{"mem_add"    }      = "";
  $link_image{"edit_entry" }      = "";
  $link_image{"edit_tags"  }      = "";
  $link_image{"tell_friend"}      = "";
  $link_image{"watch_comments"}   = "";
  $link_image{"unwatch_comments"} = "";
  $link_image{"nav_next"   }      = "";
(Reply) (Parent) (Thread)
From: soup_nazi
2007-04-06 05:29 pm (UTC)
$link_image{"watch_comments"} = ""; worked perfectly. Thanks!!
(Reply) (Parent) (Thread)
[User Picture]From: agneson9
2008-08-19 06:25 pm (UTC)
1. ALWAYS striphtml from Location
2. Change from TEXT to IMAGE linkbar's '#comments', 'leave a comment' 'permalink'
3. Enable ljuser icons in the userinfo
4. Remove or retool the section below the navlinks but about the entries.
(Reply) (Thread)
[User Picture]From: agneson9
2008-08-19 06:26 pm (UTC)
What changes should I make if I want to

1. ALWAYS striphtml from Location
2. Change from TEXT to IMAGE linkbar's '#comments', 'leave a comment' 'permalink'
3. Enable ljuser icons in the userinfo
4. Remove or retool the section below the navlinks but about the entries.

?
(Reply) (Parent) (Thread)