2
# category_to_tag.rb - show categories list in end of each section
4
# Copyright (C) 2005, TADA Tadashi <sho@spc.gr.jp>
5
# You can redistribute it and/or modify it under GPL2.
8
if respond_to?( :categorized_title_of_day ) then # BlogKit
9
def categorized_title_of_day( date, title )
10
@category_to_tag_list = {}
11
cats, stripped = title.scan( /^((?:\[[^\]]+\])+)\s*(.*)/ )[0]
13
cats.scan( /\[([^\]]+)\]+/ ).flatten.each do |tag|
14
@category_to_tag_list[tag] = true # true when blog
21
add_body_leave_proc do |date|
22
feed ? '' : category_to_tag_list
24
elsif respond_to?( :category_anchor ) # diary
25
add_section_enter_proc do |date, index|
26
@category_to_tag_list = {}
29
alias subtitle_link_original subtitle_link
30
def subtitle_link( date, index, subtitle )
33
s = subtitle.sub( /^(\[([^\[]+?)\])+/ ) do
34
$&.scan( /\[(.*?)\]/ ) do |tag|
35
@category_to_tag_list[CGI::unescapeHTML(tag[0])] = false # false when diary
40
subtitle_link_original( date, index, s.strip )
42
add_section_leave_proc do |date, index|
43
feed ? '' : category_to_tag_list
47
def category_to_tag_list
48
if @category_to_tag_list and not @category_to_tag_list.empty? then
49
r = '<div class="tags">Tags: '
50
@category_to_tag_list.each do |tag, blog|
52
r << %Q|<a href="#{h @index}?blogcategory=#{h tag}">#{tag}</a> |
54
r << category_anchor( "#{tag}" ).sub( /^\[/, '' ).sub( /\]$/, '' ) << ' '