Class: Gluttonberg::Public::PagesController

Inherits:
BaseController 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



66
67
68
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 66

def error_404
  render :layout => "bare" , :template => 'exceptions/not_found' , :status => 404, :handlers => [:haml], :formats => [:html]
end

#restrict_site_accessObject



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

def restrict_site_access
  setting = Gluttonberg::Setting.get_setting("restrict_site_access", current_site_config_name)
  if setting == params[:password]
    cookies[:restrict_site_access] = "allowed"
    redirect_to( params[:return_url] || "/")
    return
  else
    cookies[:restrict_site_access] = ""
  end
  respond_to do |format|
    format.html{ render :layout => false }
  end
end

#showObject

If localized template file exist then render that file otherwise render non-localized template for ajax request do not render layout



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

def show
  return unless verify_page_access
  if current_user && params[:preview].to_s == "true"
    Gluttonberg::AutoSave.load_version(@page.current_localization)
  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

Html version of site sitemap



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

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

#stylesheetsObject

serve CMS based css to public



53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/gluttonberg/public/pages_controller.rb', line 53

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