Sha256: bad1a660a0cf9b3005d6c72c18f1745cf668af9f7946605d94ad91c085d09e2f

Contents?: true

Size: 1.54 KB

Versions: 52

Compression:

Stored size: 1.54 KB

Contents

#
# category_to_tag.rb - show categories list in end of each section
#
# Copyright (C) 2005, TADA Tadashi <sho@spc.gr.jp>
# You can redistribute it and/or modify it under GPL2.
#

if respond_to?( :categorized_title_of_day ) then # BlogKit
	def categorized_title_of_day( date, title )
		@category_to_tag_list = {}
		cats, stripped = title.scan( /^((?:\[[^\]]+\])+)\s*(.*)/ )[0]
		if cats then
			cats.scan( /\[([^\]]+)\]+/ ).flatten.each do |tag|
				@category_to_tag_list[tag] = true # true when blog
			end
		else
			stripped = title
		end
		stripped
	end
	add_body_leave_proc do |date|
		feed? ? '' : category_to_tag_list
	end
elsif respond_to?( :category_anchor ) # diary
	add_section_enter_proc do |date, index|
		@category_to_tag_list = {}
		''
	end
	alias subtitle_link_original subtitle_link
	def subtitle_link( date, index, subtitle )
		s = ''
		if subtitle then
			s = subtitle.sub( /^(\[([^\[]+?)\])+/ ) do
				$&.scan( /\[(.*?)\]/ ) do |tag|
					@category_to_tag_list[CGI::unescapeHTML(tag[0])] = false # false when diary
				end
				''
			end
		end
		subtitle_link_original( date, index, s.strip )
	end
	add_section_leave_proc do |date, index|
		feed? ? '' : category_to_tag_list
	end
end

def category_to_tag_list
	if @category_to_tag_list and not @category_to_tag_list.empty? then
		r = '<div class="tags">Tags: '
		@category_to_tag_list.each do |tag, blog|
			if blog
				r << %Q|<a href="#{h @index}?blogcategory=#{h tag}">#{tag}</a> |
			else
				r << category_anchor( "#{tag}" ).sub( /^\[/, '' ).sub( /\]$/, '' ) << ' '
			end
		end
		r << "</div>\n"
	end
end

Version data entries

52 entries across 46 versions & 2 rubygems

Version Path
tdiary-contrib-5.3.0 plugin/category_to_tag.rb
tdiary-contrib-5.2.4 plugin/category_to_tag.rb
tdiary-contrib-5.2.3 plugin/category_to_tag.rb
tdiary-contrib-5.2.2 plugin/category_to_tag.rb
tdiary-contrib-5.2.1 plugin/category_to_tag.rb
tdiary-contrib-5.2.0 plugin/category_to_tag.rb
tdiary-contrib-5.1.7 plugin/category_to_tag.rb
tdiary-contrib-5.1.6 plugin/category_to_tag.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/plugin/category_to_tag.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/plugin/category_to_tag.rb
tdiary-contrib-5.1.5 plugin/category_to_tag.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/plugin/category_to_tag.rb
tdiary-contrib-5.1.4 plugin/category_to_tag.rb
tdiary-contrib-5.1.3 plugin/category_to_tag.rb
tdiary-contrib-5.1.2 plugin/category_to_tag.rb
tdiary-contrib-5.1.1 plugin/category_to_tag.rb
tdiary-contrib-5.1.0 plugin/category_to_tag.rb
tdiary-contrib-5.0.13 plugin/category_to_tag.rb
tdiary-contrib-5.0.12 plugin/category_to_tag.rb
tdiary-contrib-5.0.11 plugin/category_to_tag.rb