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.
Class Method Summary collapse
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.
33 34 35 36 37 38 |
# File 'lib/omf-web/theme/abstract_page.rb', line 33 def initialize(, opts) #puts "KEYS>>>>> #{opts.keys.inspect}" super opts @widget = @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
27 28 29 |
# File 'lib/omf-web/theme/abstract_page.rb', line 27 def opts @opts end |
Class Method Details
.add_depends_on(type, url) ⇒ Object
29 30 31 |
# File 'lib/omf-web/theme/abstract_page.rb', line 29 def self.add_depends_on(type, url) depends_on type.to_sym, url end |
Instance Method Details
#collect_data_sources(dsa) ⇒ Object
115 116 117 |
# File 'lib/omf-web/theme/abstract_page.rb', line 115 def collect_data_sources(dsa) dsa end |
#content ⇒ Object
40 41 |
# File 'lib/omf-web/theme/abstract_page.rb', line 40 def content end |
#data_source_widgets ⇒ Object
Return an array of widgets to collect data sources from
66 67 68 69 70 71 72 73 |
# File 'lib/omf-web/theme/abstract_page.rb', line 66 def # puts ">>>>> #{@widget.class}" # if @widget.respond_to? :data_source_widgets # @widget.data_source_widgets # else [@widget] # end end |
#render_additional_headers ⇒ Object
111 112 113 |
# File 'lib/omf-web/theme/abstract_page.rb', line 111 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
103 104 105 106 107 108 109 |
# File 'lib/omf-web/theme/abstract_page.rb', line 103 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
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 |
# File 'lib/omf-web/theme/abstract_page.rb', line 75 def render_data_sources return unless @widget require 'omf_oml/table' require 'set' dss = Set.new .each do |w| w.collect_data_sources(dss) end return if dss.empty? js = dss.map 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[ require(['omf/data_source_repo'], function(ds) { #{js.join("\n")} }); // ]]> </script> } end |
#render_flash ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/omf-web/theme/abstract_page.rb', line 43 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
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/omf-web/theme/abstract_page.rb', line 119 def to_html(opts = {}) page_title = @page_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 |