spiderfw 0.6.16 → 0.6.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/Rakefile +8 -5
- 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 +3 -3
- data/apps/core/auth/po/spider_auth.pot +3 -3
- data/apps/core/components/data/locale/it/LC_MESSAGES/spider_components.mo +0 -0
- data/apps/core/components/po/it/spider_components.po +7 -7
- data/apps/core/components/po/spider_components.pot +7 -7
- data/apps/core/components/public/js/spider.js +4 -2
- data/apps/core/forms/data/locale/it/LC_MESSAGES/spider_forms.mo +0 -0
- data/apps/core/forms/po/it/spider_forms.po +2 -2
- data/apps/core/forms/po/spider_forms.pot +2 -2
- data/apps/core/forms/widgets/form/form.rb +20 -6
- data/apps/master/_init.rb +0 -1
- data/apps/master/data/locale/it/LC_MESSAGES/master.mo +0 -0
- data/apps/master/master.rb +4 -0
- data/apps/master/po/it/master.po +62 -25
- data/apps/master/po/master.pot +45 -20
- data/apps/messenger/_init.rb +2 -21
- data/apps/messenger/backends/sms/test.rb +25 -0
- data/apps/messenger/config/test.config.yml +6 -1
- data/apps/messenger/controllers/mixins/messenger_helper.rb +30 -5
- data/apps/messenger/data/locale/it/LC_MESSAGES/spider_messenger.mo +0 -0
- data/apps/messenger/messenger.rb +40 -2
- data/apps/servant/lib/commands_processor.rb +1 -1
- data/apps/worker/worker.rb +15 -10
- data/data/locale/it/LC_MESSAGES/spider.mo +0 -0
- data/lib/spiderfw/app.rb +3 -3
- data/lib/spiderfw/cache/template_cache.rb +4 -0
- data/lib/spiderfw/cmd/cmd.rb +0 -2
- data/lib/spiderfw/cmd/commands/app.rb +89 -6
- data/lib/spiderfw/cmd/commands/setup.rb +13 -40
- data/lib/spiderfw/config/configuration.rb +1 -0
- data/lib/spiderfw/config/options/spider.rb +9 -8
- data/lib/spiderfw/controller/mixins/http_mixin.rb +9 -0
- data/lib/spiderfw/env.rb +3 -1
- data/lib/spiderfw/i18n/cldr.rb +39 -13
- data/lib/spiderfw/i18n/i18n.rb +9 -0
- data/lib/spiderfw/i18n/javascript_parser.rb +1 -1
- data/lib/spiderfw/i18n/shtml_parser.rb +1 -1
- data/lib/spiderfw/model/base_model.rb +1 -1
- data/lib/spiderfw/model/inline_model.rb +13 -1
- data/lib/spiderfw/model/mappers/db_mapper.rb +5 -0
- data/lib/spiderfw/model/mappers/mapper.rb +9 -4
- data/lib/spiderfw/model/migrations/drop_element.rb +26 -0
- data/lib/spiderfw/model/migrations/irreversible_migration.rb +9 -0
- data/lib/spiderfw/model/migrations/migration.rb +7 -0
- data/lib/spiderfw/model/migrations/replace.rb +32 -0
- data/lib/spiderfw/model/migrations.rb +21 -0
- data/lib/spiderfw/model/model.rb +4 -1
- data/lib/spiderfw/model/storage/db/db_storage.rb +1 -1
- data/lib/spiderfw/setup/app_manager.rb +281 -200
- data/lib/spiderfw/setup/setup_task.rb +80 -35
- data/lib/spiderfw/spider.rb +28 -13
- data/lib/spiderfw/templates/layout.rb +40 -8
- data/lib/spiderfw/templates/resources/sass.rb +21 -0
- data/lib/spiderfw/test.rb +1 -1
- data/lib/spiderfw/utils/events/event_source.rb +1 -2
- data/lib/spiderfw/utils/gems.rb +5 -1
- metadata +11 -4
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'apps/messenger/lib/sms_backend'
|
2
|
+
|
3
|
+
module Spider; module Messenger; module Backends; module SMS
|
4
|
+
|
5
|
+
module Test
|
6
|
+
include Messenger::SMSBackend
|
7
|
+
|
8
|
+
def self.sent_sms
|
9
|
+
@sent_sms ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.after_test
|
13
|
+
@sent_sms = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.send_message(msg)
|
17
|
+
Spider.logger.debug("Sending SMS #{msg.ticket}")
|
18
|
+
self.sent_sms << msg
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end; end; end; end
|
@@ -22,9 +22,14 @@ module Spider; module Messenger
|
|
22
22
|
klass ||= self.class.app if self.class.respond_to?(:app)
|
23
23
|
klass ||= Spider.home
|
24
24
|
msg = Spider::Messenger::MessengerHelper.send_email(klass, template, scene, from, to, headers, attachments, params)
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
sent_email(msg.ticket)
|
26
|
+
msg.ticket
|
27
|
+
end
|
28
|
+
|
29
|
+
def send_sms(to, text, params={})
|
30
|
+
msg = Spider::Messenger.sms(to, text, params)
|
31
|
+
sent_sms(msg.ticket)
|
32
|
+
msg.ticket
|
28
33
|
end
|
29
34
|
|
30
35
|
def self.send_email(klass, template, scene, from, to, headers={}, attachments=[], params={})
|
@@ -75,10 +80,30 @@ module Spider; module Messenger
|
|
75
80
|
Messenger.email(from, to, mail_headers, mail_body, params)
|
76
81
|
end
|
77
82
|
|
83
|
+
def sent_email(ticket)
|
84
|
+
sent_message(ticket, :email)
|
85
|
+
end
|
86
|
+
|
87
|
+
def sent_sms(ticket)
|
88
|
+
sent_message(ticket, :sms)
|
89
|
+
end
|
90
|
+
|
91
|
+
def sent_message(ticket, type)
|
92
|
+
return unless ticket
|
93
|
+
type = type.to_sym
|
94
|
+
@messenger_sent = Spider::Request.current[:messenger_sent]
|
95
|
+
@messenger_sent ||= {}
|
96
|
+
@messenger_sent[type] ||= []
|
97
|
+
@messenger_sent[type] << ticket
|
98
|
+
Spider::Request.current[:messenger_sent] = @messenger_sent
|
99
|
+
end
|
100
|
+
|
78
101
|
def after(action='', *params)
|
102
|
+
@messenger_sent = Spider::Request.current[:messenger_sent]
|
79
103
|
return super unless Spider.conf.get('messenger.send_immediate') && @messenger_sent
|
80
|
-
|
81
|
-
|
104
|
+
@messenger_sent.each do |type, msgs|
|
105
|
+
Spider::Messenger.process_queue(type, msgs)
|
106
|
+
end
|
82
107
|
end
|
83
108
|
|
84
109
|
end
|
Binary file
|
data/apps/messenger/messenger.rb
CHANGED
@@ -3,11 +3,32 @@ require 'fileutils'
|
|
3
3
|
module Spider
|
4
4
|
|
5
5
|
module Messenger
|
6
|
+
|
7
|
+
def self.app_init
|
8
|
+
available_backends = {}
|
9
|
+
base = File.join(Spider::Messenger.path, 'backends')
|
10
|
+
Dir.new(base).each do |type|
|
11
|
+
next if type[0].chr == '.'
|
12
|
+
type_dir = File.join(base, type)
|
13
|
+
next unless File.directory?(type_dir)
|
14
|
+
available_backends[type.to_sym] = []
|
15
|
+
Dir.new(type_dir).each do |bcknd|
|
16
|
+
next if bcknd[0].chr == '.'
|
17
|
+
name = File.basename(bcknd, '.rb')
|
18
|
+
available_backends[type.to_sym] << name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
available_backends.each do |type, backends|
|
22
|
+
Spider.config_option("messenger.#{type}.backends")[:params][:choices] = backends
|
23
|
+
Spider.config_option("messenger.#{type}.backend")[:params][:choices] = backends
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
6
27
|
|
7
28
|
def self.queues
|
8
29
|
{
|
9
|
-
:email => { :label => _("Email"), :model => :Email }
|
10
|
-
|
30
|
+
:email => { :label => _("Email"), :model => :Email },
|
31
|
+
:sms => { :label => _("SMS"), :model => :SMS }
|
11
32
|
}
|
12
33
|
end
|
13
34
|
|
@@ -117,6 +138,23 @@ module Spider
|
|
117
138
|
msg.save
|
118
139
|
return msg
|
119
140
|
end
|
141
|
+
|
142
|
+
|
143
|
+
def self.after_test
|
144
|
+
self.backends.each do |queue, mods|
|
145
|
+
mods.each do |mod|
|
146
|
+
mod.after_test if mod.respond_to?(:after_test)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.before_test
|
152
|
+
self.backends.each do |queue, mods|
|
153
|
+
mods.each do |mod|
|
154
|
+
mod.after_test if mod.respond_to?(:after_test)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
120
158
|
|
121
159
|
|
122
160
|
end
|
data/apps/worker/worker.rb
CHANGED
@@ -6,14 +6,19 @@ require 'apps/worker/models/job'
|
|
6
6
|
module Spider
|
7
7
|
|
8
8
|
module Worker
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
@options = {}
|
10
|
+
|
11
|
+
def self.app_init
|
12
|
+
@pid_file = Spider.paths[:var]+'/run/worker.pid'
|
13
|
+
@script_file = Spider.paths[:config]+'/worker.rb'
|
14
|
+
@scripts_dir = Spider.paths[:config]+'/worker'
|
15
|
+
@mutex = Mutex.new
|
16
|
+
@options = {
|
17
|
+
:fork => Spider.conf.get('worker.fork'),
|
18
|
+
:detach => Spider.conf.get('worker.detach')
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
17
22
|
|
18
23
|
def self.pid_file
|
19
24
|
@pid_file
|
@@ -146,10 +151,10 @@ module Spider
|
|
146
151
|
return job.uuid
|
147
152
|
end
|
148
153
|
|
149
|
-
def self.cron(time, params, &proc)
|
154
|
+
def self.cron(time, params=nil, &proc)
|
150
155
|
raise "The cron method must be used only in worker init scripts" unless @runner
|
151
156
|
check_params(params) if params
|
152
|
-
@runner.cron(time, params)
|
157
|
+
@runner.cron(time, params, &proc)
|
153
158
|
end
|
154
159
|
|
155
160
|
def self.every(time, params=nil, &proc)
|
Binary file
|
data/lib/spiderfw/app.rb
CHANGED
@@ -58,7 +58,7 @@ module Spider
|
|
58
58
|
if u = Spider.conf.get("#{@dotted_name}.http_url")
|
59
59
|
if action
|
60
60
|
u += '/' if u[-1].chr != '/'
|
61
|
-
u += action
|
61
|
+
u += action.to_s
|
62
62
|
end
|
63
63
|
return u
|
64
64
|
end
|
@@ -167,10 +167,10 @@ module Spider
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def relative_path
|
170
|
-
if
|
170
|
+
if Spider.paths[:apps] && @path.index(Spider.paths[:apps]) == 0
|
171
171
|
return @path[Spider.paths[:apps].length+1..-1]
|
172
172
|
else
|
173
|
-
return @path[
|
173
|
+
return @path[$SPIDER_PATHS[:core_apps].length+1..-1]
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
data/lib/spiderfw/cmd/cmd.rb
CHANGED
@@ -32,11 +32,9 @@ module Spider; module CommandLine
|
|
32
32
|
}
|
33
33
|
opt.on("--devel", _("Set runmode to devel"), "-d") do
|
34
34
|
$SPIDER_RUNMODE = 'devel'
|
35
|
-
Spider.runmode = 'devel' if Spider && Spider.respond_to?(:runmode=)
|
36
35
|
end
|
37
36
|
opt.on("--test", _("Set runmode to test")) do
|
38
37
|
$SPIDER_RUNMODE = 'test'
|
39
|
-
Spider.runmode = 'test' if Spider && Spider.respond_to?(:runmode=)
|
40
38
|
end
|
41
39
|
opt.on("--http-proxy [PROXY]", _("Proxy server to use for http operations (http://user:pass@host:port)")){ |p|
|
42
40
|
ENV['http_proxy'] = p
|
@@ -119,23 +119,46 @@ class AppCommand < CmdParse::Command
|
|
119
119
|
opt.on("--no-activate", _("Don't activate installed apps")){ |s| @no_activate = true }
|
120
120
|
end
|
121
121
|
install.set_execution_block do |args|
|
122
|
+
$SPIDER_INTERACTIVE = true
|
122
123
|
unless File.exist?('init.rb') && File.directory?('apps')
|
123
124
|
puts _("Please execute this command from the home folder")
|
124
125
|
exit
|
125
126
|
end
|
126
127
|
require 'spiderfw/setup/app_manager'
|
127
128
|
options = {
|
128
|
-
:
|
129
|
+
:use_git => @git, :all => @all, :no_deps => @no_deps, :optional => @optional,
|
129
130
|
:no_gems => @no_gems, :no_optional_gems => @no_optional_gems, :no_activate => @no_activate
|
130
131
|
}
|
131
132
|
options[:url] = @server_url if @server_url
|
132
|
-
Spider::AppManager.
|
133
|
+
if @git && !Spider::AppManager.git_available?
|
134
|
+
puts _("git gem not available; install git gem for Git support")
|
135
|
+
exit
|
136
|
+
end
|
137
|
+
apps = args
|
138
|
+
installed = []
|
139
|
+
apps.each do |app|
|
140
|
+
installed << app if Spider::AppManager.installed?(app)
|
141
|
+
end
|
142
|
+
unless installed.empty?
|
143
|
+
puts _("%s already installed") % installed.join(', ')
|
144
|
+
end
|
145
|
+
specs = Spider::AppManager.resolve(apps, options)
|
146
|
+
iapps = specs[:install].map{ |spec| spec.app_id }
|
147
|
+
deps = iapps - apps
|
148
|
+
unless deps.empty?
|
149
|
+
puts _("The following apps will be installed as a dependency: %s") % deps.join(', ')
|
150
|
+
end
|
151
|
+
unless specs[:update].empty?
|
152
|
+
puts _("The following apps will be updated as a dependency: %s") % specs[:update].map{ |s| s.app_id }.join(', ')
|
153
|
+
end
|
154
|
+
Spider::AppManager.new.install(specs, options)
|
133
155
|
end
|
134
156
|
self.add_command(install)
|
135
157
|
|
136
158
|
activate = CmdParse::Command.new('activate', false )
|
137
159
|
activate.short_desc = _("Activate an app")
|
138
160
|
activate.set_execution_block do |args|
|
161
|
+
$SPIDER_INTERACTIVE = true
|
139
162
|
apps = args
|
140
163
|
require 'spiderfw/spider'
|
141
164
|
apps = Spider.get_app_deps(apps)
|
@@ -148,7 +171,7 @@ class AppCommand < CmdParse::Command
|
|
148
171
|
update.options = CmdParse::OptionParserWrapper.new do |opt|
|
149
172
|
opt.on("--all", _("Update all apps"), "-a"){ |a| @all = true }
|
150
173
|
opt.on("--no-git", _("Don't use git for updating apps"), "-g"){ |r| @no_git = true }
|
151
|
-
opt.on("--no-dependencies", _("Don't install other apps this one depends on"), "-d"){ |d|
|
174
|
+
opt.on("--no-dependencies", _("Don't install/update other apps this one depends on"), "-d"){ |d|
|
152
175
|
@no_deps = true
|
153
176
|
}
|
154
177
|
opt.on("--no-gems", _("Don't install ruby gems this app depends on"), "-g"){ |g| @no_gems = true }
|
@@ -156,8 +179,13 @@ class AppCommand < CmdParse::Command
|
|
156
179
|
opt.on("--no-optional-gems", _("Don't install optional gem dependencies"), "-G"){ |g|
|
157
180
|
@no_optional_gems = true
|
158
181
|
}
|
182
|
+
opt.on("--no-activate", _("Don't activate installed apps, if any")){ |s| @no_activate = true }
|
183
|
+
opt.on("--refresh", _("Update apps even if the version has not changed"), "-r"){ |r| @refresh = true }
|
184
|
+
opt.on("--no-clear-cache", _("Don't clear cache"), "-C"){ |c| @no_clear_cache = true }
|
185
|
+
opt.on("--no-restart", _("Don't restart the server after the udpate"), "-R"){ |r| @no_restart = true }
|
159
186
|
end
|
160
187
|
update.set_execution_block do |args|
|
188
|
+
$SPIDER_INTERACTIVE = true
|
161
189
|
unless File.exist?('init.rb') && File.directory?('apps')
|
162
190
|
puts _("Please execute this command from the home folder")
|
163
191
|
exit
|
@@ -165,12 +193,67 @@ class AppCommand < CmdParse::Command
|
|
165
193
|
require 'spiderfw/setup/app_manager'
|
166
194
|
options = {
|
167
195
|
:no_git => @no_git, :all => @all, :no_deps => @no_deps, :no_optional => @no_optional,
|
168
|
-
:no_gems => @no_gems, :no_optional_gems => @no_optional_gems
|
196
|
+
:no_gems => @no_gems, :no_optional_gems => @no_optional_gems, :no_activate => @no_activate,
|
197
|
+
:clear_cache => !@no_clear_cache, :restart => !@no_restart
|
169
198
|
}
|
170
199
|
options[:url] = @server_url if @server_url
|
171
|
-
|
200
|
+
apps = args
|
201
|
+
options[:refresh] = apps if @refresh
|
202
|
+
apps.each do |app|
|
203
|
+
unless Spider::AppManager.installed?(app)
|
204
|
+
puts _("App %s is not installed") % app
|
205
|
+
exit
|
206
|
+
end
|
207
|
+
end
|
208
|
+
specs = Spider::AppManager.resolve(apps, options)
|
209
|
+
unless specs[:install].empty?
|
210
|
+
puts _("The following apps will be installed as a dependency: %s") % specs[:install].map{ |s| s.app_id }.join(', ')
|
211
|
+
end
|
212
|
+
uapps = specs[:update].map{ |spec| spec.app_id }
|
213
|
+
udeps = uapps - apps
|
214
|
+
unless udeps.empty?
|
215
|
+
puts _("The following apps will be updated as a dependency: %s") % udeps.join(', ')
|
216
|
+
end
|
217
|
+
noupdate = apps - uapps
|
218
|
+
unless noupdate.empty?
|
219
|
+
puts _("Already up-to-date: %s") % noupdate.join(', ')
|
220
|
+
end
|
221
|
+
Spider::AppManager.new.install(specs, options)
|
172
222
|
end
|
173
223
|
self.add_command(update)
|
174
224
|
|
225
|
+
setup = CmdParse::Command.new( 'setup', false )
|
226
|
+
setup.short_desc = _("Setup an app")
|
227
|
+
setup.options = CmdParse::OptionParserWrapper.new do |opt|
|
228
|
+
opt.on("--from [VERSION]", _("Assume a specific version is installed"), "-f"){ |from|
|
229
|
+
@from = Gem::Version.new(from)
|
230
|
+
}
|
231
|
+
opt.on("--to [VERSION]", _("Setup to a specific version"), "-t"){ |to|
|
232
|
+
@to = Gem::Version.new(to)
|
233
|
+
}
|
234
|
+
opt.on("--version [VERSION]", _("Only run the setup script for the given version"), "-v"){ |v|
|
235
|
+
@version = Gem::Version.new(v)
|
236
|
+
}
|
237
|
+
opt.on("--all", _("Setup all active apps")){ |all|
|
238
|
+
@all = true
|
239
|
+
}
|
240
|
+
opt.on("--no-cleanup", _("Don't cleanup"), "-C"){ |no_cleanup| @no_cleanup = true }
|
241
|
+
end
|
242
|
+
|
243
|
+
setup.set_execution_block do |args|
|
244
|
+
$SPIDER_INTERACTIVE = true
|
245
|
+
require 'spiderfw/setup/app_manager'
|
246
|
+
tasks = Spider::AppManager.new.setup(name)
|
247
|
+
unless @no_cleanup
|
248
|
+
tasks.each do |t|
|
249
|
+
begin
|
250
|
+
t.do_cleanup
|
251
|
+
rescue => exc
|
252
|
+
Spider.logger.error(exc)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
175
258
|
end
|
176
|
-
end
|
259
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spiderfw/setup/setup_task'
|
2
|
-
|
3
1
|
class SetupCommand < CmdParse::Command
|
4
2
|
|
5
3
|
|
@@ -23,10 +21,13 @@ class SetupCommand < CmdParse::Command
|
|
23
21
|
opt.on("--all", _("Setup all active apps")){ |all|
|
24
22
|
@all = true
|
25
23
|
}
|
24
|
+
opt.on("--no-cleanup", _("Don't cleanup"), "-C"){ |no_cleanup| @no_cleanup = true }
|
26
25
|
end
|
27
26
|
|
28
27
|
set_execution_block do |apps|
|
29
|
-
|
28
|
+
$SPIDER_INTERACTIVE = true
|
29
|
+
require 'spiderfw/spider'
|
30
|
+
Spider.init_base
|
30
31
|
apps = Spider.apps.keys if @all
|
31
32
|
if (apps.length > 1) && (@to || @from || @version)
|
32
33
|
raise "Can't use --from, --to or --version with multiple apps"
|
@@ -38,48 +39,20 @@ class SetupCommand < CmdParse::Command
|
|
38
39
|
wizard.run
|
39
40
|
|
40
41
|
end
|
42
|
+
tasks = []
|
41
43
|
apps.each do |name|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
next unless File.exist?(path)
|
48
|
-
tasks = []
|
49
|
-
if @version
|
50
|
-
tasks = ["#{@version}.rb"]
|
51
|
-
else
|
52
|
-
tasks = Dir.entries(path).reject{ |p| p[0].chr == '.'}.sort{ |a, b|
|
53
|
-
va = Gem::Version.new(File.basename(a, '.rb'))
|
54
|
-
vb = Gem::Version.new(File.basename(b, '.rb'))
|
55
|
-
va <=> vb
|
56
|
-
}
|
57
|
-
if @from || @to
|
58
|
-
tasks.reject!{ |t|
|
59
|
-
v = Gem::Version.new(File.basename(t, '.rb'))
|
60
|
-
true if @from && v < @from
|
61
|
-
true if @to && v > @to
|
62
|
-
false
|
63
|
-
}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
done_tasks = []
|
67
|
-
Spider::Model::Managed.no_set_dates = true
|
68
|
-
tasks.each do |task|
|
69
|
-
Spider.logger.info("Running setup task #{path+'/'+task}")
|
70
|
-
t = Spider::SetupTask.load("#{path}/#{task}")
|
71
|
-
t.app = app
|
44
|
+
require 'spiderfw/setup/app_manager'
|
45
|
+
tasks += Spider::AppManager.new.setup(name)
|
46
|
+
end
|
47
|
+
unless @no_cleanup
|
48
|
+
tasks.each do |t|
|
72
49
|
begin
|
73
|
-
|
74
|
-
t.do_up
|
50
|
+
t.do_cleanup
|
75
51
|
rescue => exc
|
76
|
-
|
77
|
-
raise
|
52
|
+
Spider.logger.error(exc)
|
78
53
|
end
|
79
54
|
end
|
80
|
-
|
81
|
-
app.installed_version = app.version
|
82
|
-
end
|
55
|
+
end
|
83
56
|
end
|
84
57
|
|
85
58
|
|
@@ -30,7 +30,7 @@ module Spider
|
|
30
30
|
:default => Proc.new{ Spider.config.get('runmode') == 'devel' ? true : false }
|
31
31
|
config_option 'webserver.port', _("Port to use for the http server"), :type => Fixnum, :default => 8080
|
32
32
|
config_option 'webserver.force_threads', _("Force threading on non-threaded adapters"), :type => Spider::DataTypes::Bool,
|
33
|
-
:default => Proc.new{ RUBY_VERSION_PARTS[1] == '8' && !Object.const_defined?(:PhusionPassenger) ? true : false }
|
33
|
+
:default => Proc.new{ Spider.runmode != 'test' && RUBY_VERSION_PARTS[1] == '8' && !Object.const_defined?(:PhusionPassenger) ? true : false }
|
34
34
|
config_option 'webserver.timeout', _("Time allowed for each request (in seconds)"), :type=> Fixnum, :default => nil
|
35
35
|
config_option 'webserver.respawn_on_change', _("Restart the webserver when application code changes"), :type => Spider::Bool,
|
36
36
|
:default => Proc.new{ RUBY_PLATFORM !~ /win32|mingw32/ && Spider.config.get('runmode') == 'devel' ? true : false }
|
@@ -104,12 +104,12 @@ module Spider
|
|
104
104
|
config_option 'http.charset', _("The charset to use for http requests"), :default => 'UTF-8'
|
105
105
|
|
106
106
|
config_option 'log.console', _("Level of debug output to console"),
|
107
|
-
:default => Proc.new{ Spider.
|
107
|
+
:default => Proc.new{ Spider.runmode == 'devel' ? :DEBUG : false },
|
108
108
|
:process => lambda{ |opt| opt && opt != 'false' ? opt.to_s.upcase.to_sym : false },
|
109
109
|
:choices => [false, :DEBUG, :WARN, :INFO, :ERROR]
|
110
110
|
config_option 'log.errors', _("Log errors to errors.log file"), :type => Spider::DataTypes::Bool, :default => true
|
111
111
|
config_option 'log.level', _("Log level to use for main log file (false for no logging)"),
|
112
|
-
:default => Proc.new{ Spider.
|
112
|
+
:default => Proc.new{ Spider.runmode == 'devel' ? :DEBUG : :INFO },
|
113
113
|
:choices => [false, :DEBUG, :WARN, :INFO, :ERROR],
|
114
114
|
:process => lambda{ |opt| opt && opt != 'false' ? opt.to_s.upcase.to_sym : false }
|
115
115
|
config_option 'log.file_name', _("Name of the main log file"), :default => 'site.log'
|
@@ -159,7 +159,7 @@ module Spider
|
|
159
159
|
|
160
160
|
|
161
161
|
config_option 'errors.send_email', _("Send an e-mail to the technical administrator when errors occur"), :type => Spider::DataTypes::Bool,
|
162
|
-
:default => lambda{ Spider.
|
162
|
+
:default => lambda{ Spider.runmode == 'production' ? true : false }
|
163
163
|
|
164
164
|
config_option 'devel.trace.extended', _("Use ruby-debug to provide extended traces"), :default => lambda{
|
165
165
|
RUBY_VERSION_PARTS[1] == '8'
|
@@ -168,19 +168,20 @@ module Spider
|
|
168
168
|
config_option 'devel.trace.show_instance_variables', _("Show locals in debug traces"), :default => true
|
169
169
|
|
170
170
|
config_option 'javascript.compress', _("Compress JavaScript files"),
|
171
|
-
:default => lambda{ Spider.
|
171
|
+
:default => lambda{ Spider.runmode == 'production' ? true : false }, :type => Spider::DataTypes::Bool
|
172
172
|
config_option 'css.compress', _("Combine CSS files"),
|
173
|
-
:default => lambda{ Spider.
|
173
|
+
:default => lambda{ Spider.runmode == 'production' ? true : false }, :type => Spider::DataTypes::Bool
|
174
174
|
config_option 'css.cachebuster', _("Use cache busters for CSS urls"), :type => Symbol,
|
175
175
|
:default => :soft, :choices => [false, :soft, :hard, :hardcopy]
|
176
176
|
config_option 'assets.use_cdn', _("Use a Content Delivery Network for assets if defined"), :type => Spider::Bool,
|
177
|
-
:default => lambda{ Spider.
|
177
|
+
:default => lambda{ Spider.runmode == 'production' ? true : false }
|
178
178
|
|
179
179
|
config_option 'http_proxy', _("Proxy to use for http clients (http://user:pass@host:port)"), :type => String,
|
180
180
|
:do => lambda{ |val| ENV['http_proxy'] = val }
|
181
181
|
|
182
182
|
config_option 'resources.disable_custom', _("Disable resource overriding in home"), :type => Spider::Bool, :default => false
|
183
|
-
|
183
|
+
|
184
|
+
config_option 'migrations.window', _("Fetch window to use when migrating models"), :type => Fixnum, :default => 100
|
184
185
|
|
185
186
|
|
186
187
|
end
|
@@ -211,6 +211,15 @@ module Spider; module ControllerMixins
|
|
211
211
|
@http_auth_realm
|
212
212
|
end
|
213
213
|
|
214
|
+
|
215
|
+
def http_url(action=nil)
|
216
|
+
return nil unless Spider.site
|
217
|
+
u = "http://#{Spider.site.domain}"
|
218
|
+
u += ":#{Spider.site.port}" unless Spider.site.port == 80
|
219
|
+
u += HTTPMixin.reverse_proxy_mapping(self.url(action))
|
220
|
+
u
|
221
|
+
end
|
222
|
+
|
214
223
|
end
|
215
224
|
|
216
225
|
class HTTPStatus < RuntimeError
|
data/lib/spiderfw/env.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
RUBY_VERSION_PARTS = RUBY_VERSION.split('.')
|
2
2
|
ENV['LC_CTYPE'] = 'en_US.UTF-8'
|
3
3
|
|
4
|
-
$SPIDER_PATH
|
4
|
+
$SPIDER_PATH ||= File.expand_path(File.dirname(__FILE__)+'/../..')
|
5
|
+
$SPIDER_PATHS ||= {}
|
6
|
+
$SPIDER_PATHS[:core_apps] ||= File.join($SPIDER_PATH, 'apps')
|
5
7
|
$SPIDER_LIB = $SPIDER_PATH+'/lib'
|
6
8
|
$SPIDER_RUN_PATH ||= Dir.pwd
|
7
9
|
ENV['GETTEXT_PATH'] += ',' if (ENV['GETTEXT_PATH'])
|
data/lib/spiderfw/i18n/cldr.rb
CHANGED
@@ -13,13 +13,10 @@ module Spider; module I18n
|
|
13
13
|
|
14
14
|
end
|
15
15
|
|
16
|
-
def localize_date_time(object, format =
|
16
|
+
def localize_date_time(object, format = 'medium', options={})
|
17
17
|
options[:calendar] ||= 'gregorian'
|
18
|
-
|
19
|
-
|
20
|
-
format = @cldr.calendar.dateformat_defaults[options[:calendar]]
|
21
|
-
end
|
22
|
-
|
18
|
+
format = 'medium' if format == :default
|
19
|
+
|
23
20
|
time_format = nil
|
24
21
|
date_format = nil
|
25
22
|
format_string = nil
|
@@ -30,7 +27,7 @@ module Spider; module I18n
|
|
30
27
|
date_format = @cldr.calendar.dateformats[options[:calendar].to_sym][format.to_s].dup
|
31
28
|
end
|
32
29
|
if (date_format && time_format)
|
33
|
-
dt_f = @cldr.calendar.datetimeformats[options[:calendar].to_s]
|
30
|
+
dt_f = @cldr.calendar.datetimeformats[options[:calendar].to_sym][format.to_s]
|
34
31
|
format_string = dt_f.sub('{1}', date_format).sub('{0}', time_format)
|
35
32
|
else
|
36
33
|
format_string = date_format ? date_format : time_format
|
@@ -59,22 +56,20 @@ module Spider; module I18n
|
|
59
56
|
if (time_format)
|
60
57
|
am = @cldr.calendar.am[options[:calendar].to_s]
|
61
58
|
pm = @cldr.calendar.pm[options[:calendar].to_s]
|
62
|
-
format_string.gsub!(/%p/, object.hour < 12 ? am : pm) if object.respond_to? :hour
|
59
|
+
format_string.gsub!(/%p/, object.hour < 12 ? 'am' : 'pm') if object.respond_to? :hour
|
63
60
|
end
|
64
61
|
object.strftime(format_string)
|
65
62
|
end
|
66
63
|
|
67
64
|
# FIXME: add extended format handling like in localize
|
68
|
-
def parse_dt(string, format =
|
65
|
+
def parse_dt(string, format = 'medium', options = {})
|
66
|
+
format = 'medium' if format == :default
|
69
67
|
options[:calendar] ||= 'gregorian'
|
70
68
|
|
71
|
-
if (format == :default)
|
72
|
-
format = @cldr.calendar.dateformat_defaults[options[:calendar]]
|
73
|
-
end
|
74
69
|
time_format = @cldr.calendar.timeformats[options[:calendar].to_sym][format.to_s].dup
|
75
70
|
date_format = @cldr.calendar.dateformats[options[:calendar].to_sym][format.to_s].dup
|
76
71
|
if (options[:return] == :datetime)
|
77
|
-
dt_f = @cldr.calendar.datetimeformats[options[:calendar].to_s]
|
72
|
+
dt_f = @cldr.calendar.datetimeformats[options[:calendar].to_s][format.to_s]
|
78
73
|
format_string = dt_f.sub('{1}', date_format).sub('{0}', time_format)
|
79
74
|
klass = DateTime
|
80
75
|
elsif (options[:return] == :date)
|
@@ -166,6 +161,37 @@ module Spider; module I18n
|
|
166
161
|
separator = @cldr.number.symbol_decimal
|
167
162
|
Spider::I18n.do_parse_number(string, delimiter, separator, options)
|
168
163
|
end
|
164
|
+
|
165
|
+
def list(enumerable)
|
166
|
+
return enumerable.join(', ') unless @cldr.core.respond_to?(:list_patterns) # old cldr version
|
167
|
+
patterns = @cldr.core.list_patterns
|
168
|
+
str = ""
|
169
|
+
|
170
|
+
def sub_pattern(pattern, items)
|
171
|
+
str = pattern.clone
|
172
|
+
items.each_index do |i|
|
173
|
+
str.sub!("{#{i}}", items[i])
|
174
|
+
end
|
175
|
+
str
|
176
|
+
end
|
177
|
+
if pattern = patterns[enumerable.length.to_s]
|
178
|
+
return sub_pattern(pattern, enumerable)
|
179
|
+
end
|
180
|
+
length = enumerable.length
|
181
|
+
str = enumerable.last.to_s
|
182
|
+
(length-2).downto(0) do |i|
|
183
|
+
pattern = nil
|
184
|
+
if i == length -2
|
185
|
+
pattern = patterns['end']
|
186
|
+
elsif i == 0
|
187
|
+
pattern = patterns['start']
|
188
|
+
end
|
189
|
+
pattern ||= patterns['middle']
|
190
|
+
str = sub_pattern(pattern, [enumerable[i].to_s, str])
|
191
|
+
end
|
192
|
+
return str
|
193
|
+
|
194
|
+
end
|
169
195
|
|
170
196
|
end
|
171
197
|
|