Sha256: 3780e2188fd4f50206069aac0255c96b025e4b33303bf985a9ec4a6af800c739

Contents?: true

Size: 1.45 KB

Versions: 19

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'
      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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
classiccms-0.7.5 lib/classiccms/controllers/website.rb
classiccms-0.7.4 lib/classiccms/controllers/website.rb
classiccms-0.7.3 lib/classiccms/controllers/website.rb
classiccms-0.7.2 lib/classiccms/controllers/website.rb
classiccms-0.7.1 lib/classiccms/controllers/website.rb
classiccms-0.7.0 lib/classiccms/controllers/website.rb
classiccms-0.6.9 lib/classiccms/controllers/website.rb
classiccms-0.6.8 lib/classiccms/controllers/website.rb
classiccms-0.6.7 lib/classiccms/controllers/website.rb
classiccms-0.6.6 lib/classiccms/controllers/website.rb
classiccms-0.6.5 lib/classiccms/controllers/website.rb
classiccms-0.6.4 lib/classiccms/controllers/website.rb
classiccms-0.6.3 lib/classiccms/controllers/website.rb
classiccms-0.6.2 lib/classiccms/controllers/website.rb
classiccms-0.6.1 lib/classiccms/controllers/website.rb
classiccms-0.6.0 lib/classiccms/controllers/website.rb
classiccms-0.5.17 lib/classiccms/controllers/website.rb
classiccms-0.5.16 lib/classiccms/controllers/website.rb
classiccms-0.5.15 lib/classiccms/controllers/website.rb