Storystate 0+1i

My very first published plugin for Blosxom. You can download it here.

Storystate provides a number of convenience variables for use with the interpolate_fancy plugin by Blosxom author Rael Dornfest. It was designed to be especially useful with writeback. Storystate also allows presence of a meta-writeback tag to control if writebacks are open or closed. It’s basically useless without interpolate_fancy.

NOTE: best if used with interpolate_fancy version 2003-09-07 or later.

Excerpt from the POD docs:

Just drop it in your $plugin_dir. Optionally, you can adjust the values of the configuration variables at the top of the file. There are covered later.

Most of the variables are simple boolean indicators, using undef for false. This allows them to be used with interpolate_fancy’s and constructs. Some variables are story specific, (updated for each story), while others are based on the request url and are valid in the head and foot as well.

The request flag variables are:

  • $permalink true if request url is a subdir permalink, e.g. /this/that/story.html
  • $datepermalink true if request url is a date permalink, e.g. /2003/09/07/story.html
  • $anypermalink true if request url is either of above
  • $blogroot true if request is for blog’s root e.g. / or /index.html
  • $archive true if request if date style, e.g. /2003/09
  • $category true if request is subdir style, e.g. /this/that

The story-specific flag variables are:

  • $writeback_closed true if writebacks are closed for story (see below)
  • $permalink_wbopen true if !$writeback_closed and $permalink
  • $permalink_wbclosed true if $writeback_closed and $permalink

The idea of closing writebacks is that you are no longer accepting comments for a given story. Just add meta-writeback: on or meta-writeback: off to the header of the story. If no meta-writeback header is found, the value of the config variable $writeback_default is used instead. Values are on (writebacks open) and off (writebacks closed). This is of course dependant upon you implementing checks against these variables in our story template, see the example below.

There is also a story-specific text variable:

  • $writeback_message description of writeback state for story

This is useful for links to your writeback page. It returns (by default):

  • ‘Add the first comment’ If writebacks are open for story and no comments exist
  • ‘No Comments’ if writebacks are close and no comments exist
  • ‘1 comment’ if only one comment
  • ‘n comments’ if >1 comment, n=$writeback::count

These messages are configurable, see the config variables at the top of the file, they are documented inline.

See the POD docs for an example of usage, I just can’t get sample HTML to play nice with Textile2.

Both comments and pings are currently closed.

4 Responses to “Storystate 0+1i”

  1. Lars Kellogg-Stedman Says:

    storystate thoughts<br/>

    The regex used to set the $permalink variable doesn’t work for “top level” stories, where path_info might look like:


    The existing regex always checks for a “/”:


    Removing the first component of the regex seems to make things work:


    On a different note, the documentation should probably clearly reflect the fact that neither permalinkwbopen nor permalinkwbclosed care about date based permalinks — they look only at $permalink. And in fact, $datepermalink appears to never get set anyway. Maybe it should just be removed from the docs.

  2. Peter Says:

    I use plugin visitors and yoyur storystate. The interfere. I made visitors run before storystate by renaming it to 20visitors.

    Are you planning an update ?

  3. Jason Says:

    Conflicts with visitors?<br/>


    I’m not familiar with the visitors plugin, so I wasn’t planning any update related to conflicts. Can you provide some detail on the conflict? I’ll try to take a look at the visitors plugin code as well.

    However, renaming visitors should (probably) not be needed because storystate moves itself to the end of the plugins list in order to ensure that its story() method runs after writeback::story() – this ensures the writeback count is correct. If you want to see how this chicanery is accomplished, look at filter() method of storystate.

  4. Tim Lambert Says:

    Automatically closing writebacks<br/>

    I wanted to automatically close writebacks after 60 days (because of spam attacks). So I added this to your plugin:

    sub date { my ($pkg, $file, $dateref, $mtime, $dw,$mo,$monum,$da,$ti,$yr) = @_;

    # default to closed for stories older than 6086400 secs = 60 days $writeback_default = (time – $mtime) > 6086400 ? ‘off’ : ‘on’; 1; }