1 # Blosxom plugin: storytitle
2 # Author(s): Struan Donald <code@exo.org.uk>
4 # Documentation: see bottom of file or perldoc title
9 use vars qw($sep $right $right_sep $left_sep $page_title $page_title_left $page_title_right);
11 # ------------------ Config variables ---------------------
13 # default seperator to add to story title
14 $sep = ' : ' unless defined $sep;
16 # do we default to the right aligned title
17 # 1 for right aligned, 0 for left
18 $right = 0 unless defined $right;
20 # seperator for right aligned title
21 $right_sep = ''|| $sep unless defined $right_sep;
23 # seperator for left aligned title
24 $left_sep = '' || $sep unless defined $left_sep;
26 # ------ Output variables --------------------------------
31 # ---------------------------------------------------------
35 my ($p, $dir, $head) = @_;
38 $title = (defined $blosxom::path_info_da ? "$blosxom::path_info_da/" : "") . (defined $blosxom::path_info_mo ? "$blosxom::path_info_mo/" : "") . "$blosxom::path_info_yr" ;
40 } elsif ($dir =~ m#(.*?)/?([\-\.\w]+)\.(\w+)$# and $2 ne 'index') {
41 my $file = join('/', $blosxom::datadir, $1, "$2.txt");
42 my $fh = new FileHandle;
43 if (-f "$file" && $fh->open("< $file")) {
44 chomp($title = <$fh>);
48 if (defined $title and $title =~ /\S/) {
49 $page_title_right = $right_sep . $title;
50 $page_title_left = $title . $left_sep;
51 $page_title = $right ? $page_title_right : $page_title_left;
52 } else { # these need to be reset otherwise we'll get the last value
53 $page_title_right = undef;
54 $page_title_left = undef;
64 Blosxom Plug-in: storytitle
68 Allows you to include the story title in the page header for individually views blosxom stories.
72 Put title in your plug-ins directory.
74 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'.
76 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.
78 =head2 LEFT AND RIGHT ALIGNED TITLES
80 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.
82 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.
90 0.5 - deals with filenames with like foo.bar.txt and foo-bar.txt (thanks to
91 Antti Vähä-Sipilä for pointing this out)
92 catches titles containing only white space.
94 0.4 - bugfix to stop title values hanging around under static generation
96 0.3 - fixed left_title to actually be a left title
98 0.2 - introduced left and right options
102 Struan Donald <code@exo.org.uk>, http://exo.org.uk/code/
106 Lim Chee Aun <http://phoenity.com/> for the left/right sided titles idea.
110 Blosxom Home/Docs/Licensing:http://blosxom.sourceforge.net/
112 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
116 None known; please send bug reports and feedback to the Blosxom
117 development mailing list <blosxom-devel@lists.sourceforge.net>.
121 Copyright (C) 2003 Struan Donald.
123 This program is free software; you can redistribute
124 it and/or modify it under the same terms as Perl itself.