zena 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/.gitignore +2 -0
  2. data/History.txt +12 -0
  3. data/app/controllers/application_controller.rb +0 -1
  4. data/app/controllers/columns_controller.rb +11 -1
  5. data/app/controllers/nodes_controller.rb +79 -19
  6. data/app/controllers/versions_controller.rb +0 -2
  7. data/app/controllers/virtual_classes_controller.rb +19 -6
  8. data/app/models/column.rb +5 -1
  9. data/app/models/comment.rb +1 -6
  10. data/app/models/node.rb +21 -3
  11. data/app/models/role.rb +21 -0
  12. data/app/models/site.rb +7 -2
  13. data/app/models/template.rb +3 -3
  14. data/app/models/text_document.rb +4 -4
  15. data/app/models/user.rb +21 -8
  16. data/app/views/columns/_li.html.erb +1 -0
  17. data/app/views/nodes/_groups.rhtml +1 -1
  18. data/app/views/sites/_form.erb +3 -1
  19. data/app/views/sites/_li.erb +1 -0
  20. data/app/views/sites/index.erb +1 -1
  21. data/app/views/virtual_classes/_form.erb +11 -2
  22. data/app/views/virtual_classes/_li.erb +5 -2
  23. data/bin/zena +1 -1
  24. data/bricks/math/lib/bricks/math.rb +1 -1
  25. data/bricks/mongrel/README +3 -0
  26. data/bricks/mongrel/zena/deploy.rb +56 -0
  27. data/bricks/passenger/README +3 -0
  28. data/bricks/passenger/zena/deploy.rb +49 -0
  29. data/config/bricks.yml +6 -0
  30. data/config/deploy.rb +24 -18
  31. data/config/gems.yml +3 -3
  32. data/db/migrate/20100915062903_add_api_group_id_to_site.rb +9 -0
  33. data/lib/tasks/zena.rake +39 -35
  34. data/lib/zena.rb +5 -6
  35. data/lib/zena/acts/enrollable.rb +37 -6
  36. data/lib/zena/app.rb +4 -2
  37. data/lib/zena/deploy.rb +110 -150
  38. data/lib/zena/deploy/awstats.conf.rhtml +4 -4
  39. data/lib/zena/deploy/httpd.rhtml +2 -1
  40. data/lib/zena/deploy/stats.vhost.rhtml +7 -7
  41. data/lib/zena/deploy/vhost.rhtml +1 -1
  42. data/lib/zena/deploy/vhost_www.rhtml +4 -4
  43. data/lib/zena/foxy_parser.rb +6 -5
  44. data/lib/zena/info.rb +1 -1
  45. data/lib/zena/integration/test_case.rb +8 -3
  46. data/lib/zena/parser.rb +11 -11
  47. data/lib/zena/parser/zafu_tags.rb +2 -2
  48. data/lib/zena/remote.rb +16 -0
  49. data/lib/zena/remote/connection.rb +67 -0
  50. data/lib/zena/remote/interface.rb +405 -0
  51. data/lib/zena/remote/klass.rb +14 -0
  52. data/lib/zena/remote/mock.rb +58 -0
  53. data/lib/zena/remote/node.rb +76 -0
  54. data/lib/zena/routes.rb +2 -1
  55. data/lib/zena/use.rb +9 -4
  56. data/lib/zena/use/ajax.rb +3 -3
  57. data/lib/zena/use/authlogic.rb +8 -1
  58. data/lib/zena/use/context.rb +22 -21
  59. data/lib/zena/use/dates.rb +26 -3
  60. data/lib/zena/use/display.rb +33 -5
  61. data/lib/zena/use/forms.rb +90 -12
  62. data/lib/zena/use/fulltext.rb +1 -1
  63. data/lib/zena/use/i18n.rb +118 -31
  64. data/lib/zena/use/query_builder.rb +7 -5
  65. data/lib/zena/use/query_node.rb +30 -4
  66. data/lib/zena/use/rendering.rb +1 -1
  67. data/lib/zena/use/search.rb +10 -7
  68. data/lib/zena/use/urls.rb +3 -3
  69. data/lib/zena/use/zafu_attributes.rb +2 -2
  70. data/lib/zena/use/zafu_eval.rb +1 -1
  71. data/lib/zena/use/zafu_safe_definitions.rb +1 -0
  72. data/lib/zena/use/zafu_templates.rb +1 -1
  73. data/lib/zena/zafu_compiler.rb +5 -1
  74. data/public/javascripts/zena.js +4 -4
  75. data/public/stylesheets/admin.css +1 -0
  76. data/test/custom_queries/complex.host.yml +3 -3
  77. data/test/fixtures/files/translations_fr.yml +4 -1
  78. data/test/functional/application_controller_test.rb +2 -2
  79. data/test/functional/nodes_controller_test.rb +57 -5
  80. data/test/functional/users_controller_test.rb +10 -9
  81. data/test/functional/virtual_classes_controller_test.rb +48 -0
  82. data/test/integration/navigation_test.rb +13 -1
  83. data/test/integration/query_node/filters.yml +5 -0
  84. data/test/integration/query_node_test.rb +1 -1
  85. data/test/integration/zafu_compiler/ajax.yml +13 -19
  86. data/test/integration/zafu_compiler/basic.yml +0 -72
  87. data/test/integration/zafu_compiler/complex.yml +1 -1
  88. data/test/integration/zafu_compiler/complex_ok.yml +19 -0
  89. data/test/integration/zafu_compiler/dates.yml +62 -1
  90. data/test/integration/zafu_compiler/display.yml +4 -4
  91. data/test/integration/zafu_compiler/forms.yml +19 -7
  92. data/test/integration/zafu_compiler/i18n.yml +56 -1
  93. data/test/integration/zafu_compiler/later.yml +23 -1
  94. data/test/integration/zafu_compiler/relations.yml +1 -1
  95. data/test/integration/zafu_compiler/roles.yml +29 -1
  96. data/test/integration/zafu_compiler/safe_definitions.yml +1 -1
  97. data/test/integration/zafu_compiler/zafu_attributes.yml +2 -1
  98. data/test/integration/zafu_compiler_test.rb +5 -3
  99. data/test/sites/zena/columns.yml +3 -0
  100. data/test/sites/zena/roles.yml +0 -1
  101. data/test/sites/zena/sites.yml +1 -0
  102. data/test/sites/zena/versions.yml +2 -0
  103. data/test/unit/node_test.rb +27 -9
  104. data/test/unit/relation_proxy_test.rb +7 -4
  105. data/test/unit/remote_test.rb +379 -0
  106. data/test/unit/user_test.rb +47 -0
  107. data/test/unit/zena/acts/enrollable_test.rb +36 -7
  108. data/test/unit/zena/acts/serializable_test.rb +14 -2
  109. data/test/unit/zena/use/i18n_test.rb +32 -5
  110. data/test/unit/zena/use/query_node_test.rb +13 -1
  111. data/zena.gemspec +25 -11
  112. metadata +24 -10
@@ -43,7 +43,7 @@ class TextDocument < Document
43
43
  return text
44
44
  end
45
45
 
46
- current_dir = parent.fullpath
46
+ base_path = parent.fullpath
47
47
 
48
48
  res.gsub!(/url\(\s*(.*?)\s*\)/) do
49
49
  match, src = $&, $1
@@ -71,7 +71,7 @@ class TextDocument < Document
71
71
  else
72
72
  if new_src = helper.send(:template_url_for_asset,
73
73
  :src => src,
74
- :base_path => current_dir,
74
+ :base_path => base_path,
75
75
  :parse_assets => true )
76
76
 
77
77
  "url(#{quote}#{new_src}#{quote})"
@@ -118,7 +118,7 @@ class TextDocument < Document
118
118
  if key == 'text' && prop['content_type'] == 'text/css'
119
119
  res = text.dup
120
120
  # use parent as relative root
121
- current_dir = parent.fullpath
121
+ base_path = parent.fullpath
122
122
 
123
123
  res.gsub!(/url\(('|")(.*?)\1\)/) do
124
124
  if $2[0..6] == 'http://'
@@ -128,7 +128,7 @@ class TextDocument < Document
128
128
  if url =~ /\A\/\w\w\/.*?(\d+)(_\w+|)\./
129
129
  zip, mode = $1, $2
130
130
  if asset = secure(Node) { Node.find_by_zip(zip) }
131
- if asset.fullpath =~ /\A#{current_dir}\/(.+)/
131
+ if asset.fullpath =~ /\A#{base_path}\/(.+)/
132
132
  "url(#{quote}#{$1}#{mode}.#{asset.prop['ext']}#{quote})"
133
133
  else
134
134
  "url(#{quote}/#{asset.fullpath}#{mode}.#{asset.prop['ext']}#{quote})"
data/app/models/user.rb CHANGED
@@ -192,6 +192,11 @@ class User < ActiveRecord::Base
192
192
  status == User::Status[:deleted]
193
193
  end
194
194
 
195
+ # Return true if the visitor is allowed API acces
196
+ def api_authorized?
197
+ group_ids.include?(current_site.api_group_id)
198
+ end
199
+
195
200
  # Returns a list of the group ids separated by commas for the user (this is used mainly in SQL clauses).
196
201
  # TODO: Performance
197
202
  #
@@ -199,9 +204,18 @@ class User < ActiveRecord::Base
199
204
  # Zena::Db.fetch_ids("SELECT group_id FROM groups_users WHERE user_id = #{id} ORDER BY name ASC", 'group_id')
200
205
  def group_ids
201
206
  @group_ids ||= if is_admin?
202
- site.groups.map{|g| g[:id]}
207
+ site.groups.map(&:id)
208
+ else
209
+ groups.all(:order=>'name').map(&:id)
210
+ end
211
+ end
212
+
213
+ # Return all groups (used in forms) managed by the user.
214
+ def all_groups
215
+ if is_admin?
216
+ site.groups
203
217
  else
204
- groups.find(:all, :order=>'name').map{ |g| g[:id] }
218
+ groups.all(:order=>'name').map(&:id)
205
219
  end
206
220
  end
207
221
 
@@ -265,13 +279,12 @@ class User < ActiveRecord::Base
265
279
 
266
280
  @contact = secure!(BaseContact) { BaseContact.new(
267
281
  # owner is the user except for anonymous and super user.
268
- # TODO: not sure this is a good idea...
269
- :user_id => (self[:id] == site[:anon_id] || self[:id] == site[:su_id]) ? visitor[:id] : self[:id],
282
+ :user_id => visitor[:id],
270
283
  :title => (name.blank? || first_name.blank?) ? login : fullname,
271
284
  :first_name => first_name,
272
- :name => (name || login ),
285
+ :name => (name || login),
273
286
  :email => email,
274
- :v_status => Zena::Status[:pub]
287
+ :v_status => Zena::Status[:pub]
275
288
  )}
276
289
 
277
290
  @contact[:parent_id] = site[:root_id]
@@ -360,8 +373,8 @@ class User < ActiveRecord::Base
360
373
  g_ids.compact!
361
374
  self.groups = []
362
375
  g_ids.each do |id|
363
- group = Group.find(id)
364
- unless site.being_created? || group.site_id == self.site_id
376
+ group = Group.find(:first, :conditions => {:id => id})
377
+ unless group && (group.site_id == self.site_id || site.being_created?)
365
378
  errors.add('group', 'not found')
366
379
  next
367
380
  end
@@ -4,6 +4,7 @@
4
4
  :url => edit_column_path(li),
5
5
  :method => :get) %></td>
6
6
  <td class='ruby'>
7
+ <span class='spacer'><%= (li.role.kind_of?(VirtualClass) ? '+ ' : '<span>* </span>') %></span>
7
8
  <span class='constant'><%= li.role.name %></span>
8
9
  <span class='text'>p.<%= li.ptype %></span>
9
10
  <span class='string'>'<%= li.name %>'<span><%= li.import_result ? " (#{li.import_result})" : ''%><% if !li.index.blank? -%>, <span class='symbol'>:index</span> =&gt; <span class='symbol'>:<%= li.index %></span><% end -%>
@@ -15,7 +15,7 @@
15
15
  <li><label><%= _('publishers') %></label><%= select('node', 'dgroup_id', form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li>
16
16
  <li><label><%= _('writers') %></label><%= select('node', 'wgroup_id', form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li>
17
17
  <li><label><%= _('readers') %></label><%= select('node', 'rgroup_id', form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li>
18
- <li><label><%= _('skin') %></label><%= select('node', 'skin', form_skins,{}, {:disabled=>(@node[:inherit] == 1)}) %></li>
18
+ <li><label><%= _('skin') %></label><%= select('node', 'skin_id', form_skins, {}, {:disabled=>(@node[:inherit] == 1)}) %></li>
19
19
  <li class='submit'><%= submit_tag _('change') %></li>
20
20
  </form>
21
21
  <% else %>
@@ -5,7 +5,7 @@
5
5
  link_to_function _('btn_x'), "['add_site', 'add_site_form'].each(Element.toggle)"
6
6
  end %>
7
7
  </td>
8
- <td class='add' colspan='8'>
8
+ <td class='add' colspan='9'>
9
9
  <div id='site_errors'><%= error_messages_for(:site, :object => @site) %></div>
10
10
  <% unless @site.new_record? %>
11
11
  <%= form_remote_tag(:url => site_path(@site), :method => :put ) %>
@@ -20,6 +20,8 @@
20
20
  <tr><td class='label'><%= _('redit_time') %></td><td><%= text_field('site', :redit_time, :size=>15, :value => @site.redit_time) %></td></tr>
21
21
  <tr><td class='label'><%= _('public group') %></td><td><%= @site.public_group.name %></td></tr>
22
22
  <tr><td class='label'><%= _('site group') %></td><td><%= @site.site_group.name %></td></tr>
23
+ <tr><td class='label'><%= _('API group') %></td><td><%= select('site', 'api_group_id', visitor.all_groups.map{|g| [g.name, g.id]}, {:include_blank => true, :selected => @site.api_group_id} ) %></td></tr>
24
+
23
25
  <tr><td class='label'><%= _('options') %></td><td>
24
26
  <% Site.attributes_for_form[:bool].each do |sym| -%>
25
27
  <input type='hidden' name='site[<%= sym %>]' value=''/>
@@ -8,6 +8,7 @@
8
8
  <% end -%>
9
9
  <td class='public_group'><%= li.public_group.name %></td>
10
10
  <td class='site_group' ><%= li.site_group.name %></td>
11
+ <td class='api_group' ><%= li.api_group ? li.api_group.name : _('no API') %></td>
11
12
  <td class='redit_time' ><%= li.redit_time %></td>
12
13
  <td class='options'><%= Site.attributes_for_form[:bool].reject{|sym| !li.send(sym)}.join(', ') %></td>
13
14
  </tr>
@@ -1,6 +1,6 @@
1
1
  <h2 class='title'><%= _('manage sites') %></h2>
2
2
 
3
3
  <table id='site_list' class='admin' cellspacing="0">
4
- <tr><th class='nav' colspan='9'><%= will_paginate @sites %>
4
+ <tr><th class='nav' colspan='10'><%= will_paginate @sites %>
5
5
  <%= render :partial=>'sites/li', :collection=>@sites %>
6
6
  </table>
@@ -14,13 +14,22 @@
14
14
  <% end %>
15
15
  <table cellspacing='0' class='edit_virtual_class'>
16
16
  <tr><td class='label'><%= _('name')%> </td><td><%= text_field('virtual_class', 'name', :size=>15 ) %></td></tr>
17
- <tr><td class='label'><%= _('superclass')%></td><td><%= select('virtual_class', 'superclass', Node.classes_for_form(:without => (@virtual_class.new_record? ? nil : @virtual_class.to_s)), :selected => @virtual_class.superclass.to_s ) %></td></tr>
17
+ <tr>
18
+ <td class='label'><%= _('type')%> </td>
19
+ <% if @virtual_class.new_record? %><td>
20
+ <%= select('virtual_class', 'type', ['Class', 'Role'], :selected => 'Class' ) %></td>
21
+ <% else -%>
22
+ <td><%= @virtual_class.kind_of?(VirtualClass) ? 'Class' : 'Role' %></td>
23
+ <% end -%>
24
+ </tr>
25
+
26
+ <tr><td class='label'><%= _('superclass')%></td><td><%= select('virtual_class', 'superclass', Node.classes_for_form(:without => ((@virtual_class.new_record? || @virtual_class.kind_of?(Role)) ? nil : @virtual_class.to_s)), :selected => @virtual_class.superclass.to_s ) %></td></tr>
18
27
 
19
28
  <% Zena::Use::Fulltext::FULLTEXT_FIELDS.reverse_each do |fld| -%>
20
29
  <tr><td class='label'><%= _(fld)%></td><td><%= text_area('virtual_class', fld, :rows => 2, :cols => 30) %></td></tr>
21
30
  <% end -%>
22
31
 
23
- <tr><td class='label'><%= _('create group')%></td><td><%= select('virtual_class', 'create_group_id', visitor.groups.map{|g| [g.name, g.id]} ) %></td></tr>
32
+ <tr><td class='label'><%= _('create group')%></td><td><%= select('virtual_class', 'create_group_id', visitor.all_groups.map{|g| [g.name, g.id]} ) %></td></tr>
24
33
  <tr><td class='label'><%= _('auto create discussion')%></td><td><%= check_box('virtual_class', 'auto_create_discussion') %></td></tr>
25
34
  <tr><td class='label'><%= _('icon')%> </td><td><%= text_field('virtual_class', 'icon', :size=>15 ) %></td></tr>
26
35
  <tr><td colspan='3'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr>
@@ -1,7 +1,7 @@
1
1
  <% if li.kind_of?(Class) -%>
2
2
  <tr class='real_class'>
3
3
  <td class="adm_icon"><%= _('virtual_class_img') %></td>
4
- <td class='ruby'><span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') %></span><span class='constant'><%= li.name %></span></td>
4
+ <td class='ruby'><span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') + '+ ' %></span><span class='constant'><%= li.name %></span></td>
5
5
  <td>&nbsp;</td>
6
6
  <td class="auto_create_discussion" >&nbsp;</td>
7
7
  </tr>
@@ -11,7 +11,10 @@
11
11
  :update =>"virtual_class#{li[:id]}",
12
12
  :url => edit_virtual_class_path(li),
13
13
  :method => :get) %></td>
14
- <td class='ruby'><span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') %></span><span class='constant'><%= li.name %><%= li.import_result ? " (#{li.import_result})" : ''%></span></td>
14
+ <td class='ruby'>
15
+ <span class='spacer'><%= li.kpath[1..-1].gsub(/./, '| ') %><%= li.kind_of?(VirtualClass) ? '+ ' : '| <span>* </span>' %></span>
16
+ <span class='constant'><%= li.name %><%= (li.kind_of?(VirtualClass) && li.import_result) ? " (#{li.import_result})" : ''%></span>
17
+ </td>
15
18
  <td class='idx'><%= Zena::Use::Fulltext::FULLTEXT_FIELDS.map {|fld| li[fld].blank? ? nil : fld.gsub('idx_text_','')}.compact.join(', ') %>
16
19
  <td class="auto_create_discussion" ><%= li.auto_create_discussion ? _('auto discussion') : '' %></td>
17
20
  </tr>
data/bin/zena CHANGED
@@ -19,4 +19,4 @@ Rails::Generator::Base.use_application_sources!
19
19
  Rails::Generator::Scripts::Generate.new.run(
20
20
  args,
21
21
  :generator => 'app'
22
- )
22
+ )
@@ -26,7 +26,7 @@ module Bricks
26
26
  filename = math_id + '.png'
27
27
  filepath = node.asset_path(filename)
28
28
  unless File.exist?(filepath)
29
- if opts[:preview]
29
+ if !Bricks::CONFIG['math']['live'] && opts[:preview]
30
30
  # do not render image during preview
31
31
  tag = content =~ /\n/ ? 'pre' : 'span'
32
32
  return "<#{tag} class='math_preview'>#{content}</#{tag}>"
@@ -0,0 +1,3 @@
1
+ This brick contains rules to deploy a Zena application by using a Mongrel cluster and load balancing.
2
+
3
+ You should enable this brick if and only if you intend to deploy your application with Mongrel.
@@ -0,0 +1,56 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ brick_deploy = :mongrel
3
+ if self[:app_type] != brick_deploy
4
+ puts %Q{##############################################################################
5
+ ERROR: Loading '#{brick_deploy}' deploy rules when deploying with #{app_type}
6
+ incompatibility between config/bricks.yml (enabled #{brick_deploy} brick) and
7
+ config/deploy.rb (:app_type = #{app_type})
8
+ ##############################################################################}
9
+ else
10
+ #========================== MONGREL ===============================#
11
+ namespace :app do
12
+
13
+ desc "configure mongrel"
14
+ task :configure, :roles => :app do
15
+ run "#{in_current} mongrel_rails cluster::configure -e production -p #{mongrel_port} -N #{mongrel_count} -c #{deploy_to}/current -P log/mongrel.pid -l log/mongrel.log -a 127.0.0.1 --user www-data --group www-data"
16
+ run "#{in_current} echo 'config_script: config/mongrel_upload_progress.conf' >> config/mongrel_cluster.yml"
17
+ end
18
+
19
+ desc "Stop the drb upload_progress server"
20
+ task :upload_progress_stop , :roles => :app do
21
+ run "#{in_current} ruby lib/upload_progress_server.rb stop"
22
+ end
23
+
24
+ desc "Start the drb upload_progress server"
25
+ task :upload_progress_start , :roles => :app do
26
+ run "#{in_current} lib/upload_progress_server.rb start"
27
+ end
28
+
29
+ desc "Restart the upload_progress server"
30
+ task :upload_progress_restart, :roles => :app do
31
+ upload_progress_stop
32
+ upload_progress_start
33
+ end
34
+
35
+ desc "Restart mongrels"
36
+ task :restart, :roles => :app do
37
+ stop
38
+ start
39
+ end
40
+
41
+ desc "Start mongrels"
42
+ task :start, :roles => :app do
43
+ configure
44
+ upload_progress_start
45
+ run "#{in_current} mongrel_rails cluster::start"
46
+ end
47
+
48
+ desc "Stop mongrels"
49
+ task :stop, :roles => :app do
50
+ configure
51
+ upload_progress_stop
52
+ run "#{in_current} mongrel_rails cluster::stop"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ This brick contains rules to deploy a Zena application by using Passenger.
2
+
3
+ You should enable this brick if and only if you intend to deploy your application with Passenger.
@@ -0,0 +1,49 @@
1
+ # Passenger deployment recipes
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ brick_deploy = :passenger
4
+
5
+ if self[:app_type] != brick_deploy
6
+ puts %Q{##############################################################################
7
+ ERROR: Loading '#{brick_deploy}' deploy rules when deploying with #{app_type}
8
+ incompatibility between config/bricks.yml (enabled #{brick_deploy} brick) and
9
+ config/deploy.rb (:app_type = #{app_type})
10
+ ##############################################################################}
11
+ else
12
+ namespace :upload_progress do
13
+ desc "Build and install upload progress extension for Apache2"
14
+ task :setup, :roles => :app do
15
+ tmp_dir = "/tmp/mod_upload_progress.tmp"
16
+ c_file = File.read("#{Zena::ROOT}/vendor/apache2_upload_progress/mod_upload_progress.c")
17
+ run "test -e #{tmp_dir} || mkdir #{tmp_dir}"
18
+ put c_file, "#{tmp_dir}/mod_upload_progress.c"
19
+ run "cd #{tmp_dir} && apxs2 -c -i mod_upload_progress.c && rm -rf #{tmp_dir}"
20
+ end
21
+ end
22
+
23
+ before "zena:setup", "upload_progress:setup"
24
+
25
+ namespace :app do
26
+
27
+ desc "Restart Passenger app"
28
+ task :restart, :roles => :app do
29
+ stop
30
+ start
31
+ end
32
+
33
+ desc "Start Passenger app"
34
+ task :start, :roles => :app do
35
+ run "#{in_current} touch tmp/restart.txt"
36
+ end
37
+
38
+ desc "Stop Passenger app (only halt upload DRB)"
39
+ task :stop, :roles => :app do
40
+ # Cannot stop
41
+ end
42
+
43
+ desc "Kill Passenger spawner"
44
+ task :kill, :roles => :app do
45
+ run "kill $( passenger-memory-stats | grep 'Passenger spawn server' | awk '{ print $1 }' )"
46
+ end
47
+ end
48
+ end
49
+ end
data/config/bricks.yml CHANGED
@@ -5,6 +5,9 @@ test:
5
5
  worker: OFF
6
6
 
7
7
  development:
8
+ math:
9
+ switch: ON
10
+ live: ON
8
11
  tags: ON
9
12
  captcha: ON
10
13
  sphinx:
@@ -21,6 +24,9 @@ development:
21
24
  data2pdf: ON
22
25
 
23
26
  production:
27
+ math:
28
+ switch: ON
29
+ live: ON
24
30
  tags: ON
25
31
  captcha: ON
26
32
  sphinx:
data/config/deploy.rb CHANGED
@@ -1,24 +1,27 @@
1
- set :db_name, "zena" # If you change this: no dots in this name !
2
- set :server_ip, nil # FIXME: set this to your remote server IP in the form: "215.0.0.1"
3
- set :mongrel_port, "8000"
4
- set :mongrel_count, "3"
5
- set :db_password, nil # FIXME: set password (can be anything).
6
- set :db_user, "zena"
7
- set :repository, "http://svn.zenadmin.org/zena/trunk"
1
+ set :db_name, "zena" # If you change this: no dots in this name !
2
+ set :server_ip, nil # FIXME: set this to your remote server IP in the form: "215.0.0.1"
3
+ set :app_type, :passenger
4
+ set :db_password, nil # FIXME: set password (can be anything).
5
+
6
+ # You need to give the public key from the server to the git repository if the application is not public
7
+ set :scm, 'git'
8
+ set :repository, 'git@github.com:YOUR_PROJECT/APPLICATION.git'
9
+ set :branch, 'master'
8
10
 
9
11
  if self[:server_ip]
10
12
  #================= ADVANCED SETTINGS =============#
11
13
 
12
- set :deploy_to, "/var/zena"
13
- set :sites_root, "/var/www/zena"
14
- set :vhost_root, "/etc/apache2/sites-available"
15
- set :deflate, true
16
- set :debug_deflate, false
17
- set :debug_rewrite, false
18
- set :static, []
19
- set :apache2_reload_cmd, "/etc/init.d/apache2 reload"
20
- set :debian_host, true
21
- set :ssh_user, "root"
14
+ set :deploy_to, "/home/#{db_name}/app"
15
+ set :sites_root, "/home/#{db_name}/sites"
16
+
17
+ set :vhost_root, "/etc/apache2/sites-available"
18
+ set :deflate, true
19
+ set :debug_deflate, false
20
+ set :debug_rewrite, false
21
+ set :static, []
22
+ set :apache2_reload_cmd, "/etc/init.d/apache2 reload"
23
+ set :debian_host, true
24
+ set :ssh_user, "root"
22
25
 
23
26
  role :web, "#{ssh_user}@#{server_ip}"
24
27
  role :app, "#{ssh_user}@#{server_ip}"
@@ -33,13 +36,16 @@ if self[:server_ip]
33
36
  ::RAILS_ENV = 'production'
34
37
  end
35
38
 
36
- # This file is copied into zena applications.
37
39
  deploy_path = "#{RAILS_ROOT}/lib/zena/deploy"
38
40
  if File.exist?("#{deploy_path}.rb")
39
41
  # We are running directly inside zena
40
42
  require deploy_path
41
43
  else
42
44
  # Zena app, using zena as gem
45
+ env = File.read(File.join(File.dirname(__FILE__), 'environment.rb'))
46
+ if env =~ /config.gem.*zena.*version.*'(.*?)'/
47
+ gem 'zena', "= #{$1}"
48
+ end
43
49
  require 'zena/deploy'
44
50
  end
45
51
 
data/config/gems.yml CHANGED
@@ -12,12 +12,12 @@ will_paginate: '~> 2.3.12'
12
12
  differ: '>= 0.1.1'
13
13
  shoulda: '>= 2.10.2'
14
14
 
15
- querybuilder: '>= 0.8.0'
15
+ querybuilder: '>= 0.9.0'
16
16
  yamltest: '>= 0.7.0'
17
- rubyless: '>= 0.6.0'
17
+ rubyless: '>= 0.7.0'
18
18
  property: '>= 1.1.0'
19
19
  versions: '>= 0.3.1'
20
- zafu: '>= 0.6.2'
20
+ zafu: '>= 0.7.1'
21
21
 
22
22
  jeweler:
23
23
 
@@ -0,0 +1,9 @@
1
+ class AddApiGroupIdToSite < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :sites, :api_group_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :sites, :api_group_id
8
+ end
9
+ end