Sha256: 21d881f88544d1dc48cdc92f7b4e9656f8f4ee7114f35d765531813246f31423

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 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'
      content_type :js
      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'
      content_type :css
      show params[:splat].join, :views => [File.join(Dir.pwd, 'public/stylesheets')]
    end
    get '/:id/?*' do
      response.headers['Cache-Control'] = 'no-cache'
      pass unless Slug.where(_id: params[:id]).exists?
      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

8 entries across 8 versions & 1 rubygems

Version Path
classiccms-0.5.14 lib/classiccms/controllers/website.rb
classiccms-0.5.13 lib/classiccms/controllers/website.rb
classiccms-0.5.12 lib/classiccms/controllers/website.rb
classiccms-0.5.11 lib/classiccms/controllers/website.rb
classiccms-0.5.10 lib/classiccms/controllers/website.rb
classiccms-0.5.9 lib/classiccms/controllers/website.rb
classiccms-0.5.8 lib/classiccms/controllers/website.rb
classiccms-0.5.7 lib/classiccms/controllers/website.rb