As is the case with the original tutorial, this code has a few limitations. I only wanted to make hidden entries, so I didn't play around much with the creation of "announcements". As a result, I don't know how to customize it as much as I would like to, but maybe in the future I'll get around to toying with it. Anyway, please make note of the following:
- formatting does not carry over to ReplyPage or EntryPage, so any special annoucements will be indistinguishable from regular entries & hidden entries will be visible
- people on your friends page will not see any of the special formatting, so unless you want the entries viewable from other people's friends pages, make sure the entry is backdated
- The special "announcement" entry type does not print any user information (including userpics & metadata), so it is likely that this code will need to be tweaked depending on who uses it
The tag names that you want to use to "activate" the special formatting can be set to whatever you want; I have indicated what you need to change in red. In the code, the two tags are "announcement" & "hidden". Hidden entries can be linked to explicitly, but will not be viewable on recent entries pages or day pages UNLESS you add the argument "?.unmask=true" to the end of the page URL. Announcement entries do not display a date; in the place where the date & security icon would be in a normal layout, the subject is there instead.
function Page::print_entry(Entry e) {
# If the page is a Recent Page or a Day Page do this
if($this instanceof RecentPage or $this isa DayPage) {
var Color fg;
var Color bg;
var bool tags_match = false;
var bool tags_hide = false;
# Determines if tags are used in the entry and if the tags used are special
if ((size $e.tags > 0) and $*tags_aware) {
foreach var Tag t ($e.tags) {
if (($t.name == "announcement") and ($.args{"unmask"} != "true")) {
$tags_match = true;
}
if (($t.name == "hidden") and ($.args{"unmask"} != "true")) {
$tags_hide = true;
}
}
# Prints the entry in the announcement format if the appropriate tag was used and unmask=false
if ($tags_match == 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();
}
# Prints entries regularly unless the tag to hide entries was used or unmask=true
elseif (($tags_hide == false) or ($.args{"unmask"} == "true")) {
print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);
}
}
elseif (size $e.tags == 0) {
print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);
}
}
# If the page is a Friends Page print entries normally
if($this instanceof FriendsPage) {
var FriendsPage fp = $this as FriendsPage;
print_entry($this, $e, $fp.friends{$e.journal.username}.bgcolor, $fp.friends{$e.journal.username}.fgcolor, false);
}
}
Edit: I fixed a bug that made entries without tags hidden.