Class: OMF::Web::Theme::AbstractPage
- Inherits:
-
Erector::Widget
- Object
- Erector::Widget
- OMF::Web::Theme::AbstractPage
- Defined in:
- lib/omf-web/theme/abstract_page.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #collect_data_sources(dsa) ⇒ Object
- #content ⇒ Object
-
#data_source_widgets ⇒ Object
Return an array of widgets to collect data sources from.
-
#initialize(widget, opts) ⇒ AbstractPage
constructor
A new instance of AbstractPage.
- #render_additional_headers ⇒ Object
- #render_data_source(ds) ⇒ Object
- #render_data_sources ⇒ Object
- #render_flash ⇒ Object
- #to_html(opts = {}) ⇒ Object
Constructor Details
#initialize(widget, opts) ⇒ AbstractPage
Returns a new instance of AbstractPage.
20 21 22 23 24 25 |
# File 'lib/omf-web/theme/abstract_page.rb', line 20 def initialize(, opts) #puts "KEYS>>>>> #{opts.keys.inspect}" super opts = @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
18 19 20 |
# File 'lib/omf-web/theme/abstract_page.rb', line 18 def opts @opts end |
Instance Method Details
#collect_data_sources(dsa) ⇒ Object
119 120 121 |
# File 'lib/omf-web/theme/abstract_page.rb', line 119 def collect_data_sources(dsa) dsa end |
#content ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/omf-web/theme/abstract_page.rb', line 27 def content javascript %{ if (typeof(LW) == "undefined") LW = {}; LW.session_id = OML.session_id = '#{Thread.current["sessionID"]}'; L.provide('jquery', ['vendor/jquery/jquery.js']); //L.provide('jquery.periodicalupdater', ['vendor/jquery/jquery.periodicalupdater.js']); //L.provide('jquery.ui', ['vendor/jquery-ui/js/jquery-ui.min.js']); } end |
#data_source_widgets ⇒ Object
Return an array of widgets to collect data sources from
61 62 63 64 65 66 67 68 |
# File 'lib/omf-web/theme/abstract_page.rb', line 61 def # puts ">>>>> #{@widget.class}" # if @widget.respond_to? :data_source_widgets # @widget.data_source_widgets # else [] # end end |
#render_additional_headers ⇒ Object
115 116 117 |
# File 'lib/omf-web/theme/abstract_page.rb', line 115 def render_additional_headers #"\n\n<link href='/resource/css/incoming.css' media='all' rel='stylesheet' type='text/css' />\n" end |
#render_data_source(ds) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/omf-web/theme/abstract_page.rb', line 107 def render_data_source(ds) dspa = OMF::Web::DataSourceProxy.for_source(ds) dspa.collect do |dsp| dsp.reset() dsp.to_javascript(ds) end.join("\n") end |
#render_data_sources ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/omf-web/theme/abstract_page.rb', line 70 def render_data_sources return unless require 'omf-oml/table' require 'set' dss = Set.new .each do |w| w.collect_data_sources(dss) end #puts ">>>>>>>>>>> #{dss.inspect}" # dsh = {} # dss.each do |ds| # name = ds[:name].to_s # dsh[name] = ds.merge(dsh[name] || {}) # end #puts ">>>> #{dsh.inspect}" return if dss.empty? js = dss.map do |ds| render_data_source(ds) end # js = dsh.values.to_a.collect do |ds| # render_data_source(ds) # end # Calling 'javascript' doesn't seem to work here. No idea why, so let's do it by hand %{ <script type="text/javascript"> // <![CDATA[ #{js.join("\n")} // ]]> </script> } end |
#render_flash ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omf-web/theme/abstract_page.rb', line 38 def render_flash return unless @flash if @flash[:notice] div :class => 'flash_notice flash' do text @flash[:notice] end end if @flash[:alert] div :class => 'flash_alert flash' do a = @flash[:alert] if a.kind_of? Array ul do a.each do |t| li t end end else text a end end end end |
#to_html(opts = {}) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/omf-web/theme/abstract_page.rb', line 123 def to_html(opts = {}) page_title = @title # context may get screwed up below, so put title into scope b = super if @opts[:request].params.key?('embedded') b else e = render_externals << render_additional_headers << render_data_sources r = Erector.inline do instruct html do head do title page_title || "OMF WEB" #<link rel="shortcut icon" href="/resource/theme/@theme/img/favicon.ico"> #<link rel="apple-touch-icon" href="/resource/theme/@theme/img/apple-touch-icon.png"> text! e.join("\n") end body do text! b end end end r.to_html(opts) end end |