Class: Juli::Command::Tag

Inherits:
Object
  • Object
show all
Includes:
Util, Visitor::Html::TagHelper
Defined in:
lib/juli/command/tag.rb

Overview

generate _tag.shtml which shows tag-search-result HTML page.

Instance Method Summary collapse

Methods included from Visitor::Html::TagHelper

#content_tag, #tag

Methods included from Util

#camelize, conf, find_template, in_filename, juli_repo, mkdir, out_filename, str_limit, str_trim, to_wikiname, underscore, usage, visitor, visitor_list

Constructor Details

#initializeTag

Returns a new instance of Tag.



9
10
11
# File 'lib/juli/command/tag.rb', line 9

def initialize
  @tag_macro = Juli::Macro::Tag.new
end

Instance Method Details

#run(opts) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/juli/command/tag.rb', line 13

def run(opts)
  # tag list
  body = (:a, '', :name=>'top').force_encoding('UTF-8') +
         "<h2>#{I18n.t('tag_list')}</h2>\n".force_encoding('UTF-8')
  for tag in @tag_macro.tag_db.keys do
    body += gen_tag_list(tag)
  end
  body += gen_tag_list(
              Juli::Macro::Tag::NO_TAG,
              I18n.t(Juli::Macro::Tag::NO_TAG))
  body += "\n\n" + '<br/>'*50

  # tag detail
  for tag in @tag_macro.tag_db.keys do
    body += gen_tag_detail(tag)
  end
  body += gen_tag_detail(
              Juli::Macro::Tag::NO_TAG,
              I18n.t(Juli::Macro::Tag::NO_TAG))

  title       = I18n.t('tag_list')
  contents    = ''
  prototype   = 'prototype.js'
  javascript  = 'juli.js'
  stylesheet  = 'juli.css'
  erb = ERB.new(File.read(find_template('simple.html')))
  File.open(File.join(conf['output_top'], '_tag.shtml'), 'w') do |f|
    f.write(erb.result(binding))
  end
end