Planet Debian now has Javascript to facilitate the persistent hiding of particular feeds.
The code is still in flux, but appears to work.
Comments welcome, especially from people better at Javascript than myself!
The way it works was chosen to minimise the changes requred:
- Each entry is wrapped within a new <div>
- The DIV has an ID & a CLASS attribute added.
At load-time the function hideHosts() is called. If a comma-separated cookie called "excludes" is present this is split and iterated over.
For each domain-name in the list the current document is searched for elements having a class prefixed with that hostname - if any match and they have an ID defined (regardless of what that might be) they are hidden.
And thats it.
The changes to the template were minimal; each index entry already has a "link" attribute, so I just had to add this:
<div class="<!-- tmpl_var name='link' escape='html' -->" id="<!-- tmpl_var name='link' escape='html' -->" > .... </div>
Because the ID and LINK attributes are URLs there is a little mangling, and inefficiency. But I didn't want to change the core of the PlanetPlanet to define a "hostname" attribute for each feed member...
In an ideal world I'd add "class='feed, $link'" and then iterate over that at load-time to attach handlers, and an ID appropriately. But that is a little scary.. If it works in IE great. I've tested Firefox & Ephinay
ObQuote: Terminator II
Update: Moved javascript into external file, and removed the image toggling, it seemed to fail and I'm not sure why. I will investigate.
Tags: planet-debian, planet-planet 2 comments