Class: SparklesAppResource
- Inherits:
-
Orange::Resource
- Object
- Orange::Resource
- SparklesAppResource
- Defined in:
- lib/orange-sparkles/sparkles_app_resource.rb
Instance Method Summary collapse
- #add_tab(resource, text = nil) ⇒ Object
- #default_style? ⇒ Boolean
- #init ⇒ Object
- #javascripts ⇒ Object
- #sidebar? ⇒ Boolean
- #site_name(packet, default = "An Orange Site") ⇒ Object
- #stack_init ⇒ Object
- #stylesheets ⇒ Object
- #tabs ⇒ Object
Instance Method Details
#add_tab(resource, text = nil) ⇒ Object
61 62 63 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 61 def add_tab(resource, text = nil) @tabs << {:resource => resource, :text => (text || resource.to_s.capitalize)} end |
#default_style? ⇒ Boolean
69 70 71 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 69 def default_style? orange.["sparkles.default_style"] || stylesheets.empty? end |
#init ⇒ Object
29 30 31 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 29 def init @tabs = [] end |
#javascripts ⇒ Object
52 53 54 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 52 def javascripts orange.["sparkles.javascripts"] || [] end |
#sidebar? ⇒ Boolean
58 59 60 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 58 def orange.["sidebar_on"] || false end |
#site_name(packet, default = "An Orange Site") ⇒ Object
55 56 57 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 55 def site_name(packet, default = "An Orange Site") packet['site'] ? packet['site'].name : default end |
#stack_init ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 32 def stack_init orange[:scaffold].add_scaffold_type(:markdown) do |name, val, opts| packet = opts[:packet] opts = opts.with_defaults({:value => '', :label => false, :show => false, :wrap_tag => 'div'}) if opts[:show] packet.markdown(val || '') else val = '' if val.blank? val.gsub!("\n", '
') ret = "<textarea name='#{opts[:model_name]}[#{name}]' class='markdown-editor'>#{val}</textarea>" ret = "<label for=''>#{opts[:display_name]}</label><br />" + ret if opts[:label] ret = "<#{opts[:wrap_tag]}>#{ret}</#{opts[:wrap_tag]}>" if opts[:wrap_tag] ret end end end |
#stylesheets ⇒ Object
49 50 51 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 49 def stylesheets orange.["sparkles.stylesheets"] || [] end |
#tabs ⇒ Object
64 65 66 67 68 |
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 64 def tabs tabs = orange.["sparkles.tabs"] || [] tabs = (tabs + @tabs) unless @tabs.blank? tabs.collect{|hash| Mash.new(hash)} || [] end |