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

Trackback Pings

TrackBack URL for this entry:
http://molelog.molehill.org/~jtl/mt/mt-tb.cgi/442

Comments

aufrank

I ended up getting a 500 error with caching enabled on the calendar plugin— any ideas?

Here’s the error:
[Mon Apr 28 14:55:12 2003] [notice] Accept mutex: sysvsem (Default: sysvsem)
calendar debug 1: start() called, enabled
calendar debug 1: filter() called
calendar debug 1: cache miss: %stories
calendar debug 1: filter() done
calendar debug 1: head() called
calendar debug 1: cache miss pml 2003 4 html
calendar debug 1: cache miss nml 2003 4 html
calendar debug 1: cache miss pyl 2003 html
calendar debug 1: cache miss nyl 2003 html
calendar debug 1: cache miss mc 2003 4 28 html
calendar debug 1: cache miss yc 2003 4 html
calendar debug 1: cache miss c 2003 4 28 html
calendar debug 1: Saving cache
can’t write into /home/httpd/blosxom/plugins//state/.calendar.cache: Permission
denied at /home/httpd/blosxom/plugins/calendar line 349
[Mon Apr 28 14:55:25 2003] [error] [client 127.0.0.1] Premature end of script he
aders: /home/httpd/cgi-bin/blosxom.cgi
calendar debug 1: start() called, enabled

this refers to a line containing Storable::lock_file — could that be the problem?

/au

2003-04-28 12:15:00

Todd Larason

the “permission denied” is the important bit — the script doesn’t have permission to write to the plugin state dir, but it needs it.

2003-04-29 00:10:00

Tommy Williams

I only use blosxom in static mode. What change is necessary to blosxom (and calendar) in order to generate the appropriate dates for static mode? When I go back to my March archives, for example, I would like to see the month of March calendar rather than (for now) the month of May.

Thanks.

2003-05-02 07:09:00

Todd Larason

Blosxom needs to make path_info_{yr,mo,mo_num,da} available to plugins in static mode. this message to the blosxom list contains a proposed patch to fix that, which will hopefully be in 2.0rc3.

With that change to 2.0rc2 (or with an upgrade to 2.0rc3 when it’s available, hopefully), I think it Just Works.

2003-05-02 11:51:00

Tommy Williams

I tried your patch on my copy of 2.0rc2 (it was a different line number, but the change was obvious). Nothing broke, but it didn’t give me the April calendar when viewing the April individual entries. I’ll investigate some more.

2003-05-05 10:57:00

Mark Mayer

I installed 6i in my plugins folder. I’m running Blosxom rc5. What do I need to add to foot.html to make it work? Step #3 in the install instructions above display as your calendar in my browser. I cut and pasted from source, and, suprise, got Tod’s calendar instead of my own.

2003-06-11 13:38:00

Kim Gammelgård

Thanks for a good plugin! It just worked!. Running on MacOSX 10.1.5/Blosxom 2.

2003-08-28 15:59:00

Sam

Reading earlier comments gives me the impression that links to given months or days will result in the correct $calendar::month_calendar being generated as of blosxom 2rc3 or later. Even in static mode. I have not observed this to be the case.

For example, a link to an individual story in August will get the August calendar, following a link to 2003/08/ will display the calendar for the current month (which just happens to be September) rather than showing me $calendar::month_calendar for August. I’m running the release version of blosxom 2.0 (in static-only mode).

I’ve noticed that the molelog archive calendar suffers from the same problem. I don’t suppose that this is the intended behavior?

2003-09-06 17:05:00

Anonymous


Watch out, the Blosxom calendar plugin starts the week on Sunday! I really need to get around to changing it — ideas, anybody? I took a look in the plugin a couple days ago, and couldn’t figure it out. :( Update, 2003-10-02: Turns out that the currently current version of the calendar plugin does indeed have a starting day of the week variable. Oops.

2003-10-01 05:40:00

Sharat

How would you generate a calender with all the months of the year, not just the current month.

2003-10-05 18:22:00

Andy Fragen

I see this has been discussed earlier but I’m not clear on the exact solution. Currently using blosxom 2.0 and Calendar 6i in static mode.

2003-10-21 20:39:00

Clemens

Is there any working solution for the problem that the calendar don’t show the correct month in static mode, when I change e.g. to a previous month… ??

2003-11-03 14:55:00

Tim

Very nice plugin, thanks very much. I added a summary to the table defs, so it will verify as XHTML.

2004-02-15 14:32:00

Conrad Whelan

Thanks a bunch, so simple to put it in, and it worked straight-away…excellent.

2004-03-02 20:27:00

Ramon Souza

Worked great for me..

had no problems.

2004-04-24 14:20:00

Rob Lusardi

This is great! Just loaded. Worked right away with no problems. Is there a way to change the arrows?

2004-06-14 18:01:00

Rob Lusardi

This is great! Just loaded. Worked right away with no problems. Is there a way to change the arrows?

2004-06-14 20:12:00

Marcel

my calender works also but i have a few problems and questions!

i can set the “Configuration Variables” to whatever I want, the calender always shows the english terms!

and i’ve seen somewhere where the people could select the month and year in a dropdown menu!

how can i realize this?

thanks

2004-08-02 01:47:00

marcel

hey,

the calender works fine for me but i’m having a question and problem!

whatever i wrote to all the configuration variables, it always displays the default english words!

and how can i display the month and years in a drowdown menu? i have seen that on a site already!

thanks

2004-08-02 02:18:00

eltejano

hopefully this is a permissions prob, but I’m getting an error here:

Not enough arguments for mkdir at calendar line 348, near “$blosxom::plugin_state_dir;”

any ideas to fix or troubleshoot this? I’m unfortunately not able to log either for some reason.

(blosxom 2.0)

2004-08-05 22:28:00

Post a comment




Remember Me?

(you may use HTML tags for style)