Sha256: f32ee19836bf1d7732a009f0650770e721b1b9dcc8f89ff118cc2fd2d3675080

Contents?: true

Size: 855 Bytes

Versions: 29

Compression:

Stored size: 855 Bytes

Contents

module RsPages
  extend ActiveSupport::Concern
  included do
    before_filter :find_page
  end

  private

  def find_page
    @seo_page = find_seo_page request.path
    if !@seo_page.nil? && !@seo_page.redirect.blank?
      redirect_to @seo_page.redirect, status: :moved_permanently
    end
  end

  def find_seo_page(path)
    do_redirect = false
    if path[0] != '/'
      path = '/' + path
    end
    if path.length > 1 && path[-1] == '/'
      path = path[0..-2]
      do_redirect = true
    end

    page = Page.enabled.where(fullpath: path).first
    if page.nil?
      do_redirect = true
      spath = path.chomp(File.extname(path))
      if spath != path
        page = Page.enabled.where(fullpath: spath).first
      end
    end
    if !page.nil? && do_redirect
      redirect_to path, status: :moved_permanently
    end

    page
  end

end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
rocket_cms-0.6.15 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.14 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.13 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.12 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.11 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.10 app/controllers/concerns/rs_pages.rb
ack_rocket_cms-0.7.2.1 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.9 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.8 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.7 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.6 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.5 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.4 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.3 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.2 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.1 app/controllers/concerns/rs_pages.rb
rocket_cms-0.6.0 app/controllers/concerns/rs_pages.rb
rocket_cms-0.5.24 app/controllers/concerns/rs_pages.rb
rocket_cms-0.5.23 app/controllers/concerns/rs_pages.rb
rocket_cms-0.5.22 app/controllers/concerns/rs_pages.rb