nimbu 0.13.0 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nimbu/auth.rb +1 -1
- data/lib/nimbu/command/server.rb +92 -34
- data/lib/nimbu/server/base.rb +7 -3
- data/lib/nimbu/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acf58907df8ef86e997d2694f21ecc4239fa45e9530a4f3b108518939c218ed5
|
4
|
+
data.tar.gz: d4e92c37600d974a88f7add9d705981d3a44ac58c36d5294fedaf8839859bb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53b91cb9662cf50224bf77273c4ddd44006bede74661cebeacb4327e3611df69fb7c765873d1f371cf8ffb2d262f83b5b91958bf113be6e6d8e9e357cbd9405c
|
7
|
+
data.tar.gz: c88ec2b024acdc576b5a3185d4b24c0200140d41d2b768a6c06bd4fb37f470792f0859bbc4529267e207df352f262ba79c7ed21f21adaa816e751021eb959ff1
|
data/lib/nimbu/auth.rb
CHANGED
data/lib/nimbu/command/server.rb
CHANGED
@@ -17,6 +17,7 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
17
17
|
# --webpack RES # comma separated list of webpack resources (relative to /javascripts)
|
18
18
|
# --webpackurl URL # proxy requests for webpack resources to the given URL prefix (default: http://localhost:8080)
|
19
19
|
# --nocookies # disable session refresh cookie check
|
20
|
+
# --dir DIR # root of your project (default: current directory)
|
20
21
|
#
|
21
22
|
def index
|
22
23
|
require 'rubygems'
|
@@ -26,6 +27,9 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
26
27
|
require 'filewatcher'
|
27
28
|
require 'pathname'
|
28
29
|
require 'lolcat'
|
30
|
+
require 'socket'
|
31
|
+
|
32
|
+
Nimbu.cli_options[:dir] = options[:dir] if options[:dir]
|
29
33
|
|
30
34
|
# Check if config file is present?
|
31
35
|
if !Nimbu::Auth.read_configuration
|
@@ -81,17 +85,6 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
|
-
def bare
|
85
|
-
puts "Starting server..."
|
86
|
-
server_options = {
|
87
|
-
:Port => options[:port] || 4567,
|
88
|
-
:DocumentRoot => Dir.pwd
|
89
|
-
}
|
90
|
-
Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
|
91
|
-
[:INT, :TERM].each { |sig| trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop } }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
88
|
def haml
|
96
89
|
require 'haml'
|
97
90
|
puts "Starting..."
|
@@ -107,42 +100,75 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
107
100
|
|
108
101
|
protected
|
109
102
|
|
103
|
+
def ipv6_supported?
|
104
|
+
begin
|
105
|
+
socket = Socket.new(Socket::AF_INET6, Socket::SOCK_STREAM)
|
106
|
+
socket.close
|
107
|
+
true
|
108
|
+
rescue Errno::EAFNOSUPPORT
|
109
|
+
false
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def project_root
|
114
|
+
Nimbu.cli_options[:dir] || Dir.pwd
|
115
|
+
end
|
116
|
+
|
117
|
+
def default_host
|
118
|
+
if ipv6_supported?
|
119
|
+
"::"
|
120
|
+
else
|
121
|
+
"127.0.0.1"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
110
125
|
def run_on_windows!
|
111
126
|
server_thread = Thread.new do
|
112
127
|
Thread.current[:stdout] = StringIO.new
|
113
128
|
puts "Starting server..."
|
114
129
|
server_options = {
|
115
130
|
:Port => options[:port] || 4567,
|
116
|
-
:DocumentRoot =>
|
131
|
+
:DocumentRoot => project_root,
|
132
|
+
:Host => default_host
|
117
133
|
}
|
118
134
|
server_options.merge!({:Host => options[:host]}) if options[:host]
|
119
135
|
Rack::Handler::Thin.run Nimbu::Server::Base, server_options do |server|
|
120
|
-
[:INT, :TERM].each
|
136
|
+
[:INT, :TERM].each do |sig|
|
137
|
+
trap(sig) do
|
138
|
+
server.respond_to?(:stop!) ? server.stop! : server.stop
|
139
|
+
exit(0)
|
140
|
+
end
|
141
|
+
end
|
121
142
|
end
|
122
143
|
end
|
123
144
|
|
124
145
|
haml_thread = Thread.new do
|
125
|
-
#
|
126
|
-
# compiler_read.close
|
146
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt haml")
|
127
147
|
puts "Starting watcher..."
|
128
148
|
HamlWatcher.watch
|
129
149
|
end if @with_haml
|
130
150
|
|
131
|
-
if @with_compass
|
151
|
+
compass_pid = if @with_compass
|
152
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt compass")
|
132
153
|
puts "Starting..."
|
133
154
|
cmd = "bundle exec nimbu server:compass"
|
134
|
-
|
155
|
+
Process.spawn(cmd, out: $stdout, err: [:child, :out])
|
135
156
|
end
|
136
157
|
|
137
158
|
server_thread.join
|
138
159
|
haml_thread.join if @with_haml
|
139
160
|
|
140
|
-
[:INT, :TERM].each do |sig|
|
161
|
+
[:HUP, :INT, :TERM].each do |sig|
|
141
162
|
trap(sig) do
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
163
|
+
should_wait = false
|
164
|
+
|
165
|
+
if compass_pid && running?(compass_pid)
|
166
|
+
should_wait = true
|
167
|
+
Process.kill('INT', compass_pid)
|
168
|
+
end
|
169
|
+
|
170
|
+
Process.waitall if should_wait
|
171
|
+
exit(0)
|
146
172
|
end
|
147
173
|
end
|
148
174
|
|
@@ -162,11 +188,19 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
162
188
|
puts "Starting server..."
|
163
189
|
server_options = {
|
164
190
|
:Port => options[:port] || 4567,
|
165
|
-
:DocumentRoot => Dir.pwd
|
191
|
+
:DocumentRoot => options[:dir] || Dir.pwd,
|
192
|
+
:Host => default_host,
|
166
193
|
}
|
167
194
|
server_options.merge!({:Host => options[:host]}) if options[:host]
|
168
195
|
Rack::Handler::Thin.run Nimbu::Server::Base, **server_options do |server|
|
169
|
-
|
196
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt server")
|
197
|
+
|
198
|
+
[:INT, :TERM].each do |sig|
|
199
|
+
trap(sig) do
|
200
|
+
server.respond_to?(:stop!) ? server.stop! : server.stop
|
201
|
+
exit(0)
|
202
|
+
end
|
203
|
+
end
|
170
204
|
end
|
171
205
|
end
|
172
206
|
|
@@ -175,7 +209,8 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
175
209
|
haml_read.close
|
176
210
|
puts "Starting..."
|
177
211
|
haml_listener = HamlWatcher.watch
|
178
|
-
|
212
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt haml")
|
213
|
+
[:HUP, :INT, :TERM].each do |sig|
|
179
214
|
Signal.trap(sig) do
|
180
215
|
puts green("== Stopping HAML watcher\n")
|
181
216
|
Thread.new { haml_listener.stop }
|
@@ -185,6 +220,7 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
185
220
|
end if @with_haml
|
186
221
|
|
187
222
|
compass_pid = Process.fork do
|
223
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt compass")
|
188
224
|
$stdout.reopen(compass_write)
|
189
225
|
compass_read.close
|
190
226
|
puts "Starting..."
|
@@ -192,7 +228,10 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
192
228
|
end if @with_compass
|
193
229
|
|
194
230
|
watch_server_pid = Process.fork do
|
195
|
-
|
231
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt server-watcher")
|
232
|
+
|
233
|
+
[:HUP, :INT, :TERM].each { |sig| trap(sig) { exit } }
|
234
|
+
|
196
235
|
server_write.close
|
197
236
|
server_read.each do |line|
|
198
237
|
print cyan("SERVER: ") + white(line) + ""
|
@@ -200,7 +239,9 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
200
239
|
end
|
201
240
|
|
202
241
|
watch_haml_pid = Process.fork do
|
203
|
-
|
242
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt haml-watcher")
|
243
|
+
[:HUP, :INT, :TERM].each { |sig| trap(sig) { exit } }
|
244
|
+
|
204
245
|
haml_write.close
|
205
246
|
haml_read.each do |line|
|
206
247
|
print magenta("HAML: ") + white(line) + ""
|
@@ -208,22 +249,39 @@ class Nimbu::Command::Server < Nimbu::Command::Base
|
|
208
249
|
end if @with_haml
|
209
250
|
|
210
251
|
watch_compass_pid = Process.fork do
|
211
|
-
|
252
|
+
Process.setproctitle("#{$0} => nimbu-toolbelt haml-compass")
|
253
|
+
[:HUP, :INT, :TERM].each { |sig| trap(sig) { exit } }
|
254
|
+
|
212
255
|
compass_write.close
|
213
256
|
compass_read.each do |line|
|
214
257
|
print yellow("COMPASS: ") + white(line) + ""
|
215
258
|
end
|
216
259
|
end if @with_compass
|
217
260
|
|
218
|
-
[:INT, :TERM].each do |sig|
|
261
|
+
[:HUP, :INT, :TERM].each do |sig|
|
219
262
|
trap(sig) do
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
263
|
+
should_wait = false
|
264
|
+
@child_pids_running.each do |pid|
|
265
|
+
if running?(server_pid)
|
266
|
+
should_wait = true
|
267
|
+
Process.kill('INT', pid)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
Process.waitall if should_wait
|
272
|
+
exit(0)
|
224
273
|
end
|
225
274
|
end
|
226
275
|
|
276
|
+
@child_pids_running = [
|
277
|
+
server_pid,
|
278
|
+
haml_pid,
|
279
|
+
compass_pid,
|
280
|
+
watch_server_pid,
|
281
|
+
watch_haml_pid,
|
282
|
+
watch_compass_pid
|
283
|
+
].compact!
|
284
|
+
|
227
285
|
Process.waitall
|
228
286
|
end
|
229
287
|
|
@@ -268,7 +326,7 @@ class HamlWatcher
|
|
268
326
|
|
269
327
|
def watch
|
270
328
|
refresh
|
271
|
-
current_dir = File.join(Dir.pwd, 'haml/')
|
329
|
+
current_dir = File.join(Nimbu.cli_options[:dir] || Dir.pwd, 'haml/')
|
272
330
|
puts ">>> Haml is polling for changes. Press Ctrl-C to Stop."
|
273
331
|
Filewatcher.new('haml/**/*.haml', every: true).watch do |filename, event|
|
274
332
|
begin
|
data/lib/nimbu/server/base.rb
CHANGED
@@ -22,7 +22,7 @@ module Nimbu
|
|
22
22
|
|
23
23
|
set :method_override, true
|
24
24
|
set :static, true # set up static file routing
|
25
|
-
set :public_folder, Dir.pwd # set up the static dir (with images/js/css inside)
|
25
|
+
set :public_folder, Nimbu.cli_options[:dir] || Dir.pwd # set up the static dir (with images/js/css inside)
|
26
26
|
|
27
27
|
set :views, File.expand_path('../views', __FILE__) # set up the views dir
|
28
28
|
set :haml, { format: :html5 } # if you use haml
|
@@ -229,8 +229,8 @@ module Nimbu
|
|
229
229
|
end
|
230
230
|
|
231
231
|
def load_files(type)
|
232
|
-
glob = Dir["#{
|
233
|
-
directory = "#{
|
232
|
+
glob = Dir["#{project_root}/#{type}/**/*.liquid","#{project_root}/#{type}/**/*.liquid.haml"]
|
233
|
+
directory = "#{project_root}/#{type}/"
|
234
234
|
glob.each do |file|
|
235
235
|
name = file.gsub(/#{directory}/i,"")
|
236
236
|
code = IO.read(file).force_encoding('UTF-8')
|
@@ -247,6 +247,10 @@ module Nimbu
|
|
247
247
|
request.path =~ /^\/downloads\// && request.query_string =~ /key=/
|
248
248
|
end
|
249
249
|
|
250
|
+
def project_root
|
251
|
+
Nimbu.cli_options[:dir] || Dir.pwd
|
252
|
+
end
|
253
|
+
|
250
254
|
end
|
251
255
|
end
|
252
256
|
end
|
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.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zenjoy BVBA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.2.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.2.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sinatra-contrib
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
353
|
- !ruby/object:Gem::Version
|
354
354
|
version: '0'
|
355
355
|
requirements: []
|
356
|
-
rubygems_version: 3.
|
356
|
+
rubygems_version: 3.1.6
|
357
357
|
signing_key:
|
358
358
|
specification_version: 4
|
359
359
|
summary: Client library and CLI to design websites on the Nimbu platform.
|