Class: OMF::Web::Theme::Page

Inherits:
AbstractPage show all
Defined in:
lib/omf-web/theme/bright/page.rb

Direct Known Subclasses

WidgetPage

Instance Attribute Summary

Attributes inherited from AbstractPage

#opts

Instance Method Summary collapse

Methods inherited from AbstractPage

add_depends_on, #collect_data_sources, #data_source_widgets, #initialize, #render_additional_headers, #render_data_source, #render_data_sources, #render_flash, #to_html

Constructor Details

This class inherits a constructor from OMF::Web::Theme::AbstractPage

Instance Method Details

#contentObject

end



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/omf-web/theme/bright/page.rb', line 36

def content
  super
  @renderer = @widget.content
  div :id => 'doc3' do
    if @renderer.render? :header
      div :id => 'hd' do
        if @renderer.render? :top_line
          render_top_line
        end
        if @renderer.render? :title
          render_title
        end
      end
    end
    div :id => 'bd' do
      render_body
    end
    if @renderer.render? :footer
      div :id => 'ft' do
        render_footer
      end
    end
  end
end

#render_bodyObject



152
153
154
155
# File 'lib/omf-web/theme/bright/page.rb', line 152

def render_body
  render_flash
  render_card_body
end

#render_card_bodyObject



157
158
159
160
161
# File 'lib/omf-web/theme/bright/page.rb', line 157

def render_card_body
  return unless @widget
  Thread.current["top_renderer"] = self
  rawtext @renderer.to_html
end


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/omf-web/theme/bright/page.rb', line 163

def render_footer
  if @footer_right.is_a? Proc
    widget(Erector.inline(&@footer_right))
  else
    span :style => 'float:right;margin-right:10pt' do
      text @footer_right || "omf-web V#{OMF::Web::VERSION}"
    end
  end
  if @footer_left.is_a? Proc
    widget(Erector.inline(&@footer_left))
  else
    text @footer_left || 'Brought to you by the TEMPO Team'
  end

end

#render_tab_menuObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/omf-web/theme/bright/page.rb', line 68

def render_tab_menu
  ol :id => :tab_menu do
    @tabs.each do |h|
      lopts = h[:id] == @tab ? {:class => :current} : {}
      li lopts do
        #a :href => "#{@prefix}/#{h[:id]}?sid=#{Thread.current["sessionID"]}" do
        a :href => "#{@prefix}/#{h[:id]}" do
          span h[:name], :class => :tab_text
        end
      end
    end
  end
end

#render_titleObject



148
149
150
# File 'lib/omf-web/theme/bright/page.rb', line 148

def render_title
  h1 @page_title || 'Missing :page_title'
end

#render_tools_menuObject

end



88
89
90
91
92
# File 'lib/omf-web/theme/bright/page.rb', line 88

def render_tools_menu
  ol :id => :tools_menu do
    render_tools_menu_authenticate
  end
end

#render_tools_menu_authenticateObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/omf-web/theme/bright/page.rb', line 94

def render_tools_menu_authenticate
  if user = OMF::Web::Rack::SessionAuthenticator.user()
    puts "USER>>>>> #{user}"
    li do
      a href: '#', class: 'user' do
        i class: "icon-user icon-white"
        text user[:name]
      end
    end
    li id: 'logout_li' do
      a id: 'logout_a', href: '#', class: 'logout' do
        i class: "icon-off icon-white"
        text 'Log out'
      end
    end
    am = "render_tools_menu_authenticate_#{user[:method]}".to_sym
    puts "METHOD>>>>> #{am}"
    if respond_to?(am)
      send(am, user)
    else
      javascript %{
        $('#logout_a').href = '/auth/logout'
      }
    end
  end
end

#render_tools_menu_authenticate_persona(user) ⇒ Object



121
122
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/bright/page.rb', line 121

def render_tools_menu_authenticate_persona(user)
  javascript %{
    $('#logout_li').hide();
    $.getScript("https://login.persona.org/include.js")
      .done(function(script, textStatus) {
        $('#logout_li').show();
        $('#logout_a').click(function() {
          navigator.id.logout();
        })
        navigator.id.watch({
          loggedInUser: '#{user}',
          onlogin: function(assertion) {},
          onlogout: function() {
            $.ajax({
              type: 'POST',
              url: '/auth/logout',
              success: function(res, status, xhr) {
                window.location = '/';
              },
              error: function(xhr, status, err) { alert("Logout failure: " + err); }
            });
          }
        })
      });
  }
end

#render_top_lineObject



61
62
63
64
65
66
# File 'lib/omf-web/theme/bright/page.rb', line 61

def render_top_line
  div :id => :top_line do
    render_tab_menu
    render_tools_menu
  end
end