nimbu 0.5.8.1 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c4f71c912ce81f8c717792ed4b2f21bdfb6cb39
4
- data.tar.gz: d4c2c195155b4647bc3166c8882ad9e42a3f23f7
3
+ metadata.gz: b3b793979f2d9f9e9c660aa4d3e174fb1c09726d
4
+ data.tar.gz: a42ee27c1fd151a73c6345f9e49f50c0d2172ab3
5
5
  SHA512:
6
- metadata.gz: 5e33503a27e4f505c556b02fb65ba0cf054fe806027466386a4e39aaf81bfdff91d0543775ccb97ba0ec70f2013e9affd71498583c5caab7cba6c3a9df228e91
7
- data.tar.gz: 79b883e4fd94d43ff9731935a28d7586057e09a2375abb8c63f72c3f0377679a58eef04d52558b424a5f139332e8a1791a44defba669e1dcc1ec17e51cb0546a
6
+ metadata.gz: 91155767ca0d7c66253b8e8773a9bce89185adb86e05755160a14dce417f3c182aaef329ff934235af4be4af681e028d5f4a8073ee3c6f3b6e023af7b422b420
7
+ data.tar.gz: 5394c86eebfd7eac95e0c9c8fd3a0676cb3b0bd5f9a9f3279d4dd46141287e9ef5280963e6e5b8bae7ec1e91fe416696a838c623bc641c1ea3fd4ed3d365143e
@@ -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
- if result["template"].nil?
129
- raise Sinatra::NotFound
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
- 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
128
+ if result["template"].nil? && !request.xhr?
129
+ raise Sinatra::NotFound
130
+ end
149
131
 
150
- if template_code=~ /You have an Error in your HAML code/
151
- return template_code
152
- end
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
- # 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
150
+ if template_code=~ /You have an Error in your HAML code/
151
+ return template_code
152
+ end
162
153
 
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")
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
- 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
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
- puts green(" using layout '#{layout}'")
177
+ puts green(" using layout '#{layout}'")
178
178
 
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
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
- if snippets.any?
189
- puts green(" using snippets '#{snippets.keys.join('\', \'')}'")
190
- end
188
+ if snippets.any?
189
+ puts green(" using snippets '#{snippets.keys.join('\', \'')}'")
191
190
  end
192
191
  else
193
192
  template_file = ""
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Nimbu
3
- VERSION = "0.5.8.1"
3
+ VERSION = "0.5.9"
4
4
  end
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.8.1
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-19 00:00:00.000000000 Z
11
+ date: 2013-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor