Sha256: 95cbf0fcd26229b279ba82c2987010df9acc53ff0da08bff42fb83d7818f65e3

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'haml'
require 'sinatra'
require 'json'

module Nutcracker
  module Web
    class App < Sinatra::Base
      enable :inline_templates
      set :root, File.expand_path('../'*4,__FILE__)

      def initialize(nutcracker = nil)
        @nutcracker = nutcracker
        super()
      end

      get '/' do
        haml :index
      end

      get '/overview.json' do
        content_type :json
        overview.to_json
      end

      def overview
        @nutcracker.overview rescue
         JSON.parse File.read File.join(settings.root,"example.json")
      end  

      def self.assets
        require 'sprockets'
        Sprockets::Environment.new { |env|
          %w(javascripts stylesheets templates).each { |asset|
            env.append_path File.join(settings.root,"assets/#{asset}")
          }
        }
      end

    end
  end
end

__END__

@@ layout
%html
  %head
    %title Nutcracker-Web
    %script(type='text/javascript' src='http://www.google.com/jsapi')
    %script(type='text/javascript' src='assets/application.js')
    %link(rel='stylesheet' href='assets/application.css')
  %body
    = yield

@@ index
#navbar
.container
  #container{ "data-clusters" => overview.to_json }
    loading...
#footer
- 3.times do
  %br

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nutcracker-web-0.0.4 lib/nutcracker/web/app.rb