1 # Blosxom Plugin: prevnexstory
2 # Author(s): Barijaona Ramaholimihaso
3 # Based on chrono_nav plugin by Victor Ganata <aswang@fatoprofugus.net>
4 # and tree plug-in by Ryan Schram
5 # Ideas From: Tatsuhiko Miyagawa
6 # Version: 2006-01-01blosxom2
7 # Documentation: See the bottom of this file or type: perldoc tree
13 use vars qw($prevlink $nextlink $prevtitle $nexttitle $prevdate $nextdate @file_info @dir_info $files_ref @monthname @monthabbr);
14 # --- Configuration Variables ---
16 @monthname = qw/January February March
19 October November December/ if ($#monthname != 11);
20 @monthabbr = qw/Jan Feb Mar
23 Oct Nov Dec/ if ($#monthabbr != 11);
25 # -------------------------------------------------------------------
41 %$files_ref = %blosxom::files;
42 # Take %files and find all the places blosxom will generate a story page.
43 @file_info = sort { $files_ref->{$b} <=> $files_ref->{$a} } keys %$files_ref;
50 if (($blosxom::path_info =~ /$blosxom::flavour$/) or (($blosxom::path_info =~ /$blosxom::file_extension$/) && ($blosxom::static_or_dynamic eq "static"))) {
51 # It's an individual story file.
52 my %path2idx = map { $file_info[$_] => $_ } 0..$#file_info;
54 my $key = "$blosxom::datadir/$blosxom::path_info";
55 $key =~ s#$blosxom::flavour#$blosxom::file_extension#;
56 my $index = $path2idx{"$key"};
57 if ($index < $#file_info ){ ($prevlink , $prevtitle, $prevdate) = make_link($index + 1) ;}
58 else {undef $prevlink};
59 if ($index > 0 ){ ($nextlink , $nexttitle, $nextdate) = make_link($index - 1) ;}
60 else {undef $nextlink;};
63 elsif (($blosxom::path_info eq "") && ($blosxom::path_info_yr eq "")) {
64 # it's the blog main page
65 if ($blosxom::num_entries <= $#file_info ){($prevlink, $prevtitle, $prevdate) = make_link($blosxom::num_entries) ;}
66 else { undef $prevlink ;};
77 my ($array_index) = @_;
78 my $file = $file_info[$array_index];
79 my($path, $fn) = $file =~ m!^$blosxom::datadir/(?:(.*)/)?(.*)\.$blosxom::file_extension!;
82 my $fh = FileHandle->new();
83 if (-f $file && $fh->open("< $file")) {
84 chomp($title = <$fh>);
87 $path = $path . ( $path ne "" ? "/" : "") ;
88 my @date = localtime($files_ref->{$file_info[$array_index]});
91 my $year = $date[5] + 1900;
93 #here we format the date as a text
94 my $datetext = $mday." ".$monthname[$month]." ".$year ;
95 return (qq($blosxom::url/$path$fn.$blosxom::flavour), $title, $datetext);
108 Blosxom Plug-in: chrono_nav
112 Populates the prevnexstory namespace with links for pointing to preceding
113 and following stories (arranged chronologically). I suggest you use it with interpolate_fancy for testing whether $prevnextstory::prevlink and $prevnextstory::nextlink are defined to avoid spurious links to appear when there is no older or fresher story.
117 Drop this plugin into your plugin directory. Place substitution
118 variables $prevnextstory::prevlink and $prevnextstory::nextlink in your flavour file as an href value for an anchor element. You can also use $prevnextstory::prevtitle and $prevnextstory::nextlink to get the titles of those stories, and $prevnextstory::prevdate and $prevnextstory::nextdate to get their publication dates. If you need the dates, you will have to adapt the @monthname and @monthabbr lists to your needs, and in some cases modify the formatting performed by the make_list subroutine (default date format is DD/MM/YYYY, with month names in French).
124 Version number is the date on which this version of the plug-in was created.
128 2006-01-01blosxom2 : take into account the corrections of $path_info in recent versions of blosxom.cgi
130 2004-08-22blosxom2 : First published version
134 Barijaona Ramaholimihaso
135 Based on chrono_nav plugin by Victor Ganata (<aswang@fatoprofugus.net>, http://blog.fatoprofugus.net )
136 which was itself based on tree plugin by Ryan Schram (http://www.rschram.org)
137 with inspiration and some code techniques used in prevnextentry from Tatsuhiko Miyagawa (http://www.bulknews.net)
141 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net
143 Blosxom Plugin Docs: http://blosxom.sourceforge.net/plugins/
147 None known; please send bug reports and feedback to the Blosxom development mailing list <blosxom-devel@lists.sourceforge.net>.
151 Copyright 2003-2007, Barijaona Ramaholimihaso
153 Blosxom and config Plug-in
154 Copyright 2003, Rael Dornfest
156 Permission is hereby granted, free of charge, to any person obtaining a
157 copy of this software and associated documentation files (the "Software"),
158 to deal in the Software without restriction, including without limitation
159 the rights to use, copy, modify, merge, publish, distribute, sublicense,
160 and/or sell copies of the Software, and to permit persons to whom the
161 Software is furnished to do so, subject to the following conditions:
163 The above copyright notice and this permission notice shall be included
164 in all copies or substantial portions of the Software.
166 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
169 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
170 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
171 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
172 OTHER DEALINGS IN THE SOFTWARE.