sinatra-support 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +10 -0
- data/lib/sinatra/support/csssupport.rb +31 -2
- data/lib/sinatra/support/i18nsupport.rb +8 -8
- data/lib/sinatra/support/jssupport.rb +14 -7
- data/lib/sinatra/support/version.rb +1 -1
- metadata +2 -2
data/HISTORY.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
v1.0.2 - Mar 29, 2011
|
2
|
+
---------------------
|
3
|
+
|
4
|
+
### Added:
|
5
|
+
* Implement CssSupport's `css_aggressive_mtime` directive
|
6
|
+
|
7
|
+
### Minor changes:
|
8
|
+
* Update I18n helpers documentation
|
9
|
+
* Update documentation for JsSupport and CssSupport
|
10
|
+
|
1
11
|
v1.0.1 - Mar 27, 2011
|
2
12
|
---------------------
|
3
13
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# This plugin supports Sass, Less and SCSS and guesses by the
|
18
18
|
# file name.
|
19
19
|
#
|
20
|
-
# ==
|
20
|
+
# == Sass caveats
|
21
21
|
#
|
22
22
|
# Note that you will need to set your Sass/SCSS +load_path+ settings.
|
23
23
|
#
|
@@ -28,9 +28,31 @@
|
|
28
28
|
# m.set :scss, self.scss.merge(:style => :compressed) if m.production?
|
29
29
|
# end
|
30
30
|
#
|
31
|
+
# == Less caveats
|
32
|
+
#
|
33
|
+
# If you're using Less, it's best you separate your CSS into many files,
|
34
|
+
# as Less is pretty slow. By default however, CssSupport will ask browsers
|
35
|
+
# to recache all CSS files even when one is changed, which is to your
|
36
|
+
# disadvantage considering Less's speed.
|
37
|
+
#
|
38
|
+
# You can disable this behavior so that browsers will only fetch CSS files
|
39
|
+
# that changed.
|
40
|
+
#
|
41
|
+
# register Sinatra::CssSupport
|
42
|
+
# Main.set :css_aggressive_mtime, false
|
43
|
+
#
|
44
|
+
# == Settings
|
45
|
+
#
|
46
|
+
# [+css_max_age+] The maximum time (in seconds) a browser
|
47
|
+
# should hold onto a cached copy.
|
48
|
+
# (default: 30 days)
|
49
|
+
# [+css_aggressive_mtime+] If true, ask browsers to recache all CSS files
|
50
|
+
# when one is updated. Default: true
|
51
|
+
#
|
31
52
|
module Sinatra::CssSupport
|
32
53
|
def self.registered(app)
|
33
54
|
app.set :css_max_age, app.development? ? 0 : 86400*30
|
55
|
+
app.set :css_aggressive_mtime, true
|
34
56
|
end
|
35
57
|
|
36
58
|
def serve_css(url_prefix, options={})
|
@@ -41,7 +63,13 @@ module Sinatra::CssSupport
|
|
41
63
|
fname = Dir[File.join(prefix, "#{name}.{css,scss,less}")].first or pass
|
42
64
|
|
43
65
|
content_type :css, :charset => 'utf-8'
|
44
|
-
|
66
|
+
|
67
|
+
if settings.css_aggressive_mtime
|
68
|
+
last_modified Dir[prefix, "**/*"].map { |f| File.mtime(f).to_i }.max
|
69
|
+
else
|
70
|
+
last_modified File.mtime(fname)
|
71
|
+
end
|
72
|
+
|
45
73
|
cache_control :public, :must_revalidate, :max_age => settings.css_max_age
|
46
74
|
|
47
75
|
if fname =~ /\.scss$/
|
@@ -56,3 +84,4 @@ module Sinatra::CssSupport
|
|
56
84
|
end
|
57
85
|
end
|
58
86
|
end
|
87
|
+
|
@@ -8,19 +8,20 @@
|
|
8
8
|
# set :default_locale, 'fr' # Optional; defaults to 'en'
|
9
9
|
# end
|
10
10
|
#
|
11
|
-
# Be sure that you have the +I18n+ gem.
|
11
|
+
# Be sure that you have the +I18n+ gem. Use +gem install i18n+, or if you're
|
12
|
+
# using Bundler:
|
12
13
|
#
|
13
14
|
# # Gemfile
|
14
15
|
# gem "i18n"
|
15
16
|
#
|
16
|
-
# (or +gem install i18n+)
|
17
|
-
#
|
18
17
|
# Then put your locale YAML files into +./config/locales+ (whatever path you
|
19
18
|
# use for {#load_locales}:
|
20
19
|
#
|
21
20
|
# # config/locales/en.yml
|
22
21
|
# en:
|
23
22
|
# an_article: "An article"
|
23
|
+
# create: "Create"
|
24
|
+
# delete: "Delete"
|
24
25
|
#
|
25
26
|
# == Helpers
|
26
27
|
#
|
@@ -67,21 +68,20 @@
|
|
67
68
|
# == Locale files
|
68
69
|
#
|
69
70
|
# This gem does not ship with default options for time, date and such.
|
70
|
-
# You may want to get those from:
|
71
|
-
#
|
72
|
-
# https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
|
71
|
+
# You may want to get those from the Rails-I18n project:
|
72
|
+
# https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
|
73
73
|
#
|
74
74
|
# == Using a different backend
|
75
75
|
#
|
76
76
|
# Instead of calling {#load_locales}, just load the right I18n backend
|
77
77
|
# using the I18n gem.
|
78
78
|
#
|
79
|
-
# You can also just use I18n.store_translations if you still want to use
|
79
|
+
# You can also just use +I18n.store_translations+ if you still want to use
|
80
80
|
# the default simple I18n backend.
|
81
81
|
#
|
82
82
|
# == Settings
|
83
83
|
#
|
84
|
-
# [+default_locale+] The locale to use by default. Defaults to +
|
84
|
+
# [+default_locale+] The locale to use by default. Defaults to +en+.
|
85
85
|
#
|
86
86
|
module Sinatra::I18nSupport
|
87
87
|
def self.registered(app)
|
@@ -4,16 +4,18 @@
|
|
4
4
|
#
|
5
5
|
# require 'sinatra/support/jssupport'
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# class Main < Sinatra::Base
|
8
|
+
# register Sinatra::JsSupport
|
9
|
+
# serve_js '/js', from: './app/js'
|
10
|
+
# end
|
8
11
|
#
|
9
|
-
#
|
10
|
-
# serve_js '/js', from: './app/js'
|
11
|
-
#
|
12
|
-
# Assuming you have a +app/js/jquery.js+ file, you will
|
13
|
-
# then be able to access it from the given URL prefix.
|
12
|
+
# You'll be able to access files via +/js+:
|
14
13
|
#
|
14
|
+
# # This will serve /app/js/jquery.js. (or .coffee)
|
15
15
|
# $ curl "http://localhost:4567/js/jquery.js"
|
16
16
|
#
|
17
|
+
# == CoffeeScript support
|
18
|
+
#
|
17
19
|
# This plugin supports CoffeeScript. To use it, simply
|
18
20
|
# add a CoffeeScript file in the JS file path.
|
19
21
|
#
|
@@ -22,7 +24,12 @@
|
|
22
24
|
#
|
23
25
|
# $ curl "http://localhost:4567/js/application.js"
|
24
26
|
#
|
25
|
-
# To use CoffeeScript,
|
27
|
+
# To use CoffeeScript, install the +coffee_script+ gem.
|
28
|
+
# If you're using Bundler, that is:
|
29
|
+
#
|
30
|
+
# # Gemfile
|
31
|
+
# gem "coffee-script", require: "coffee_script"
|
32
|
+
#
|
26
33
|
#
|
27
34
|
module Sinatra::JsSupport
|
28
35
|
def self.registered(app)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sinatra-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cyril David
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-29 00:00:00 +08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|