Possibly useful bugfixes and tweaks - Wide Lines






[livredor]
widelines
11:10 am on Monday, March 27th, 2006
Possibly useful bugfixes and tweaks
Previous Entry Next Entry


Uh, hi guys. *looks round nervously*

With the recent LJ code changes, there are a couple of bugs in the current version of Widelines, and a couple of features available in S2 that haven't been incorporated yet. So I've had a go at tweaking the layout to fix these things, plus add a couple of features from other layouts that I like. There may well be better ways to do these things, but I'm hoping my attempts might be a useful starting point.

The most critical issue is that voiceposts (what used to be called phone posts) break page display because they're incompatible with what used to be the standard way of printing entry text. The fix for this is to replace print $e.text with $e->print_text()

So, in function lay_print_thisentry, you need:
# Print entry
"""<div class="entry">""";
$e->print_text();
"""</div><p />""";


Props to kunzite1 who figured out this bug and explained in very clear terms how to fix it!
More minor things: S2 now supports time zones for comments. I've changed function EntryPage::print_comment to take advantage of this feature in S2 Core, like so:
# Print poster, date, IP address

"""<td><table style="width: 100%">
<tr><td align="left" style="width: 50%">
<table>
<tr><th align="right">$*text_comment_from</th><td>$poster</td></tr>
<tr><th align="right">$*text_comment_date</th><td style="white-space: nowrap">""";
print $c->time_display("long", "short");
"""</td></tr>""";
if ($c.metadata{"poster_ip"})
{
"""<tr><th align="right">$*text_comment_ipaddr</th><td>(""" + $c.metadata{"poster_ip"} + """)</td></tr>""";
}
"""</table></td>""";


The general princple is that print $c.time becomes print $c->time_display, with appropriate variables for the date and time. Note that if a user is in a different timezone, it might change the day of posting as well as the time, so you need both in the function. My code is loosely based on alsatia's fix for her Gradient Strip style, which I altered to show the date and time in a format consistent with Widelines.
The way Widelines handles CSS in function Page::print is fantastic! But there's one thing lacking, in my view, namely the equivalent of S1's GLOBAL_HEAD. I want this feature, not only because I started out as an S1 person, but also because one often needs global CSS rules as well as page-specific ones. And because sometimes it's good to put custom stuff in the <head> other than CSS. For example, in my version I specify rules for the appearance of blockquotes and quoted material, and those apply in general, so repeating the same rules on every page is silly. And I have <meta> tags to identify my journal's location for GeoURL.

Anyway, I take no credit for this "fix", I just used something that's already available in the base S2 code, just incorporated it into the Widelines layout. Namely, the lovely function: print_custom_head. So it's in function Page::print (). After the end of the stylesheet, I added:
$this->print_custom_head();
Finally, a couple of little things that I feel enhance the entry printing function. I like the poster userpic to link to the poster's userinfo, but some people expect it to link it to the pics page. So, within function Page::print ():
# Print entry's icon and link it to poster's info
<a href=\"""";
print $e.poster->base_url();
"""/info\">
<img align=$subject_align src="$entrypic.url" width="$entrypic.width" height="$entrypic.height" alt="" border="0"></a>""";


Or, for the link to the userpics page:
# Print entry's icon and link it to poster's userpics page
<a href=\"$*SITEROOT/allpics.bml?user=$e.poster.username><img align=$subject_align src="$entrypic.url" width="$entrypic.width" height="$entrypic.height" alt="" border="0"></a>""";


Widelines doesn't seem to have an easy way to link directly to the entry, if there are no comments and no LJ-cut. There are various ways to do this but I find it aesthetic to use the entry subject as a link, thus:
# Print subject and make it a permalink
if ($e.subject)
{
"""
<div class="entry_title"><a href="$e.permalink_url">$e.subject</a></div>
""";
}

else
{
"""
<div class="entry_title"><a href="$e.permalink_url">&lt;untitled&gt;</a></div>
""";
}


Mainly because you can do it in S1, I find it convenient to have the option to make protected entries appear differently from public ones. I've done this with an empty <div> which I then style using CSS. I know some people hate non-semantic divs, but I find this convenient, so:
# Print invisible div in front of locked text to allow CSS to alter appearance of locked entries if desired
if ($e.security)
{
"<div class='protected_entry_wrap'>";
}


# Print entry, making sure not to break entries with voiceposts
"""<div class="entry">""";
$e->print_text();
"""</div><p />""";

if ($e.security)
{"</div>";
}



Many thanks to cmshaw for writing and maintaining Widelines, and especially for writing such clear code which is easy for a non-programmer like me to tweak! If I knew what I was doing better I could contribute more, but I'm hoping this stuff might be useful to some, especially the fix for the broken Voice posts.

Oh, and if it helps to see all this code in action, my theme layer is available. Though my theme layer contains a lot of other junk too, so might not be the clearest.


Mood: helpful
Music: Beth Orton: Pieces of sky

Previous Entry Next Entry




Post a comment
View all comments chronologically



cmshaw: L33t Girl
From:cmshaw
Date:March 27th, 2006 - 07:56 pm
(Link)
Thank you, livredor! This is fantastic.
(Reply to this comment) (Thread on this comment)



Post a comment
View all comments chronologically