Module: GraphStarter::ApplicationHelper
- Defined in:
- app/helpers/graph_starter/application_helper.rb
Instance Method Summary collapse
- #app_user ⇒ Object
- #app_user_is_admin? ⇒ Boolean
-
#asset_icon(asset, image = (image_unspecified = true; nil)) ⇒ Object
I know, right?.
- #asset_path(asset) ⇒ Object
- #engine_view {|eval("__FILE__.gsub(Rails.root.to_s, GraphStarter::Engine.root.to_s)",b.binding)| ... } ⇒ Object
- #missing_image_tag ⇒ Object
- #present_asset(object) {|AssetPresenter.new(object, self)| ... } ⇒ Object
- #render_body(asset, model_slug) ⇒ Object
Instance Method Details
#app_user ⇒ Object
29 30 31 |
# File 'app/helpers/graph_starter/application_helper.rb', line 29 def app_user defined?(:current_user) ? current_user : nil end |
#app_user_is_admin? ⇒ Boolean
25 26 27 |
# File 'app/helpers/graph_starter/application_helper.rb', line 25 def app_user_is_admin? current_user && current_user.respond_to?(:admin?) && current_user.admin? end |
#asset_icon(asset, image = (image_unspecified = true; nil)) ⇒ Object
I know, right?
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/graph_starter/application_helper.rb', line 38 def asset_icon(asset, image = (image_unspecified = true; nil)) image_url = if !image_unspecified image.source.url if image.present? elsif (asset.class.has_images? || asset.class.has_image?) && asset.first_image_source_url.present? asset.first_image_source_url end if image_url image_tag image_url, class: 'ui avatar image' else content_tag :i, '', class: [asset.class.icon_class || 'folder', 'large', 'icon'] end end |
#asset_path(asset) ⇒ Object
3 4 5 6 7 |
# File 'app/helpers/graph_starter/application_helper.rb', line 3 def asset_path(asset) # graph_starter.asset_path({id: asset.slug, model_slug: asset.class.model_slug}.merge(options)) # Switched to string for performance "/#{asset.class.model_slug}/#{asset.slug}" end |
#engine_view {|eval("__FILE__.gsub(Rails.root.to_s, GraphStarter::Engine.root.to_s)",b.binding)| ... } ⇒ Object
9 10 11 |
# File 'app/helpers/graph_starter/application_helper.rb', line 9 def engine_view(&b) yield eval("__FILE__.gsub(Rails.root.to_s, GraphStarter::Engine.root.to_s)",b.binding) end |
#missing_image_tag ⇒ Object
33 34 35 |
# File 'app/helpers/graph_starter/application_helper.rb', line 33 def missing_image_tag @missing_image_tag ||= image_tag 'missing.png' end |
#present_asset(object) {|AssetPresenter.new(object, self)| ... } ⇒ Object
21 22 23 |
# File 'app/helpers/graph_starter/application_helper.rb', line 21 def present_asset(object) yield(AssetPresenter.new(object, self)) if block_given? end |
#render_body(asset, model_slug) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/helpers/graph_starter/application_helper.rb', line 13 def render_body(asset, model_slug) views = Dir.glob(Rails.root.join("app/views/#{model_slug}/_body.html.*")) partial_path = views.present? ? "#{model_slug}/body" : '/graph_starter/assets/body' render partial: partial_path, locals: {asset: asset} end |