Monday, March 18, 2002


Life Strategies from Phillip C. McGraw, Ph.D.

1. You either get it, or you don't
2. There are no accidents
3. People do what works
4. You cannot change what you do not acknowledge
5. Life rewards action
6. There is no reality, only perception
7. Life is managed, not cured
8. We teach others how to treat us
9. There is freedom in forgiveness
10. You have to name it to claim it


11:04:45 AM    trackback []     Articulate [] 

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 + "

" + d + ": " + "http://radio.weblogs.com/0100887/";
    s = s + d + ".html#a" + itemno;
    s = s + "\">";
    s = s + title;
    s = s + "

";
    };
  };
 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., ) has been in the wrong place since the advent of titles. It should come before, not after, the title.

 

[
Jon's Radio]
11:03:13 AM    trackback []     Articulate []