wire-framework 0.1.5.1 → 0.1.5.2
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/app/db.rb +1 -1
- data/lib/app/login.rb +1 -1
- data/lib/app/render/page.rb +13 -12
- data/lib/app/render/style.rb +2 -3
- data/lib/closet/context.rb +3 -3
- data/lib/wire.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec09ae1db5056dace28e0d574e44b42f96b54558
|
4
|
+
data.tar.gz: a47551aae8e917c6e48e417931fad6a7c11b5af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3547a7e673112f1adaf7264511afcc1c350bf00bbd981d31393858bcbbba240bc2b36db37146bf033c3bf7f4ab5331d3405ff35bc12e8a3d16ecfc5280f1a09e
|
7
|
+
data.tar.gz: a6b7b0cfa9a7e5a688a1a799b2c2d935d92cd49ec802c294ecb28c1013d908e8c4ff5447684bebf83e3da1240892d9c3eacc4a8b227b44faf08086dda98b8e3b
|
data/lib/app/db.rb
CHANGED
data/lib/app/login.rb
CHANGED
@@ -23,7 +23,7 @@ module Login
|
|
23
23
|
# @param [Hash] context the context for this request
|
24
24
|
# @return [Response] a redirect message returning to the previous page
|
25
25
|
def self.invoke(actions, context)
|
26
|
-
[307, { 'Location'
|
26
|
+
[307, { 'Location' => context.referer.join('/') }, ['Login Redirect']]
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/app/render/page.rb
CHANGED
@@ -25,26 +25,26 @@ module Render
|
|
25
25
|
# @param [Tilt::Template] template a pre-loaded Tilt template to render
|
26
26
|
# @param [String] content the content to render into the page
|
27
27
|
# @return [Response] a Rack Response triplet, or status code
|
28
|
-
def render_template(actions, context, template, content)
|
28
|
+
def self.render_template(actions, context, template, content)
|
29
29
|
if template['file']
|
30
30
|
hash = { actions: actions, context: context, content: content }
|
31
31
|
template['sources'].each do |k, s|
|
32
|
-
uri = "http://#{context.
|
32
|
+
uri = "http://#{context.config['remote'].split('/')[0]}"
|
33
33
|
go_ahead = true
|
34
34
|
if s.is_a? Hash
|
35
|
-
uri += "/#{
|
35
|
+
uri += "/#{s['uri']}"
|
36
36
|
case s['key']
|
37
37
|
when 'user'
|
38
38
|
go_ahead = (context.user and !context.user.empty?)
|
39
39
|
uri += "/#{context.user}"
|
40
40
|
when 'resource'
|
41
|
-
go_ahead = (context.
|
42
|
-
uri += "/#{context.
|
41
|
+
go_ahead = (context.resource and !context.resource.empty?)
|
42
|
+
uri += "/#{context.resource}"
|
43
43
|
else
|
44
44
|
# do nothing
|
45
45
|
end
|
46
46
|
else
|
47
|
-
uri += s
|
47
|
+
uri += "#{s}"
|
48
48
|
end
|
49
49
|
temp = []
|
50
50
|
if go_ahead
|
@@ -52,15 +52,15 @@ module Render
|
|
52
52
|
end
|
53
53
|
if temp[0] == 200
|
54
54
|
begin
|
55
|
-
hash[k] = JSON.parse_clean(temp[2])
|
55
|
+
hash[k.to_sym] = JSON.parse_clean(temp[2])
|
56
56
|
rescue
|
57
|
-
hash[k] = temp[2]
|
57
|
+
hash[k.to_sym] = temp[2]
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
message = template[:path].render(self, hash)
|
62
62
|
if template['use_layout']
|
63
|
-
message = render_template(actions, context, $
|
63
|
+
message = render_template(actions, context, $wire_templates['layout'], message)
|
64
64
|
end
|
65
65
|
else
|
66
66
|
message = 'Invalid Template'
|
@@ -73,11 +73,12 @@ module Render
|
|
73
73
|
# @param [Hash] context the context for this request
|
74
74
|
# @param [Symbol] specific the kind of read to perform
|
75
75
|
# @return [Response] a Rack Response triplet, or status code
|
76
|
-
def do_read(actions, context, specific)
|
76
|
+
def self.do_read(actions, context, specific)
|
77
77
|
if context.resource
|
78
78
|
result = context.forward(specific)
|
79
79
|
#TODO: fix lookup
|
80
|
-
|
80
|
+
name = context.config['template']
|
81
|
+
template = $wire_templates[name]
|
81
82
|
if template
|
82
83
|
result[1]['Content-Type'] = 'text/html'
|
83
84
|
result[2] = render_template(actions, context, template, result[2])
|
@@ -97,7 +98,7 @@ module Render
|
|
97
98
|
when :create, :update, :delete
|
98
99
|
context.forward(context.action)
|
99
100
|
when :read
|
100
|
-
if context.
|
101
|
+
if context.id
|
101
102
|
do_read(actions, context, :read)
|
102
103
|
else
|
103
104
|
do_read(actions, context, :readAll)
|
data/lib/app/render/style.rb
CHANGED
@@ -35,9 +35,8 @@ module Render
|
|
35
35
|
# @param [Hash] context the context for this request
|
36
36
|
# @return [Response] a Rack Response triplet, or status code
|
37
37
|
def self.do_read_all(context)
|
38
|
-
|
39
|
-
|
40
|
-
headers = {'Cache-Control': 'public,max-age=3600'}
|
38
|
+
template = context.config['styles'][context.resource]
|
39
|
+
headers = {'Cache-Control' => 'public,max-age=3600'}
|
41
40
|
if template
|
42
41
|
headers['Content-Type'] = 'text/css'
|
43
42
|
[200, headers, [template]]
|
data/lib/closet/context.rb
CHANGED
@@ -102,7 +102,7 @@ module Wire
|
|
102
102
|
if @config
|
103
103
|
@app = @uri[1]
|
104
104
|
@resource = @uri[2]
|
105
|
-
@id = @uri[3...@uri.length].join('/')
|
105
|
+
@id = @uri.length > 3 ? @uri[3...@uri.length].join('/') : nil
|
106
106
|
else
|
107
107
|
throw Exception.new("App: #{@uri[1]} is Undefined")
|
108
108
|
end
|
@@ -137,9 +137,9 @@ module Wire
|
|
137
137
|
headers = { referer: @referer.join('/'),
|
138
138
|
remote_user: @user }
|
139
139
|
verb = CONVERT[method]
|
140
|
-
uri = "http://#{@
|
140
|
+
uri = "http://#{@config['remote']}/#{@resource}"
|
141
141
|
if [:update, :read, :delete].include?(method)
|
142
|
-
uri += "/#{@
|
142
|
+
uri += "/#{@id}"
|
143
143
|
end
|
144
144
|
uri += '?' + @query_string
|
145
145
|
body = [:create, :update].include?(method) ? @body : nil
|
data/lib/wire.rb
CHANGED