Permalink
Browse files

Update Pinion to the newest version.

I've also made our usage of Pinion fit the newer way of doing things.
  • Loading branch information...
1 parent e3c38d0 commit b070dc60db498ffb1bf53cce0bbc2785b661d929 @cespare cespare committed Aug 9, 2012
View
@@ -13,7 +13,7 @@ gem "resque"
gem "sass", "~> 3.1.16"
# For managing compiling and caching assets
-gem "pinion", "~> 0.1.5"
+gem "pinion"
# Really nice scss mixin library.
gem "bourbon"
View
@@ -65,7 +65,7 @@ GEM
nokogiri (1.5.0)
open4 (1.3.0)
pathological (0.2.4)
- pinion (0.1.5)
+ pinion (0.2.2)
rack (~> 1.0)
polyglot (0.3.2)
pony (1.3)
@@ -171,7 +171,7 @@ DEPENDENCIES
mysql2
nokogiri
pathological
- pinion (~> 0.1.5)
+ pinion
pony
pry
pygments.rb
View
@@ -1,15 +1,17 @@
require "bundler/setup"
require "pathological"
+require "bourbon"
require "coffee-script"
require "json"
require "methodchain"
require "nokogiri"
+require "open-uri"
require "openid"
require "openid/extensions/ax"
require "openid/store/filesystem"
-require "open-uri"
require "pinion"
+require "pinion/sinatra_helpers"
require "redcarpet"
require "redis"
require "sass"
@@ -45,11 +47,17 @@
class BarkeepServer < Sinatra::Base
attr_accessor :current_user
- def initialize(pinion)
- @pinion = pinion
- super()
+ # Set up Pinion to manage static and compiled assets.
+ set :pinion, Pinion::Server.new("/assets")
+ configure do
+ pinion.convert :scss => :css
+ pinion.convert :coffee => :js
+ pinion.watch "public"
+ pinion.watch "#{Gem.loaded_specs["bourbon"].full_gem_path}/app/assets/stylesheets"
end
+ helpers Pinion::SinatraHelpers
+
# Pinion will handle all static routes
disable :static
set :views, "views"
@@ -147,7 +155,7 @@ def ensure_required_params(*required_params)
end
end
- get("/favicon.ico") { redirect @pinion.asset_url("favicon.ico") }
+ get("/favicon.ico") { redirect asset_url("favicon.ico") }
get("/") { redirect "/commits" }
View
@@ -1,20 +1,6 @@
require "./barkeep_server"
require "resque/server"
-require "pinion"
-# NOTE(caleb): We need to require bourbon somewhere so that it is available when the sass is compiled (inside
-# Pinion -- see the watch for the bourbon styles directory below). If we do not require bourbon, there will be
-# annoying bugs because the sass extension function 'compact', defined in Ruby, will be unavailable, and the
-# generated css will contain invalid things like "compact(#fff, #000, false, false, false...)"
-require "bourbon"
-
-PINION_MOUNT_POINT = "/assets"
-pinion = Pinion::Server.new(PINION_MOUNT_POINT)
-pinion.convert :scss => :css
-pinion.convert :coffee => :js
-pinion.watch "public"
-pinion.watch "#{Gem.loaded_specs["bourbon"].full_gem_path}/app/assets/stylesheets"
-
-map(PINION_MOUNT_POINT) { run pinion }
map("/resque") { run Resque::Server.new }
-map("/") { run BarkeepServer.new(pinion) }
+map(BarkeepServer.pinion.mount_point) { run BarkeepServer.pinion }
+map("/") { run BarkeepServer }
View
@@ -21,11 +21,6 @@ def stub_commit(sha, user)
end
end
-class StubPinion
- def css_url(_) "" end
- def js_url(_) "" end
-end
-
# This dataset stub can be used to spy on the parameters being sent through our datasets. Use it like this:
# @dataset = DatasetStub.new([movie1, movie2])
# Movie.stubs(:dataset).returns(@dataset)
View
@@ -7,7 +7,7 @@ class ApiTest < Scope::TestCase
include Rack::Test::Methods
include StubHelper
- def app() BarkeepServer.new(StubPinion.new) end
+ def app() BarkeepServer.new end
setup do
@@repo = MetaRepo.new("/dev/null")
@@ -5,7 +5,7 @@ class BarkeepServerTest < Scope::TestCase
include Rack::Test::Methods
include StubHelper
- def app() BarkeepServer.new(StubPinion.new) end
+ def app() BarkeepServer.new end
setup do
@@repo = MetaRepo.new("/dev/null")
View
@@ -1,4 +1,4 @@
-<%= @pinion.css_url("/css/admin.css") %>
+<%= css_url("/css/admin.css") %>
<div id="admin" class="copy">
<%= yield %>
View
@@ -4,7 +4,7 @@
- repos_hashes: an array of repo hashes of the form { :git_repo, :newest_commit }.
%>
-<%= @pinion.js_url("/coffee/repos.js") %>
+<%= js_url("/coffee/repos.js") %>
<div id="repos">
View
@@ -1,6 +1,6 @@
-<%= @pinion.js_url("/coffee/commit.js") %>
-<%= @pinion.js_url("/vendor/jquery.easing.1.3.js") %>
-<%= @pinion.js_url("/vendor/mustache.js") %>
+<%= js_url("/coffee/commit.js") %>
+<%= js_url("/vendor/jquery.easing.1.3.js") %>
+<%= js_url("/vendor/mustache.js") %>
<script id="context-expander-template" type="text/x-mustache-template">
<%= MustacheRenderer.context_expander_source %>
</script>
View
@@ -1,6 +1,6 @@
-<%= @pinion.js_url("/coffee/smart_search.js") %>
-<%= @pinion.js_url("/coffee/commit_search.js") %>
-<%= @pinion.js_url("/vendor/jquery.easing.1.3.js") %>
+<%= js_url("/coffee/smart_search.js") %>
+<%= js_url("/coffee/commit_search.js") %>
+<%= js_url("/vendor/jquery.easing.1.3.js") %>
<!-- These options apply to all commit lists shown on the page. -->
<% if current_user %>
View
@@ -4,16 +4,16 @@
<title>Barkeep</title>
<link href='//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic' \
rel='stylesheet' type='text/css' />
- <%= @pinion.css_url("/css/styles.css") %>
- <%= @pinion.js_url("/vendor/jquery-1.7.min.js") %>
- <%= @pinion.js_url("/vendor/jquery-ui-1.8.19.custom.min.js") %>
- <%= @pinion.js_url("/vendor/jquery.json-2.2.min.js") %>
- <%= @pinion.js_url("/vendor/jquery.tipsy.js") %>
- <%= @pinion.js_url("/vendor/jquery.hotkeys.js") %>
- <%= @pinion.js_url("/vendor/livecss.js") %>
- <%= @pinion.js_url("/coffee/constants.js") %>
- <%= @pinion.js_url("/coffee/util.js") %>
- <%= @pinion.js_url("/coffee/snippets.js") %>
+ <%= css_url("/css/styles.css") %>
+ <%= js_url("/vendor/jquery-1.7.min.js") %>
+ <%= js_url("/vendor/jquery-ui-1.8.19.custom.min.js") %>
+ <%= js_url("/vendor/jquery.json-2.2.min.js") %>
+ <%= js_url("/vendor/jquery.tipsy.js") %>
+ <%= js_url("/vendor/jquery.hotkeys.js") %>
+ <%= js_url("/vendor/livecss.js") %>
+ <%= js_url("/coffee/constants.js") %>
+ <%= js_url("/coffee/util.js") %>
+ <%= js_url("/coffee/snippets.js") %>
<script>
$(document).ready(function() {
View
@@ -1,6 +1,6 @@
-<%= @pinion.js_url("/vendor/flot/jquery.flot.min.js") %>
-<%= @pinion.js_url("/vendor/flot/jquery.flot.pie.min.js") %>
-<%= @pinion.js_url("/coffee/stats.js") %>
+<%= js_url("/vendor/flot/jquery.flot.min.js") %>
+<%= js_url("/vendor/flot/jquery.flot.pie.min.js") %>
+<%= js_url("/coffee/stats.js") %>
<div id="stats">
<% if current_user %>
View
@@ -1,5 +1,5 @@
-<%= @pinion.css_url("/css/user_settings.css") %>
-<%= @pinion.js_url("/coffee/user_settings.js") %>
+<%= css_url("/css/user_settings.css") %>
+<%= js_url("/coffee/user_settings.js") %>
<div id="settings" class="copy">
<div class="column">

0 comments on commit b070dc6

Please sign in to comment.