Changeset 87
- Timestamp:
- 04/02/06 12:59:38 (2 years ago)
- Files:
-
- blosxom_plugins/trunk/tagging (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
blosxom_plugins/trunk/tagging
r42 r87 1 1 # Blosxom Plugin: tagging 2 2 # Author: Gosuke Miyashita <miya@mizzy.org> 3 # Version: 2006-0 1-053 # Version: 2006-04-02 4 4 # Blosxom Home/Docs/Licensing: http://www.blosxom.com/ 5 5 … … 8 8 use strict; 9 9 use CGI qw(param url); 10 use vars qw($list $current_tag $find_tag $tags_in_this $tags_in_this_array );10 use vars qw($list $current_tag $find_tag $tags_in_this $tags_in_this_array $related_tags); 11 11 use Storable qw(store retrieve); 12 12 use Jcode; … … 58 58 } 59 59 } 60 60 61 61 foreach my $tag (sort keys %tags){ 62 62 my $encoded_tag = $tag; … … 64 64 $list .= "<li><a href='$url?tag=$encoded_tag'>$tag</a> ($tags{$tag})</li>\n"; 65 65 } 66 67 }else {66 } 67 else { 68 68 foreach my $tag (sort keys %$tags_list){ 69 69 if(($find_tag and $tag =~ /^$find_tag/i) or !$find_tag){ … … 132 132 133 133 134 ## find entries that have tags 134 ## find entries that have tags 135 135 if(param('tag')){ 136 136 my @tags = split(/,/, param('tag')); 137 137 my ($files_have_tags, $cnt); 138 138 139 139 foreach my $tag (@tags){ 140 140 if(!$files_have_tags and !$cnt){ 141 141 %$files_have_tags = map { $_ => $files->{$_} } @{$tags_to_files->{$tag}}; 142 } else { 142 } 143 else { 143 144 my $files_have_tags_tmp; 144 145 foreach my $file (keys %$files_have_tags){ … … 156 157 157 158 %$files = %$files_have_tags; 159 160 my %related_tags; 161 for my $file (keys %$files){ 162 for my $tag (@{$files_to_tags->{$file}}){ 163 if(param('tag') !~ /$tag/){ 164 $related_tags{$tag}++; 165 } 166 } 167 } 168 169 $related_tags = '<ul>'; 170 for my $tag (sort keys %related_tags){ 171 my $encoded_tag = $tag; 172 my $current_tag = param('tag'); 173 $encoded_tag =~ s/(\W)/sprintf("%%%02X", ord($1))/ego; 174 $related_tags .= "<li><a href='$blosxom::url/?tag=$current_tag,$encoded_tag'>$tag</a> ($related_tags{$tag})</li>\n"; 175 } 176 $related_tags .= '</ul>'; 158 177 } 159 178 … … 169 188 foreach (sort @tags) { 170 189 my $encoded_tag = $_; 171 $encoded_tag =~ s/(\W)/sprintf("%%%02X", ord($1))/ego; 190 $encoded_tag =~ s/(\W)/sprintf("%%%02X", ord($1))/ego; 172 191 $tags_in_this .= "<a href='$blosxom::url/?tag=$encoded_tag'>$_</a> "; 173 192 }
