Update flavourpathinfo to use Blosxom::Debug.
[blosxom-plugins.git] / general / storytitle
blobbc0e74926b28ab8909034e8dc0663fc370f4f0e8
1 # Blosxom plugin: storytitle
2 # Author(s): Struan Donald <code@exo.org.uk>
3 # Version: 0.5
4 # Documentation: see bottom of file or perldoc title
6 package storytitle;
8 # ------------------ Config variables ---------------------
10 # default seperator to add to story title
12 my $sep = ' : ';
14 # do we default to the right aligned title
15 # 1 for right aligned, 0 for left
17  my $right = 0;
19 # seperator for right aligned title 
21 my $right_sep = ''
22     || $sep;
24 # seperator for left aligned title
26 my $left_sep = ''
27     || $sep;
29 # ---------------------------------------------------------
31 sub start { 1; }
32 sub head {
33     my ($p, $dir, $head) = @_;
34     my $title;
35     if (!$dir) {
36         $title = (defined $blosxom::path_info_da ? "$blosxom::path_info_da/" : "") . (defined $blosxom::path_info_mo ? "$blosxom::path_info_mo/" : "") . "$blosxom::path_info_yr" ;
37         
38     } elsif ($dir =~ m#(.*?)/?([\-\.\w]+)\.(\w+)$# and $2 ne 'index') {
39         $file = join('/', $blosxom::datadir, $1, "$2.txt");
40         my $fh = new FileHandle;
41         if (-f "$file" && $fh->open("< $file")) {
42             chomp($title = <$fh>);
43             $fh->close;
44         }
45     }
46     if (defined $title and $title =~ /\S/) {
47         $page_title_right = $right_sep . $title;
48         $page_title_left = $title . $left_sep;
49         $page_title =  $right ? $page_title_right : $page_title_left;
50     } else { # these need to be reset otherwise we'll get the last value
51         $page_title_right = undef;
52         $page_title_left = undef;
53         $page_title = undef;
54     } 
59 __END__
60 =head1 NAME
62 Blosxom Plug-in: storytitle
64 =head1 SYNOPSIS
66 Allows you to include the story title in the page header for individually views blosxom stories.
68 =head2 QUICK START
70 Put title in your plug-ins directory.
72 If required change the $sep variable. This controls the seperator that goes at the start of the story title. E.g. if $sep is ' : ' and the story title is 'A blosxom entry' then the plugin will return ' : A blosxom entry'.
74 Now all individually displayed stories can have their title in the pages title tag, or anywhere else in the page header you want. Just place $storytitle::page_title where you want to display the story title.
76 =head2 LEFT AND RIGHT ALIGNED TITLES
78 If you have a need for a left aligned title (i.e. you want to have 'story title : somethign else') then you can use either $storytitle::page_title_left or set the value of $right in the configuration to 0. In that case $storytitle::page_title will have the seperator at the left.
80 You can also individually configure the left and right sided seperators with the left_sep and right_sep configuration options. $storytitle::page_title_left and $storytitle::page_title_right will access the left and right sided titles.
82 =head1 VERSION
84 0.5
86 =head2 CHANGES
88 0.5 - deals with filenames with like foo.bar.txt and foo-bar.txt (thanks to
89       Antti Vähä-Sipilä for pointing this out)
90       catches titles containing only white space.
92 0.4 - bugfix to stop title values hanging around under static generation
94 0.3 - fixed left_title to actually be a left title
96 0.2 - introduced left and right options
98 =head1 AUTHOR
100 Struan Donald <code@exo.org.uk>, http://exo.org.uk/code/
102 =head2 CREDITS
104 Lim Chee Aun <http://phoenity.com/> for the left/right sided titles idea.
106 =head1 SEE ALSO
108 Blosxom Home/Docs/Licensing:http://blosxom.sourceforge.net/
110 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
112 =head1 BUGS
114 None known; please send bug reports and feedback to the Blosxom
115 development mailing list <blosxom-devel@lists.sourceforge.net>.
117 =head1 COPYRIGHT
119 Copyright (C) 2003 Struan Donald. 
121 This program is free software; you can redistribute
122 it and/or modify it under the same terms as Perl itself.
124 =cut