Sha256: ac7644764f5c6c793140d93169a1c5996d32a86c26883ef4fbe535246839fbe0

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

require 'classiccms/controllers/application'

module Classiccms
  class WebsiteController < ApplicationController
    set :multi_views,   [ File.join(Dir.pwd, 'app/views')]
    set :root, Dir.pwd
    set :public_folder, Proc.new { File.join(Dir.pwd, 'public') }

    get '/' do
      response.headers['Cache-Control'] = 'no-cache'

      index = CONFIG[:home].kind_of?(String) ? CONFIG[:home] : 'application/index'
      @routes = get_route(get_first_item)
      @routes << nil
      show index
    end
    get '/javascripts/*.js' do
      response.headers['Cache-Control'] = ENV['RACK_ENV'] == 'development' ? 'no-cache' : 'public, max-age=86400'
      show params[:splat].join, :views => [File.join(Dir.pwd, 'public/javascripts')]
    end
    get '/stylesheets/*.css' do
      response.headers['Cache-Control'] = ENV['RACK_ENV'] == 'development' ? 'no-cache' : 'public, max-age=86400'
      show params[:splat].join, :views => [File.join(Dir.pwd, 'public/stylesheets')]
    end
    get '/:id/?*' do
      response.headers['Cache-Control'] = 'no-cache'
      pass unless Slug.exists?(conditions: {_id: params[:id]})
      index = CONFIG[:home].kind_of?(String) ? CONFIG[:home] : 'application/index'


      item = Base.find(Slug.find(params[:id]).document_id)
      @routes = get_route(item)
      @routes << nil
      show index
    end

    use Dragonfly::Middleware, :image
    not_found do
      show :'404', views: File.join(Classiccms::ROOT, 'views/cms')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
classiccms-0.3.8 lib/classiccms/controllers/website.rb
classiccms-0.3.7 lib/classiccms/controllers/website.rb
classiccms-0.3.6 lib/classiccms/controllers/website.rb
classiccms-0.3.5 lib/classiccms/controllers/website.rb
classiccms-0.3.4 lib/classiccms/controllers/website.rb
classiccms-0.3.3 lib/classiccms/controllers/website.rb
classiccms-0.3.2 lib/classiccms/controllers/website.rb
classiccms-0.3.1 lib/classiccms/controllers/website.rb
classiccms-0.3.0 lib/classiccms/controllers/website.rb