Calendar Plugin 0+6i

Calendar's been updated.

Feature changes:

  • New configuration variable $first_dow lets you control which day of week weeks start with
  • New variable $count available in templates, the number of stories in the day/week/month/year
  • Besides $year_calendar, year calendars are built for each year from the current year back to the first year with stories, named $year_calendar_2003 and so on.
  • The default templates include story counts in appropriate places.
  • When generating a month calendar for year with no month specified, choose the last month in the year with stories in it, rather than always choosing December; use December if the year has no stories at all.
  • When saving the cache, try to create the plugin state dir if it doesn't exist.
  • When counting stories, ignore any stories with a timestamp that matches $^T. This does mean that during the second a new story is posted, a generated calendar may not be quite right, but also makes the cache work much better with plugins that dynamically create 'stories' that shouldn't get counted, so long as they set the timestamp to $^T (such as a not-yet-released version of AutoCorrect) -- that's the whole point of these $^T changes.

Bug Fixes:

  • In month calendar, include 'week_foot' for partial last week, if there is one (ie, include the final <tr>)
  • Clear the cache if the day changes, not just when stories are added
  • Properly count the number of stories to tell when to clear the cache; 0+5i accidentally used the number of hash buckets filled rather than the number of items in the hash -- oops
  • If a year before 1970 is (apparently) requested, forcibly switch to year 2000 and log the full requested path, to try to figure out what causes this. Earlier versions would die when trying to build the month calendar. If you see "Bad year ... requested" lines logged, please let me know.

Changed for reasons only I care about:

  • Use $^T rather than time in various places

Things I'd like to be able to do, but can't reasonably without Blosxom changes:

  • use the built-in interpolation system, including any interpolate plugin that's installed
  • create months for appropriate dates in static mode

To install:

  1. download and unzip the plugin.
  2. Copy it to your plugins directory. Make sure it's world-readable.
  3. Modify a head or foot file to include $calendar::calendar, $calendar::month_calendar or $calendar::year_calendar
  4. Try it out — load your blog in your browser. If you see a calendar, great!
  5. Look at your error log. Verify you have an 'enabled' line.
  6. If you're wanting to verify caching is working, load the page again, and now look for an error log line "calendar debug 1: Using cached state"
  7. Once you're satisfied it's working, edit the $debug_level configuration variable to 0. There are a couple other configuration variables you may wish to change, too.
  8. Drop me a note to let me know you're using it; if you're having problems, let me know and I might be able to help. If everything's working okay, please let me know that, too.

Molelog is running this, with some customized templates and stylesheets.

Stylesheet:

.calendar { }
.calendar table {
	margin-left:		auto; 
	margin-right:		auto;
}
.calendar table .prev-link {
	margin-left:		0; 
	text-align:		left;
}
.calendar table .next-link {
	margin-right:		0;
	text-align:		right;
}
.month-calendar, .year-calendar {
	border-collapse:	collapse; 
}
.month-calendar-head, .year-calendar-head {
	font-size:		110%;
	font-weight:		bold;
}
.month-calendar-day-head, .year-calendar-subhead {
	font-weight:		normal;
}

.month-calendar {
	text-align: 		center;
}

.month-calendar-day-noday,
.month-calendar-day-link,
.month-calendar-day-nolink,
.month-calendar-day-this-day,
.month-calendar-day-future {
	font-family:		Georgia,New Century Schoolbook,Times,serif;
}

.year-calendar-month-link, 
.year-calendar-month-nolink,
.year-calendar-this-month, 
.year-calendar-month-future {
}

.month-calendar-day-future, .year-calendar-month-future {
	color:			#83660F;
}

.month-calendar {
	background:		#fff3de;
	border: 		1px solid #83660f;
}
.calendar th {
	border-bottom: 		1px dotted #83660f;
}
.Saturday {
	border-left:		1px dotted #83660f;
}
.Sunday {
	border-right:		1px dotted #83660f;
}
.Saturday, .Sunday {
	background:		#f5deb3;
}
.month-calendar-day-this-day, .year-calendar-this-month {
	background:		#a5e4ff;
}
.year-calendar {
	background:		#fff3de;
	border: 		1px dotted #83660f;
}

calendar.calendar.html":http://molelog.molehill.org/blog/flavours/html/":

<div class="calendar">
  <table>
    <tr>
      <td colspan="2">$calendar::month_calendar</td>
    </tr>
    <tr>
      <td class="prev-link">$prev_month_link</td>
      <td class="next-link">$next_month_link</td>
    </tr>
  </table>
  <table>
    <tr>
      <td>$calendar::year_calendar_2001</td>
      <td>$calendar::year_calendar_2002</td>
      <td>$calendar::year_calendar_2003</td>
    </tr>
  </table>
</div>

calendar.month_head.html:

<table class="month-calendar">
  <caption class="month-calendar-head">
    <a title="$monthname $year ($count stories)" href="$url">
      $monthname $year
    </a>
  </caption>

calendar.next_month_link.html:

<a title="$monthname $year ($count)" href="$url">
  $monthabbr '$year2digit&rarr;
</a>

calendar.next_month_nolink.html:

&rarr;
calendar.next_year_link.html:

<a title="$year ($count)" href="$url">
  '$year2digit &rarr;
</a>

calendar.next_year_nolink.html:

&rarr;

calendar.prev_month_link.html:

<a title="$monthname $year ($count)" href="$url">
  &larr; $monthabbr '$year2digit
</a>

calendar.prev_month_nolink.html:

&larr;

calendar.prev_year_link.html:

<a title="$year ($count)" href="$url">
  &larr; '$year2digit
</a>

calendar.prev_year_nolink.html:

&larr;

calendar.year_hear.html:

<table class="year-calendar">
  <caption class="year-calendar-head">
    <a title="$year ($count)" href="$url">$year</a>
  </caption>

2003-04-13 21:32:00 | Comments (20) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar

Calendar Plugin 0+5i

Calendar's been updated.

User-visible Interesting Changes, in rough order by interestingness:

  • On single-article pageviews, create a calendar for the date of the article (this only works in dynamic mode currently, requires a Blosxom change to give full $path_info support in static mode)
  • requires Blosxom 2.0rc1 2.0rc2 or newer
  • uses the built-in templating system, including any template plugin that's installed
  • cached layouts are keyed based on flavour, so if you have template files that vary by flavour it will actually work now
  • variables in templates can be interpolated with ${name} as well as $name
  • with the default templates, the current day/month is only a link if there are stories for it
  • this_day template split into this_day_link and this_day_nolink
  • this_month template split into this_month_link and this_month_nolink
  • the default templates are in the 'error' flavour rather than 'html', so they're used for any flavours that don't override them (the same effect was achieved a different way in 0+4i)
  • cache is only enabled if the available Storable supports lock_retrieve
  • the cache is flushed every time a story is added, not once a day -- this is required for the this_day_link and this_month_link support

Things I'd like to be able to do, but can't reasonably without Blosxom changes:

  • use the built-in interpolation system, including any interpolate plugin that's installed
  • create months for appropriate dates in static mode

To install:

  1. download and unzip the plugin.
  2. Copy it to your plugins directory. Make sure it's world-readable.
  3. Modify a head or foot file to include $calendar::calendar, $calendar::month_calendar or $calendar::year_calendar
  4. Try it out — load your blog in your browser. If you see a category tree, great!
  5. Look at your error log. Verify you have an 'enabled' line.
  6. If you're wanting to verify caching is working, load the page again, and now look for an error log line "calendar debug 1: Using cached state"
  7. Once you're satisfied it's working, edit the $debug_level configuration variable to 0. There are a couple other configuration variables you may wish to change, too.
  8. Drop me a note to let me know you're using it; if you're having problems, let me know and I might be able to help. If everything's working okay, please let me know that, too.

Molelog is running this, with some customized templates and stylesheets.

Stylesheet:

.calendar { }
.month-calendar, .year-calendar {
	border-collapse:	collapse; 
}
.month-calendar-head, .year-calendar-head {
	font-size:		110%;
	font-weight:		bold;
}
.month-calendar-day-head, .year-calendar-subhead {
	font-weight:		normal;
/*	font-size:		80%; */
}

.month-calendar-day-noday,
.month-calendar-day-link,     .year-calendar-month-link,
.month-calendar-day-nolink,   .year-calendar-month-nolink,
.month-calendar-day-this-day, .year-calendar-this-month,
.month-calendar-day-future,   .year-calendar-month-future  {
	text-align:		center;
	font-family:		"Georgia", "New Century Schoolbook", "Times", serif;
}

.month-calendar-day-future, .year-calendar-month-future {
	color:			#83660F;
}

.Saturday, .Sunday {
	background:		#f5deb3;
}

.month-calendar-day-this-day, .year-calendar-this-month {
	background:		#a5e4ff;
}

calendar.calendar.html:

<div align="center" class="calendar">
  <table>
    <tr>
      <td colspan="2">$calendar::month_calendar</td>
      <td> </td>
      <td colspan="2">$calendar::year_calendar</td>
    </tr>
    <tr>
      <td align="left">$prev_month_link</td>
      <td align="right">$next_month_link</td>
      <td> </td>
      <td align="left">$prev_year_link</td>
      <td align="right">$next_year_link</td>
    </tr>
  </table>
</div>

calendar.month_head.html:

<table class="month-calendar">
  <caption class="month-calendar-head">
    <a title="$monthname $year" href="$url">$monthname</a>
  </caption>

calendar.year_head.html:

<table class="year-calendar">
  <caption class="year-calendar-head">
    <a title="$year" href="$url">$year</a>
  </caption>
  <tr>
    <th class="year-calendar-subhead" colspan=$months_per_row>
      Months
    </th>
  </tr>

calendar.next_month_link.html:

<span class="text-align: right">
  <a title="$monthname $year" href="$url">$monthabbr &rarr;</a>
</span>

calendar.next_month_nolink.html:

<span class="text-align: right">&rarr;</span>

calendar.next_year_link.html:

<span class="text-align: right">
  <a title="$year" href="$url">'$year2digit &rarr;</a>
</span>

calendar.next_year_link.html:

<span class="text-align: right">&rarr;</span>

calendar.prev_month_link.html:

<span class="text-align: left">
  <a title="$monthname $year" href="$url">&larr; $monthabbr</a>
</span>

calendar.prev_month_nolink.html:

<span class="text-align: left">&larr;</span>

calendar.prev_year_link.html:

<span class="text-align: left">
  <a title="$year" href="$url">&larr; '$year2digit</a>
</span>

calendar.prev_year_nolink.html:

<span class="text-align: left">&larr;</span>

2003-03-24 05:40:00 | Comments (1) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar

Calendar Plugin 0+4i

Update: There are newer versions available; please use the newest version unless you have a particular reason not to.

Calendar has been updated. Changes:


  • Bugfix: Deal okay with urls like ".../2003/nosuchmonth"; 0+3i will loop forever trying to find the previouis month with stories, chewing up CPU time

  • Bugfix: properly dispose of the cache every night. 0+3i computes the key incorrectly, keeping the cache for a month rather than a day; this leads to days with stories not getting links.

  • Improvement: Only saves the cache if something has changed

Things still to do:


  • Keep better track of people who deserve thanks. Mea culpa.

To install:


  1. download and unzip the plugin.

  2. Copy it to your plugins directory. Make sure it's world-readable.

  3. Modify a head or foot file to include $calendar::calendar, $calendar::month_calendar or $calendar::year_calendar.
  4. Try it out — load your blog in your browser. If you see a category tree, great!

  5. Look at your error log. Verify you have some lines like the following:

    calendar debug 1: start() called, enabled
    calendar debug 1: filter() called
    calendar debug 1: head() called
    calendar debug 1: head() done, length($month_calendar, 
       $year_calendar, $calendar) =  3174 1228 4488
    

    The numbers will be different, but the rest shouldn't be. If none of them are there, the plugin isn't getting invoked at all for some reason -- is it in the right place? Is it named "calendar"? Is it readable?


  6. If you're wanting to verify caching is working, load the page again, and now look for an error log line:

    calendar debug 1: Using cached state
    

  7. Once you're satisfied it's working, edit the $debug_level configuration variable to 0. There are a couple other configuration variables you may wish to change, too.

  8. Drop me a note to let me know you're using it; if you're having problems, let me know and I might be able to help. If everything's working okay, please let me know that, too.


You can see a sample if you like. The stylesheet being used there is:

.calendar { }
.month-calendar, .year-calendar {
	border-collapse: collapse; 
}
.month-calendar-head, .year-calendar-head {
	font-family:	 "Trebuchet MS",Verdana,Geneva,Arial,Sans-serif;
	font-size:	 110%;
	font-weight:	 bold;
}
.month-calendar-day-head, .year-calendar-subhead {
	font-family:	 "Trebuchet MS",Verdana,Geneva,Arial,Sans-serif;
	font-weight:	 normal;
}

.month-calendar-day-noday,
.month-calendar-day-link,     .year-calendar-month-link,
.month-calendar-day-nolink,   .year-calendar-month-nolink,
.month-calendar-day-this-day, .year-calendar-this-month,
.month-calendar-day-future,   .year-calendar-month-future  {
	text-align:	 center;
}

.Saturday, .Sunday {
	background:	 #f5deb3;
}

.month-calendar-day-this-day, .year-calendar-this-month {
	background:	 #e9967a;
}
.month-calendar-day-future, .year-calendar-month-future {
	color:		 #808080;
}

2003-03-06 03:58:00 | Comments (0) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar

Calendar Plugin 0+3i

Update: There are newer versions available; please use the newest version unless you have a particular reason not to.

Calendar has been updated. Changes:


  • Configurable day of week names

  • Configurable number of months per row

  • styles to identify months and days in the future

  • styles identify days of the week

  • Most of class names changed; if you've customized a stylesheet, you'll need to update it. Hopefully that won't happen again. (Yes, I said that last time, too. Turns out "_" isn't valid in class names.)

  • If you have Storable installed, the tree data and partial results can be cached. It's not completely clear whether this is a win or not; it will depend on things like the number of stories, the speed of your disks relative to your CPU, and the like. If you're concerned about it, you should benchmark it on your own system.

  • Other stuff too, I think.

  • POD documentation is included

Things still to do:


  • Keep better track of people who deserve thanks. Mea culpa.

  • Keep better track of changes, or release often enough that it's not too painful to sort through the diffs

To install:


  1. download and unzip the plugin.

  2. Copy it to your plugins directory. Make sure it's world-readable.

  3. Modify a head or foot file to include $calendar::calendar, $calendar::month_calendar or $calendar::year_calendar.
  4. Try it out — load your blog in your browser. If you see a category tree, great!

  5. Look at your error log. Verify you have some lines like the following:

    calendar debug 1: start() called, enabled
    calendar debug 1: filter() called
    calendar debug 1: head() called
    calendar debug 1: head() done, length($month_calendar, 
       $year_calendar, $calendar) =  3174 1228 4488
    

    The numbers will be different, but the rest shouldn't be. If none of them are there, the plugin isn't getting invoked at all for some reason -- is it in the right place? Is it named "calendar"? Is it readable?


  6. If you're wanting to verify caching is working, load the page again, and now look for an error log line:

    calendar debug 1: Using cached state
    

  7. Once you're satisfied it's working, edit the $debug_level configuration variable to 0. There are a couple other configuration variables you may wish to change, too.

  8. Drop me a note to let me know you're using it; if you're having problems, let me know and I might be able to help. If everything's working okay, please let me know that, too.


You can see a sample if you like. The stylesheet being used there is:

.calendar { }
.month-calendar, .year-calendar {
	border-collapse: collapse; 
}
.month-calendar-head, .year-calendar-head {
	font-family:	 "Trebuchet MS",Verdana,Geneva,Arial,Sans-serif;
	font-size:	 110%;
	font-weight:	 bold;
}
.month-calendar-day-head, .year-calendar-subhead {
	font-family:	 "Trebuchet MS",Verdana,Geneva,Arial,Sans-serif;
	font-weight:	 normal;
}

.month-calendar-day-noday,
.month-calendar-day-link,     .year-calendar-month-link,
.month-calendar-day-nolink,   .year-calendar-month-nolink,
.month-calendar-day-this-day, .year-calendar-this-month,
.month-calendar-day-future,   .year-calendar-month-future  {
	text-align:	 center;
}

.Saturday, .Sunday {
	background:	 #f5deb3;
}

.month-calendar-day-this-day, .year-calendar-this-month {
	background:	 #e9967a;
}
.month-calendar-day-future, .year-calendar-month-future {
	color:		 #808080;
}

2003-03-01 18:11:00 | Comments (0) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar

Calendar Plugin 0+2i

Update: There are newer versions available; please use the newest version unless you have a particular reason not to.

Calendar's been updated. Changes:


  • When used with Blosxom 2.0beta2, displays a calendar for the currently-viewed time period, not the current date

  • a year/month calendar is included as well as a month/day calendar. $calendar::calendar is both side-by-side. If you'd like just one or the other, use $calendar::month_calendar or $calendar::year_calendar.

  • Previous/next arrows are included in the table captions. They're 'smart' -- the month ones will skip over months without any stories; neither will link to months/years without any stories. They do assume that there aren't any empty years, though -- if you posted in 2001 and 2003 but not 2002, they won't act right.

  • The current day is highlighted, if there is one. "current day" is today, if no time period is specified, or the day being browsed if there is one. If a month or year is being browsed, there is no 'current day'.

  • The current month is hilighted, if there is one. "current month" is today, if no time period is specified, or the month being browsed if there is one. If a year is being browsed, there is no 'current month'.

  • All the formatting is controlled via a templating system similar to Blosxom's. You probably won't feel the need to override the standard formatting (although you probably will want to add some stylesheeting), but you can if you want.

  • Debugging output is available, and some is turned on by default. Once you have it working, turn it off or you'll fill your error logs with output you don't need.

  • Some of the class names have changed; if you've customized a stylesheet, you'll need to update it. Hopefully that won't happen again.

Things still to do (maybe):


  • Write some real docs, include them in the plugin itself.

  • When browsing a full year, what month should be displayed? Right now it's december. Is there necessarily a better choice? Decide, and use it.

To install:


  1. download and unzip the plugin.

  2. Copy it to your plugins directory. Make sure it's world-readable.

  3. Modify a head or foot file to include $calendar::calendar, $calendar::month_calendar or $calendar::year_calendar

  4. Try it out — load your blog in your browser. If you see a calendar, great!

  5. Look at your error log. Verify you have some lines like the following:

    calendar debug 1: filter() called
    calendar debug 1: filter() done
    calendar debug 1: head() called
    calendar debug 1: head() done, length($month_calendar, ...
             $year_calendar, $calendar) =  3973 1112 5128
    
    The numbers will be different, but the rest shouldn't be. If none of them are there, the plugin isn't getting invoked at all for some reason -- is it in the right place? Is it named "calendar"? Is it readable?

  6. Once you're satisfied it's working, edit the $debug_level configuration variable to 0. If you want to use non-English month names, this is a good time to change those, too.

  7. Drop me a note to let me know you're using it; if you're having problems, let me know and I might be able to help. If everything's working okay, please let me know that, too.


You can see a sample if you like. The stylesheet being used there is:

.month_calendar, .year_calendar {}
.month_calendar_head, .year_calendar_head {
	font-size:		90%;
	font-weight:		bold;
}
.month_calendar_day_head, .year_calendar_subhead {
	font-size:		70%;
	font-weight:		normal;
}
.month_calendar_day_noday,
.month_calendar_day_link,     .year_calendar_month_link,
.month_calendar_day_nolink,   .year_calendar_month_nolink,
.month_calendar_day_this_day, .year_calendar_this_month  {
	text-align:		right;
}
.month_calendar_day_this_day, .year_calendar_this_month {
	background:		#eeeeee;
}

2003-02-23 19:17:00 | Comments (0) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar

Calendar Plugin 0+1i

Update: There are newer versions available; please use the newest version unless you have a particular reason not to.

Third plugin: calendar

This builds a calendar display of the current month. Days with articles are links to that day's archive page; days without articles aren't links.


  1. download it, and rename it "calendar"

  2. Stick it in your blosxoms plugin directory

  3. Look at the configuration variables; there's probably not anything you'll want to fiddle with, though.

  4. Add "$calendar::calendar" to your head.$flavour or tail.$flavour file
  5. Maybe add some things to your stylesheet

This uses Time::Local which I think has only been standard since perl 5.6.1. If you don't have it, first let me know so I can judge how big an issue this is; then either install it, or edit the plugin: remove the use Time::Local; line, then find

    # XXX this isn't quite right in the face of daylight savings time
#   $monthstart = $now - ($now[3]-1)*86400;
    $monthstart = timelocal(0,0,0,1,$month-1,$year-1900);

around line 100; uncomment the 2nd line and and comment the third.

Things that I'm considering for this


  • add a year/month calendar for the current year

  • add a list of years with articles

  • add next/previous arrows to the month -- also to the day? the UI for that isn't clear

  • when displaying old articles, display the calendar for that month, not the current one. I'm not sure that info is currently available to the plugins

  • more output formats?

  • anything else wanted/needed?

The stylesheet bits I'm using:

.calendar {}
.calendar_month_head {
	font-size:		9pt;
	font-weight:		normal;
}
.calendar_day_head {
	font-size:		7pt;
	font-weight:		normal;
}
.calendar_day_noday {}
.calendar_day_link {
	text-align:		right;
}
.calendar_day_nolink {
	text-align:		right;
}

2003-02-21 03:24:00 | Comments (3) | TrackBack (0) | Computers::Internet::Web::Blosxom::Plugins::Calendar