From: Matthijs Kooijman Date: Tue, 27 Apr 2010 22:51:05 +0000 (+0200) Subject: tagging: Allow using titles in for related stories. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=HEAD;p=matthijs%2Fupstream%2Fblosxom-plugins.git tagging: Allow using titles in for related stories. Previously, the filename was always used. Now there is a configuration option, $related_story_title, which is disabled by default but allows showing the title instead. --- diff --git a/xtaran/tagging b/xtaran/tagging index bde29eb..0e408a1 100644 --- a/xtaran/tagging +++ b/xtaran/tagging @@ -229,6 +229,8 @@ our $related_story_join = "\n" unless defined $related_story_join; our $related_story_prefix = '' unless defined $related_story_suffix; our $related_story_class = 'related_stories' unless defined $related_story_class; +# Use the title of the post for the link instead of the filename +our $related_story_title = 0 unless defined $related_story_title; our $shared_tags_text = 'shared tags' unless defined $shared_tags_text; @@ -257,6 +259,7 @@ $related_stories = ''; $related_tags = ''; %tags = (); +%titles = (); %related_tags = (); sub start { @@ -322,8 +325,13 @@ sub story { $opath =~ s!\Q$blosxom::datadir\E!$blosxom::url!; $opath =~ s!\Q$blosxom::file_extension\E$!$blosxom::default_flavour!; - my $title = $other; - $title =~ s!^.*/([^/]+)\.$blosxom::file_extension$!$1!; + my $title; + if ($related_story_title) { + $title = $titles{$other}; + } else { + $title = $other; + $title =~ s!^.*/([^/]+)\.$blosxom::file_extension$!$1!; + } my $shared_tags_list = join(', ', @{$other_stories{$other}}); my $shared_tags_number = scalar(@{$other_stories{$other}}); @@ -369,6 +377,10 @@ sub filter { my $tags_found = 0; my $empty_line_found = 0; while ($_ = ) { + # Take the title from the first line + if (not defined $titles{$key}) { + $titles{$key} = $_; + } last if /^\s*$/; if (m!^$tag_re(.+?)$!) { my @localtags = split($split_re, $1);