Octopress有一个第三方插件octopress-cumulus,可以生成酷酷的3D Tag Cloud。当然,本质上,这还是Category Cloud。但它的效果可以为我使用。因此,先按照该插件的要求,下载对应的文件。最重要的两个文件是source/javascripts目录下的tagcloud.swf与plugin目录下的category_cloud.rb。前者是生成3D效果的Flash;后者则是读取Category信息到swf中的插件。至于source/_includes/custom/asides/目录下的category_cloud.html文件,则是用于显示边栏的Tag Cloud效果。
moduleJekyll# The TagIndex class creates a single tag page for the specified tag.classTagIndex<Page# Initializes a new TagIndex.## +base+ is the String path to the <source>.# +tag_dir+ is the String path between <source> and the tag folder.# +tag+ is the tag currently being processed.definitialize(site,base,tag_dir,tag)@site=site@base=base@dir=tag_dir@name='index.html'self.process(@name)# Read the YAML data from the layout page.self.read_yaml(File.join(base,'_layouts'),'tag_index.html')self.data['tag']=tag# Set the title for this page.title_prefix=site.config['tag_title_prefix']||'Tag: 'self.data['title']="#{title_prefix}#{tag}"# Set the meta-description for this page.meta_description_prefix=site.config['tag_meta_description_prefix']||'Tag: 'self.data['description']="#{meta_description_prefix}#{tag}"endend# The tagFeed class creates an Atom feed for the specified tag.classTagFeed<Page# Initializes a new tagFeed.## +base+ is the String path to the <source>.# +tag_dir+ is the String path between <source> and the tag folder.# +tag+ is the tag currently being processed.definitialize(site,base,tag_dir,tag)@site=site@base=base@dir=tag_dir@name='atom.xml'self.process(@name)# Read the YAML data from the layout page.self.read_yaml(File.join(base,'_includes/custom'),'tag_feed.xml')self.data['tag']=tag# Set the title for this page.title_prefix=site.config['tag_title_prefix']||'Tag: 'self.data['title']="#{title_prefix}#{tag}"# Set the meta-description for this page.meta_description_prefix=site.config['tag_meta_description_prefix']||'Tag: 'self.data['description']="#{meta_description_prefix}#{tag}"# Set the correct feed URL.self.data['feed_url']="#{tag_dir}/#{name}"endend# The Site class is a built-in Jekyll class with access to global site config information.classSite# Creates an instance of tagIndex for each tag page, renders it, and# writes the output to a file.## +tag_dir+ is the String path to the tag folder.# +tag+ is the tag currently being processed.defwrite_tag_index(tag_dir,tag)index=TagIndex.new(self,self.source,tag_dir,tag)index.render(self.layouts,site_payload)index.write(self.dest)# Record the fact that this page has been added, otherwise Site::cleanup will remove it.self.pages<<index# Create an Atom-feed for each index.feed=TagFeed.new(self,self.source,tag_dir,tag)feed.render(self.layouts,site_payload)feed.write(self.dest)# Record the fact that this page has been added, otherwise Site::cleanup will remove it.self.pages<<feedend# Loops through the list of tag pages and processes each one.defwrite_tag_indexesifself.layouts.key?'tag_index'dir=self.config['tag_dir']||'tags'self.tags.keys.eachdo|tag|self.write_tag_index(File.join(dir,tag.gsub(/_|\P{Word}/,'-').gsub(/-{2,}/,'-').downcase),tag)end# Throw an exception if the layout couldn't be found.elsethrow"No 'tag_index' layout found."endendend# Jekyll hook - the generate method is called by jekyll, and generates all of the tag pages.classGenerateTags<Generatorsafetruepriority:lowdefgenerate(site)site.write_tag_indexesendend# Adds some extra filters used during the tag creation process.moduleFilters# Outputs a list of tags as comma-separated <a> links. This is used# to output the tag list for each post on a tag page.## +tags+ is the list of tags to format.## Returns string#deftag_links(tags)dir=@context.registers[:site].config['tag_dir']tags=tags.sort!.mapdo|item|"<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/,'-').gsub(/-{2,}/,'-').downcase}/'>#{item}</a>"endcasetags.lengthwhen0""when1tags[0].to_selse"#{tags[0...-1].join(', ')}, #{tags[-1]}"endend# Outputs the post.date as formatted html, with hooks for CSS styling.## +date+ is the date object to format as HTML.## Returns stringdefdate_to_html_string(date)result='<span class="month">'+date.strftime('%b').upcase+'</span> 'result+=date.strftime('<span class="day">%d</span> ')result+=date.strftime('<span class="year">%Y</span> ')resultendendend