spiderfw 0.5.15 → 0.5.16
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/apps/core/auth/data/locale/it/LC_MESSAGES/spider_auth.mo +0 -0
- data/apps/core/auth/po/it/spider_auth.po +8 -5
- data/apps/core/auth/po/spider_auth.pot +2 -2
- data/apps/core/components/data/locale/it/LC_MESSAGES/spider_components.mo +0 -0
- data/apps/core/components/po/it/spider_components.po +11 -7
- data/apps/core/components/po/spider_components.pot +9 -5
- data/apps/core/components/public/js/spider.js +19 -0
- data/apps/core/components/widgets/month_calendar/month_calendar.rb +16 -9
- data/apps/core/forms/data/locale/it/LC_MESSAGES/spider_forms.mo +0 -0
- data/apps/core/forms/po/it/spider_forms.po +18 -5
- data/apps/core/forms/po/spider_forms.pot +16 -4
- data/apps/master/po/master.pot +400 -0
- data/apps/messenger/data/locale/it/LC_MESSAGES/spider_messenger.mo +0 -0
- data/apps/messenger/po/it/spider_messenger.po +48 -8
- data/apps/messenger/po/spider_messenger.pot +39 -3
- data/data/locale/it/LC_MESSAGES/spider.mo +0 -0
- data/lib/spiderfw/app.rb +16 -15
- data/lib/spiderfw/cmd/commands/app.rb +60 -0
- data/lib/spiderfw/controller/controller.rb +5 -1
- data/lib/spiderfw/controller/controller_mixin.rb +1 -0
- data/lib/spiderfw/controller/dispatcher.rb +1 -0
- data/lib/spiderfw/controller/mixins/visual.rb +16 -8
- data/lib/spiderfw/home.rb +3 -2
- data/lib/spiderfw/i18n/javascript_parser.rb +1 -1
- data/lib/spiderfw/model/base_model.rb +16 -6
- data/lib/spiderfw/model/mappers/db_mapper.rb +2 -2
- data/lib/spiderfw/model/mappers/mapper.rb +7 -2
- data/lib/spiderfw/model/query.rb +11 -1
- data/lib/spiderfw/setup/app_manager.rb +60 -0
- data/lib/spiderfw/templates/blocks/widget.rb +1 -1
- data/lib/spiderfw/utils/annotations.rb +1 -1
- data/lib/spiderfw/widget/widget.rb +12 -1
- data/lib/spiderfw/widget/widget_plugin.rb +15 -1
- data/lib/spiderfw.rb +46 -51
- metadata +8 -4
@@ -10,10 +10,15 @@ module Spider; module ControllerMixins
|
|
10
10
|
|
11
11
|
def self.included(klass)
|
12
12
|
klass.extend(ClassMethods)
|
13
|
-
klass.
|
14
|
-
klass
|
15
|
-
|
16
|
-
|
13
|
+
klass.extend(OutputFormatMethods)
|
14
|
+
define_format_annotations(klass)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.define_format_annotations(klass)
|
18
|
+
klass.define_annotation(:html) { |k, m, params| k.output_format(m, :html, params) }
|
19
|
+
klass.define_annotation(:xml) { |k, m, params| k.output_format(m, :xml, params) }
|
20
|
+
klass.define_annotation(:json) { |k, m, params| k.output_format(m, :json, params) }
|
21
|
+
klass.define_annotation(:text) { |k, m, params| k.output_format(m, :text, params) }
|
17
22
|
end
|
18
23
|
|
19
24
|
def before(action='', *params)
|
@@ -411,9 +416,8 @@ module Spider; module ControllerMixins
|
|
411
416
|
return bt
|
412
417
|
end
|
413
418
|
|
414
|
-
|
415
|
-
|
416
|
-
|
419
|
+
module OutputFormatMethods
|
420
|
+
|
417
421
|
def output_format(method=nil, format=nil, params={})
|
418
422
|
return @default_output_format unless method
|
419
423
|
@output_formats ||= {}
|
@@ -449,7 +453,11 @@ module Spider; module ControllerMixins
|
|
449
453
|
def default_output_format(format)
|
450
454
|
@default_output_format = format if format
|
451
455
|
@default_output_format
|
452
|
-
end
|
456
|
+
end
|
457
|
+
|
458
|
+
end
|
459
|
+
|
460
|
+
module ClassMethods
|
453
461
|
|
454
462
|
|
455
463
|
def layouts
|
data/lib/spiderfw/home.rb
CHANGED
@@ -23,9 +23,10 @@ module Spider
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def list_apps
|
26
|
-
|
26
|
+
apps_path = Spider.respond_to?(:paths) ? Spider.paths[:apps] : File.join(@path, 'apps')
|
27
|
+
apps_dir = Pathname.new(apps_path)
|
27
28
|
apps = []
|
28
|
-
Dir.glob("#{
|
29
|
+
Dir.glob("#{apps_path}/**/_init.rb").each do |path|
|
29
30
|
dir = Pathname.new(File.dirname(path))
|
30
31
|
apps << dir.relative_path_from(apps_dir).to_s
|
31
32
|
end
|
@@ -66,6 +66,8 @@ module Spider; module Model
|
|
66
66
|
attr_accessor :_parent
|
67
67
|
# If _parent is a model instance, which element points to this one
|
68
68
|
attr_accessor :_parent_element
|
69
|
+
#
|
70
|
+
attr_accessor :_check_if_saved
|
69
71
|
|
70
72
|
# If this object is used as a superclass in class_table_inheritance, points to the current subclass
|
71
73
|
attr_accessor :_subclass_object
|
@@ -1091,7 +1093,7 @@ module Spider; module Model
|
|
1091
1093
|
# See #self.where for parameter syntax.
|
1092
1094
|
def self.load(*params, &proc)
|
1093
1095
|
qs = self.where(*params, &proc)
|
1094
|
-
qs.
|
1096
|
+
qs.only_one
|
1095
1097
|
return qs[0]
|
1096
1098
|
end
|
1097
1099
|
|
@@ -1530,7 +1532,7 @@ module Spider; module Model
|
|
1530
1532
|
checks.each do |msg, check|
|
1531
1533
|
test = case check
|
1532
1534
|
when Regexp
|
1533
|
-
val
|
1535
|
+
val.blank? ? true : check.match(val.to_s)
|
1534
1536
|
when Proc
|
1535
1537
|
check.call(val)
|
1536
1538
|
end
|
@@ -2464,20 +2466,28 @@ module Spider; module Model
|
|
2464
2466
|
h
|
2465
2467
|
end
|
2466
2468
|
|
2467
|
-
def self.from_hash_dump(h)
|
2469
|
+
def self.from_hash_dump(h, options={})
|
2468
2470
|
obj = self.static
|
2471
|
+
obj._check_if_saved = true if options[:check_if_saved]
|
2469
2472
|
h.each do |key, val|
|
2470
2473
|
el = self.elements[key.to_sym]
|
2471
2474
|
next unless el
|
2472
2475
|
if el.multiple? && val
|
2473
2476
|
qs = obj.get(el)
|
2474
2477
|
val.each do |v|
|
2475
|
-
v = el.model.from_hash_dump(v) if v.is_a?(Hash)
|
2478
|
+
v = el.model.from_hash_dump(v, options) if v.is_a?(Hash)
|
2476
2479
|
qs << v
|
2477
2480
|
end
|
2478
2481
|
else
|
2479
|
-
val = el.model.from_hash_dump(val) if val.is_a?(Hash)
|
2480
|
-
|
2482
|
+
val = el.model.from_hash_dump(val, options) if val.is_a?(Hash)
|
2483
|
+
case el.type.name.to_sym
|
2484
|
+
when :Date, :DateTime
|
2485
|
+
val = el.type.parse(val) unless val.blank?
|
2486
|
+
end
|
2487
|
+
begin
|
2488
|
+
obj.set(el, val)
|
2489
|
+
rescue # FIXME: should be and option
|
2490
|
+
end
|
2481
2491
|
end
|
2482
2492
|
end
|
2483
2493
|
obj
|
@@ -134,7 +134,7 @@ module Spider; module Model; module Mappers
|
|
134
134
|
return nil unless save[:values].length > 0
|
135
135
|
condition = Condition.and
|
136
136
|
@model.primary_keys.each do |key|
|
137
|
-
condition[key.name] =
|
137
|
+
condition[key.name] = obj.get(key)
|
138
138
|
end
|
139
139
|
preprocess_condition(condition)
|
140
140
|
save[:condition], save[:joins] = prepare_condition(condition)
|
@@ -310,7 +310,7 @@ module Spider; module Model; module Mappers
|
|
310
310
|
keys = []
|
311
311
|
primary_keys = []
|
312
312
|
types = {}
|
313
|
-
if (query.limit && query.order.empty?)
|
313
|
+
if (query.limit && query.order.empty? && !query.only_one?)
|
314
314
|
@model.primary_keys.each do |key|
|
315
315
|
elements << key.name unless elements.include?(key.name)
|
316
316
|
query.order_by(key.name, :asc)
|
@@ -164,7 +164,7 @@ module Spider; module Model
|
|
164
164
|
@model.extended_models.each do |m, el|
|
165
165
|
sub = obj.get(el)
|
166
166
|
done_extended << el
|
167
|
-
if mode == :update || sub.class.auto_primary_keys?
|
167
|
+
if mode == :update || sub.class.auto_primary_keys? || sub._check_if_saved
|
168
168
|
sub.save if (obj.element_modified?(el) || !obj.primary_keys_set?) && sub.mapper.class.write?
|
169
169
|
else
|
170
170
|
sub.insert unless sub.in_storage?
|
@@ -222,7 +222,12 @@ module Spider; module Model
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
end
|
225
|
-
save_mode =
|
225
|
+
save_mode = nil
|
226
|
+
if obj.class.auto_primary_keys? && !obj._check_if_saved
|
227
|
+
save_mode = (!is_insert && obj.primary_keys_set?) ? :update : :insert
|
228
|
+
else
|
229
|
+
save_mode = obj.in_storage? ? :update : :insert
|
230
|
+
end
|
226
231
|
before_save(obj, save_mode)
|
227
232
|
# @model.elements_array.select{ |el| el.attributes[:integrated_model] }.each do |el|
|
228
233
|
# obj.get(el).save if obj.element_modified?(el)
|
data/lib/spiderfw/model/query.rb
CHANGED
@@ -123,6 +123,16 @@ module Spider; module Model
|
|
123
123
|
def first
|
124
124
|
self.limit = 1
|
125
125
|
end
|
126
|
+
|
127
|
+
def only_one
|
128
|
+
self.limit = 1
|
129
|
+
@only_one = true
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
def only_one?
|
134
|
+
@only_one
|
135
|
+
end
|
126
136
|
|
127
137
|
def page(page, rows)
|
128
138
|
page = page.to_i
|
@@ -159,4 +169,4 @@ module Spider; module Model
|
|
159
169
|
|
160
170
|
|
161
171
|
|
162
|
-
end; end
|
172
|
+
end; end
|
@@ -75,6 +75,66 @@ module Spider
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
def self.update(specs, home_path, options)
|
80
|
+
options[:use_git] = true unless options[:use_git] == false
|
81
|
+
specs = [specs] unless specs.is_a?(Array)
|
82
|
+
pre_setup(specs, options)
|
83
|
+
specs.each do |spec|
|
84
|
+
if spec.git_repo && options[:use_git]
|
85
|
+
git_update(spec, home_path)
|
86
|
+
else
|
87
|
+
pack_update(spec, home_path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.git_update(spec, home_path)
|
93
|
+
require 'grit'
|
94
|
+
home_repo = Grit::Repo.new(home_path)
|
95
|
+
app_path = File.join(home_path, "apps/#{spec.id}")
|
96
|
+
app_repo = Grit::Repo.new(app_path)
|
97
|
+
puts _("Updating %s from %s") % [spec.app_id, spec.git_repo]
|
98
|
+
Dir.chdir(app_path) do
|
99
|
+
app_repo.git.checkout({}, "master")
|
100
|
+
end
|
101
|
+
cmd = "#{Grit::Git.git_binary} --git-dir='#{app_path}/.git' pull"
|
102
|
+
response = err = nil
|
103
|
+
Dir.chdir(app_path) do
|
104
|
+
response, err = app_repo.git.wild_sh(cmd)
|
105
|
+
end
|
106
|
+
if response =~ /Aborting/
|
107
|
+
puts err
|
108
|
+
return
|
109
|
+
end
|
110
|
+
Dir.chdir(app_path) do
|
111
|
+
app_repo.git.reset({:hard => true}, 'HEAD')
|
112
|
+
app_repo.git.checkout
|
113
|
+
end
|
114
|
+
|
115
|
+
home_repo.add("apps/#{spec.id}")
|
116
|
+
home_repo.commit_index(_("Updated app %s") % spec.id)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.pack_update(spec, home_path)
|
120
|
+
require 'fileutils'
|
121
|
+
require 'date'
|
122
|
+
require 'time'
|
123
|
+
app_path = File.join(home_path, "apps/#{spec.id}")
|
124
|
+
tmp_path = File.join(home_path, 'tmp')
|
125
|
+
FileUtils.mkdir_p(tmp_path)
|
126
|
+
tmp_app_path = File.join(tmp_path, "#{spec.id}-update-#{DateTime.now}")
|
127
|
+
FileUtils.mv(app_path, tmp_app_path)
|
128
|
+
begin
|
129
|
+
pack_install(spec, home_path)
|
130
|
+
FileUtils.rmdir(tmp_app_path)
|
131
|
+
rescue
|
132
|
+
puts _("Update of %s failed" % spec.id)
|
133
|
+
FileUtils.mv(tmp_app_path, app_path)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
78
138
|
|
79
139
|
end
|
80
140
|
|
@@ -62,7 +62,7 @@ module Spider; module TemplateBlocks
|
|
62
62
|
end
|
63
63
|
html.gsub!("'", "\\\\'")
|
64
64
|
init += "add_widget('#{id}', #{klass}.new(@request, @response), {#{init_params.join(', ')}}, '#{html}', #{t_param})\n"
|
65
|
-
c = "yield
|
65
|
+
c = "yield :\"#{id}\"\n"
|
66
66
|
return CompiledBlock.new(init, c)
|
67
67
|
end
|
68
68
|
|
@@ -181,7 +181,7 @@ module Annotations
|
|
181
181
|
|
182
182
|
# Searches for a defined annotation in class and ancestors.
|
183
183
|
def find_defined_annotation(name)
|
184
|
-
return nil if self.class == Module
|
184
|
+
return nil if self.class == Module && !@defined_annotations
|
185
185
|
k = self
|
186
186
|
while (k != Object)
|
187
187
|
return nil unless k < Annotations
|
@@ -263,6 +263,7 @@ module Spider
|
|
263
263
|
@widgets_runtime_content = {}
|
264
264
|
@widget_procs = {}
|
265
265
|
@runtime_overrides = []
|
266
|
+
@_plugins = []
|
266
267
|
end
|
267
268
|
|
268
269
|
def full_id
|
@@ -308,8 +309,8 @@ module Spider
|
|
308
309
|
widget_init(action)
|
309
310
|
return unless active?
|
310
311
|
#Spider.logger.debug("Preparing widget #{self}")
|
311
|
-
prepare
|
312
312
|
prepare_scene(@scene)
|
313
|
+
prepare
|
313
314
|
@before_done = true
|
314
315
|
end
|
315
316
|
|
@@ -776,9 +777,19 @@ module Spider
|
|
776
777
|
mod = self.class.plugin(name)
|
777
778
|
return unless mod
|
778
779
|
self.extend(mod)
|
780
|
+
@_plugins << mod
|
779
781
|
@runtime_overrides << [name, mod.get_overrides, mod.overrides_path]
|
780
782
|
end
|
781
783
|
|
784
|
+
def controller_action?(method)
|
785
|
+
r = super
|
786
|
+
return r if r
|
787
|
+
@_plugins.each do |pl|
|
788
|
+
return r if r = pl.controller_action?(method)
|
789
|
+
end
|
790
|
+
return false
|
791
|
+
end
|
792
|
+
|
782
793
|
end
|
783
794
|
|
784
795
|
module WidgetScene
|
@@ -5,10 +5,12 @@ module Spider
|
|
5
5
|
def self.included(mod)
|
6
6
|
mod.extend(ModuleMethods)
|
7
7
|
mod.module_eval{ include Annotations }
|
8
|
+
Spider::ControllerMixins::Visual.define_format_annotations(mod)
|
9
|
+
mod.extend(Spider::ControllerMixins::Visual::OutputFormatMethods)
|
8
10
|
end
|
9
11
|
|
10
12
|
module ModuleMethods
|
11
|
-
|
13
|
+
|
12
14
|
def plugin_name
|
13
15
|
@plugin_name
|
14
16
|
end
|
@@ -41,6 +43,18 @@ module Spider
|
|
41
43
|
}
|
42
44
|
end
|
43
45
|
|
46
|
+
def controller_actions(*methods)
|
47
|
+
if (methods.length > 0)
|
48
|
+
@controller_actions ||= []
|
49
|
+
@controller_actions += methods
|
50
|
+
end
|
51
|
+
@controller_actions
|
52
|
+
end
|
53
|
+
|
54
|
+
def controller_action?(method)
|
55
|
+
@controller_actions && @controller_actions.include?(method)
|
56
|
+
end
|
57
|
+
|
44
58
|
end
|
45
59
|
|
46
60
|
end
|
data/lib/spiderfw.rb
CHANGED
@@ -3,6 +3,7 @@ require 'spiderfw/env'
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'find'
|
5
5
|
require 'fileutils'
|
6
|
+
require 'pathname'
|
6
7
|
require 'spiderfw/autoload'
|
7
8
|
require 'spiderfw/requires'
|
8
9
|
|
@@ -61,12 +62,13 @@ module Spider
|
|
61
62
|
setup_paths(@root)
|
62
63
|
all_apps = find_all_apps
|
63
64
|
all_apps.each do |path|
|
64
|
-
|
65
|
+
opts = File.join(path, 'config/options.rb')
|
66
|
+
require opts if File.exist?(opts)
|
65
67
|
end
|
66
68
|
@runmode = nil
|
67
69
|
self.runmode = $SPIDER_RUNMODE if $SPIDER_RUNMODE
|
68
|
-
load_configuration($SPIDER_PATH
|
69
|
-
load_configuration(@root
|
70
|
+
load_configuration File.join($SPIDER_PATH, 'config')
|
71
|
+
load_configuration File.join(@root, 'config')
|
70
72
|
start_loggers
|
71
73
|
# @controller = Controller
|
72
74
|
@paths[:spider] = $SPIDER_PATH
|
@@ -74,8 +76,9 @@ module Spider
|
|
74
76
|
if ($SPIDER_CONFIG_SETS)
|
75
77
|
$SPIDER_CONFIG_SETS.each{ |set| @configuration.include_set(set) }
|
76
78
|
end
|
77
|
-
|
78
|
-
|
79
|
+
init_file = File.join($SPIDER_RUN_PATH, 'init.rb')
|
80
|
+
if File.exist?(init_file)
|
81
|
+
@home.instance_eval(File.read(init_file), init_file)
|
79
82
|
end
|
80
83
|
@logger.close(STDERR)
|
81
84
|
@logger.open(STDERR, Spider.conf.get('debug.console.level')) if Spider.conf.get('debug.console.level')
|
@@ -85,15 +88,6 @@ module Spider
|
|
85
88
|
mod.app_init if mod.respond_to?(:app_init)
|
86
89
|
end
|
87
90
|
@init_done=true
|
88
|
-
# routes_file = "#{@paths[:config]}/routes.rb"
|
89
|
-
# if (File.exist?(routes_file))
|
90
|
-
# load(routes_file)
|
91
|
-
# end
|
92
|
-
# else
|
93
|
-
# @apps.each do |name, app|
|
94
|
-
# @controller.route('/'+app.name.gsub('::', '/'), app.controller, :ignore_case => true)
|
95
|
-
# end
|
96
|
-
# end
|
97
91
|
end
|
98
92
|
|
99
93
|
#
|
@@ -106,7 +100,7 @@ module Spider
|
|
106
100
|
|
107
101
|
# Invoked before a server is started. Apps may implement the app_startup method, that will be called.
|
108
102
|
def startup
|
109
|
-
unless File.exists?(Spider.paths[:root]
|
103
|
+
unless File.exists?(File.join(Spider.paths[:root], 'init.rb'))
|
110
104
|
raise "The server must be started from the root directory"
|
111
105
|
end
|
112
106
|
if (Spider.conf.get('template.cache.reload_on_restart'))
|
@@ -181,9 +175,9 @@ module Spider
|
|
181
175
|
@logger.error("Unable to create log folder")
|
182
176
|
end
|
183
177
|
if (File.exist?(@paths[:log]))
|
184
|
-
@logger.open(@paths[:log]
|
178
|
+
@logger.open(File.join(@paths[:log], 'error.log'), :ERROR) if Spider.conf.get('log.errors')
|
185
179
|
if (Spider.conf.get('log.debug.level'))
|
186
|
-
@logger.open(@paths[:log]
|
180
|
+
@logger.open(File.join(@paths[:log], 'debug.log'), Spider.conf.get('log.debug.level'))
|
187
181
|
end
|
188
182
|
end
|
189
183
|
$LOG = @logger
|
@@ -192,23 +186,23 @@ module Spider
|
|
192
186
|
# Sets the default paths (see #paths).
|
193
187
|
def setup_paths(root)
|
194
188
|
@paths[:root] = root
|
195
|
-
@paths[:apps] = root
|
196
|
-
@paths[:core_apps] = $SPIDER_PATH
|
197
|
-
@paths[:config] = root
|
198
|
-
@paths[:layouts] = root
|
199
|
-
@paths[:var] = root
|
200
|
-
@paths[:certs] = @paths[:config]
|
201
|
-
@paths[:tmp] = root
|
202
|
-
@paths[:data] = root
|
203
|
-
@paths[:log] = @paths[:var]
|
189
|
+
@paths[:apps] = File.join(root, 'apps')
|
190
|
+
@paths[:core_apps] = File.join($SPIDER_PATH, 'apps')
|
191
|
+
@paths[:config] = File.join(root, 'config')
|
192
|
+
@paths[:layouts] = File.join(root, 'layouts')
|
193
|
+
@paths[:var] = File.join(root, 'var')
|
194
|
+
@paths[:certs] = File.join(@paths[:config], 'certs')
|
195
|
+
@paths[:tmp] = File.join(root, 'tmp')
|
196
|
+
@paths[:data] = File.join(root, 'data')
|
197
|
+
@paths[:log] = File.join(@paths[:var], 'log')
|
204
198
|
end
|
205
199
|
|
206
200
|
# Finds an app by name, looking in paths[:apps] and paths[:core_apps]. Returns the found path.
|
207
201
|
def find_app(name)
|
208
202
|
path = nil
|
209
203
|
[@paths[:apps], @paths[:core_apps]].each do |base|
|
210
|
-
test = base
|
211
|
-
if
|
204
|
+
test = File.join(base, name)
|
205
|
+
if File.exist?(File.join(test, '_init.rb'))
|
212
206
|
path = test
|
213
207
|
break
|
214
208
|
end
|
@@ -218,8 +212,8 @@ module Spider
|
|
218
212
|
|
219
213
|
def find_apps(name)
|
220
214
|
[@paths[:apps], @paths[:core_apps]].each do |base|
|
221
|
-
test = base
|
222
|
-
if
|
215
|
+
test = File.join(base, name)
|
216
|
+
if File.exist?(test)
|
223
217
|
return find_apps_in_folder(test)
|
224
218
|
end
|
225
219
|
end
|
@@ -234,16 +228,17 @@ module Spider
|
|
234
228
|
|
235
229
|
def load_app_at_path(path)
|
236
230
|
return if @loaded_apps[path]
|
231
|
+
relative_path = path
|
232
|
+
if path.index(Spider.paths[:root])
|
233
|
+
home = Pathname.new(Spider.paths[:root])
|
234
|
+
pname = Pathname.new(path)
|
235
|
+
relative_path = pname.relative_path_from(home).to_s
|
236
|
+
end
|
237
237
|
@loaded_apps[path] = true
|
238
|
-
last_name =
|
238
|
+
last_name = File.basename(path)
|
239
239
|
app_files = ['_init.rb', last_name+'.rb', 'cmd.rb']
|
240
|
-
app_files.each{ |f| require
|
241
|
-
|
242
|
-
# ENV['GETTEXT_PATH'] += ',' if ENV['GETTEXT_PATH']
|
243
|
-
# ENV['GETTEXT_PATH'] += "#{path}/data/locale"
|
244
|
-
# end
|
245
|
-
# GETTEXT_PATH is broken at the moment in gettext 2.1.0
|
246
|
-
GetText::LocalePath.add_default_rule("#{path}/data/locale/%{lang}/LC_MESSAGES/%{name}.mo")
|
240
|
+
app_files.each{ |f| require File.join(relative_path, f) if File.exist?(File.join(path, f)) }
|
241
|
+
GetText::LocalePath.add_default_rule(File.join(path, "data/locale/%{lang}/LC_MESSAGES/%{name}.mo"))
|
247
242
|
end
|
248
243
|
|
249
244
|
def load_apps(*l)
|
@@ -264,7 +259,7 @@ module Spider
|
|
264
259
|
if (File.basename(path) == '_init.rb')
|
265
260
|
app_paths << File.dirname(path)
|
266
261
|
Find.prune
|
267
|
-
elsif
|
262
|
+
elsif File.exist?(File.join(path, '_init.rb'))
|
268
263
|
app_paths << path
|
269
264
|
Find.prune
|
270
265
|
end
|
@@ -273,16 +268,16 @@ module Spider
|
|
273
268
|
end
|
274
269
|
|
275
270
|
def find_apps_in_folder(path)
|
276
|
-
path += '/' unless path[-1].chr == '/'
|
277
271
|
return unless File.directory?(path)
|
278
|
-
return [path] if File.exist?(path
|
272
|
+
return [path] if File.exist?(File.join(path, '_init.rb'))
|
279
273
|
found = []
|
280
274
|
Dir.new(path).each do |f|
|
281
275
|
next if f[0].chr == '.'
|
282
|
-
|
283
|
-
|
276
|
+
found_path = File.join(path, f)
|
277
|
+
if File.exist?(File.join(found_path, '/_init.rb'))
|
278
|
+
found << found_path
|
284
279
|
else
|
285
|
-
found += find_apps_in_folder(
|
280
|
+
found += find_apps_in_folder(found_path)
|
286
281
|
end
|
287
282
|
end
|
288
283
|
return found
|
@@ -302,8 +297,8 @@ module Spider
|
|
302
297
|
|
303
298
|
def load_configuration(path)
|
304
299
|
return unless File.directory?(path)
|
305
|
-
path
|
306
|
-
require
|
300
|
+
opts = File.join(path, 'options.rb')
|
301
|
+
require opts if File.exist?(opts)
|
307
302
|
Dir.new(path).each do |f|
|
308
303
|
f.untaint # FIXME: security parse
|
309
304
|
case f
|
@@ -311,7 +306,7 @@ module Spider
|
|
311
306
|
next
|
312
307
|
when /\.(yaml|yml)$/
|
313
308
|
begin
|
314
|
-
@configuration.load_yaml(path
|
309
|
+
@configuration.load_yaml(File.join(path, f))
|
315
310
|
rescue ConfigurationException => exc
|
316
311
|
if (exc.type == :yaml)
|
317
312
|
@logger.error("Configuration file #{path+f} is not valid YAML")
|
@@ -320,7 +315,6 @@ module Spider
|
|
320
315
|
end
|
321
316
|
end
|
322
317
|
end
|
323
|
-
#load(package_path+'/config/'+f)
|
324
318
|
end
|
325
319
|
end
|
326
320
|
|
@@ -440,6 +434,7 @@ module Spider
|
|
440
434
|
end
|
441
435
|
search_locations.each do |p|
|
442
436
|
found = first_found(extensions, p[0]+'/'+path)
|
437
|
+
next if found == cur_path
|
443
438
|
definer = path_app || p[1]
|
444
439
|
return Resource.new(found, definer) if found
|
445
440
|
end
|
@@ -488,7 +483,7 @@ module Spider
|
|
488
483
|
base = p[0]
|
489
484
|
base = File.join(base, start) if start
|
490
485
|
extensions.each do |ext|
|
491
|
-
Dir.glob("
|
486
|
+
Dir.glob(File.join(base, "*.#{ext}")).each do |f|
|
492
487
|
res << (Pathname.new(f).relative_path_from(pname)).to_s
|
493
488
|
end
|
494
489
|
end
|
@@ -514,7 +509,7 @@ module Spider
|
|
514
509
|
loaded.push(file)
|
515
510
|
else
|
516
511
|
$:.each do |dir|
|
517
|
-
file_path = dir
|
512
|
+
file_path = File.join(dir, file)
|
518
513
|
if (file_path =~ /^#{path}/) # FileTest.exists?(file_path) &&
|
519
514
|
loaded.push(file_path)
|
520
515
|
end
|
@@ -553,7 +548,7 @@ module Spider
|
|
553
548
|
init_debug
|
554
549
|
end
|
555
550
|
if (mode != 'production')
|
556
|
-
Spider.paths[:var]
|
551
|
+
Spider.paths[:var] = File.join(Spider.paths[:var], mode)
|
557
552
|
end
|
558
553
|
end
|
559
554
|
|
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: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 16
|
10
|
+
version: 0.5.16
|
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: 2010-
|
18
|
+
date: 2010-12-07 00:00:00 +01:00
|
19
19
|
default_executable: spider
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- apps/core/auth/views/login.shtml
|
280
280
|
- apps/core/components/_init.rb
|
281
281
|
- apps/core/components/assets.rb
|
282
|
+
- apps/core/components/data/locale/it/LC_MESSAGES/spider_components.mo
|
282
283
|
- apps/core/components/po/it/spider_components.po
|
283
284
|
- apps/core/components/po/spider_components.pot
|
284
285
|
- apps/core/components/public/css/admin.css
|
@@ -557,6 +558,7 @@ files:
|
|
557
558
|
- apps/core/components/widgets/tabs/tabs.rb
|
558
559
|
- apps/core/components/widgets/tabs/tabs.shtml
|
559
560
|
- apps/core/forms/_init.rb
|
561
|
+
- apps/core/forms/data/locale/it/LC_MESSAGES/spider_forms.mo
|
560
562
|
- apps/core/forms/po/it/spider_forms.po
|
561
563
|
- apps/core/forms/po/spider_forms.pot
|
562
564
|
- apps/core/forms/public/ckeditor/adapters/jquery.js
|
@@ -803,6 +805,7 @@ files:
|
|
803
805
|
- apps/master/plugins/resources/mysql/mysql.rb
|
804
806
|
- apps/master/plugins/site_types/spider/spider.rb
|
805
807
|
- apps/master/po/it/spider_master.po
|
808
|
+
- apps/master/po/master.pot
|
806
809
|
- apps/master/po/spider_master.pot
|
807
810
|
- apps/master/public/css/img/web.png
|
808
811
|
- apps/master/public/css/login.css
|
@@ -835,6 +838,7 @@ files:
|
|
835
838
|
- apps/messenger/config/worker/queue.rb
|
836
839
|
- apps/messenger/controllers/messenger_controller.rb
|
837
840
|
- apps/messenger/controllers/mixins/messenger_helper.rb
|
841
|
+
- apps/messenger/data/locale/it/LC_MESSAGES/spider_messenger.mo
|
838
842
|
- apps/messenger/lib/email_backend.rb
|
839
843
|
- apps/messenger/lib/sms_backend.rb
|
840
844
|
- apps/messenger/messenger.rb
|