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.0.10 plugin/category_to_tag.rb
tdiary-contrib-5.0.9 plugin/category_to_tag.rb
tdiary-contrib-5.0.8 plugin/category_to_tag.rb
tdiary-contrib-5.0.7 plugin/category_to_tag.rb
tdiary-contrib-5.0.6 plugin/category_to_tag.rb
tdiary-contrib-5.0.5 plugin/category_to_tag.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/category_to_tag.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-fa9c20aa0d97/plugin/category_to_tag.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-f08988dfa0f6/plugin/category_to_tag.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-a3c5f37278c4/plugin/category_to_tag.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/category_to_tag.rb
tdiary-contrib-5.0.4 plugin/category_to_tag.rb
tdiary-5.0.4 vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/category_to_tag.rb
tdiary-contrib-5.0.3 plugin/category_to_tag.rb
tdiary-contrib-5.0.2 plugin/category_to_tag.rb
tdiary-contrib-5.0.1 plugin/category_to_tag.rb
tdiary-contrib-5.0.0 plugin/category_to_tag.rb
tdiary-contrib-4.2.1 plugin/category_to_tag.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/bundler/gems/tdiary-contrib-2ab36447ae2a/plugin/category_to_tag.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/bundler/gems/tdiary-contrib-d189eb6688f1/plugin/category_to_tag.rb