Elvish Wanderer (aelana) wrote in s2component,
Elvish Wanderer
aelana
s2component

Override blitz...

Ok time to further my exploration of s2 and mangling of component :) *chuckle*

I wanted to be able to have two "different" kind of entries on my Recent and Day view...
I wanted to be able to format an entry where the title ends up in the top area instead of the date/time and remove things like the user icon and the like (for announcements, see http://www.livejournal.com/users/aelana at the top -- the welcome message is a forward-dated message that is set using the code below to an announcemnt).
The other was a hidden entry that doesn't show up on the recent or day views, but can be linked to explicitly.

While musing about how to code this I noticed in xevinx's journal that he was thinking about doing it by date but that didn't seem right or generic enough for me (i want to be able to randomly do them throughout my journal not just at the top and bottom)... so I settled on doing it based on two special moods...

The code below overwrites the print_entry function in the RecentPage and DayPage (and FriendsPage, just to change it back for the Friends Page) so that if an entry has the mood "special/announcement" it is formatted like an announcement, and if it is "special/hidden" it hides it... if you tack "?.unmask=true" it will display all the events "normally" (so you can do things like find out links for hidden entries, etc)...

Enjoy.

(note - I couldn't override in the ReplyPage and EntryPage for some reason, so this formatting does not carry over to those... also your friends will not see the special formatting, so changes are you will want to set backdate on entries that you do this to so it doesnt go to their friends' pages)
(also note - this does not do anything with poster name etc, so it may need tweaking for community and shared journal use - or not depending on who/why you want to use it)


function DayPage::print_entry(Entry e) {
  var Color fg;
  var Color bg;

  if (($e.metadata{"mood"} == "special/announcement") and ($.args{"unmask"} != "true")) {
    print_entry_header("<b>$e.subject</b>");
    print_system_box_top();
    print_content_top();
    print $e.text;
    print_content_bottom();

    if ($e.comments.enabled) {
      if (not ($e.comments.count == 0)) {
        """<div class="entryComments">""";
        $e.comments->print_readlink();
        """ """;
        print $*comment_divider;
        """ """;      
      }
      $e.comments->print_postlink();
      """</div>""";
    }

    print_system_box_bottom();
    print_spacer();
  } elseif ((not ($e.metadata{"mood"} == "special/hidden")) or ($.args{"unmask"} == "true")) {
    print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);  
  }
}

function RecentPage::print_entry(Entry e) {
  var Color fg;
  var Color bg;

  if (($e.metadata{"mood"} == "special/announcement") and ($.args{"unmask"} != "true")) {
    print_entry_header("<b>$e.subject</b>");
    print_system_box_top();
    print_content_top();
    print $e.text;
    print_content_bottom();

    if ($e.comments.enabled) {
        """<div class="entryComments">""";
      if (not ($e.comments.count == 0)) {
        $e.comments->print_readlink();
        """ """;
        print $*comment_divider;
        """ """;      
      }
      $e.comments->print_postlink();
      """</div>""";
    }

    print_system_box_bottom();
    print_spacer();
  } elseif ((not ($e.metadata{"mood"} == "special/hidden")) or ($.args{"unmask"} == "true")) {
    print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);  
  }
}


function FriendsPage::print_entry(Entry e) {
  print_entry($this, $e, $.friends{$e.journal.username}.bgcolor, $.friends{$e.journal.username}.fgcolor, false);
}
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 22 comments