Sha256: 22ce50cb483917d7905f48ebdeb027772170ca602d43888df6be4b7954c4d8ce
Contents?: true
Size: 1.05 KB
Versions: 26
Compression:
Stored size: 1.05 KB
Contents
class PagesController < CmsController before_filter :find_page, only: :show private def find_page root = ActiveadminSelleoCms::Page.root raise "Create at least one page" unless root page_id = nil 5.downto(1).each do |l| if params["slug#{l}"] and page = ActiveadminSelleoCms::Page.where(parent_id: page_id).find_by_slug(params["slug#{l}"]) page_id = page.id end end @page = ActiveadminSelleoCms::Page.find_by_id(page_id) if !@page or (!@page.is_published? and @page != root) redirect_to page_path(I18n.locale, root) elsif @page.redirect_to_first_sub_page redirect_to page_path(I18n.locale, @page.children.first || root) elsif @page.is_link_url redirect_to @page.link_url end end public def show @page.update_column(:views, (@page.views || 0) + 1) render action: :show, layout: @page.layout_name end def index respond_to do |format| format.html { redirect_to page_path(I18n.locale, ActiveadminSelleoCms::Page.root) } format.json end end end
Version data entries
26 entries across 26 versions & 1 rubygems