Module: Xhive::ApplicationHelper
- Defined in:
- app/helpers/xhive/application_helper.rb
Instance Method Summary collapse
- #current_site ⇒ Object
- #include_custom_stylesheets ⇒ Object
- #initialize_widgets_loader ⇒ Object
-
#render_page_with(key = nil, options = {}, &block) ⇒ Object
Public: looks for a map and renders the corresponding page.
-
#safe_user ⇒ Object
Private: Returns a safe user, e.i.
Instance Method Details
#current_site ⇒ Object
28 29 30 31 32 33 |
# File 'app/helpers/xhive/application_helper.rb', line 28 def current_site domain = request.host @current_site ||= Site.where(:domain => domain).first || Site.first fail "No Site defined. Please create a default Site." unless @current_site.present? @current_site end |
#include_custom_stylesheets ⇒ Object
7 8 9 |
# File 'app/helpers/xhive/application_helper.rb', line 7 def include_custom_stylesheets "<link href='#{xhive.stylesheets_path}' media='all' rel='stylesheet' type='text/css'/>".html_safe end |
#initialize_widgets_loader ⇒ Object
3 4 5 |
# File 'app/helpers/xhive/application_helper.rb', line 3 def "<script type='text/javascript'>WidgetLoader.load()</script>".html_safe end |
#render_page_with(key = nil, options = {}, &block) ⇒ Object
Public: looks for a map and renders the corresponding page.
key - The String containing the key to look for (default = nil). options - The Hash the data to pass to the rendered page. block - The block for a custom render if no map is found.
Returns: the rendered page.
19 20 21 22 23 24 25 26 |
# File 'app/helpers/xhive/application_helper.rb', line 19 def render_page_with(key = nil, ={}, &block) page = Xhive::Mapper.page_for(current_site, controller_path, action_name, key, ) if page.present? render :inline => page.present_content(), :layout => true else block_given? ? yield : render end end |
#safe_user ⇒ Object
Private: Returns a safe user, e.i. a logged user or a guest user.
This is just a placeholder and should be implemented in the host app.
Example:
def safe_user
current_user || AnonymousUser.new
end
Returns: an anonymous user.
47 48 49 |
# File 'app/helpers/xhive/application_helper.rb', line 47 def safe_user AnonymousUser.new end |