Sha256: 79486ad80dc862069882f2724660b5424b66df355b3bf422985c22b5802f32c0

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

# -*- mode: ruby; coding: utf-8 -*-
#
# Copyright (C) 2011  Kouhei Sutou <kou@clear-code.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

require "sinatra/base"
require "haml"

module Rabbit
  module Middleware
    class Controller < Sinatra::Base
      attr_accessor :rabbit

      set :app_file, File.join(File.dirname(__FILE__), "config.ru")

      layout

      before do
        content_type("text/html", "charset" => "UTF-8")
      end

      get "/" do
        haml :index
      end

      get "/pages/next" do
        @rabbit.move_to_next_if_can
        haml :index
      end

      get "/pages/previous" do
        @rabbit.move_to_previous_if_can
        haml :index
      end

      get "/pages/:number" do |number|
        @rabbit.move_to_if_can(number.to_i)
        haml :index
      end

      def title
        "Rabbit"
      end

      def slide_title
        @rabbit.slide_title
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbit-1.0.9 lib/rabbit/middleware/controller.rb