nimbu 0.5.8.1 → 0.5.9
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/nimbu/server/base.rb +72 -73
- data/lib/nimbu/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: b3b793979f2d9f9e9c660aa4d3e174fb1c09726d
|
4
|
+
data.tar.gz: a42ee27c1fd151a73c6345f9e49f50c0d2172ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91155767ca0d7c66253b8e8773a9bce89185adb86e05755160a14dce417f3c182aaef329ff934235af4be4af681e028d5f4a8073ee3c6f3b6e023af7b422b420
|
7
|
+
data.tar.gz: 5394c86eebfd7eac95e0c9c8fd3a0676cb3b0bd5f9a9f3279d4dd46141287e9ef5280963e6e5b8bae7ec1e91fe416696a838c623bc641c1ea3fd4ed3d365143e
|
data/lib/nimbu/server/base.rb
CHANGED
@@ -105,89 +105,88 @@ module Nimbu
|
|
105
105
|
# end
|
106
106
|
### GET THE TEMPLATES ###
|
107
107
|
path = request.path == "/" ? request.path : request.path.gsub(/\/$/,'')
|
108
|
-
if !request.xhr?
|
109
|
-
begin
|
110
|
-
params = ({} || params).merge({:simulator => {
|
111
|
-
:host => request.host,
|
112
|
-
:port => request.port,
|
113
|
-
:path => path,
|
114
|
-
:method => method,
|
115
|
-
:session => session,
|
116
|
-
:headers => request.env.to_json,
|
117
|
-
}})
|
118
|
-
result = nimbu.simulator(:subdomain => Nimbu::Auth.site).recipe(params)
|
119
|
-
puts result if Nimbu.debug
|
120
|
-
rescue Exception => e
|
121
|
-
if e.respond_to?(:http_body)
|
122
|
-
return e.http_body
|
123
|
-
else
|
124
|
-
raise e
|
125
|
-
end
|
126
|
-
end
|
127
108
|
|
128
|
-
|
129
|
-
|
109
|
+
begin
|
110
|
+
params = ({} || params).merge({:simulator => {
|
111
|
+
:host => request.host,
|
112
|
+
:port => request.port,
|
113
|
+
:path => path,
|
114
|
+
:method => method,
|
115
|
+
:session => session,
|
116
|
+
:headers => request.env.to_json,
|
117
|
+
}})
|
118
|
+
result = nimbu.simulator(:subdomain => Nimbu::Auth.site).recipe(params)
|
119
|
+
puts result if Nimbu.debug
|
120
|
+
rescue Exception => e
|
121
|
+
if e.respond_to?(:http_body)
|
122
|
+
return e.http_body
|
123
|
+
else
|
124
|
+
raise e
|
130
125
|
end
|
126
|
+
end
|
131
127
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
puts green(" => using template '#{template}'")
|
136
|
-
# Read the template file
|
137
|
-
template_file = File.join(Dir.pwd,'templates',template)
|
138
|
-
template_file_haml = File.join(Dir.pwd,'templates',"#{template}.haml")
|
139
|
-
|
140
|
-
if File.exists?(template_file)
|
141
|
-
template_code = IO.read(template_file).force_encoding('UTF-8')
|
142
|
-
elsif File.exists?(template_file_haml)
|
143
|
-
template_code = IO.read(template_file_haml).force_encoding('UTF-8')
|
144
|
-
template = "#{template}.haml"
|
145
|
-
else
|
146
|
-
puts red("Layout file '#{template_file}' is missing...")
|
147
|
-
return render_missing(File.join('templates',template),'template')
|
148
|
-
end
|
128
|
+
if result["template"].nil? && !request.xhr?
|
129
|
+
raise Sinatra::NotFound
|
130
|
+
end
|
149
131
|
|
150
|
-
|
151
|
-
|
152
|
-
|
132
|
+
unless result["template"] == "<<<< REDIRECT >>>>"
|
133
|
+
template = result["template"].gsub(/buddha$/,'liquid')
|
134
|
+
# Then render everything
|
135
|
+
puts green(" => using template '#{template}'")
|
136
|
+
# Read the template file
|
137
|
+
template_file = File.join(Dir.pwd,'templates',template)
|
138
|
+
template_file_haml = File.join(Dir.pwd,'templates',"#{template}.haml")
|
139
|
+
|
140
|
+
if File.exists?(template_file)
|
141
|
+
template_code = IO.read(template_file).force_encoding('UTF-8')
|
142
|
+
elsif File.exists?(template_file_haml)
|
143
|
+
template_code = IO.read(template_file_haml).force_encoding('UTF-8')
|
144
|
+
template = "#{template}.haml"
|
145
|
+
else
|
146
|
+
puts red("Layout file '#{template_file}' is missing...")
|
147
|
+
return render_missing(File.join('templates',template),'template')
|
148
|
+
end
|
153
149
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
# There seems to be a special layout?
|
158
|
-
layout = $1
|
159
|
-
else
|
160
|
-
layout = 'default.liquid'
|
161
|
-
end
|
150
|
+
if template_code=~ /You have an Error in your HAML code/
|
151
|
+
return template_code
|
152
|
+
end
|
162
153
|
|
163
|
-
|
164
|
-
|
165
|
-
|
154
|
+
# Parse template file for a special layout
|
155
|
+
search = Regexp.new("\{\% layout \'(.*)\' \%\}")
|
156
|
+
if search =~ template_code
|
157
|
+
# There seems to be a special layout?
|
158
|
+
layout = $1
|
159
|
+
else
|
160
|
+
layout = 'default.liquid'
|
161
|
+
end
|
166
162
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
163
|
+
# Read the layout file
|
164
|
+
layout_file = File.join(Dir.pwd,'layouts',layout)
|
165
|
+
layout_file_haml = File.join(Dir.pwd,'layouts',"#{layout}.haml")
|
166
|
+
|
167
|
+
if File.exists?(layout_file)
|
168
|
+
layout_code = IO.read(layout_file).force_encoding('UTF-8')
|
169
|
+
elsif File.exists?(layout_file_haml)
|
170
|
+
layout = "#{layout}.haml"
|
171
|
+
layout_code = IO.read(layout_file_haml).force_encoding('UTF-8')
|
172
|
+
else
|
173
|
+
puts red("Layout file '#{layout_file}' is missing...")
|
174
|
+
return render_missing(File.join('layouts',layout),'layout')
|
175
|
+
end
|
176
176
|
|
177
|
-
|
177
|
+
puts green(" using layout '#{layout}'")
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
179
|
+
begin
|
180
|
+
snippets = parse_snippets(template_code)
|
181
|
+
snippets = parse_snippets(layout_code,snippets)
|
182
|
+
rescue Exception => e
|
183
|
+
# If there is a snippet missing, we raise an error
|
184
|
+
puts red("Snippet file '#{e.message}' is missing...")
|
185
|
+
return render_missing(e.message,'snippet')
|
186
|
+
end
|
187
187
|
|
188
|
-
|
189
|
-
|
190
|
-
end
|
188
|
+
if snippets.any?
|
189
|
+
puts green(" using snippets '#{snippets.keys.join('\', \'')}'")
|
191
190
|
end
|
192
191
|
else
|
193
192
|
template_file = ""
|
data/lib/nimbu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nimbu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zenjoy BVBA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|