spiderfw 0.6.23 → 0.6.24

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.
Files changed (74) hide show
  1. data/CHANGELOG +10 -1
  2. data/README.rdoc +1 -1
  3. data/VERSION +1 -1
  4. data/apps/config_editor/_init.rb +1 -2
  5. data/apps/config_editor/controllers/config_editor_controller.rb +1 -7
  6. data/apps/core/admin/controllers/admin_controller.rb +1 -1
  7. data/apps/core/admin/public/css/sass/admin.css +35 -31
  8. data/apps/core/admin/public/sass/admin.scss +6 -1
  9. data/apps/core/components/widgets/crud/crud.shtml +2 -2
  10. data/apps/core/components/widgets/table/table.rb +5 -5
  11. data/apps/core/forms/tags/element_row.erb +15 -10
  12. data/apps/core/forms/widgets/form/form.rb +35 -22
  13. data/apps/core/forms/widgets/inputs/checkbox/checkbox.shtml +2 -2
  14. data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +2 -2
  15. data/apps/core/forms/widgets/inputs/file_input/file_input.shtml +2 -2
  16. data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +2 -2
  17. data/apps/core/forms/widgets/inputs/input/input.shtml +2 -2
  18. data/apps/core/forms/widgets/inputs/password/password.shtml +2 -2
  19. data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +1 -1
  20. data/apps/core/forms/widgets/inputs/select/select.shtml +2 -2
  21. data/apps/core/forms/widgets/inputs/text/text.shtml +2 -2
  22. data/apps/core/forms/widgets/inputs/text_area/text_area.shtml +2 -2
  23. data/apps/core/forms/widgets/inputs/time_span/time_span.shtml +1 -1
  24. data/blueprints/home/config.ru +8 -0
  25. data/lib/spiderfw/app.rb +416 -224
  26. data/lib/spiderfw/cmd/commands/app.rb +243 -239
  27. data/lib/spiderfw/cmd/commands/cert.rb +421 -417
  28. data/lib/spiderfw/cmd/commands/config.rb +85 -82
  29. data/lib/spiderfw/cmd/commands/console.rb +64 -40
  30. data/lib/spiderfw/cmd/commands/content.rb +29 -25
  31. data/lib/spiderfw/cmd/commands/create.rb +58 -54
  32. data/lib/spiderfw/cmd/commands/model.rb +118 -114
  33. data/lib/spiderfw/cmd/commands/setup.rb +55 -51
  34. data/lib/spiderfw/cmd/commands/test.rb +63 -59
  35. data/lib/spiderfw/cmd/commands/webserver.rb +56 -51
  36. data/lib/spiderfw/config/options/spider.rb +4 -3
  37. data/lib/spiderfw/controller/controller.rb +2 -0
  38. data/lib/spiderfw/controller/http_controller.rb +1 -2
  39. data/lib/spiderfw/controller/mixins/static_content.rb +3 -3
  40. data/lib/spiderfw/controller/mixins/visual.rb +30 -15
  41. data/lib/spiderfw/controller/response.rb +84 -0
  42. data/lib/spiderfw/controller/session/file_session.rb +2 -2
  43. data/lib/spiderfw/http/adapters/rack.rb +12 -13
  44. data/lib/spiderfw/http/server.rb +80 -46
  45. data/lib/spiderfw/i18n/cldr.rb +6 -9
  46. data/lib/spiderfw/model/base_model.rb +103 -23
  47. data/lib/spiderfw/model/condition.rb +110 -25
  48. data/lib/spiderfw/model/mappers/db_mapper.rb +14 -6
  49. data/lib/spiderfw/model/mappers/mapper.rb +440 -197
  50. data/lib/spiderfw/model/model.rb +105 -21
  51. data/lib/spiderfw/model/model_hash.rb +9 -1
  52. data/lib/spiderfw/model/query.rb +50 -9
  53. data/lib/spiderfw/model/query_set.rb +211 -44
  54. data/lib/spiderfw/model/request.rb +28 -21
  55. data/lib/spiderfw/model/storage/base_storage.rb +125 -10
  56. data/lib/spiderfw/model/storage/db/db_storage.rb +7 -4
  57. data/lib/spiderfw/model/storage.rb +8 -1
  58. data/lib/spiderfw/setup/spider_setup_wizard.rb +9 -7
  59. data/lib/spiderfw/spider.rb +270 -43
  60. data/lib/spiderfw/templates/layout.rb +9 -4
  61. data/lib/spiderfw/templates/resources/sass.rb +3 -2
  62. data/lib/spiderfw/templates/template.rb +1 -0
  63. data/lib/spiderfw/utils/annotations.rb +3 -1
  64. data/lib/spiderfw/utils/logger.rb +1 -1
  65. data/lib/spiderfw/utils/monkey/symbol.rb +4 -2
  66. data/lib/spiderfw/utils/shared_store/file_shared_store.rb +2 -2
  67. data/lib/spiderfw/utils/thread_out.rb +3 -1
  68. data/public/css/error_page.css +83 -0
  69. data/public/js/error_page.js +5 -0
  70. data/spider.gemspec +4 -1
  71. data/templates/email/error.erb +9 -0
  72. metadata +28 -12
  73. data/apps/config_editor/widgets/edit_bool/edit_bool.rb +0 -8
  74. data/apps/config_editor/widgets/edit_bool/edit_bool.shtml +0 -5
@@ -1,89 +1,92 @@
1
- class ConfigCommand < CmdParse::Command
1
+ module Spider::CommandLine
2
2
 
3
+ class ConfigCommand < CmdParse::Command
3
4
 
4
- def initialize
5
- super( 'config', true, true )
6
- @short_desc = _("Manage configuration")
7
-
8
- list = CmdParse::Command.new( 'list', false )
9
- list.short_desc = _("List configuration options")
10
- list.options = CmdParse::OptionParserWrapper.new do |opt|
11
- opt.on("--info", _("Show info"), "-i"){ |i|
12
- @info = true
13
- }
14
- end
15
-
16
- list.set_execution_block do |args|
17
- require 'spiderfw/spider'
18
- Spider.init_base
19
- search = args.first
20
- max_len = 0
21
- opts = Spider.config.options_list
22
- opts.each{ |o| max_len = o.length if o.length > max_len }
23
- opts.sort.each{ |o|
24
- next if search && o.index(search) != 0
25
- str = o.ljust(max_len + 2)
26
- if @info
27
- option = Spider.config.option(o)
28
- str += " #{option[:description]}" if option
29
- end
30
- puts str
31
- }
32
- end
33
-
34
- self.add_command(list)
35
-
36
- info = CmdParse::Command.new('info', false)
37
- info.short_desc = _("Get information about a configuration option")
38
- info.set_execution_block do |args|
39
- require 'spiderfw/spider'
40
- Spider.init_base
41
- option = Spider.config.option(args.first)
42
- if option && option[:params]
43
- print args[0]
44
- print ":\n"+option[:description]+"\n" if option[:description] && !option[:description].empty?
45
- puts
46
- puts "#{( _('Type') +':').ljust(10)} #{option[:params][:type]}" if option[:params][:type]
47
- default_str = nil
48
- if default = option[:params][:default]
49
- default_str = default.is_a?(Proc) ? _('Dynamic') : default
50
- end
51
- puts "#{( _('Default') +':').ljust(10)} #{default_str}" if default_str
52
- if choices = option[:params][:choices]
53
- choices = choices.call if choices.is_a?(Proc)
54
- puts "#{( _('Choices') +':').ljust(10)} #{choices.join(', ')}"
5
+
6
+ def initialize
7
+ super( 'config', true, true )
8
+ @short_desc = _("Manage configuration")
9
+
10
+ list = CmdParse::Command.new( 'list', false )
11
+ list.short_desc = _("List configuration options")
12
+ list.options = CmdParse::OptionParserWrapper.new do |opt|
13
+ opt.on("--info", _("Show info"), "-i"){ |i|
14
+ @info = true
15
+ }
16
+ end
17
+
18
+ list.set_execution_block do |args|
19
+ require 'spiderfw/spider'
20
+ Spider.init_base
21
+ search = args.first
22
+ max_len = 0
23
+ opts = Spider.config.options_list
24
+ opts.each{ |o| max_len = o.length if o.length > max_len }
25
+ opts.sort.each{ |o|
26
+ next if search && o.index(search) != 0
27
+ str = o.ljust(max_len + 2)
28
+ if @info
29
+ option = Spider.config.option(o)
30
+ str += " #{option[:description]}" if option
31
+ end
32
+ puts str
33
+ }
34
+ end
35
+
36
+ self.add_command(list)
37
+
38
+ info = CmdParse::Command.new('info', false)
39
+ info.short_desc = _("Get information about a configuration option")
40
+ info.set_execution_block do |args|
41
+ require 'spiderfw/spider'
42
+ Spider.init_base
43
+ option = Spider.config.option(args.first)
44
+ if option && option[:params]
45
+ print args[0]
46
+ print ":\n"+option[:description]+"\n" if option[:description] && !option[:description].empty?
47
+ puts
48
+ puts "#{( _('Type') +':').ljust(10)} #{option[:params][:type]}" if option[:params][:type]
49
+ default_str = nil
50
+ if default = option[:params][:default]
51
+ default_str = default.is_a?(Proc) ? _('Dynamic') : default
52
+ end
53
+ puts "#{( _('Default') +':').ljust(10)} #{default_str}" if default_str
54
+ if choices = option[:params][:choices]
55
+ choices = choices.call if choices.is_a?(Proc)
56
+ puts "#{( _('Choices') +':').ljust(10)} #{choices.join(', ')}"
57
+ end
58
+ else
59
+ puts _("Configuration option not found")
55
60
  end
56
- else
57
- puts _("Configuration option not found")
58
61
  end
62
+
63
+ self.add_command(info)
64
+
65
+ get = CmdParse::Command.new('get', false)
66
+ get.short_desc = _("Get the current value of a configuration option")
67
+ get.set_execution_block do |args|
68
+ require 'spiderfw/spider'
69
+ Spider.init_base
70
+ puts Spider.conf.get(args.first)
71
+ end
72
+
73
+ self.add_command(get)
74
+
75
+ set = CmdParse::Command.new('set', false)
76
+ set.short_desc = _("Set the value of a configuration option")
77
+ set.set_execution_block do |args|
78
+ require 'spiderfw/spider'
79
+ require 'lib/spiderfw/config/configuration_editor'
80
+ Spider.init_base
81
+ editor = Spider.config.get_editor
82
+ editor.set(*args)
83
+ editor.save
84
+ end
85
+
86
+ self.add_command(set)
87
+
59
88
  end
60
89
 
61
- self.add_command(info)
62
-
63
- get = CmdParse::Command.new('get', false)
64
- get.short_desc = _("Get the current value of a configuration option")
65
- get.set_execution_block do |args|
66
- require 'spiderfw/spider'
67
- Spider.init_base
68
- puts Spider.conf.get(args.first)
69
- end
70
-
71
- self.add_command(get)
72
-
73
- set = CmdParse::Command.new('set', false)
74
- set.short_desc = _("Set the value of a configuration option")
75
- set.set_execution_block do |args|
76
- require 'spiderfw/spider'
77
- require 'lib/spiderfw/config/configuration_editor'
78
- Spider.init_base
79
- editor = Spider.config.get_editor
80
- editor.set(*args)
81
- editor.save
82
- end
83
-
84
- self.add_command(set)
85
-
86
90
  end
87
-
88
- end
89
-
91
+
92
+ end
@@ -1,47 +1,71 @@
1
- class ConsoleCommand < CmdParse::Command
2
-
3
-
4
- def initialize
5
- super( 'console', false )
6
- @short_desc = _("Open a console")
7
- # @description = _("")
8
- @opts = {}
9
-
10
- self.options = CmdParse::OptionParserWrapper.new do |opt|
11
- opt.on("--irb [IRB]",
12
- _("Use irb instead of ripl (use given executable if supplied)"),
13
- "-i"){ |irb|
14
- @opts[:irb] = irb ? irb : 'irb'
15
- }
16
- end
17
-
18
- set_execution_block do
19
- unless @opts[:irb]
20
- begin
21
- require 'rubygems'
22
- require 'ripl'
23
- rescue LoadError
24
- @opts[:irb] = 'irb'
25
- end
1
+ module Spider::CommandLine
2
+
3
+ class ConsoleCommand < CmdParse::Command
4
+
5
+
6
+ def initialize
7
+ super( 'console', false )
8
+ @short_desc = _("Open a console")
9
+ # @description = _("")
10
+ @opts = {}
11
+
12
+ self.options = CmdParse::OptionParserWrapper.new do |opt|
13
+ opt.on("--irb [IRB]", _("Use irb (you can specify the executable to use)"), "-i"){ |irb|
14
+ @opts[:irb] = irb ? irb : 'irb'
15
+ }
16
+ opt.on('--ripl' ,_("User ripl"), "-r"){ |ripl| @opts[:ripl] = true }
17
+ opt.on('--pry', _("Use Pry if available (the default)"))
26
18
  end
27
- if @opts[:irb]
28
- ENV['SPIDER_RUNMODE'] = $SPIDER_RUNMODE if ($SPIDER_RUNMODE)
29
- ENV['SPIDER_CONFIG_SETS'] = $SPIDER_CONFIG_SETS.join(',') if ($SPIDER_CONFIG_SETS)
30
- exec("#{@opts[:irb]} -I #{$SPIDER_LIB} -r spiderfw")
31
- else
32
- require 'ripl/irb'
33
- require 'ripl/multi_line'
34
-
35
- Ripl.config[:irb_verbose] = false
36
- Ripl::Runner.load_rc(Ripl.config[:riplrc])
37
-
38
- require 'spiderfw/init'
39
- Object.send(:remove_const, :IRB) if Object.const_defined?(:IRB)
40
- Ripl.shell.loop
19
+
20
+ set_execution_block do
21
+ if @opts[:ripl]
22
+ begin
23
+ require 'rubygems'
24
+ require 'ripl'
25
+ rescue LoadError
26
+ @opts[:irb] = 'irb'
27
+ end
28
+ end
29
+ unless @opts[:irb]
30
+ begin
31
+ require 'rubygems'
32
+ require 'pry'
33
+ rescue LoadError
34
+ @opts[:irb] = 'irb'
35
+ end
36
+ end
37
+ if @opts[:irb]
38
+ ENV['SPIDER_RUNMODE'] = $SPIDER_RUNMODE if ($SPIDER_RUNMODE)
39
+ ENV['SPIDER_CONFIG_SETS'] = $SPIDER_CONFIG_SETS.join(',') if ($SPIDER_CONFIG_SETS)
40
+ exec("#{@opts[:irb]} -I #{$SPIDER_LIB} -r spiderfw")
41
+ elsif @opts[:ripl]
42
+ require 'ripl/irb'
43
+ require 'ripl/multi_line'
44
+
45
+ Ripl.config[:irb_verbose] = false
46
+ Ripl::Runner.load_rc(Ripl.config[:riplrc])
47
+
48
+ require 'spiderfw/init'
49
+ Object.send(:remove_const, :IRB) if Object.const_defined?(:IRB)
50
+ Ripl.shell.loop
51
+ else
52
+ try_require 'pry-nav'
53
+ try_require 'pry-stack_explorer'
54
+ require 'spiderfw/init'
55
+ Pry.start
56
+ end
41
57
  end
58
+
59
+
42
60
  end
43
61
 
62
+ def try_require(lib)
63
+ begin
64
+ require lib
65
+ rescue LoadError => e
66
+ end
67
+ end
44
68
 
45
69
  end
46
70
 
47
- end
71
+ end
@@ -1,33 +1,37 @@
1
1
  require 'fileutils'
2
2
 
3
- class ContentCommand < CmdParse::Command
3
+ module Spider::CommandLine
4
4
 
5
+ class ContentCommand < CmdParse::Command
5
6
 
6
- def initialize
7
- super( 'content', true, true )
8
- @short_desc = _("Manage static content")
9
-
10
- publish = CmdParse::Command.new( 'publish', false )
11
- publish.short_desc = _("Publish apps static content to home public folder")
12
- publish.options = CmdParse::OptionParserWrapper.new do |opt|
13
- end
14
-
15
- publish.set_execution_block do |args|
16
- require 'spiderfw/init'
17
- Spider::StaticContent.publish
18
- end
19
-
20
- self.add_command(publish)
21
-
22
- compress = CmdParse::Command.new('compress', false)
23
- compress.short_desc = _("Compress Javascript files")
24
- compress.set_execution_block do |args|
25
- require 'spiderfw/init'
26
- Spider::ContentUtils.compress(*args)
7
+
8
+ def initialize
9
+ super( 'content', true, true )
10
+ @short_desc = _("Manage static content")
11
+
12
+ publish = CmdParse::Command.new( 'publish', false )
13
+ publish.short_desc = _("Publish apps static content to home public folder")
14
+ publish.options = CmdParse::OptionParserWrapper.new do |opt|
15
+ end
16
+
17
+ publish.set_execution_block do |args|
18
+ require 'spiderfw/init'
19
+ Spider::StaticContent.publish
20
+ end
21
+
22
+ self.add_command(publish)
23
+
24
+ compress = CmdParse::Command.new('compress', false)
25
+ compress.short_desc = _("Compress Javascript files")
26
+ compress.set_execution_block do |args|
27
+ require 'spiderfw/init'
28
+ Spider::ContentUtils.compress(*args)
29
+ end
30
+
31
+ self.add_command(compress)
32
+
27
33
  end
28
34
 
29
- self.add_command(compress)
30
-
31
35
  end
32
-
36
+
33
37
  end
@@ -1,69 +1,73 @@
1
1
  require 'spiderfw/spider'
2
2
  require 'spiderfw/create'
3
3
 
4
- class CreateCommand < CmdParse::Command
4
+ module Spider::CommandLine
5
5
 
6
+ class CreateCommand < CmdParse::Command
6
7
 
7
- def initialize
8
- super( 'create', true, true )
9
- @short_desc = _("Create a working dir for development or installation")
10
- # @description = _("")
11
8
 
12
- app = CmdParse::Command.new( 'app', false )
13
- app.short_desc = _("Create a new application")
14
- app.options = CmdParse::OptionParserWrapper.new do |opt|
15
- opt.on("--path",
16
- _("The path where to create the app (defaults to the app folder under the current path)"),
17
- "-p"){ |path|
18
- @path = path
19
- }
20
- opt.on("--module", _("The module name; by default, the app name will be camelized"), "-m"){ |module_name|
21
- @module_name = module_name
22
- }
23
- end
24
- app.set_execution_block do |names|
25
- @path ||= Dir.pwd+'/apps'
26
- names.each do |name|
27
- Spider::Create.app(name, @path, @module_name)
28
- Spider.output "Created app #{name} at #{@path}/#{name}" if ($verbose)
9
+ def initialize
10
+ super( 'create', true, true )
11
+ @short_desc = _("Create a working dir for development or installation")
12
+ # @description = _("")
13
+
14
+ app = CmdParse::Command.new( 'app', false )
15
+ app.short_desc = _("Create a new application")
16
+ app.options = CmdParse::OptionParserWrapper.new do |opt|
17
+ opt.on("--path",
18
+ _("The path where to create the app (defaults to the app folder under the current path)"),
19
+ "-p"){ |path|
20
+ @path = path
21
+ }
22
+ opt.on("--module", _("The module name; by default, the app name will be camelized"), "-m"){ |module_name|
23
+ @module_name = module_name
24
+ }
29
25
  end
30
- end
31
- self.add_command(app, false)
32
-
33
- install = CmdParse::Command.new('home', false)
34
- install.short_desc = _("Create an installation")
35
- install.options = CmdParse::OptionParserWrapper.new do |opt|
36
- opt.on("--path [PATH]",
37
- _("The path where to create the installation (defaults to the path)"),
38
- "-p"){ |path|
39
- @path = path
40
- }
41
- opt.on("--no-wizard", _("Don't launch wizard"), "-W"){ |w| @no_wizard = true }
42
- opt.on("--non-interactive", _("Non interactive"), "-i"){ |i|
43
- @no_wizard = true
44
- }
45
- end
46
- install.set_execution_block do |installs|
47
- @path ||= Dir.pwd
48
- installs.each do |inst|
49
- Spider::Create.home(inst, @path)
50
- unless @no_wizard
51
- Dir.chdir(inst) do
52
- $SPIDER_RUN_PATH = Dir.pwd
53
- $:.push($SPIDER_RUN_PATH)
54
- require 'spiderfw/init'
55
- require 'lib/spiderfw/setup/spider_setup_wizard'
56
- wizard = Spider::SpiderSetupWizard.new
57
- wizard.first_run = true
58
- wizard.implementation(Spider::ConsoleWizard)
59
- wizard.run
26
+ app.set_execution_block do |names|
27
+ @path ||= Dir.pwd+'/apps'
28
+ names.each do |name|
29
+ Spider::Create.app(name, @path, @module_name)
30
+ Spider.output "Created app #{name} at #{@path}/#{name}" if ($verbose)
31
+ end
32
+ end
33
+ self.add_command(app, false)
34
+
35
+ install = CmdParse::Command.new('home', false)
36
+ install.short_desc = _("Create an installation")
37
+ install.options = CmdParse::OptionParserWrapper.new do |opt|
38
+ opt.on("--path [PATH]",
39
+ _("The path where to create the installation (defaults to the path)"),
40
+ "-p"){ |path|
41
+ @path = path
42
+ }
43
+ opt.on("--no-wizard", _("Don't launch wizard"), "-W"){ |w| @no_wizard = true }
44
+ opt.on("--non-interactive", _("Non interactive"), "-i"){ |i|
45
+ @no_wizard = true
46
+ }
47
+ end
48
+ install.set_execution_block do |installs|
49
+ @path ||= Dir.pwd
50
+ installs.each do |inst|
51
+ Spider::Create.home(inst, @path)
52
+ unless @no_wizard
53
+ Dir.chdir(inst) do
54
+ $SPIDER_RUN_PATH = Dir.pwd
55
+ $:.push($SPIDER_RUN_PATH)
56
+ require 'spiderfw/init'
57
+ require 'lib/spiderfw/setup/spider_setup_wizard'
58
+ wizard = Spider::SpiderSetupWizard.new
59
+ wizard.first_run = true
60
+ wizard.implementation(Spider::ConsoleWizard)
61
+ wizard.run
62
+ end
60
63
  end
61
64
  end
62
65
  end
63
- end
64
- self.add_command(install, false)
66
+ self.add_command(install, false)
65
67
 
66
68
 
69
+ end
70
+
67
71
  end
68
72
 
69
73
  end