nameandnature: Giles from Buffy (Default)
[personal profile] nameandnature
Some of you customise your journal's appearance using LiveJournal's S2 system. The whole thing looks a bit baroque, with much mentioning of "layers", so I thought I'd just ask questions of people who might know how to do what I want.

I have a thingy which generates an Atom feed from the comments on each of public postings (by "thingy" I mean a couple of Python scripts, one of which is a heavily modified version of ljdump and the other of which is a script which generates the feeds using the dumped information. I might publish them if anyone's interested). Proper blogs have these feeds, so I thought mine should too.

I would like to make people's browsers aware of the feed when viewing an entry, which means sticking some extra <link> elements into the <head> element of the entry view. I'd also like to link to the feed somewhere on the entry page, probably in the little list of stuff you can do with the entry (you know, permalink, write a comment, add to memories, denounce, and so on). The link would reference http://www.noctua.org.uk/paul/lj/feeds/nnnn.xml, where nnnn is the unique number which LJ puts in the permalink to the entry itself (for example, this entry's number is 83644).

At some stage the script is also going to produce a single feed of all comments on my public postings (and maybe all my comments on your public postings, if you don't object). So I'd also like to know how to stick stuff in the <head> of the entire journal view (which already links to the Atom feed of my postings which LJ generates itself).

Any help you can give in telling me where to start with this stuff would be much appreciated.

Date: 2008-04-29 11:11 pm (UTC)
liv: cartoon of me with long plait, teapot and purple outfit (bunneh)
From: [personal profile] liv
OK, the actual process of getting to a point where you can even get into the code is far more of a pain than it should be. This tutorial is probably a starting point.

To put extra links in the <head> you want to create a function called function Page::print_custom_head(). Once you have a theme layer open in the layer editor, you can just define the function there. After that the syntax is {"""<a href="">""";}. You can't put any scripting language there, but if it's just a link to a page generated by your Python somewhere else, that should be fine. You don't have to rewrite the whole <head> section, just include any additional lines you want to go in there and let the layout layer handle the rest of it.

Adding links to the linkbar is possible, but as a non-programmer I find it quite difficult. Essentially LJ's code generates the linkbar by iterating over some keys, and the code that actually determines what happens is hidden somewhere, it's not an explicit part of the public layers. You're using one of the user-created styles, which is frankly a lot better written than the LJ originating ones, so you might have a chance.

The relevant bits you need to modify are function EntryLite::print_linkbar() and function Entry::print_linkbar() (search within layout code for the default version). If you use that in your theme layer, you can over-write that default version. S2 is mostly Perl, so I'm hoping you'll be able to read the code in order to decide what to do with it. Other bit of information you need is a variable to generate the entry number on its own (as opposed to generating the entry link); I think $e.itemid will work.

This is muddled because I have absolutely no programming knowledge, which makes it hard to explain the stuff I've picked up about S2. I'm sorry if I've spelled out things which are completely obvious to a programmer, and even more so if I've left out critical information, but hopefully that can be remedied if you ask what you need to know.

Profile

nameandnature: Giles from Buffy (Default)
nameandnature

December 2025

S M T W T F S
 123456
78910111213
14151617181920
2122 2324252627
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 2nd, 2026 04:58 am
Powered by Dreamwidth Studios