js-asset_paths 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/js-asset_paths.js.erb +46 -0
- data/lib/js_asset_paths/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e8f95af4b58712151ef9f237345f0546a95d67e
|
4
|
+
data.tar.gz: 664cca57ab4041c46f36d2dfda64ea0353f009dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee47050e597cde02c12e83317f7b19ca6de371290eab4d7eacb22001b9a8ed366554c6f680a64619e6aa23f4e927f94f3e1093455aaef2d4f0559c04ea3664a
|
7
|
+
data.tar.gz: 0a62de50dc0f26ddbbcb2aea49dc917638415e0a687cb64d419f75ebf6bd39e9acc4782abf4c28b56f2fb51571f3d2f090597ecad629a454eb6e9363bfff9add
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<%# encoding: utf-8 %>
|
2
|
+
|
3
|
+
var PathHelper = (function(definitions) {
|
4
|
+
var assetExtensions = <%= ActionView::Helpers::AssetUrlHelper::ASSET_EXTENSIONS.to_json %>;
|
5
|
+
var assetPublicDirectories = <%= ActionView::Helpers::AssetUrlHelper::ASSET_PUBLIC_DIRECTORIES.to_json %>;
|
6
|
+
|
7
|
+
return {
|
8
|
+
assetPath: function(source, opts) {
|
9
|
+
return [prefix(source), filename(source, opts)].join("/");
|
10
|
+
},
|
11
|
+
|
12
|
+
<% JsAssetPaths::ASSET_METHODS.map(&:to_s).each_with_index do |method, i| %>
|
13
|
+
<%= "#{method.split('_').first}Path: function(source) {" %>
|
14
|
+
<%= %Q(return this.assetPath(source, { type: "#{method.split('_').first}" });) %>
|
15
|
+
<%= "}#{',' unless i == JsAssetPaths::ASSET_METHODS.count - 1}" %>
|
16
|
+
<% end %>
|
17
|
+
};
|
18
|
+
|
19
|
+
function prefix(path) {
|
20
|
+
var prefix = path.split("/");
|
21
|
+
|
22
|
+
prefix.pop();
|
23
|
+
prefix.shift();
|
24
|
+
prefix.unshift("assets");
|
25
|
+
|
26
|
+
return prefix.join("/");
|
27
|
+
}
|
28
|
+
|
29
|
+
function filename(source, opts) {
|
30
|
+
var key = source;
|
31
|
+
|
32
|
+
if (opts && opts.type) {
|
33
|
+
key = [assetPublicDirectories[opts.type], key].join("/");
|
34
|
+
|
35
|
+
if (source.split(".").length === 1) {
|
36
|
+
key = [key, assetExtensions[opts.type]].join(".");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
if (definitions[key]) {
|
41
|
+
return definitions[key];
|
42
|
+
} else {
|
43
|
+
throw "Unknown asset '" + key + "'. If you created it recently, you may need to restart Rails.";
|
44
|
+
}
|
45
|
+
}
|
46
|
+
})(<%= JsAssetPaths::Generator.generate! %>);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-asset_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sonny Michaud
|
@@ -135,6 +135,7 @@ executables: []
|
|
135
135
|
extensions: []
|
136
136
|
extra_rdoc_files: []
|
137
137
|
files:
|
138
|
+
- app/assets/javascripts/js-asset_paths.js.erb
|
138
139
|
- lib/js-asset_paths.rb
|
139
140
|
- lib/js_asset_paths.rb
|
140
141
|
- lib/js_asset_paths/engine.rb
|