Class: Gluttonberg::Public::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/public/pages_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#locale, #page

Instance Method Summary collapse

Instance Method Details

#error_404Object



63
64
65
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 63

def error_404
  render :layout => "bare" , :template => 'gluttonberg/public/exceptions/not_found.html.haml' , :status => 404
end

#restrict_site_accessObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 30

def restrict_site_access
  setting = Gluttonberg::Setting.get_setting("restrict_site_access")
  if setting == params[:password]
    cookies[:restrict_site_access] = "allowed"
    redirect_to( params[:return_url] || "/")
    return
  else
    cookies[:restrict_site_access] = ""  
  end
  render :layout => false
end

#showObject

If localized template file exist then render that file otherwise render non-localized template



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 7

def show
  if Gluttonberg::Member.enable_members == true && !@page.is_public?
    return unless require_member
    unless current_member.does_member_have_access_to_the_page?(page)
      raise CanCan::AccessDenied
    end  
  end
  
  template = page.view
  template_path = "pages/#{template}"
  
  if locale && File.exists?(File.join(Rails.root,  "app/views/pages/#{template}.#{locale.slug}.html.haml" ) )
    template_path = "pages/#{template}.#{locale.slug}"
  end  
  
  # do not render layout for ajax requests
  if request.xhr?
    render :template => template_path, :layout => false
  else
    render :template => template_path, :layout => page.layout
  end
end

#sitemapObject



42
43
44
45
46
47
48
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 42

def sitemap
  begin
    SitemapGenerator::Interpreter.respond_to?(:run)
  rescue
    render :layout => "bare" , :template => 'gluttonberg/public/exceptions/not_found.html.haml' , :status => 404
  end
end

#stylesheetsObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 50

def stylesheets
  @stylesheet = Stylesheet.find(:first , :conditions => { :slug => params[:id] })
  unless params[:version].blank?
    @version = params[:version]  
    @stylesheet.revert_to(@version)
  end
  if @stylesheet.blank?
    render :text => ""
  else  
    render :text => @stylesheet.value
  end  
end