sass_on_heroku_with_rack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README +42 -0
- data/Rakefile +17 -0
- data/app/controllers/sass_on_heroku_with_rack/stylesheets_controller.rb +13 -0
- data/config/routes.rb +3 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/engine.rb +8 -0
- data/lib/sass_on_heroku_with_rack/version.rb +3 -0
- data/lib/sass_on_heroku_with_rack.rb +1 -0
- data/sass_on_heroku_with_rack.gemspec +25 -0
- data/uninstall.rb +1 -0
- metadata +116 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
SassOnHerokuWithRack
|
2
|
+
====================
|
3
|
+
|
4
|
+
For use with Heroku and Rails3 only.
|
5
|
+
|
6
|
+
A Rails engine that lets you use sass with Heroku easily. Create a stylesheet link tag pointing to any scss or sass file at /stylesheets and that will get mapped to the generated sass source.
|
7
|
+
|
8
|
+
Add this to you Gemfile if you are using bundler:
|
9
|
+
gem 'sass_on_heroku_with_rack', :git => 'https://github.com/rdy/sass_on_heroku_with_rack.git'
|
10
|
+
|
11
|
+
Or you can build and install the gem.
|
12
|
+
|
13
|
+
The generated sass files will be cached with varnish because of the cache control headers. Anytime you deploy to heroku the cached files will be flushed automatically so you don't have to worry about the old versions.
|
14
|
+
|
15
|
+
Configuration is simple, you still you configure your sass plugin normally. I use the following defaults for my /config/initializer/sass_plugin_options.rb:
|
16
|
+
|
17
|
+
Sass::Plugin.options[:template_location] = './app/stylesheets'
|
18
|
+
Sass::Plugin.options[:load_paths] = ['./app/stylesheets']
|
19
|
+
Sass::Plugin.options[:syntax] = :scss
|
20
|
+
|
21
|
+
Also the last important thing to do is to add the following line to your production.rb:
|
22
|
+
|
23
|
+
Sass::Plugin.options[:never_update] = true
|
24
|
+
|
25
|
+
The benefit of this plugin is mapping all the generated sass files automatically so you can create multiple stylesheets at the same time for different resources and get automatic caching with varnish on Heroku.
|
26
|
+
|
27
|
+
Example
|
28
|
+
=======
|
29
|
+
|
30
|
+
If you've made all the correct configuration changes all you need to do is link to your stylesheets.
|
31
|
+
|
32
|
+
For example in your layout:
|
33
|
+
<%= stylesheet_link_tag 'application' %>
|
34
|
+
<%= stylesheet_link_tag 'iphone', :media => 'handheld, only screen and (max-device-width: 480px)' %>
|
35
|
+
<%= stylesheet_link_tag 'iphone4', :media => 'handheld, only screen and (-webkit-min-device-pixel-ratio:2)' %>
|
36
|
+
|
37
|
+
Will map to files in:
|
38
|
+
/app/stylesheets/application.scss
|
39
|
+
/app/stylesheets/iphone.scss
|
40
|
+
/app/stylesheets/iphone4.scss
|
41
|
+
|
42
|
+
Copyright (c) 2010 Ryan Dy, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
spec = nil
|
6
|
+
File.open('sass_on_heroku_with_rack.gemspec', 'r') {|f| spec = eval(f.read)}
|
7
|
+
|
8
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
9
|
+
pkg.need_zip = false
|
10
|
+
pkg.need_tar = false
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
task :default => :spec
|
16
|
+
|
17
|
+
task :default => [:spec]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class SassOnHerokuWithRack::StylesheetsController < ActionController::Metal
|
2
|
+
include ActionController::Rendering
|
3
|
+
|
4
|
+
def show
|
5
|
+
response.headers['Cache-Control'] = "public, max-age=#{1.year.seconds.to_i}" if Rails.env.production?
|
6
|
+
|
7
|
+
sass_options = Sass::Plugin.options
|
8
|
+
sass_options.merge! :style => :compressed unless Rails.env.development?
|
9
|
+
extension = sass_options[:syntax] == :scss ? 'scss' : 'sass'
|
10
|
+
filename = Rails.root.join('app', 'stylesheets', "#{params[:stylesheet]}.#{extension}")
|
11
|
+
render :text => Sass::Engine.new(File.read(filename), sass_options).render, :content_type => 'text/css'
|
12
|
+
end
|
13
|
+
end
|
data/config/routes.rb
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/lib/engine.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'engine' if defined?(Rails)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sass_on_heroku_with_rack/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sass_on_heroku_with_rack"
|
7
|
+
s.version = SassOnHerokuWithRack::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ryan Dy"]
|
10
|
+
s.email = ["ryan.dy@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/sass_on_heroku_with_rack"
|
12
|
+
s.summary = %q{Runs sass on heroku using rack middleware}
|
13
|
+
s.description = %q{Runs sass on heroku using rack middleware. This takes advantage of heroku's varnish to refresh the stylsehet.'}
|
14
|
+
|
15
|
+
s.rubyforge_project = "sass_on_heroku_with_rack"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "rspec-rails"
|
19
|
+
s.add_development_dependency "gemcutter"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sass_on_heroku_with_rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Ryan Dy
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-03 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec-rails
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: gemcutter
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
description: Runs sass on heroku using rack middleware. This takes advantage of heroku's varnish to refresh the stylsehet.'
|
60
|
+
email:
|
61
|
+
- ryan.dy@gmail.com
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- MIT-LICENSE
|
72
|
+
- README
|
73
|
+
- Rakefile
|
74
|
+
- app/controllers/sass_on_heroku_with_rack/stylesheets_controller.rb
|
75
|
+
- config/routes.rb
|
76
|
+
- init.rb
|
77
|
+
- install.rb
|
78
|
+
- lib/engine.rb
|
79
|
+
- lib/sass_on_heroku_with_rack.rb
|
80
|
+
- lib/sass_on_heroku_with_rack/version.rb
|
81
|
+
- sass_on_heroku_with_rack.gemspec
|
82
|
+
- uninstall.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/sass_on_heroku_with_rack
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: sass_on_heroku_with_rack
|
111
|
+
rubygems_version: 1.3.7
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Runs sass on heroku using rack middleware
|
115
|
+
test_files: []
|
116
|
+
|