spiderfw 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/apps/app_server/_init.rb +8 -0
  2. data/apps/app_server/app_server.rb +60 -0
  3. data/apps/app_server/config/options.rb +2 -0
  4. data/apps/app_server/controllers/app_server_controller.rb +20 -0
  5. data/apps/app_server/lib/app.rb +21 -0
  6. data/apps/app_server/lib/git_app.rb +22 -0
  7. data/apps/app_server/views/app_list.shtml +8 -0
  8. data/apps/app_server/views/app_server.layout.shtml +14 -0
  9. data/apps/cas_server/_init.rb +1 -1
  10. data/apps/config_editor/_init.rb +14 -0
  11. data/apps/config_editor/config_editor.appspec +3 -0
  12. data/apps/config_editor/controllers/config_editor_controller.rb +88 -0
  13. data/apps/config_editor/views/config_editor.layout.shtml +20 -0
  14. data/apps/config_editor/views/index.shtml +23 -0
  15. data/apps/config_editor/widgets/edit/edit.rb +13 -0
  16. data/apps/config_editor/widgets/edit/edit.shtml +4 -0
  17. data/apps/core/auth/models/group.rb +2 -2
  18. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.js +187 -0
  19. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.min.js +1 -0
  20. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.spider.1.0.js +193 -0
  21. data/apps/core/components/widgets/table/table.rb +19 -9
  22. data/apps/core/components/widgets/table/table.shtml +2 -2
  23. data/apps/core/forms/widgets/inputs/subform/subform.rb +10 -0
  24. data/apps/core/forms/widgets/inputs/subform/subform.shtml +5 -0
  25. data/apps/hippo/script/converti_strutture.rb +335 -0
  26. data/apps/master/_init.rb +12 -0
  27. data/apps/master/controllers/master_controller.rb +110 -0
  28. data/apps/master/master.appspec +5 -0
  29. data/apps/master/models/customer.rb +13 -0
  30. data/apps/master/models/installation.rb +10 -0
  31. data/apps/master/models/resource.rb +10 -0
  32. data/apps/master/models/servant.rb +25 -0
  33. data/apps/master/views/customer.shtml +20 -0
  34. data/apps/master/views/customers.shtml +10 -0
  35. data/apps/master/views/index.shtml +4 -0
  36. data/apps/master/views/installation.shtml +36 -0
  37. data/apps/master/views/master.layout.shtml +14 -0
  38. data/apps/master/views/servant.shtml +26 -0
  39. data/apps/master/views/servants.shtml +7 -0
  40. data/apps/servant/_init.rb +5 -0
  41. data/apps/servant/bin/spider-servant.rb +47 -0
  42. data/apps/servant/lib/resource.rb +11 -0
  43. data/apps/servant/lib/resources/db/mysql.rb +31 -0
  44. data/apps/servant/lib/resources/db.rb +54 -0
  45. data/apps/servant/lib/servant.rb +82 -0
  46. data/apps/servant/servant.appspec +4 -0
  47. data/apps/servant/var/log/error.log +1 -0
  48. data/apps/worker/worker.rb +1 -1
  49. data/blueprints/install/config.ru +12 -0
  50. data/lib/spiderfw/app.rb +8 -0
  51. data/lib/spiderfw/cmd/cmd.rb +4 -2
  52. data/lib/spiderfw/cmd/commands/content.rb +33 -0
  53. data/lib/spiderfw/cmd/commands/{init.rb → create.rb} +4 -4
  54. data/lib/spiderfw/config/options/spider.rb +4 -0
  55. data/lib/spiderfw/controller/controller.rb +11 -1
  56. data/lib/spiderfw/controller/dispatcher.rb +2 -0
  57. data/lib/spiderfw/controller/home_controller.rb +7 -1
  58. data/lib/spiderfw/controller/mixins/static_content.rb +17 -3
  59. data/lib/spiderfw/controller/mixins/visual.rb +2 -2
  60. data/lib/spiderfw/controller/session.rb +2 -0
  61. data/lib/spiderfw/create.rb +2 -2
  62. data/lib/spiderfw/model/base_model.rb +11 -0
  63. data/lib/spiderfw/model/condition.rb +37 -7
  64. data/lib/spiderfw/model/mappers/db_mapper.rb +67 -71
  65. data/lib/spiderfw/model/mappers/mapper.rb +92 -31
  66. data/lib/spiderfw/model/model.rb +1 -0
  67. data/lib/spiderfw/model/query.rb +1 -3
  68. data/lib/spiderfw/model/query_funcs.rb +51 -0
  69. data/lib/spiderfw/model/storage/db/adapters/oci8.rb +4 -1
  70. data/lib/spiderfw/model/storage/db/db_schema.rb +15 -1
  71. data/lib/spiderfw/model/storage/db/db_storage.rb +8 -2
  72. data/lib/spiderfw/static_content.rb +84 -0
  73. data/lib/spiderfw/utils/monkey/date_time.rb +4 -0
  74. data/lib/spiderfw/utils/monkey/hpricot_compat.rb +0 -0
  75. data/lib/spiderfw/utils/monkey/object.rb +25 -0
  76. data/lib/spiderfw/utils/test_case.rb +24 -0
  77. metadata +54 -24
  78. data/apps/cms/models/content.rb +0 -16
  79. data/apps/cms/models/news_item.rb +0 -7
  80. data/apps/cms/models/translation.rb +0 -14
  81. data/apps/cms/views/admin/admin.shtml +0 -16
  82. data/apps/cms/views/admin/content.shtml +0 -4
  83. data/apps/core/acl/_init.rb +0 -10
  84. data/apps/core/acl/controllers/acl_controller.rb +0 -14
  85. data/apps/core/acl/models/permission.rb +0 -11
  86. data/apps/core/acl/views/acl.layout.shtml +0 -8
  87. data/apps/core/acl/views/index.shtml +0 -3
  88. data/apps/git_model_versioning/models/mixins/git_versioned.rb +0 -91
  89. data/apps/master/controllers/git.rb +0 -32
  90. data/apps/saml/_init.rb +0 -13
  91. data/apps/saml/controllers/saml2idp.rb +0 -18
  92. data/apps/saml/lib/bindings/http_redirect_binding.rb +0 -14
  93. data/apps/saml/lib/messages/authn_request.rb +0 -52
  94. data/apps/saml/lib/saml.rb +0 -10
  95. data/apps/soap/soap.gemspec +0 -10
  96. data/blueprints/model.rb +0 -15
  97. /data/blueprints/{install → home}/config/config.yml +0 -0
  98. /data/blueprints/{install → home}/init.rb +0 -0
@@ -0,0 +1,110 @@
1
+ module Spider; module Master
2
+
3
+ class MasterController < Spider::PageController
4
+
5
+ layout 'master'
6
+
7
+ route /customers\/(\d+)\/installations\//, :installations
8
+
9
+ __.html :template => 'index'
10
+ def index
11
+ end
12
+
13
+ __.html
14
+ def customers(id=nil)
15
+ if id
16
+ visual_params[:template] = 'customer'
17
+ @scene.customer = Customer.new(id) if id && id != 'new'
18
+ @scene.edit = (@request.params['_w'] && @request.params['_w'].key?('customer_form')) || @request.params.key?('edit') || id == 'new'
19
+ @scene.pk = id
20
+ get_template
21
+ if id == 'new' && @template.widgets[:customer_form]
22
+ @template.widgets[:customer_form].attributes[:auto_redirect] = Master.url+'/customers'
23
+ end
24
+ else
25
+ @scene.customers = Customer.all
26
+ visual_params[:template] = 'customers'
27
+ end
28
+ end
29
+
30
+
31
+
32
+ __.html :template => 'installation'
33
+ def installations(id, customer_id)
34
+ @customer = Customer.new(customer_id)
35
+ @installation = Installation.new(id) unless id == 'new'
36
+ if id == 'new'
37
+ if @request.params.key?('installation_create') && !@request.params['installation_name'].empty?
38
+ i = Installation.new(:name => @request.params['installation_name'])
39
+ i.customer = @customer
40
+ i.save
41
+ redirect(File.dirname(@request.path)+"/#{i.id}")
42
+ end
43
+ else
44
+ if @request.params.key?('save_apps')
45
+ @installation.apps = @request.params['apps'].keys.join(',')
46
+ @installation.save
47
+ redirect(request.path)
48
+ end
49
+ @scene.install_apps = (@installation.apps && !@installation.apps.empty?) ? @installation.apps.split(',') : []
50
+ @scene.apps = Spider::AppServer.apps
51
+ end
52
+ @scene << {
53
+ :customer => @customer,
54
+ :installation => @installation
55
+ }
56
+ end
57
+
58
+ __.html
59
+ def servants(id=nil)
60
+ if id
61
+ @scene.servant = Servant.new(id)
62
+ render('servant')
63
+ else
64
+ @scene.servants = Servant.all
65
+ render('servants')
66
+ end
67
+
68
+ end
69
+
70
+ __.action
71
+ def ping
72
+ servant_id = @request.params['servant_id']
73
+ servant = Master::Servant.load(:id => servant_id)
74
+ new_servant = false
75
+ unless servant
76
+ servant = Master::Servant.static(:id => servant_id)
77
+ new_servant = true
78
+ end
79
+ servant.last_check = DateTime.now
80
+ servant.name = @request.params['servant_name']
81
+ servant.system_status = @request.params['system_status']
82
+ curr_resources = servant.resources_by_type
83
+ resources = []
84
+ if @request.params['resources']
85
+ @request.params['resources'].each do |res_type, type_resources|
86
+ type_resources.each do |name, details|
87
+ if curr_resources[res_type]
88
+ res = curr_resources[res_type][name]
89
+ end
90
+ res ||= Resource.static
91
+ res.resource_type = res_type
92
+ res.name = name
93
+ res.description = details['description']
94
+ res.save
95
+ resources << res
96
+ end
97
+ end
98
+ end
99
+ servant.resources = resources
100
+ if new_servant
101
+ servant.insert
102
+ else
103
+ servant.update
104
+ end
105
+ $out << 'ok'
106
+ end
107
+
108
+ end
109
+
110
+ end; end
@@ -0,0 +1,5 @@
1
+ id "master"
2
+ name "Master"
3
+ version "0.1"
4
+ author "Ivan Pirlik"
5
+
@@ -0,0 +1,13 @@
1
+ require 'apps/master/models/installation'
2
+
3
+ module Spider; module Master
4
+
5
+ class Customer < Spider::Model::Managed
6
+ element :name, String
7
+ element :public_key, Text
8
+ element :private_key, Text
9
+ many :installs, Installation, :add_reverse => :customer
10
+
11
+ end
12
+
13
+ end; end
@@ -0,0 +1,10 @@
1
+ module Spider; module Master
2
+
3
+ class Installation < Spider::Model::Managed
4
+ element :name, String
5
+ element :apps, Text
6
+ element :configuration, Text
7
+
8
+ end
9
+
10
+ end; end
@@ -0,0 +1,10 @@
1
+ module Spider; module Master
2
+
3
+ class Resource < Spider::Model::Managed
4
+ element :name, String
5
+ element :resource_type, String
6
+ element :description, Text
7
+
8
+ end
9
+
10
+ end; end
@@ -0,0 +1,25 @@
1
+ require 'apps/master/models/resource'
2
+
3
+ module Spider; module Master
4
+
5
+ class Servant < Spider::Model::Managed
6
+ remove_element :id
7
+ element :id, String, :primary_key => true
8
+ element :name, String
9
+ element :last_check, DateTime
10
+ element :system_status, Text
11
+ many :resources, Spider::Master::Resource, :delete_cascade => true
12
+
13
+
14
+ def resources_by_type
15
+ r = {}
16
+ self.resources.each do |res|
17
+ r[res.resource_type] ||= {}
18
+ r[res.resource_type][res.name] = res
19
+ end
20
+ r
21
+ end
22
+
23
+ end
24
+
25
+ end; end
@@ -0,0 +1,20 @@
1
+ <div>
2
+ <h3 sp:if="@customer">_(Customer %s) % @customer.name </h3>
3
+ <h3 sp:if="!@customer">_(New customer)</h3>
4
+ <tpl:pass sp:if="!@edit">
5
+ <a href="?edit">_(Edit)</a>
6
+ <a href="{ Master.url }/customers">_(List)</a>
7
+ </tpl:pass>
8
+ <tpl:pass sp:if="@edit">
9
+ <forms:form id="customer_form" model="Spider::Master::Customer" pk="@pk" auto_redirect="true"/>
10
+ </tpl:pass>
11
+ <tpl:pass sp:if="@customer && !@edit">
12
+ <h4>_(Installations)</h4>
13
+ <a href="{ @customer.id }/installations/new">_(New installation)</a>
14
+ <ul>
15
+ <li sp:each="@customer.installs |installation|">
16
+ <a href="{ customer.id }/installations/{ installation.id }">{ installation.name }</a>
17
+ </li>
18
+ </ul>
19
+ </tpl:pass>
20
+ </div>
@@ -0,0 +1,10 @@
1
+ <div>
2
+ <div class="actions">
3
+ <a href="{ Master.url }/customers/new">_(New customer)</a>
4
+ </div>
5
+ <ul>
6
+ <li sp:each="@customers |customer|">
7
+ <a href="{ Master.url }/customers/{ customer.id }">{ customer.name }</a>
8
+ </li>
9
+ </ul>
10
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <a href="{ Master.url }/customers">_(Customers)</a>
3
+ <a href="{ Master.url }/servants">_(Servants)</a>
4
+ </div>
@@ -0,0 +1,36 @@
1
+ <div>
2
+ <div class="actions">
3
+ <a href="{ Master.url }/customers/{ @customer.id }">_(Back to customer)</a>
4
+ </div>
5
+ <div sp:if="!@installation">
6
+ <h3>_(New installation for %s) % @customer.name</h3>
7
+ <form action="" method="POST">
8
+ <div class="row">
9
+ <label for="installation_name">_(Name):</label>
10
+ <input type="text" name="installation_name" id="installation_name">
11
+ <input type="submit" name="installation_create" value="Ok">
12
+ </div>
13
+ </form>
14
+ </div>
15
+ <div sp:if="@installation">
16
+ <h3 sp:if="@installation">_(Installation "%s" for %s) % [@installation.name, @customer.name] </h3>
17
+ <core:tabs id="install_tabs">
18
+ <tab id="edit" label="_(Edit installation)">
19
+ <div class="apps">
20
+ <h4>_(Apps)</h4>
21
+ <form action="" method="POST">
22
+ <ul>
23
+ <li sp:each="@apps |app|">
24
+ <input type="checkbox" name="apps[{ app.app_id }]" value="true" sp:attr-if="@install_apps.include?(app.app_id),checked">
25
+ { app.name }
26
+ </li>
27
+ </ul>
28
+ <input type="submit" name="save_apps" value="_(Save)">
29
+ </form>
30
+ </div>
31
+ </tab>
32
+ <tab id="targets" label="_(Targets)">
33
+ </tab>
34
+ </core:tabs>
35
+ </div>
36
+ </div>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Spider Master</title>
6
+ <script sp:each='@assets[:js] |script|' type="text/javascript" src="{ script }"></script>
7
+ <link sp:each='@assets[:css] |css_file|' rel='stylesheet' href='{ css_file }' />
8
+ </head>
9
+ <body>
10
+ <div id="content">
11
+ <sp:yield />
12
+ </div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,26 @@
1
+ <div>
2
+ <h3>_(Servant %s) % @servant.name </h3>
3
+ <div>
4
+ _(Last check):
5
+ { @servant.last_check.lformat(:short) }
6
+ </div>
7
+ <div id="resources">
8
+ <h4>_(Resources)</h4>
9
+ <ul>
10
+ <li sp:each="@servant.resources_by_type |type, resources|">
11
+ { type }
12
+ <ul>
13
+ <li sp:each="resources |name, resource|">
14
+ { name }: { resource.description }
15
+ </li>
16
+ </ul>
17
+ </li>
18
+ </ul>
19
+ </div>
20
+ <div>
21
+ <h4>_(System details)</h4>
22
+ <pre class="json">
23
+ { servant.system_status }
24
+ </pre>
25
+ </div>
26
+ </div>
@@ -0,0 +1,7 @@
1
+ <div>
2
+ <ul>
3
+ <li sp:each="@servants |servant|">
4
+ <a href="{ Master.url }/servants/{ servant.id }">{ servant.name }</a>
5
+ </li>
6
+ </ul>
7
+ </div>
@@ -0,0 +1,5 @@
1
+ module Spider
2
+ module Servant
3
+ include Spider::App
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'spiderfw'
4
+ require 'cmdparse'
5
+ require $SPIDER_PATH+'/apps/servant/lib/servant.rb'
6
+ require 'ruby-debug'
7
+
8
+
9
+ class Cmd
10
+
11
+ def initialize
12
+ @cmd = CmdParse::CommandParser.new( true, true )
13
+ @cmd.program_name = "spider-servant"
14
+ @cmd.options = CmdParse::OptionParserWrapper.new do |opt|
15
+ opt.separator _("Global options:")
16
+ opt.on("--verbose", _("Be verbose when outputting info"), "-v" ) {|t| $verbose = true }
17
+ opt.on("--config-file [FILE]", _("Configuration file"), "-c"){ |c| @config_file = c }
18
+ end
19
+
20
+ ping_server = CmdParse::Command.new('ping_server', false)
21
+ ping_server.set_execution_block do |args|
22
+ servant = Spider::Servant::Servant.new(@config_file)
23
+ servant.ping_server
24
+ end
25
+
26
+
27
+ @cmd.add_command(CmdParse::HelpCommand.new, true)
28
+ @cmd.add_command(ping_server)
29
+
30
+ end
31
+
32
+ def parse
33
+ cmd_name = nil
34
+ 0.upto(ARGV.length) do |i|
35
+ if (ARGV[i] && ARGV[i] != 'help' && ARGV[i][0].chr != '-')
36
+ cmd_name = ARGV[i]
37
+ break
38
+ end
39
+ end
40
+ cmd_name ||= 'help'
41
+ @cmd.parse
42
+ end
43
+
44
+ end
45
+
46
+ cmd = Cmd.new
47
+ cmd.parse
@@ -0,0 +1,11 @@
1
+ module Spider; module Servant
2
+
3
+ class Resource
4
+
5
+ def description
6
+ {}
7
+ end
8
+
9
+ end
10
+
11
+ end; end
@@ -0,0 +1,31 @@
1
+ module Spider; module Servant; module Resources
2
+
3
+ class Mysql < Db
4
+
5
+
6
+
7
+ def create_db(name)
8
+ return if db_exists?(name)
9
+ sql = "create database #{name}"
10
+ @storage.execute(sql)
11
+ end
12
+
13
+ def db_exists?(name)
14
+ sql = "select schema_name from information_schema.schemata where schema_name = '#{name}'"
15
+ res = @storage.execute(sql)
16
+ return res[0] ? true : false
17
+ end
18
+
19
+ def add_user(name, password)
20
+ sql = "create user '#{name}'@'localhost' identified by '#{password}'"
21
+ @storage.execute(sql)
22
+ end
23
+
24
+ def grant_db_to_user(db_name, user)
25
+ sql = "grant all on #{db_name}.* to '#{user}'@'localhost'"
26
+ @storage.execute(sql)
27
+ end
28
+
29
+ end
30
+
31
+ end; end; end
@@ -0,0 +1,54 @@
1
+ require 'spiderfw'
2
+
3
+ module Spider; module Servant; module Resources
4
+
5
+ class Db < Resource
6
+
7
+ def self.get_resource(url)
8
+ matches = url.match(/^(.+?):\/\/(.+)/)
9
+ adapter = matches[1]
10
+ rest = matches[2]
11
+ if (adapter =~ /(.+):(.+)/)
12
+ connector = $1
13
+ adapter = $2
14
+ url = "#{adapter}://#{rest}"
15
+ end
16
+ case adapter
17
+ when 'sqlite'
18
+ class_name = :SQLite
19
+ when 'oci8'
20
+ class_name = :OCI8
21
+ when 'mysql'
22
+ class_name = :Mysql
23
+ when 'mssql'
24
+ class_name = :MSSQL
25
+ end
26
+ return Resources.const_get(class_name).new(url)
27
+ end
28
+
29
+ def initialize(url)
30
+ @storage = Spider::Model::Storage.get_storage('db', url)
31
+ end
32
+
33
+ def create_db(name)
34
+ raise "Unimplemented"
35
+ end
36
+
37
+ def db_exists?(name)
38
+ raise "Unimplemented"
39
+ end
40
+
41
+ def add_user(name, password)
42
+ raise "Unimplemented"
43
+ end
44
+
45
+ def grant_db_to_user(db_name, user)
46
+ raise "Unimplemented"
47
+ end
48
+
49
+ def resource_type
50
+ :db
51
+ end
52
+ end
53
+
54
+ end; end; end
@@ -0,0 +1,82 @@
1
+ require 'rubygems'
2
+ require 'ohai'
3
+ require 'httpclient'
4
+ $SPIDER_SERVANT_LIB = File.dirname(__FILE__)
5
+ require "#{$SPIDER_SERVANT_LIB}/resource"
6
+ require "#{$SPIDER_SERVANT_LIB}/resources/db"
7
+ require "#{$SPIDER_SERVANT_LIB}/resources/db/mysql"
8
+
9
+ module Spider
10
+
11
+ module Servant
12
+
13
+ class Servant
14
+ DEFAULTS = {
15
+ :config_file => '/etc/spider/servant.yml'
16
+ }
17
+
18
+ def initialize(config_file=nil)
19
+ @config = {
20
+ :server_url => 'http://localhost:8989/spider/master/ping'
21
+ }
22
+ config_file ||= Servant::DEFAULTS[:config_file] if File.exists?(Servant::DEFAULTS[:config_file])
23
+ if config_file
24
+ y = YAML::load_file(config_file)
25
+ @config.merge!(y)
26
+ end
27
+ ohai = Ohai::System.new
28
+ ohai.all_plugins
29
+ @ohai = ohai
30
+ @config[:servant_id] ||= ohai["hostname"]
31
+ @config[:servant_name] ||= @config[:servant_id]
32
+ create_resources
33
+ end
34
+
35
+ def ping_server(url=nil)
36
+ url ||= @config[:server_url]
37
+
38
+ @system_status = @ohai.to_json
39
+ clnt = HTTPClient.new
40
+ clnt.post(url, Spider::HTTP.params_to_hash(self.description))
41
+ end
42
+
43
+ def create_resources
44
+ @resources = {}
45
+ return unless @config['resources'].is_a?(Hash)
46
+ @config['resources'].each do |res_type, hash|
47
+ @resources[res_type] ||= {}
48
+ case res_type
49
+ when 'db'
50
+ hash.each do |res_name, params|
51
+ @resources[res_type][res_name] = Resources::Db.get_resource(params['url'])
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def description
58
+ {
59
+ :servant_id => @config[:servant_id],
60
+ :servant_name => @config[:servant_name],
61
+ :system_status => @system_status,
62
+ :resources => resources_description
63
+ }
64
+ end
65
+
66
+ def resources_description
67
+ desc = {}
68
+ @resources.each do |type, type_resources|
69
+ desc[type] ||= {}
70
+ type_resources.each do |name, resource|
71
+ desc[type][name] = {
72
+ :description => resource.description.to_json
73
+ }
74
+ end
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,4 @@
1
+ name "Servant"
2
+ version "0.1"
3
+ author "Ivan Pirlik"
4
+ gems "ohai >0.3", "httpclient"
@@ -0,0 +1 @@
1
+ # Logfile created on Mon Apr 12 15:39:53 +0200 2010 by /
@@ -133,7 +133,7 @@ module Spider
133
133
  end
134
134
 
135
135
  def self.at(time, proc_string)
136
- job = Job.new(:uuid => ::UUID.new.generate, :time => time, :task => proc_string)
136
+ job = Job.new(:uuid => UUIDTools::UUID.random_create.to_s, :time => time, :task => proc_string)
137
137
  job.save
138
138
  return job.uuid
139
139
  end
@@ -0,0 +1,12 @@
1
+ ENV['LANG'] = 'it_IT.UTF-8'
2
+ require 'spiderfw'
3
+ require 'spiderfw/http/adapters/rack'
4
+ PhusionPassenger.on_event(:starting_worker_process) do
5
+ Spider.start_loggers
6
+ Spider.startup
7
+ end
8
+ rack_app = Spider::HTTP::RackApplication.new
9
+ app = proc do |env|
10
+ rack_app.call(env)
11
+ end
12
+ run app
data/lib/spiderfw/app.rb CHANGED
@@ -45,6 +45,14 @@ module Spider
45
45
  alias :url :request_url
46
46
 
47
47
  def pub_url
48
+ if Spider.conf.get('static_content.mode') == 'publish'
49
+ Spider::HomeController.pub_url+'/apps/'+self.short_name
50
+ else
51
+ request_url+'/public'
52
+ end
53
+ end
54
+
55
+ def pub_url!
48
56
  request_url+'/public'
49
57
  end
50
58
 
@@ -2,12 +2,13 @@ require 'rubygems'
2
2
  require 'spiderfw/i18n/gettext'
3
3
  require 'cmdparse'
4
4
  require 'spiderfw/cmd/commands/webserver'
5
- require 'spiderfw/cmd/commands/init'
5
+ require 'spiderfw/cmd/commands/create'
6
6
  require 'spiderfw/cmd/commands/console'
7
7
  require 'spiderfw/cmd/commands/test'
8
8
  require 'spiderfw/cmd/commands/setup'
9
9
  require 'spiderfw/cmd/commands/model'
10
10
  require 'spiderfw/cmd/commands/config'
11
+ require 'spiderfw/cmd/commands/content'
11
12
 
12
13
  module Spider; module CommandLine
13
14
 
@@ -36,7 +37,7 @@ module Spider; module CommandLine
36
37
 
37
38
  @cmd.add_command(CmdParse::HelpCommand.new, true)
38
39
  @cmd.add_command(WebServerCommand.new)
39
- @cmd.add_command(InitCommand.new)
40
+ @cmd.add_command(CreateCommand.new)
40
41
  @cmd.add_command(ConsoleCommand.new)
41
42
  begin
42
43
  require 'spiderfw/cmd/commands/cert'
@@ -47,6 +48,7 @@ module Spider; module CommandLine
47
48
  @cmd.add_command(SetupCommand.new)
48
49
  @cmd.add_command(ModelCommand.new)
49
50
  @cmd.add_command(ConfigCommand.new)
51
+ @cmd.add_command(ContentCommand.new)
50
52
  # @cmd.add_command(ScaffoldCommand.new)
51
53
  end
52
54
 
@@ -0,0 +1,33 @@
1
+ require 'fileutils'
2
+
3
+ class ContentCommand < CmdParse::Command
4
+
5
+
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'
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'
26
+ Spider::StaticContent.compress(*args)
27
+ end
28
+
29
+ self.add_command(compress)
30
+
31
+ end
32
+
33
+ end