Module: Rblosxom::Helpers
- Included in:
- Base
- Defined in:
- lib/rblosxom/base.rb
Instance Method Summary collapse
-
#archive_list ⇒ Object
this year archive list.
-
#category_list ⇒ Object
all category list.
- #set_common_variables ⇒ Object
Instance Method Details
#archive_list ⇒ Object
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_list ⇒ Object
all category list
46 47 48 49 50 51 52 |
# File 'lib/rblosxom/base.rb', line 46 def category_list list = [] Dir["#{.config["datadir"]}/**/*"].each do |path| list.push([path, Dir["#{path}/*.textile]}"].length]) if File.directory? path end list end |
#set_common_variables ⇒ Object
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 = .root @config = .config @log = Proc.new { if .log_file begin unless File.exist?(.log_file) File.makedirs(File.dirname(.log_file)) File.new(.log_file, "w") end log = File.writable?(.log_file) ? Logger.new(.log_file) : Logger.new(STDOUT) rescue log = Logger.new(STDOUT) end else log = Logger.new(STDOUT) end log.progname = "#{::Rblosxom.name}" log.level = .log_level ? .log_level : Logger::INFO log.datetime_format = "%Y-%m-%d %H:%M:%S %Z " log }.call require 'date' @footer = { :year => %/#{DateTime.now.year}/, :copyright => %/#{.config["copyright"]}/, :generator => %/rblosxom #{::Rblosxom::Version::STRING}/ } end |