sinatra-assets_linker 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +22 -6
- data/lib/sinatra/assets_linker.rb +8 -8
- data/lib/sinatra-assets_linker/version.rb +1 -1
- data/lib/sinatra-assets_linker.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjY4YjZhYTZmY2NmYTlmNGQwNWU4OTZkZTQwNDI1N2MyNzkyMmFhMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2JlNzMwMWU3NWJjNmUyMTdjODVmOWE1N2JjZDdmZDdlY2UxZTk2Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGI0YWE3NDA4Njk2NmIyZTQ4ZjU1OTc5OTA3OGE1NDhkMjVmMjhlY2Y5MDJj
|
10
|
+
YWRiYmUwNmEzMmY5OWY2NTk2MjE5YjY0NzNhYWM2Y2Y2MzQzNWY3ZTE3NjY0
|
11
|
+
MzRmM2NiZmNmNjIxYTIzZDFhMDA3NWI2NmJmNjVkN2U3NmRlN2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGZkNTRhYjIzMGU4ZTI0YzA0MDQ0MmZiYjExZjY0NDlmM2EwYWIyYTMzMjUz
|
14
|
+
ZWIwMzRlNDc0ZjQ1YmYwMzYzNGU1MjBkNWZmYWI1YzY1ZDg2MmM5NDZjY2Fm
|
15
|
+
OWE5YzY3NDA0ZWMwOWE5NDg5MmFjMWU5OWE5NjgzZTMwYWI0NzA=
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,8 +8,8 @@ Provided methods:
|
|
8
8
|
* `js_uri(file_name, add_script_name = true)`
|
9
9
|
* `img_uri(file_name, add_script_name = true)`
|
10
10
|
|
11
|
-
They extend the [`uri`][uri] method from the Sinatra.
|
12
|
-
Always returns relative paths, unless you set `:
|
11
|
+
They extend the [`uri`][uri] method from the Sinatra.
|
12
|
+
Always returns relative paths, unless you set `:project_cdn_url`.
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -36,12 +36,13 @@ class MyApp < Sinatra::Base
|
|
36
36
|
|
37
37
|
configure do
|
38
38
|
# define assets dirs
|
39
|
-
set :
|
40
|
-
set :
|
41
|
-
set :
|
39
|
+
set :project_css_dir, 'css_dir'
|
40
|
+
set :project_js_dir, 'js_dir'
|
41
|
+
set :project_img_dir, 'img_dir'
|
42
42
|
|
43
43
|
# optionally
|
44
|
-
set :
|
44
|
+
set :project_cdn_url, 'http://cdn.net'
|
45
|
+
set :project_assets_verbose, true
|
45
46
|
end
|
46
47
|
|
47
48
|
end
|
@@ -62,6 +63,21 @@ css_uri('file.css') # -> http://cdn.net/css_dir/file.css
|
|
62
63
|
js_uri('file.js') # -> http://cdn.net/js_dir/file.js
|
63
64
|
img_uri('file.jpg') # -> http://cdn.net/img_dir/file.jpg
|
64
65
|
```
|
66
|
+
|
67
|
+
## Configuration and defaults
|
68
|
+
|
69
|
+
* :project_css_dir [stylesheets]
|
70
|
+
* :project_js_dir [javascripts]
|
71
|
+
* :project_rjs_dir [js]
|
72
|
+
* :project_cdn_url [nil]
|
73
|
+
* :project_assets_env [development]
|
74
|
+
|
75
|
+
## Requirejs integration
|
76
|
+
|
77
|
+
If you compile your javastripts into the other directory, you can set it by
|
78
|
+
editing the `:project_rjs_dir` option, and switch loading assets from that
|
79
|
+
dir by setting: `project_assets_verbose` to `true`.
|
80
|
+
|
65
81
|
## Versioning
|
66
82
|
|
67
83
|
See [semver.org][semver]
|
@@ -17,23 +17,24 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
require
|
20
|
+
require "sinatra/base"
|
21
21
|
|
22
22
|
module Sinatra
|
23
23
|
module AssetsLinker
|
24
|
-
|
25
24
|
def css_uri(file_name, add_script_name = true)
|
26
|
-
css_dir = get_settings(:
|
25
|
+
css_dir = get_settings(:project_css_dir, "stylesheets")
|
27
26
|
generate_uri(css_dir, file_name, add_script_name)
|
28
27
|
end
|
29
28
|
|
30
29
|
def js_uri(file_name, add_script_name = true)
|
31
|
-
js_dir = get_settings(:
|
32
|
-
|
30
|
+
js_dir = get_settings(:project_js_dir, "javascripts")
|
31
|
+
rjs_dir = get_settings(:project_rjs_dir, "js")
|
32
|
+
choosen_dir = get_settings(:project_assets_verbose, false) ? rjs_dir : js_dir
|
33
|
+
generate_uri(choosen_dir, file_name, add_script_name)
|
33
34
|
end
|
34
35
|
|
35
36
|
def img_uri(file_name, add_script_name = true)
|
36
|
-
img_dir = get_settings(:
|
37
|
+
img_dir = get_settings(:project_img_dir, "images")
|
37
38
|
generate_uri(img_dir, file_name, add_script_name)
|
38
39
|
end
|
39
40
|
|
@@ -46,10 +47,9 @@ module Sinatra
|
|
46
47
|
def generate_uri(assets_dir, file_name, add_script_name)
|
47
48
|
absolute_path = false
|
48
49
|
relative_url = uri(File.join(assets_dir, file_name), absolute_path, add_script_name)
|
49
|
-
cdn_url = get_settings(:
|
50
|
+
cdn_url = get_settings(:project_cdn_url)
|
50
51
|
return File.join(cdn_url, relative_url) unless cdn_url.nil?
|
51
52
|
relative_url
|
52
53
|
end
|
53
|
-
|
54
54
|
end
|
55
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-assets_linker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Szymon Kopciewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|