Class: SparklesAppResource

Inherits:
Orange::Resource
  • Object
show all
Defined in:
lib/orange-sparkles/sparkles_app_resource.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


69
70
71
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 69

def default_style?
  orange.options["sparkles.default_style"] || stylesheets.empty?
end

#initObject



29
30
31
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 29

def init
  @tabs = []
end

#javascriptsObject



52
53
54
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 52

def javascripts
  orange.options["sparkles.javascripts"] || []
end

#sidebar?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 58

def sidebar?
  orange.options["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_initObject



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", '&#010;')
      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

#stylesheetsObject



49
50
51
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 49

def stylesheets
  orange.options["sparkles.stylesheets"] || []
end

#tabsObject



64
65
66
67
68
# File 'lib/orange-sparkles/sparkles_app_resource.rb', line 64

def tabs
  tabs = orange.options["sparkles.tabs"] || []
  tabs = (tabs + @tabs) unless @tabs.blank?
  tabs.collect{|hash| Mash.new(hash)} || []
end