class Modulobe::ModelFile
Attributes
comment[R]
file[R]
image_file[R]
length[R]
mtime[R]
name[R]
Public Class Methods
new(file)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 200 def initialize(file) @file = file @mtime = @file.mtime @length = @file.size @image_file = @file.to_s.sub(/\.mdlb\z/, '.gif').path @name = @author = @comment = nil end
Public Instance Methods
create_entry(action, path)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 265 def create_entry(action, path) href, url, img = prepare_link(action, path) name, author, comment = prepare_metadata tr = [:tr, {:class=>'model'}, [:td, img], [:td, [:div, {:class=>'author'}, author], [:div, {:class=>'name'}, [:a, {:href=>href}, name]], [:pre, {:class=>'comment'}, comment]]] return tr end
create_model_entry(action, path)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 276 def create_model_entry(action, path) href, url, img = prepare_link(action, path) name, author, comment = prepare_metadata return img end
create_rss_item(action, path)
click to toggle source
colinux:9190/modulobewiki/model.mdlbrss wiki.modulobe.com/model.mdlbrss
# File vendor/qwik/lib/qwik/modulobe.rb, line 284 def create_rss_item(action, path) href, url, img = prepare_link(action, path) name, author, comment = prepare_metadata item = [:item] item << [:title, name] item << [:link, url] src = img[2][1][:src] imgsrc = action.c_relative_to_absolute(src) html = "<p><img src=\"#{imgsrc}\" alt=\"#{name}\" width=\"100\" height=\"75\"/><br/>#{comment}</p>" item << [:description, html] item << [:author, author] item << [:pubDate, @mtime.rfc1123_date] item << [:enclosure, {:url=>url, :length=>@length, :type=>'application/xml'}] item << [:'creativeCommons:license', 'http://creativecommons.org/licenses/by-sa/2.5/deed.ja'] return item end
extract_info(str)
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 220 def extract_info(str) htree = HTree(str) wabisabi = htree.to_wabisabi info = wabisabi.get_path('//model/info') return [nil, nil, nil] unless info name = info.get_path('/name').text.set_xml_charset.to_page_charset author = info.get_path('/author').text.set_xml_charset.to_page_charset comment = info.get_path('/comment').text.set_xml_charset.to_page_charset return [name, author, comment] end
get_internal_info()
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 212 def get_internal_info if @name.nil? content = @file.read @name, @author, @comment = extract_info(content) end return @name, @author, @comment end
prepare_link(action, path)
click to toggle source
wget wiki.modulobe.com/model.mdlbrss colinux:9190/modulobewiki/model.html wget colinux:9190/modulobewiki/model.mdlbrss
# File vendor/qwik/lib/qwik/modulobe.rb, line 241 def prepare_link(action, path) # base = @file.basename('.mdlb').to_s # href = path+'/'+base+'.mdlb' model_file, model_relative = action.modulobe_model_link(@file) model_absolute = action.c_relative_to_root(model_relative) model_full = action.c_relative_to_absolute(model_relative) image_file, image_relative = action.modulobe_image_link(@file) if image_file.exist? thumb_file, thumb_relative = action.modulobe_thumb_link(@file) if ! thumb_file.exist? action.thumb_generate(image_file.basename.to_s) end img = [:img, {:src=>thumb_relative}] else img = [:img, {:width=>'100', :height=>'75', :src=>'model.files/x.gif'}] end img = [:a, {:href=>model_relative}, img] return [model_relative, model_full, img] end
prepare_metadata()
click to toggle source
# File vendor/qwik/lib/qwik/modulobe.rb, line 231 def prepare_metadata name = @name || @file.basename('.mdlb').to_s author = @author || 'anonymous' comment = @comment || '' return [name, author, comment] end