Module: Rblosxom::Helpers

Included in:
Base
Defined in:
lib/rblosxom/base.rb

Instance Method Summary collapse

Instance Method Details

#archive_listObject

this year archive list



55
56
57
58
59
60
61
62
# File 'lib/rblosxom/base.rb', line 55

def archive_list
    list = []
    now = DateTime.now
    this_year = now.year
    this_month = now.month
    1.upto(now.month) { |m| list.push(DateTime.new(this_year, m)) }
    list
end

#category_listObject

all category list



46
47
48
49
50
51
52
# File 'lib/rblosxom/base.rb', line 46

def category_list
    list = []
    Dir["#{options.config["datadir"]}/**/*"].each do |path|
        list.push([path, Dir["#{path}/*.textile]}"].length]) if File.directory? path
    end 
    list
end

#set_common_variablesObject



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
43
# File 'lib/rblosxom/base.rb', line 16

def set_common_variables
    require 'fileutils'
    require 'logger'
    @root = options.root
    @config = options.config
    @log = Proc.new {
        if options.log_file
            begin
                unless File.exist?(options.log_file)
                    File.makedirs(File.dirname(options.log_file))
                    File.new(options.log_file, "w")
                end
                log = File.writable?(options.log_file) ? Logger.new(options.log_file) : Logger.new(STDOUT)
            rescue
                log = Logger.new(STDOUT)
            end
        else
            log = Logger.new(STDOUT)
        end
        log.progname = "#{::Rblosxom.name}"
        log.level = options.log_level ? options.log_level : Logger::INFO
        log.datetime_format = "%Y-%m-%d %H:%M:%S %Z "
        log
    }.call

    require 'date'
    @footer = { :year => %/#{DateTime.now.year}/, :copyright => %/#{options.config["copyright"]}/, :generator => %/rblosxom #{::Rblosxom::Version::STRING}/ }
end