Updated: 11/14/2005; 1:40:06 AM
Radio Fun
    Radio UserLand, RSS, Weblog Tools and Design

daily link  Sunday, August 11, 2002


PrevDay and NextDay macros
[RadioFAQs]
Radio Tip: HOW TO add PrevDay and NextDay links to make navigating blog archives easier. [dws.] 
11:32:31 PM
categories: Radio Fun
 source

Radio Stuff To Try
John Udell's storyList macro

Saturday, March 16, 2002

Listing titled items on a storyList page

If I've got this right, posting this item should update my new storyList page, which enumerates all my titled items in reverse order, so that it also includes this item.

Hey, it worked. Cool. OK, here's how. First, a script which gathers all the posts that have titles:

on storyList()
 {
 local (s = "");
 local (adrblog = radio.weblog.init ());
 local (adrposts = @adrblog^.posts, i);
 for i = sizeof (adrposts^) downto 1
  {
  local (adr = @adrposts^ [i]);
  local (t = adr^);
   try
    {
    local( title = t.title); // if none, skip to next post
    local(d = date.year(t.when) + "/" + string.padWithZeros(date.month(t.when),2) + "/" + string.padWithZeros(date.day(t.when),2));
    local( itemno = nameOf(adr^) );
    regex.subst("^0+","",@itemno);
    s = s + "<p>" + d + ": " + "<a href=\"http://radio.weblogs.com/0100887/";
    s = s + d + ".html#a" + itemno;
    s = s + "\">";
    s = s + title;
    s = s + "</a></p>";
    };
  };
 return(s);
 };

I saved this as /radio/Macros/storyList.txt. Then I wrote a story that contains nothing but a reference to the macro, in other words:

<% storyList() %>

So far so good. But how to make it update when new postings appear? I got the necessary ideas from Russ Lipton and Simon Fell.

From Russ, I got the idea for a script that touches the storyList, so it will re-upstream. From Simon, I learned of the callback that can invoke that script when an item is published. So, I wrote this:

on updateStoryList(adrPost)
    {
    on touch(path)
        {
        try
        { file.touchPath(path) }
        };
    file.visitFolder(user.radio.prefs.wwwfolder + "stories\\2002\\03\\16", infinity, @touch);
    };

And I entered it as a script, called updateStoryList, in the table user.radio.callbacks.publishItem.

Nice. Now, I think I'll have a neat and automatically maintained list of my titled items.

One gripe, which I noticed again while doing this: the permalink's target (e.g., <a name="a146">) has been in the wrong place since the advent of titles. It should come before, not after, the title.

 

10:59:27 PM     
10:48:33 AM
categories: Radio Fun
 


Copyright 2005 © Bruce Zimmer