Sha256: aa56e0341031f24521592ea2b2122165b41d5d496c6d0f29c18349cacf010263

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

require "rack/contrib"
require "sinatra"
require "sinatra/reloader"
require "sassc"
require "almanack"

module Almanack
  class Server < Sinatra::Base
    require "almanack/server/helpers"
    require "almanack/server/environment"

    include Almanack::ServerContext::Environment

    set :root, -> { Almanack.config.theme_root }
    set :protection, except: :frame_options
    set :feed_path, "feed"

    use Rack::JSONP

    configure :development do
      register Sinatra::Reloader
    end

    helpers do
      include Almanack::ServerContext::Helpers
    end

    before do
      register_sass_loadpaths!
    end

    not_found do
      status 404
      erb :error
    end

    error do
      status 500
      erb :error
    end

    get "/" do
      erb :events
    end

    get "/#{settings.feed_path}.ics" do
      content_type "text/calendar"
      Almanack.calendar.ical_feed
    end

    get "/#{settings.feed_path}.json" do
      content_type :json
      Almanack.calendar.json_feed
    end

    get "/stylesheets/:name" do
      content_type :css
      auto_render_asset params[:name], within: "stylesheets"
    end

    get "/javascripts/:name" do
      content_type :js
      auto_render_asset params[:name], within: "javascripts"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
almanack-1.3.1 lib/almanack/server.rb
almanack-1.3.0 lib/almanack/server.rb
almanack-1.3.0.rc1 lib/almanack/server.rb
almanack-1.2.1 lib/almanack/server.rb