spiderfw 0.6.5 → 0.6.6
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.
- data/CHANGELOG +10 -0
- data/VERSION +1 -1
- data/apps/app_server/config/options.rb +2 -2
- data/apps/core/components/assets.rb +1 -5
- data/apps/core/components/widgets/month_calendar/month_calendar.shtml +3 -3
- data/apps/core/components/widgets/table/table.rb +2 -0
- data/apps/core/components/widgets/tabs/tabs.rb +9 -3
- data/apps/core/components/widgets/tabs/tabs.shtml +1 -1
- data/apps/master/_init.rb +3 -1
- data/apps/master/cmd.rb +1 -1
- data/apps/master/controllers/master_controller.rb +107 -103
- data/apps/master/controllers/scout_controller.rb +7 -7
- data/apps/master/controllers/{servant_controller.rb → server_controller.rb} +3 -3
- data/apps/master/data/locale/it/LC_MESSAGES/master.mo +0 -0
- data/apps/master/master.rb +4 -4
- data/apps/master/models/customer.rb +0 -3
- data/apps/master/models/installation.rb +14 -3
- data/apps/master/models/remote_log.rb +11 -0
- data/apps/master/models/scout_plugin_instance.rb +9 -9
- data/apps/master/models/scout_plugin_trigger.rb +2 -2
- data/apps/master/models/{servant.rb → server.rb} +6 -6
- data/apps/master/po/it/{spider_master.po → master.po} +127 -54
- data/apps/master/po/master.pot +23 -23
- data/apps/master/templates/email/alert.html.erb +1 -1
- data/apps/master/views/customer.shtml +3 -3
- data/apps/master/views/index.shtml +1 -2
- data/apps/master/views/installation.shtml +28 -16
- data/apps/master/views/master.layout.shtml +2 -1
- data/apps/master/views/plugin_data.shtml +1 -1
- data/apps/master/views/{servant.shtml → server.shtml} +14 -14
- data/apps/master/views/servers.shtml +11 -0
- data/apps/master/views/site_edit.shtml +1 -1
- data/apps/master/views/trigger_edit.shtml +4 -4
- data/apps/messenger/controllers/mixins/messenger_helper.rb +3 -3
- data/apps/servant/Gemfile +1 -0
- data/apps/servant/_init.rb +5 -1
- data/apps/servant/cmd.rb +14 -45
- data/apps/servant/config/options.rb +1 -0
- data/apps/servant/controllers/servant_controller.rb +7 -1
- data/apps/servant/lib/client.rb +55 -0
- data/apps/servant/servant.appspec +1 -1
- data/apps/servant/servant.rb +90 -0
- data/apps/worker/cmd.rb +9 -4
- data/apps/worker/worker.rb +11 -6
- data/blueprints/bin/spider +7 -0
- data/blueprints/home/config/config.yml +2 -3
- data/blueprints/home/init.rb +1 -1
- data/lib/spiderfw/app.rb +50 -2
- data/lib/spiderfw/cmd/commands/app.rb +22 -12
- data/lib/spiderfw/cmd/commands/config.rb +2 -1
- data/lib/spiderfw/config/configuration_editor.rb +7 -4
- data/lib/spiderfw/config/options/spider.rb +3 -1
- data/lib/spiderfw/controller/helpers/widget_helper.rb +6 -3
- data/lib/spiderfw/controller/mixins/http_mixin.rb +2 -1
- data/lib/spiderfw/controller/mixins/visual.rb +12 -10
- data/lib/spiderfw/env.rb +8 -1
- data/lib/spiderfw/home.rb +31 -4
- data/lib/spiderfw/http/server.rb +32 -14
- data/lib/spiderfw/model/mappers/mapper.rb +2 -2
- data/lib/spiderfw/model/mixins/tree.rb +7 -5
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +55 -2
- data/lib/spiderfw/model/storage/db/adapters/oracle.rb +80 -3
- data/lib/spiderfw/model/storage/db/connectors/jdbc_oracle.rb +3 -2
- data/lib/spiderfw/model/storage/db/connectors/oci8.rb +3 -2
- data/lib/spiderfw/model/storage/db/db_storage.rb +22 -0
- data/lib/spiderfw/setup/app_manager.rb +6 -2
- data/lib/spiderfw/site.rb +3 -1
- data/lib/spiderfw/spider.rb +145 -18
- data/lib/spiderfw/templates/blocks/parent_context.rb +3 -1
- data/lib/spiderfw/templates/template.rb +14 -5
- data/lib/spiderfw/widget/widget.rb +1 -0
- data/lib/spiderfw/widget/widget_attributes.rb +2 -2
- metadata +16 -16
- data/apps/master/po/spider_master.pot +0 -331
- data/apps/master/views/servants.shtml +0 -11
- data/apps/servant/lib/commands/discovery.rb +0 -0
- data/apps/servant/lib/resource.rb +0 -14
- data/apps/servant/lib/resources/db/mysql.rb +0 -35
- data/apps/servant/lib/resources/db.rb +0 -55
- data/apps/servant/lib/servant.rb +0 -88
- data/apps/servant/var/log/error.log +0 -1
@@ -270,15 +270,92 @@ module Spider; module Model; module Storage; module Db
|
|
270
270
|
end
|
271
271
|
|
272
272
|
def list_tables
|
273
|
-
|
273
|
+
tables = execute("SELECT TABLE_NAME FROM user_tables ORDER BY table_name").map{ |r| r['TABLE_NAME'] }
|
274
|
+
mv = execute("SELECT OBJECT_NAME FROM user_objects WHERE OBJECT_TYPE = 'MATERIALIZED VIEW'").map{ |r| r['OBJECT_NAME'] }
|
275
|
+
tables - mv
|
276
|
+
end
|
277
|
+
|
278
|
+
def get_table_create_sql(table)
|
279
|
+
sql = nil
|
280
|
+
connection do |c|
|
281
|
+
out = nil
|
282
|
+
cursor = c.parse('BEGIN :out1 := DBMS_METADATA.GET_DDL(object_type=>:in1, name=>:in2); END;')
|
283
|
+
cursor.bind_param(1, out, OCI8::CLOB)
|
284
|
+
cursor.bind_param(2, 'TABLE', String)
|
285
|
+
cursor.bind_param(3, table, String)
|
286
|
+
res = cursor.exec
|
287
|
+
sql = cursor[1].read
|
288
|
+
cursor.close
|
289
|
+
# cursor = c.parse('BEGIN DBMS_METADATA_UTIL.LOAD_STYLESHEETS(); END;')
|
290
|
+
# cursor.exec
|
291
|
+
end
|
292
|
+
sql
|
293
|
+
end
|
294
|
+
|
295
|
+
def dump(stream, tables=nil)
|
296
|
+
stream << "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';\n\n"
|
297
|
+
super(stream, tables)
|
298
|
+
end
|
299
|
+
|
300
|
+
def dump_table_data(table, stream)
|
301
|
+
connection do |c|
|
302
|
+
cursor = c.parse("SELECT COUNT(*) AS N FROM #{table}")
|
303
|
+
cursor.exec
|
304
|
+
num = cursor.fetch[0]
|
305
|
+
cursor.close
|
306
|
+
cursor = c.parse("select * from #{table}")
|
307
|
+
cursor.exec
|
308
|
+
if num > 0
|
309
|
+
info = describe_table(table)
|
310
|
+
fields = info[:columns]
|
311
|
+
stream << "INSERT INTO #{table} (#{info[:order].map{ |f| "#{f}"}.join(', ')})\n"
|
312
|
+
stream << "VALUES\n"
|
313
|
+
cnt = 0
|
314
|
+
while row = cursor.fetch
|
315
|
+
cnt += 1
|
316
|
+
stream << "("
|
317
|
+
info[:order].each_with_index do |f, i|
|
318
|
+
stream << dump_value(row[i], fields[f])
|
319
|
+
stream << ", " if i < fields.length - 1
|
320
|
+
end
|
321
|
+
stream << ")"
|
322
|
+
if cnt < num
|
323
|
+
stream << ",\n"
|
324
|
+
else
|
325
|
+
stream << ";\n"
|
326
|
+
end
|
327
|
+
end
|
328
|
+
stream << "\n\n"
|
329
|
+
end
|
330
|
+
cursor.close
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
def dump_value(val, field)
|
335
|
+
return 'NULL' if val.nil?
|
336
|
+
type = field[:type]
|
337
|
+
if ['CHAR', 'VARCHAR', 'VARCHAR2', 'BLOB', 'CLOB'].include?(type)
|
338
|
+
val = val.gsub("'", "''").gsub("\n", '\n').gsub("\r", '\r')
|
339
|
+
return "'#{val}'"
|
340
|
+
elsif ['DATE', 'TIME', 'DATETIME'].include?(type)
|
341
|
+
val = val.strftime("%Y-%m-%d %H:%M:%S")
|
342
|
+
return "'#{val}'"
|
343
|
+
else
|
344
|
+
return val.to_s
|
345
|
+
end
|
274
346
|
end
|
275
347
|
|
276
348
|
def describe_table(table)
|
277
349
|
primary_keys = []
|
278
350
|
o_foreign_keys = {}
|
279
351
|
columns = {}
|
352
|
+
order = []
|
280
353
|
connection do |conn|
|
281
|
-
|
354
|
+
cols = do_describe_table(conn, table)
|
355
|
+
cols.each do |col|
|
356
|
+
columns[col[:name]] = col
|
357
|
+
order << col[:name]
|
358
|
+
end
|
282
359
|
res = execute("SELECT cols.table_name, cols.COLUMN_NAME, cols.position, cons.status, cons.owner
|
283
360
|
FROM user_constraints cons, user_cons_columns cols
|
284
361
|
WHERE cons.constraint_type = 'P'
|
@@ -310,7 +387,7 @@ module Spider; module Model; module Storage; module Db
|
|
310
387
|
o_foreign_keys.each do |fk_name, fk_hash|
|
311
388
|
foreign_keys << ForeignKeyConstraint.new(fk_name, fk_hash[:table], fk_hash[:columns])
|
312
389
|
end
|
313
|
-
return {:columns => columns, :primary_keys => primary_keys, :foreign_key_constraints => foreign_keys}
|
390
|
+
return {:columns => columns, :order => order, :primary_keys => primary_keys, :foreign_key_constraints => foreign_keys}
|
314
391
|
|
315
392
|
end
|
316
393
|
|
@@ -305,16 +305,17 @@ module Spider; module Model; module Storage; module Db; module Connectors
|
|
305
305
|
def do_describe_table(conn, table)
|
306
306
|
md = get_db_metadata(conn)
|
307
307
|
res = md.getColumns(nil, @user.upcase, table, nil)
|
308
|
-
columns =
|
308
|
+
columns = []
|
309
309
|
while res.next()
|
310
310
|
col_name = res.getString("COLUMN_NAME")
|
311
311
|
col = {
|
312
|
+
:name => col_name,
|
312
313
|
:type => res.getString("TYPE_NAME"),
|
313
314
|
:length => res.getInt("COLUMN_SIZE"),
|
314
315
|
:precision => res.getInt("DECIMAL_DIGITS"),
|
315
316
|
}
|
316
317
|
col.delete(:length) if (col[:precision])
|
317
|
-
columns
|
318
|
+
columns << col
|
318
319
|
end
|
319
320
|
columns
|
320
321
|
end
|
@@ -180,10 +180,11 @@ module Spider; module Model; module Storage; module Db; module Connectors
|
|
180
180
|
end
|
181
181
|
|
182
182
|
def do_describe_table(conn, table)
|
183
|
-
columns =
|
183
|
+
columns = []
|
184
184
|
t = conn.describe_table(table)
|
185
185
|
t.columns.each do |c|
|
186
186
|
col = {
|
187
|
+
:name => c.name,
|
187
188
|
:type => c.data_type.to_s.upcase,
|
188
189
|
:length => c.data_size,
|
189
190
|
:precision => c.precision,
|
@@ -191,7 +192,7 @@ module Spider; module Model; module Storage; module Db; module Connectors
|
|
191
192
|
:null => c.nullable?
|
192
193
|
}
|
193
194
|
col.delete(:length) if (col[:precision])
|
194
|
-
columns
|
195
|
+
columns << col
|
195
196
|
end
|
196
197
|
columns
|
197
198
|
end
|
@@ -671,6 +671,28 @@ module Spider; module Model; module Storage; module Db
|
|
671
671
|
col
|
672
672
|
end
|
673
673
|
|
674
|
+
def dump(stream, tables=nil, options={})
|
675
|
+
tables ||= list_tables
|
676
|
+
options = ({
|
677
|
+
:include_create => true
|
678
|
+
}).merge(options)
|
679
|
+
tables.each do |t|
|
680
|
+
Spider.logger.info("Dumping table #{t}")
|
681
|
+
begin
|
682
|
+
if options[:include_create]
|
683
|
+
create = get_table_create_sql(t)
|
684
|
+
stream << create
|
685
|
+
stream << "\n\n"
|
686
|
+
end
|
687
|
+
dump_table_data(t, stream)
|
688
|
+
stream << "\n\n"
|
689
|
+
rescue => exc
|
690
|
+
Spider.logger.error("Failed to dump table #{t}")
|
691
|
+
Spider.logger.error(exc.message)
|
692
|
+
end
|
693
|
+
end
|
694
|
+
end
|
695
|
+
|
674
696
|
##############################################################
|
675
697
|
# Aggregates #
|
676
698
|
##############################################################
|
@@ -77,15 +77,19 @@ module Spider
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
def pre_update
|
81
|
+
end
|
82
|
+
|
80
83
|
def self.post_setup(specs, options={})
|
81
|
-
require 'bundler'
|
82
|
-
Bundler::Installer.install(options[:home_path], Bundler.definitions, {})
|
84
|
+
#require 'bundler'
|
85
|
+
#Bundler::Installer.install(options[:home_path], Bundler.definitions, {})
|
83
86
|
end
|
84
87
|
|
85
88
|
def self.update(specs, home_path, options)
|
86
89
|
options[:use_git] = true unless options[:use_git] == false
|
87
90
|
specs = [specs] unless specs.is_a?(Array)
|
88
91
|
pre_setup(specs, options)
|
92
|
+
pre_update(specs, option)
|
89
93
|
specs.each do |spec|
|
90
94
|
if spec.git_repo && options[:use_git]
|
91
95
|
git_update(spec, home_path, options)
|
data/lib/spiderfw/site.rb
CHANGED
data/lib/spiderfw/spider.rb
CHANGED
@@ -9,6 +9,11 @@ require 'spiderfw/requires'
|
|
9
9
|
|
10
10
|
require 'spiderfw/version'
|
11
11
|
|
12
|
+
begin
|
13
|
+
require 'fssm'
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
12
17
|
|
13
18
|
module Spider
|
14
19
|
|
@@ -109,6 +114,7 @@ module Spider
|
|
109
114
|
load_configuration File.join($SPIDER_PATH, 'config')
|
110
115
|
load_configuration File.join(@root, 'config')
|
111
116
|
Locale.default = Spider.conf.get('i18n.default_locale')
|
117
|
+
setup_env
|
112
118
|
@init_base_done = true
|
113
119
|
end
|
114
120
|
|
@@ -118,15 +124,21 @@ module Spider
|
|
118
124
|
# mod.app_stop if mod.respond_to?(:app_stop)
|
119
125
|
# end
|
120
126
|
# end
|
121
|
-
|
122
|
-
|
123
|
-
# Invoked before a server is started. Apps may implement the app_startup method, that will be called.
|
124
|
-
def startup
|
127
|
+
|
128
|
+
def setup_env
|
125
129
|
unless File.exists?(File.join(Spider.paths[:root], 'init.rb'))
|
126
|
-
raise "
|
130
|
+
raise "This command must be run from the root directory"
|
127
131
|
end
|
128
132
|
FileUtils.mkdir_p(Spider.paths[:tmp])
|
129
133
|
FileUtils.mkdir_p(Spider.paths[:var])
|
134
|
+
FileUtils.mkdir_p(File.join(Spider.paths[:var], 'memory'))
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
# Invoked before a long running service started. Apps may implement the app_startup method, that will be called.
|
140
|
+
def startup
|
141
|
+
setup_env
|
130
142
|
if Spider.conf.get('template.cache.reload_on_restart')
|
131
143
|
FileUtils.touch("#{Spider.paths[:tmp]}/templates_reload.txt")
|
132
144
|
end
|
@@ -144,21 +156,86 @@ module Spider
|
|
144
156
|
@apps.each do |name, mod|
|
145
157
|
mod.app_startup if mod.respond_to?(:app_startup)
|
146
158
|
end
|
147
|
-
|
148
159
|
@startup_done = true
|
160
|
+
at_exit do
|
161
|
+
Spider.shutdown
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def main_process_startup
|
166
|
+
if Object.const_defined?(:FSSM)
|
167
|
+
monitor = FSSM::Monitor.new
|
168
|
+
|
169
|
+
monitor.path(Spider.paths[:tmp], 'restart.txt') do
|
170
|
+
create { |base, relative| Process.kill 'HUP', $$ }
|
171
|
+
update { |base, relative| Process.kill 'HUP', $$ }
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
@fssm_thread = Thread.new do
|
176
|
+
monitor.run
|
177
|
+
end
|
178
|
+
Spider.logger.debug("Monitoring restart.txt")
|
179
|
+
else
|
180
|
+
Spider.logger.debug("FSSM not installed, unable to monitor restart.txt")
|
181
|
+
end
|
182
|
+
trap('TERM'){ Spider.main_process_shutdown; exit }
|
183
|
+
trap('INT'){ Spider.main_process_shutdown; exit }
|
184
|
+
trap('HUP'){ Spider.respawn! }
|
185
|
+
|
186
|
+
if @main_process_startup_blocks
|
187
|
+
@main_process_startup_blocks.each{ |block| block.call }
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
def on_main_process_startup(&proc)
|
193
|
+
@main_process_startup_blocks ||= []
|
194
|
+
@main_process_startup_blocks << proc
|
149
195
|
end
|
150
196
|
|
151
197
|
def startup_done?
|
152
198
|
@startup_done
|
153
199
|
end
|
154
200
|
|
201
|
+
def on_shutdown(&block)
|
202
|
+
@shutdown_blocks ||= []
|
203
|
+
@shutdown_blocks << block
|
204
|
+
end
|
205
|
+
|
155
206
|
# Invoked when a server is shutdown. Apps may implement the app_shutdown method, that will be called.
|
156
|
-
def shutdown
|
157
|
-
|
207
|
+
def shutdown(force=false)
|
208
|
+
unless force
|
209
|
+
#return unless Thread.current == Thread.main
|
210
|
+
return if @shutdown_done
|
211
|
+
end
|
212
|
+
@shutdown_done = true
|
213
|
+
Spider.logger.debug("Shutdown")
|
158
214
|
Debugger.post_mortem = false if Object.const_defined?(:Debugger) && Debugger.post_mortem?
|
159
215
|
@apps.each do |name, mod|
|
160
216
|
mod.app_shutdown if mod.respond_to?(:app_shutdown)
|
161
217
|
end
|
218
|
+
if @shutdown_blocks
|
219
|
+
@shutdown_blocks.each{ |b| b.call }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def shutdown!
|
224
|
+
shutdown(true)
|
225
|
+
end
|
226
|
+
|
227
|
+
def main_process_shutdown
|
228
|
+
if startup_done?
|
229
|
+
shutdown!
|
230
|
+
end
|
231
|
+
if @main_process_shutdown_blocks
|
232
|
+
@main_process_shutdown_blocks.each{ |b| b.call }
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def on_main_process_shutdown(&block)
|
237
|
+
@main_process_shutdown_blocks ||= []
|
238
|
+
@main_process_shutdown_blocks << block
|
162
239
|
end
|
163
240
|
|
164
241
|
def current
|
@@ -237,6 +314,9 @@ module Spider
|
|
237
314
|
@paths[:tmp] = File.join(root, 'tmp')
|
238
315
|
@paths[:data] = File.join(root, 'data')
|
239
316
|
@paths[:log] = File.join(@paths[:var], 'log')
|
317
|
+
@paths.each do |k, path|
|
318
|
+
@paths[k] = File.expand_path(File.readlink(path)) if File.symlink?(path)
|
319
|
+
end
|
240
320
|
end
|
241
321
|
|
242
322
|
# Finds an app by name, looking in paths[:apps] and paths[:core_apps]. Returns the found path.
|
@@ -283,7 +363,11 @@ module Spider
|
|
283
363
|
GetText::LocalePath.add_default_rule(File.join(path, "data/locale/%{lang}/LC_MESSAGES/%{name}.mo"))
|
284
364
|
end
|
285
365
|
|
366
|
+
|
286
367
|
def load_apps(*l)
|
368
|
+
if l.empty?
|
369
|
+
l = Spider.conf.get('apps')
|
370
|
+
end
|
287
371
|
l.each do |app|
|
288
372
|
load_app(app)
|
289
373
|
end
|
@@ -295,9 +379,10 @@ module Spider
|
|
295
379
|
end
|
296
380
|
end
|
297
381
|
|
298
|
-
def find_all_apps
|
382
|
+
def find_all_apps(paths=nil)
|
383
|
+
paths ||= [@paths[:core_apps], @paths[:apps]]
|
299
384
|
app_paths = []
|
300
|
-
Find.find(
|
385
|
+
Find.find(*paths) do |path|
|
301
386
|
if (File.basename(path) == '_init.rb')
|
302
387
|
app_paths << File.dirname(path)
|
303
388
|
Find.prune
|
@@ -337,6 +422,35 @@ module Spider
|
|
337
422
|
return false
|
338
423
|
end
|
339
424
|
|
425
|
+
def activate_apps(apps, specs=nil)
|
426
|
+
require 'spiderfw/config/configuration_editor'
|
427
|
+
init_base
|
428
|
+
unless specs
|
429
|
+
specs = {}
|
430
|
+
Spider.home.apps.each do |k, v|
|
431
|
+
specs[k] = v[:spec] if apps.include?(k)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
editor = Spider::ConfigurationEditor.new
|
435
|
+
Spider.config.loaded_files.each do |f|
|
436
|
+
editor.load(f)
|
437
|
+
end
|
438
|
+
c_apps = Spider.config.get('apps')
|
439
|
+
c_apps = (c_apps + apps).uniq
|
440
|
+
editor.set('apps', Spider.apps_load_order(c_apps, specs))
|
441
|
+
editor.save
|
442
|
+
end
|
443
|
+
|
444
|
+
def apps_load_order(apps, specs)
|
445
|
+
# TODO
|
446
|
+
require 'spiderfw/app'
|
447
|
+
sort = Spider::App::RuntimeSort.new
|
448
|
+
apps.each do |a|
|
449
|
+
sort.add(specs[a] ? specs[a] : a)
|
450
|
+
end
|
451
|
+
sort.tsort
|
452
|
+
end
|
453
|
+
|
340
454
|
def load_configuration(path)
|
341
455
|
return unless File.directory?(path)
|
342
456
|
opts = File.join(path, 'options.rb')
|
@@ -451,9 +565,9 @@ module Spider
|
|
451
565
|
return Resource.new(path, self)
|
452
566
|
elsif (cur_path)
|
453
567
|
if (path[0..1] == './')
|
454
|
-
return Resource.new(first_found(extensions, cur_path+path[1..-1]), owner_class)
|
568
|
+
return Resource.new(first_found(extensions, File.dirname(cur_path)+path[1..-1]), owner_class)
|
455
569
|
elsif (path[0..1] == '../')
|
456
|
-
return Resource.new(first_found(extensions, File.dirname(cur_path)+path[2..-1]), owner_class)
|
570
|
+
return Resource.new(first_found(extensions, File.dirname(File.dirname(cur_path))+path[2..-1]), owner_class)
|
457
571
|
end
|
458
572
|
end
|
459
573
|
app = nil
|
@@ -488,6 +602,7 @@ module Spider
|
|
488
602
|
return Resource.new(found, definer) if found
|
489
603
|
end
|
490
604
|
end
|
605
|
+
resource_type, path, cur_path=nil, owner_classes=nil, search_paths
|
491
606
|
return Resource.new(path)
|
492
607
|
end
|
493
608
|
|
@@ -596,12 +711,24 @@ module Spider
|
|
596
711
|
end
|
597
712
|
|
598
713
|
def respawn!
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
714
|
+
require 'rbconfig'
|
715
|
+
Spider.logger.info("Restarting")
|
716
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
|
717
|
+
Spider.main_process_shutdown
|
718
|
+
return if $SPIDER_NO_RESPAWN
|
719
|
+
cmd = $SPIDER_SCRIPT || $0
|
720
|
+
args = $SPIDER_PROC_ARGS || ARGV
|
721
|
+
Spider.logger.debug("CWD: #{Dir.pwd}")
|
722
|
+
if RUBY_PLATFORM =~ /win32|mingw32/
|
723
|
+
start_cmd = "start cmd /C #{ruby} #{cmd} #{args.join(' ')}"
|
724
|
+
Spider.logger.debug(start_cmd)
|
725
|
+
IO.popen(start_cmd)
|
726
|
+
sleep 5
|
727
|
+
else
|
728
|
+
start_cmd = "#{ruby} #{cmd} #{args.join(' ')}"
|
729
|
+
Spider.logger.debug(start_cmd)
|
730
|
+
exec(start_cmd)
|
731
|
+
end
|
605
732
|
end
|
606
733
|
|
607
734
|
def runmode=(mode)
|
@@ -13,7 +13,9 @@ module Spider; module TemplateBlocks
|
|
13
13
|
# c += "debugger\n"
|
14
14
|
parent_c, parent_init = compile_content(c, init, options)
|
15
15
|
parent_c.gsub!("'", "\\\\'")
|
16
|
-
parent_init.gsub!("'", "\\\\'")
|
16
|
+
#parent_init.gsub!("'", "\\\\'")
|
17
|
+
init = parent_init
|
18
|
+
init.gsub!('scene[', 'scene[:_parent][')
|
17
19
|
c += "self[:_parent].instance_eval('def __run_block\n;#{parent_c}\nend\n')\n"
|
18
20
|
c += "yield :_parent\n"
|
19
21
|
return CompiledBlock.new(init, c)
|
@@ -27,7 +27,7 @@ module Spider
|
|
27
27
|
attr_accessor :mode # :widget, ...
|
28
28
|
attr_accessor :assets
|
29
29
|
attr_accessor :runtime_overrides
|
30
|
-
attr_reader :overrides, :path, :subtemplates, :widgets
|
30
|
+
attr_reader :overrides, :path, :subtemplates, :widgets, :content
|
31
31
|
attr_accessor :asset_profiles
|
32
32
|
|
33
33
|
@@registered = {}
|
@@ -269,7 +269,7 @@ module Spider
|
|
269
269
|
doc = open(@path){ |f| Hpricot.XML(f) }
|
270
270
|
root = get_el(doc)
|
271
271
|
el = process_tags(root)
|
272
|
-
|
272
|
+
apply_overrides(root)
|
273
273
|
root.search('tpl:placeholder').remove # remove empty placeholders
|
274
274
|
owner_class = @owner ? @owner.class : @owner_class
|
275
275
|
@assets += owner_class.assets if owner_class
|
@@ -459,6 +459,7 @@ module Spider
|
|
459
459
|
doc = nil
|
460
460
|
if path_or_doc.is_a?(Hpricot::Doc)
|
461
461
|
doc = path_or_doc
|
462
|
+
path = @path
|
462
463
|
else
|
463
464
|
path = path_or_doc
|
464
465
|
path ||= @path
|
@@ -478,7 +479,6 @@ module Spider
|
|
478
479
|
add_overrides overrides
|
479
480
|
@overrides += orig_overrides
|
480
481
|
if root.name == 'tpl:extend'
|
481
|
-
|
482
482
|
orig_overrides = @overrides
|
483
483
|
@overrides = []
|
484
484
|
ext_src = root.get_attribute('src')
|
@@ -500,7 +500,8 @@ module Spider
|
|
500
500
|
if ext_owner && ext_owner.respond_to?(:template_paths)
|
501
501
|
ext_search_paths = ext_owner.template_paths
|
502
502
|
end
|
503
|
-
ext = self.class.real_path(ext_src,
|
503
|
+
ext = self.class.real_path(ext_src, path, ext_owner, ext_search_paths)
|
504
|
+
raise "Extended template #{ext_src} not found (search path #{path}, owner #{ext_owner}, search paths #{ext_search_paths.inspect}" unless ext
|
504
505
|
assets = []
|
505
506
|
if root.children
|
506
507
|
assets = root.children_of_type('tpl:asset')
|
@@ -525,7 +526,7 @@ module Spider
|
|
525
526
|
else
|
526
527
|
assets_html = ""
|
527
528
|
root.search('tpl:include').each do |incl|
|
528
|
-
resource = Spider.find_resource(:views, incl.get_attribute('src'),
|
529
|
+
resource = Spider.find_resource(:views, incl.get_attribute('src'), @path, [@owner.class, @definer_class])
|
529
530
|
src = resource.path
|
530
531
|
@dependencies << src
|
531
532
|
incl_el = self.get_el(src)
|
@@ -685,6 +686,7 @@ module Spider
|
|
685
686
|
scene.instance_eval("def __run_template\n"+@compiled.run_code+"end\n", @compiled.cache_path+'/run.rb', 0)
|
686
687
|
scene.__run_template do |yielded|
|
687
688
|
if yielded == :_parent
|
689
|
+
@owner.parent.template.content.merge!(@content)
|
688
690
|
@owner.parent.template.run_block
|
689
691
|
else
|
690
692
|
@content[yielded].render if @content[yielded]
|
@@ -750,6 +752,13 @@ module Spider
|
|
750
752
|
def overrides_for(widget_id)
|
751
753
|
@widgets_overrides[widget_id] || []
|
752
754
|
end
|
755
|
+
|
756
|
+
def apply_overrides(el)
|
757
|
+
if @overrides
|
758
|
+
@overrides.each{ |o| apply_override(el, o) }
|
759
|
+
end
|
760
|
+
el
|
761
|
+
end
|
753
762
|
|
754
763
|
# Applies an override to an (Hpricot) element.
|
755
764
|
def apply_override(el, override)
|
@@ -413,6 +413,7 @@ module Spider
|
|
413
413
|
if !@is_target && @widget_target
|
414
414
|
first, rest = @widget_target.split('/', 2)
|
415
415
|
@_widget = find_widget(first)
|
416
|
+
raise "#{self} couldn't find widget #{first} for target #{@widget_target}" unless @_widget
|
416
417
|
@_widget.is_target_ancestor = true
|
417
418
|
@_widget.widget_target = rest
|
418
419
|
@_widget.is_target = true unless rest
|
@@ -25,7 +25,7 @@ module Spider
|
|
25
25
|
when 'String'
|
26
26
|
v = v.to_s
|
27
27
|
when 'Symbol'
|
28
|
-
v = v.to_sym
|
28
|
+
v = v.to_sym if v
|
29
29
|
when 'TrueClass', 'FalseClass', 'Spider::DataTypes::Bool'
|
30
30
|
v = (v.to_s == 'false' || v.to_s.empty?) ? false : true
|
31
31
|
when 'Fixnum'
|
@@ -51,4 +51,4 @@ module Spider
|
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
|
-
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spiderfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Pirlik
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-19 00:00:00 +02:00
|
19
19
|
default_executable: spider
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -838,7 +838,8 @@ files:
|
|
838
838
|
- apps/master/controllers/login_controller.rb
|
839
839
|
- apps/master/controllers/master_controller.rb
|
840
840
|
- apps/master/controllers/scout_controller.rb
|
841
|
-
- apps/master/controllers/
|
841
|
+
- apps/master/controllers/server_controller.rb
|
842
|
+
- apps/master/data/locale/it/LC_MESSAGES/master.mo
|
842
843
|
- apps/master/data/locale/it/LC_MESSAGES/spider_master.mo
|
843
844
|
- apps/master/lib/resource.rb
|
844
845
|
- apps/master/lib/resources/db_resource.rb
|
@@ -850,6 +851,7 @@ files:
|
|
850
851
|
- apps/master/models/command.rb
|
851
852
|
- apps/master/models/customer.rb
|
852
853
|
- apps/master/models/installation.rb
|
854
|
+
- apps/master/models/remote_log.rb
|
853
855
|
- apps/master/models/resource.rb
|
854
856
|
- apps/master/models/scout_alert.rb
|
855
857
|
- apps/master/models/scout_average.rb
|
@@ -859,13 +861,12 @@ files:
|
|
859
861
|
- apps/master/models/scout_plugin_trigger.rb
|
860
862
|
- apps/master/models/scout_report.rb
|
861
863
|
- apps/master/models/scout_report_field.rb
|
862
|
-
- apps/master/models/
|
864
|
+
- apps/master/models/server.rb
|
863
865
|
- apps/master/plugins/resources/apache/apache.rb
|
864
866
|
- apps/master/plugins/resources/mysql/mysql.rb
|
865
867
|
- apps/master/plugins/site_types/spider/spider.rb
|
866
|
-
- apps/master/po/it/
|
868
|
+
- apps/master/po/it/master.po
|
867
869
|
- apps/master/po/master.pot
|
868
|
-
- apps/master/po/spider_master.pot
|
869
870
|
- apps/master/public/css/img/web.png
|
870
871
|
- apps/master/public/css/login.css
|
871
872
|
- apps/master/public/css/master.css
|
@@ -885,8 +886,8 @@ files:
|
|
885
886
|
- apps/master/views/plugin_data.shtml
|
886
887
|
- apps/master/views/plugin_edit.shtml
|
887
888
|
- apps/master/views/plugin_instance.shtml
|
888
|
-
- apps/master/views/
|
889
|
-
- apps/master/views/
|
889
|
+
- apps/master/views/server.shtml
|
890
|
+
- apps/master/views/servers.shtml
|
890
891
|
- apps/master/views/site.shtml
|
891
892
|
- apps/master/views/site_edit.shtml
|
892
893
|
- apps/master/views/trigger_edit.shtml
|
@@ -930,14 +931,12 @@ files:
|
|
930
931
|
- apps/servant/_init.rb
|
931
932
|
- apps/servant/bin/spider-servant.rb
|
932
933
|
- apps/servant/cmd.rb
|
934
|
+
- apps/servant/config/options.rb
|
933
935
|
- apps/servant/controllers/servant_controller.rb
|
934
|
-
- apps/servant/
|
935
|
-
- apps/servant/lib/
|
936
|
-
- apps/servant/lib/resources/db/mysql.rb
|
937
|
-
- apps/servant/lib/resources/db.rb
|
938
|
-
- apps/servant/lib/servant.rb
|
936
|
+
- apps/servant/Gemfile
|
937
|
+
- apps/servant/lib/client.rb
|
939
938
|
- apps/servant/servant.appspec
|
940
|
-
- apps/servant/
|
939
|
+
- apps/servant/servant.rb
|
941
940
|
- apps/soap/_init.rb
|
942
941
|
- apps/soap/controllers/soap_controller.rb
|
943
942
|
- apps/soap/doc/examples/example.rb
|
@@ -974,6 +973,7 @@ files:
|
|
974
973
|
- blueprints/app/views/__APP__.layout.shtml
|
975
974
|
- blueprints/app/views/index.shtml
|
976
975
|
- blueprints/app/widgets/.gitignore
|
976
|
+
- blueprints/bin/spider
|
977
977
|
- blueprints/home/.dirs
|
978
978
|
- blueprints/home/.DS_Store
|
979
979
|
- blueprints/home/.gitignore
|