OSDN Git Service

fix: any
[pettanr/pettanr.git] / app / helpers / application_helper.rb
1 module ApplicationHelper
2   def manifest
3     Manifest.manifest
4   end
5   
6   def full_url filename
7     request.protocol + request.host_with_port + filename
8   end
9   
10   def t_m(label)
11     l = label.split('.')
12     if l.size > 2
13       label
14     else
15       if l.size == 1
16         label.constantize.model_name.human
17       else
18         l.first.constantize.human_attribute_name(l.last)
19       end
20     end
21   end
22   
23   def t_select_items(items)
24     items.map {|i| [t(i[0]), i[1]] }
25   end
26   
27   def t_selected_item(name, index)
28     t(manifest.system_resources.select_items[name][index][0])
29   end
30   
31   def item_tag 
32     tag :img, :src => asset_path('item.png'), :width => 35, :height => 35
33   end
34   
35   def icon_tag name, opt = {}
36     title = opt[:object] ? (name.to_s + ' ID:' + opt[:object].id.to_s) : name
37     size = opt[:size] ? opt[:size].to_i : 35
38     tag :img, :src => '/images/' + name.to_s.underscore + '.gif', :width => size, :height => size, :alt => name.to_s + ' Icon', :title => title
39   end
40   
41   def author_icon opt = {}
42     icon_tag :Author, opt
43   end
44   
45   def artist_icon opt = {}
46     icon_tag :Artist, opt
47   end
48   
49   def scroll_icon opt = {}
50     icon_tag :Scroll, opt
51   end
52   
53   def scroll_panel_icon opt = {}
54     icon_tag :ScrollPanel, opt
55   end
56   
57   def comic_icon opt = {}
58     icon_tag :Comic, opt
59   end
60   
61   def story_icon opt = {}
62     icon_tag :Story, opt
63   end
64   
65   def story_sheet_icon opt = {}
66     icon_tag :StorySheet, opt
67   end
68   
69   def sheet_icon opt = {}
70     icon_tag :Sheet, opt
71   end
72   
73   def sheet_panel_icon opt = {}
74     icon_tag :Sheet, opt
75   end
76   
77   def panel_icon opt = {}
78     icon_tag :Panel, opt
79   end
80   
81   def panel_editor_javascript_include_tags
82     WritingFormat.enable_list().map {|wf|
83 #      javascript_include_tag wf.engine_name
84       javascript_include_tag wf.template_path_name + "/application"
85     }.join("\n") + 
86     SpeechBalloonTemplate.enable_list().map {|sbt|
87       stylesheet_link_tag sbt.template_path_name + "/application"
88     }.join("\n") + 
89     SpeechBalloonTemplate.enable_list().map {|sbt|
90       javascript_include_tag sbt.template_path_name + "/application"
91     }.join("\n")
92   end
93   
94 end