roda-cj 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/roda/plugins/assets.rb +29 -27
- data/lib/roda/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3da6c6a5dbecc79ec993e9393115ae8862e8b6
|
4
|
+
data.tar.gz: 4238915430382a9d43ccfba59f890229c3388d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a259997417cb792ac317890812d0d549bb6e4003eed49385b420de352a77c182854db078929d3dd2968c2179af289ab32625f56afd9e136445a5f45f6b0b5e7
|
7
|
+
data.tar.gz: 158e74929dd3bfbe8ef333b01f7e16567724222cb613c34351105ef8667178f7dd948aa03190edbde3e9b6c1a6a937deff8537723e4f660be61e232768e1d000
|
data/lib/roda/plugins/assets.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "tilt"
|
2
|
-
require '
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
class Roda
|
5
6
|
module RodaPlugins
|
@@ -53,7 +54,7 @@ class Roda
|
|
53
54
|
|
54
55
|
# Generates a unique id, this is used to keep concat/compiled files
|
55
56
|
# from caching in the browser when they are generated
|
56
|
-
def assets_unique_id
|
57
|
+
def assets_unique_id(type)
|
57
58
|
if unique_id = instance_variable_get("@#{type}")
|
58
59
|
unique_id
|
59
60
|
else
|
@@ -83,11 +84,13 @@ class Roda
|
|
83
84
|
|
84
85
|
private
|
85
86
|
|
86
|
-
def compile_process_files
|
87
|
+
def compile_process_files(files, type, folder)
|
87
88
|
require 'yuicompressor'
|
88
89
|
|
89
|
-
|
90
|
+
# start app instance
|
91
|
+
app = new
|
90
92
|
|
93
|
+
# content to render to file
|
91
94
|
content = ''
|
92
95
|
|
93
96
|
files.each do |file|
|
@@ -95,7 +98,7 @@ class Roda
|
|
95
98
|
file = "#{folder}/#{file}"
|
96
99
|
end
|
97
100
|
|
98
|
-
content +=
|
101
|
+
content += app.read_asset_file file, type
|
99
102
|
end
|
100
103
|
|
101
104
|
path = assets_opts[:compiled_path] \
|
@@ -150,6 +153,7 @@ class Roda
|
|
150
153
|
end
|
151
154
|
|
152
155
|
def render_asset(file, type)
|
156
|
+
# convert back url safe to period
|
153
157
|
file.gsub!(/(\$2E|%242E)/, '.')
|
154
158
|
|
155
159
|
if !assets_opts[:compiled] && !assets_opts[:concat]
|
@@ -177,7 +181,7 @@ class Roda
|
|
177
181
|
end
|
178
182
|
end
|
179
183
|
|
180
|
-
def read_asset_file
|
184
|
+
def read_asset_file(file, type)
|
181
185
|
folder = assets_opts[:"#{type}_folder"]
|
182
186
|
|
183
187
|
# If there is no file it must be a remote file request.
|
@@ -187,31 +191,29 @@ class Roda
|
|
187
191
|
file = env['SCRIPT_NAME'].gsub(/^\/#{route}\/#{folder}\//, '')
|
188
192
|
end
|
189
193
|
|
194
|
+
# If it's not a url or parent direct append the full path
|
190
195
|
if !file[/^\.\//] && !file[/^http/]
|
191
|
-
|
192
|
-
else
|
193
|
-
path = file
|
196
|
+
file = assets_opts[:path] + '/' + folder + "/#{file}"
|
194
197
|
end
|
195
198
|
|
199
|
+
# set the current engine
|
196
200
|
engine = assets_opts[:"#{type}_engine"]
|
197
201
|
|
198
|
-
|
199
|
-
|
200
|
-
render path: "#{
|
201
|
-
|
202
|
-
|
203
|
-
File.read "#{
|
204
|
-
# grab remote file content
|
202
|
+
if File.exists? "#{file}.#{engine}"
|
203
|
+
# render via tilt
|
204
|
+
render path: "#{file}.#{engine}"
|
205
|
+
elsif File.exists? "#{file}.#{type}"
|
206
|
+
# read file directly
|
207
|
+
File.read "#{file}.#{type}"
|
205
208
|
elsif file[/^http/]
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
end
|
209
|
+
# grab remote file content
|
210
|
+
Net::HTTP.get(URI.parse(file))
|
211
|
+
elsif File.exists?(file) && !file[/\.#{type}$/]
|
212
|
+
# Render via tilt if the type isn't css or js
|
213
|
+
render path: file
|
214
|
+
else
|
215
|
+
# if it is css/js read the file directly
|
216
|
+
File.read file
|
215
217
|
end
|
216
218
|
end
|
217
219
|
|
@@ -229,13 +231,13 @@ class Roda
|
|
229
231
|
|
230
232
|
# CSS tag template
|
231
233
|
# <link rel="stylesheet" href="theme.css">
|
232
|
-
def css_assets_tag
|
234
|
+
def css_assets_tag(attrs)
|
233
235
|
"<link rel=\"stylesheet\" #{attrs} />"
|
234
236
|
end
|
235
237
|
|
236
238
|
# JS tag template
|
237
239
|
# <script src="scriptfile.js"></script>
|
238
|
-
def js_assets_tag
|
240
|
+
def js_assets_tag(attrs)
|
239
241
|
"<script type=\"text/javascript\" #{attrs}></script>"
|
240
242
|
end
|
241
243
|
end
|
data/lib/roda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda-cj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|