Skip to content
Permalink
Browse files

Implement sprockets middleware

  • Loading branch information
Matteo Depalo
Matteo Depalo committed Mar 27, 2012
1 parent ffc563a commit cbe8925274e591c19e5bbdd9bca2928e1d11204a
@@ -9,7 +9,12 @@ gem 'pusher'

gem 'rake'

group :assets do
gem 'sprockets'
end

group :development, :test do
gem 'rspec'
gem 'jasmine'
gem 'foreman'
end
@@ -50,6 +50,9 @@ GEM
eventmachine (>= 0.12.9)
eventmachine (1.0.0.beta.4)
ffi (1.0.11)
foreman (0.41.0)
thor (>= 0.13.6)
hike (1.2.1)
http_parser.rb (0.5.3)
http_router (0.9.7)
rack (>= 1.0.0)
@@ -90,6 +93,13 @@ GEM
rubyzip
signature (0.1.2)
ruby-hmac
sprockets (2.3.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
url_mount (0.2.1)
rack
yajl-ruby (1.1.0)
@@ -100,9 +110,11 @@ PLATFORMS
DEPENDENCIES
em-http-request!
em-synchrony!
foreman
goliath!
jasmine
pusher
rake
rspec
sprockets
yajl-ruby
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,4 @@
//
// Router
//
//= require_self

var AppRouter = Backbone.Router.extend({

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,14 @@
module Goliath
module Rack
class Sprockets
include Goliath::Rack::AsyncMiddleware

def post_process(env, status, headers, body)
environment = ::Sprockets::Environment.new
environment.append_path 'assets/javascripts'
environment.append_path 'assets/stylesheets'
environment.call(env)
end
end
end
end
@@ -5,7 +5,7 @@
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' />
<title>Sveglia</title>
<link href='/favicon.ico' rel='icon' type='image/x-icon' />
<link href='/stylesheets/reset.css' media='all' rel='stylesheet' type='text/css' />
<link href='/reset.css' media='all' rel='stylesheet' type='text/css' />
<link href='//fonts.googleapis.com/css?family=Open+Sans:400italic,400,700' rel='stylesheet' type='text/css' />
<link href='/stylesheets/application.css' media='all' rel='stylesheet' type='text/css' />
</head>
@@ -5,18 +5,24 @@
require 'yajl'
require 'json'
require 'pusher'
require 'sprockets'

require_relative 'actions/hello'
require_relative 'actions/timers_index'
require_relative 'actions/timers_show'
require_relative 'actions/scheduler'
require_relative 'models/timer'
require_relative 'lib/goliath/rack/sprockets'

VERSION = "0.1.8".freeze

# automatically parse the JSON HTTP response
EM::HttpRequest.use EventMachine::Middleware::JSONResponse

class SprocketsAPI < Goliath::API
use Goliath::Rack::Sprockets
end

class Sveglia < Goliath::API
# map Goliath API to a specific path
get "/hello", Hello
@@ -28,7 +34,9 @@ class Sveglia < Goliath::API

# scheduler test
get "/scheduler", Scheduler


get "/assets/*", SprocketsAPI

# render static files from ./public
use(Rack::Static,
:root => Goliath::Application.app_path("public"),
@@ -43,4 +51,4 @@ class Sveglia < Goliath::API
def response(env)
raise "#response is ignored when using maps, so this exception won't raise. See spec/integration/rack_routes_spec."
end
end
end

0 comments on commit cbe8925

Please sign in to comment.
You can’t perform that action at this time.