class Modulobe::ModelList
Public Class Methods
new(files)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 36 def initialize(files) @files = files @models = {} @days = nil @timeline = nil @last_time = nil end
Public Instance Methods
empty?()
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 44 def empty? get_all_models return @models.empty? end
get_all_models()
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 49 def get_all_models @files.each {|basename| next unless /\.mdlb\z/ =~ basename if @models[basename].nil? file = @files.path(basename) model = ModelFile.new(file) model.get_internal_info @models[basename] = model end } end
get_rss(action, base)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 168 def get_rss(action, base) get_all_models # @models are cached. prepare_timeline if @timeline.nil? xml = [] xml << [:'?xml', '1.0', 'utf-8'] rss = [:rss, {:version=>'2.0', :'xmlns:creativeCommons'=> 'http://backend.userland.com/creativeCommonsRssModule'}] xml << rss channel = [:channel, [:title, 'Modulobe model gallery'], [:link, 'http://wiki.modulobe.com/'], [:description, 'The model list of Modulobe Wiki site.'], [:language, 'ja'], [:managingEditor, 'modulobe@qwik.jp'], [:webMaster, 'modulobe@qwik.jp']] rss << channel channel << [:lastBuildDate, @last_time.rfc1123_date] channel << [:ttl, '60'] @timeline.each {|model| item = model.create_rss_item(action, base) channel << item } return xml end
get_style()
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 95 def get_style return [:style, ' /* ==================== model */ div.model { margin: 1em 0; padding: 10px; border: 0; background-color: #fff; } table.model { margin: 0; width: 100%; border: 0; } tr.day th { padding: 15px 0 0 0; border-top: 0; border-right: 0; border-bottom: 0; border-left: 0; color: #0c0; background-color: transparent; } tr.model td { margin: 0; padding: 0; border: 1px solid #f30; border: 0; line-height: 1.0; } tr.model td img { margin: 10px 10px 0 10px; border: 0; border-bottom: 0; } tr.model td a { border: 0; } tr.model td div { margin: 0; padding: 0; } tr.model td div.author { font-size: small; } tr.model td div.name { margin: 0 0 0 0; font-size: medium; font-weight: bold; } tr.model td div.name a { text-decoration: underline; } tr.model td pre { margin: 0; padding: 0; border: 0; line-height: 1.0; background-color: transparent; } '] end
get_table(action, path)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 77 def get_table(action, path) get_all_models # @models are cached. prepare_timeline if @timeline.nil? trs = [] @days.to_a.sort_by {|ymd, models| ymd }.reverse.each {|ymd, models| trs << [:tr, {:class=>'day'}, [:th, {:colspan=>'3'}, ymd]] models.each {|model| trs << model.create_entry(action, path) } } table = [:table, {:class=>'model'}, *trs] div = [:div, {:class=>'model'}, table] return div end
prepare_timeline()
click to toggle source
private :get_all_models
# File vendor/qwik/lib/qwik/modulobe.rb, line 62 def prepare_timeline @timeline = @models.values.sort_by {|model| model.mtime } return if @timeline.last.nil? @last_time = @timeline.last.mtime @days = Hash.new {|h, k| h[k] = []} @timeline.reverse.each {|model| if model @days[model.mtime.ymd] << model end } end