module ApplicationHelper
+ def manifest
+ Manifest.manifest
+ end
+
+ def full_url filename
+ request.protocol + request.host_with_port + filename
+ end
+
+ def t_m(label)
+ l = label.split('.')
+ if l.size > 2
+ label
+ else
+ if l.size == 1
+ label.constantize.model_name.human
+ else
+ l.first.constantize.human_attribute_name(l.last)
+ end
+ end
+ end
+
+ def t_select_items(items)
+ items.map {|i| [t(i[0]), i[1]] }
+ end
+
+ def t_selected_item(name, index)
+ t(manifest.system_resources.select_items[name][index][0])
+ end
+
+ def item_tag
+ tag :img, :src => asset_path('item.png'), :width => 35, :height => 35
+ end
+
+ def icon_tag name, opt = {}
+ title = opt[:object] ? (name.to_s + ' ID:' + opt[:object].id.to_s) : name
+ size = opt[:size] ? opt[:size].to_i : 35
+ tag :img, :src => '/images/' + name.to_s.underscore + '.gif', :width => size, :height => size, :alt => name.to_s + ' Icon', :title => title
+ end
+
+ def author_icon opt = {}
+ icon_tag :Author, opt
+ end
+
+ def artist_icon opt = {}
+ icon_tag :Artist, opt
+ end
+
+ def scroll_icon opt = {}
+ icon_tag :Scroll, opt
+ end
+
+ def scroll_panel_icon opt = {}
+ icon_tag :ScrollPanel, opt
+ end
+
+ def comic_icon opt = {}
+ icon_tag :Comic, opt
+ end
+
+ def story_icon opt = {}
+ icon_tag :Story, opt
+ end
+
+ def story_sheet_icon opt = {}
+ icon_tag :StorySheet, opt
+ end
+
+ def sheet_icon opt = {}
+ icon_tag :Sheet, opt
+ end
+
+ def sheet_panel_icon opt = {}
+ icon_tag :Sheet, opt
+ end
+
+ def panel_icon opt = {}
+ icon_tag :Panel, opt
+ end
+
+ def panel_editor_javascript_include_tags
+ WritingFormat.enable_list().map {|wf|
+# javascript_include_tag wf.engine_name
+ javascript_include_tag wf.template_path_name + "/application"
+ }.join("\n") +
+ SpeechBalloonTemplate.enable_list().map {|sbt|
+ stylesheet_link_tag sbt.template_path_name + "/application"
+ }.join("\n") +
+ SpeechBalloonTemplate.enable_list().map {|sbt|
+ javascript_include_tag sbt.template_path_name + "/application"
+ }.join("\n")
+ end
+
end