zena 1.2.2 → 1.2.3

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 (143) hide show
  1. data/History.txt +25 -0
  2. data/app/controllers/documents_controller.rb +3 -25
  3. data/app/controllers/nodes_controller.rb +34 -24
  4. data/app/controllers/user_sessions_controller.rb +5 -4
  5. data/app/controllers/versions_controller.rb +44 -17
  6. data/app/models/acl.rb +2 -7
  7. data/app/models/group.rb +6 -2
  8. data/app/models/link.rb +14 -0
  9. data/app/models/node.rb +2 -2
  10. data/app/models/site.rb +13 -4
  11. data/app/models/text_document.rb +1 -1
  12. data/app/models/user.rb +11 -2
  13. data/app/models/virtual_class.rb +1 -1
  14. data/app/views/groups/_form.rhtml +6 -6
  15. data/app/views/nodes/render_error.rhtml +15 -0
  16. data/app/views/templates/document_create_tabs/_file.rhtml +1 -1
  17. data/app/views/templates/document_create_tabs/_import.rhtml +1 -1
  18. data/app/views/templates/document_create_tabs/_template.rhtml +1 -1
  19. data/app/views/templates/document_create_tabs/_text_document.rhtml +1 -1
  20. data/app/views/templates/edit_tabs/_title.rhtml +1 -1
  21. data/app/views/zafu/default/Node-admin.zafu +1 -1
  22. data/bricks/acls/zena/test/integration/acl_integration_test.rb +2 -2
  23. data/bricks/acls/zena/test/unit/acl_test.rb +2 -1
  24. data/bricks/fs_skin/zena/migrate/20110702010330_add_fs_skin_to_idx_templates.rb +1 -0
  25. data/bricks/fs_skin/zena/skins/blog/img/style.css +4 -4
  26. data/bricks/grid/lib/bricks/grid.rb +9 -3
  27. data/bricks/passenger/zena/deploy.rb +2 -1
  28. data/bricks/pdf/lib/bricks/pdf.rb +1 -1
  29. data/bricks/tags/zena/test/zafu/tags.yml +5 -1
  30. data/bricks/zena/zena/migrate/20120904071601_change_link_status_to_float.rb +13 -0
  31. data/config/bricks.yml +10 -10
  32. data/config/deploy.rb +1 -5
  33. data/config/gems.yml +2 -2
  34. data/db/init/base/skins/default/Node.zafu +7 -3
  35. data/db/init/base/skins/default/notes.zafu +3 -1
  36. data/lib/zafu/all.rb +0 -9
  37. data/lib/zafu/compiler.rb +0 -4
  38. data/lib/zafu/controller_methods.rb +0 -2
  39. data/lib/zafu/handler.rb +0 -5
  40. data/lib/zafu/markup.rb +4 -6
  41. data/lib/zafu/ordered_hash.rb +3 -2
  42. data/lib/zafu/parsing_rules.rb +1 -3
  43. data/lib/zafu/process/ajax.rb +4 -2
  44. data/lib/zafu/process/context.rb +34 -4
  45. data/lib/zafu/process/forms.rb +2 -2
  46. data/lib/zafu/process/ruby_less_processing.rb +5 -10
  47. data/lib/zafu/template.rb +0 -2
  48. data/lib/zafu/test_helper.rb +0 -2
  49. data/lib/zafu/view_methods.rb +0 -1
  50. data/lib/zafu.rb +1 -1
  51. data/lib/zena/acts/secure_node.rb +5 -4
  52. data/lib/zena/console.rb +19 -17
  53. data/lib/zena/core_ext/string.rb +3 -2
  54. data/lib/zena/deploy/app_init.rhtml +6 -1
  55. data/lib/zena/deploy/httpd.rhtml +16 -13
  56. data/lib/zena/deploy/stats.vhost.rhtml +1 -1
  57. data/lib/zena/deploy/vhost.rhtml +31 -11
  58. data/lib/zena/deploy/vhost_ssl_redir.rhtml +12 -0
  59. data/lib/zena/deploy/vhost_www.rhtml +1 -1
  60. data/lib/zena/deploy.rb +55 -11
  61. data/lib/zena/info.rb +1 -1
  62. data/lib/zena/parser/zazen_rules.rb +18 -9
  63. data/lib/zena/routes.rb +1 -3
  64. data/lib/zena/site_worker.rb +8 -1
  65. data/lib/zena/use/ajax.rb +29 -3
  66. data/lib/zena/use/ancestry.rb +2 -1
  67. data/lib/zena/use/authlogic.rb +12 -18
  68. data/lib/zena/use/context.rb +1 -1
  69. data/lib/zena/use/dates.rb +28 -18
  70. data/lib/zena/use/display.rb +49 -7
  71. data/lib/zena/use/forms.rb +51 -18
  72. data/lib/zena/use/html_tags.rb +6 -6
  73. data/lib/zena/use/i18n.rb +13 -4
  74. data/lib/zena/use/image_builder.rb +2 -0
  75. data/lib/zena/use/query_builder.rb +39 -14
  76. data/lib/zena/use/query_link.rb +57 -0
  77. data/lib/zena/use/query_node.rb +68 -32
  78. data/lib/zena/use/relations.rb +25 -15
  79. data/lib/zena/use/rendering.rb +66 -15
  80. data/lib/zena/use/upload.rb +34 -5
  81. data/lib/zena/use/urls.rb +28 -25
  82. data/lib/zena/use/version_hash.rb +14 -2
  83. data/lib/zena/use/zafu_safe_definitions.rb +72 -3
  84. data/lib/zena/use/zazen.rb +16 -4
  85. data/lib/zena.rb +1 -0
  86. data/public/javascripts/grid.js +213 -64
  87. data/public/javascripts/raphael.js +10 -0
  88. data/public/javascripts/zena.js +146 -22
  89. data/public/stylesheets/reset.css +12 -12
  90. data/public/stylesheets/zena.css +1 -1
  91. data/test/custom_queries/complex.host.yml +19 -0
  92. data/test/fixtures/files/TestNode.zafu +40 -4
  93. data/test/functional/nodes_controller_test.rb +84 -39
  94. data/test/functional/versions_controller_test.rb +2 -2
  95. data/test/integration/navigation_test.rb +61 -35
  96. data/test/integration/query_node/basic.yml +7 -7
  97. data/test/integration/query_node/comments.yml +1 -1
  98. data/test/integration/query_node/complex.yml +3 -3
  99. data/test/integration/query_node/filters.yml +32 -8
  100. data/test/integration/query_node/idx_key_value.yml +10 -10
  101. data/test/integration/query_node/idx_scope.yml +7 -7
  102. data/test/integration/query_node/relations.yml +4 -4
  103. data/test/integration/zafu_compiler/ajax.yml +19 -11
  104. data/test/integration/zafu_compiler/apphelper.yml +1 -1
  105. data/test/integration/zafu_compiler/asset.yml +2 -2
  106. data/test/integration/zafu_compiler/comments.yml +1 -1
  107. data/test/integration/zafu_compiler/dates.yml +1 -1
  108. data/test/integration/zafu_compiler/display.yml +49 -21
  109. data/test/integration/zafu_compiler/eval.yml +4 -4
  110. data/test/integration/zafu_compiler/forms.yml +25 -11
  111. data/test/integration/zafu_compiler/i18n.yml +5 -0
  112. data/test/integration/zafu_compiler/meta.yml +3 -3
  113. data/test/integration/zafu_compiler/query.yml +27 -9
  114. data/test/integration/zafu_compiler/relations.yml +9 -9
  115. data/test/integration/zafu_compiler/roles.yml +6 -6
  116. data/test/integration/zafu_compiler/rubyless.yml +7 -2
  117. data/test/integration/zafu_compiler/safe_definitions.yml +33 -4
  118. data/test/integration/zafu_compiler/security.yml +46 -1
  119. data/test/integration/zafu_compiler/urls.yml +28 -13
  120. data/test/integration/zafu_compiler/user.yml +12 -7
  121. data/test/integration/zafu_compiler/zafu_attributes.yml +1 -1
  122. data/test/integration/zafu_compiler/zazen.yml +5 -5
  123. data/test/integration/zafu_compiler_test.rb +18 -0
  124. data/test/selenium/Filter/filter3.rsel +20 -0
  125. data/test/selenium/Filter/filter4.rsel +20 -0
  126. data/test/sites/zena/versions.yml +2 -0
  127. data/test/unit/exif_data_test.rb +6 -1
  128. data/test/unit/group_test.rb +18 -3
  129. data/test/unit/node_test.rb +0 -7
  130. data/test/unit/project_test.rb +4 -0
  131. data/test/unit/relation_proxy_test.rb +2 -2
  132. data/test/unit/remote_test.rb +0 -9
  133. data/test/unit/role_test.rb +1 -1
  134. data/test/unit/string_hash_test.rb +1 -1
  135. data/test/unit/text_document_test.rb +13 -13
  136. data/test/unit/zena/use/html_tags_test.rb +6 -6
  137. data/test/unit/zena/use/rendering_test.rb +20 -10
  138. data/test/unit/zena/use/urls_test.rb +21 -18
  139. data/test/unit/zena/use/zafu_template_test.rb +0 -5
  140. data/test/unit/zena/use/zazen_test.rb +25 -25
  141. data/zena.gemspec +63 -57
  142. metadata +136 -130
  143. data/test/functional/nodes_controller_commit_test.rb +0 -67
@@ -22,14 +22,14 @@ form .date_box { float:none;}
22
22
  #navigation #search { float:right;}
23
23
 
24
24
  #main {float:left; width:530px; padding:10px; margin-left:50px; line-height:14px; }
25
- #right h2 {margin-top:10px; font:bold 12px Verdana, 'Trebuchet MS', Sans-serif; padding:5px 0 5px 5px; border-bottom:1px dotted #999; }
26
- #right ul {color:#999; text-align:left; margin:3px 0 8px 0; padding-left:20px; text-decoration:none; list-style-type:square; }
27
- #right ul li {padding:2px 0 2px 0px; margin:0 2px; }
25
+ #right h2 {margin-top:10px; font:bold 12px Verdana, 'Trebuchet MS', Sans-serif; padding:5px 0 5px 5px; border-bottom:1px dotted #999; }
26
+ #right ul {color:#999; text-align:left; margin:3px 0 8px 0; padding-left:20px; text-decoration:none; list-style-type:square; }
27
+ #right ul li {padding:2px 0 2px 0px; margin:0 2px; }
28
28
  #right ul a {font-weight:600; color:#173D7F; }
29
29
  #right ul a:hover { color :#333; }
30
30
 
31
31
  #right { clear:right; float:right; width:130px; padding:5px; margin-right:20px; }
32
- #right h2 {padding:2px 0 5px 0px; font:bold 14px Verdana, 'Trebuchet MS', Sans-serif; color:#444; border-bottom:1px dotted #999; margin-bottom:5px; margin-top:10px; }
32
+ #right h2 {padding:2px 0 5px 0px; font:bold 14px Verdana, 'Trebuchet MS', Sans-serif; color:#444; border-bottom:1px dotted #999; margin-bottom:5px; margin-top:10px; }
33
33
  #right div { clear:both;}
34
34
 
35
35
  #lcomments li,#lcomments ul { list-style-type:none; margin:0;padding:0; color:#444;}
@@ -51,10 +51,11 @@ module Bricks
51
51
 
52
52
  res = prefix + error.to_s
53
53
  uuid = UUIDTools::UUID.random_create.to_s.gsub('-','')[0..6]
54
+ dom_id = opts[:id] || "grid#{uuid}"
54
55
  msg = opts[:msg] || _('type to edit')
55
- res << "<table id='grid#{uuid}' data-a='node[#{attribute}]' data-msg='#{msg}' class='grid'>"
56
+ res << "<table id='#{dom_id}' data-a='node[#{attribute}]' data-msg='#{msg}' class='grid'>"
56
57
  if node.can_write? && !opts[:no_edit]
57
- js_data << "Grid.make('grid#{uuid}');"
58
+ js_data << "Grid.make('#{dom_id}');"
58
59
  end
59
60
 
60
61
 
@@ -105,7 +106,12 @@ module Bricks
105
106
  code = RubyLess.translate(node(Node).klass, attribute)
106
107
  msg = RubyLess.translate(self, "t('type to edit')")
107
108
  editable = @params[:edit] == 'true' ? '' : ', :no_edit => true'
108
- out "<%= make_table(:attribute => #{attribute.inspect}, :node => #{node(Node)}, :msg => #{msg}#{editable}) %>"
109
+ if dom_id = @params[:id]
110
+ id_opt = ":id => #{dom_id.inspect}, "
111
+ else
112
+ id_opt = ''
113
+ end
114
+ out "<%= make_table(#{id_opt}:attribute => #{attribute.inspect}, :node => #{node(Node)}, :msg => #{msg}#{editable}) %>"
109
115
  end
110
116
  end
111
117
  end # Grid
@@ -16,7 +16,8 @@ Capistrano::Configuration.instance(:must_exist).load do
16
16
  c_file = File.read("#{Zena::ROOT}/vendor/apache2_upload_progress/mod_upload_progress.c")
17
17
  run "test -e #{tmp_dir} || mkdir #{tmp_dir}"
18
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}"
19
+ run "cd #{tmp_dir} && apxs2 -c -i -a mod_upload_progress.c && rm -rf #{tmp_dir}"
20
+ run apache2_reload_cmd
20
21
  end
21
22
  end
22
23
 
@@ -107,7 +107,7 @@ module Bricks
107
107
  :type => 'text/html',
108
108
  # Compile html to pdf
109
109
  :disposition => 'inline',
110
- :data => "Could not render pdf file... <a href='#{debug_url}'>debug</a>"
110
+ :error => "Could not render pdf file... <a href='#{debug_url}'>debug</a>"
111
111
  }
112
112
  end
113
113
  end
@@ -42,4 +42,8 @@ tag_names:
42
42
 
43
43
  checkbox_tagged:
44
44
  src: "<r:input type='checkbox' name='tagged[blue]'/>"
45
- res: "<input type='hidden' name='node[tagged][blue]' value=''/><input type='checkbox' name='node[tagged][blue]' value='blue' checked='checked'/>"
45
+ res: "<input type='hidden' name='node[tagged][blue]' value=''/><input type='checkbox' name='node[tagged][blue]' value='blue' checked='checked'/>"
46
+
47
+ tag_cloud:
48
+ src: "<r:void do='tag_cloud from nodes in site' do='each' join=', '><r:name/> (<r:link_count/>)</r:void>"
49
+ res: "blue (2), sky (1)"
@@ -0,0 +1,13 @@
1
+ class ChangeLinkStatusToFloat < ActiveRecord::Migration
2
+ def self.up
3
+ remove_index :links, :name => "index_links_on_status"
4
+ change_column :links, :status, :float, :default => nil
5
+ add_index :links, ["status"], :name => "index_links_on_status"
6
+ end
7
+
8
+ def self.down
9
+ remove_index :links, :name => "index_links_on_status"
10
+ change_column :links, :status, :integer, :default => nil
11
+ add_index :links, ["status"], :name => "index_links_on_status"
12
+ end
13
+ end
data/config/bricks.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  test:
2
- # Integration testing does not use 'port' settings so we must use 80...
3
- asset_port: 80
2
+ # asset_port: 80
4
3
  tags: ON
5
4
  captcha: ON
6
5
  acls: ON
@@ -13,9 +12,9 @@ test:
13
12
 
14
13
 
15
14
  development:
16
- asset_port: 7999
17
- mongrel: ON
18
- passenger: OFF
15
+ # asset_port: 7999
16
+ mongrel: OFF
17
+ passenger: ON
19
18
  uv:
20
19
  switch: ON
21
20
  activate_if:
@@ -51,11 +50,12 @@ development:
51
50
  gem: 'delayed_job'
52
51
 
53
52
  production:
54
- # Port used only to provide assets during custom rendering (pdf).
55
- # We need this to avoid deadlocks.
56
- asset_port: 7999
57
- mongrel: ON
58
- passenger: OFF
53
+ # Port used only to provide assets during custom rendering (pdf).
54
+ # We need this to avoid deadlocks with round-robin based serving.
55
+ # asset_port: 7999
56
+ cache_path: '/public/cache'
57
+ mongrel: OFF
58
+ passenger: ON
59
59
  uv:
60
60
  switch: ON
61
61
  activate_if:
data/config/deploy.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  set :db_name, "zena" # If you change this: no dots in this name !
2
2
  set :server_ip, 'nil' # FIXME: set this to your remote server IP in the form: "215.0.0.1"
3
3
  set :db_password, nil # FIXME: set password (can be anything).
4
- set :app_type, :mongrel
5
- set :mongrel_port, 8000
6
- set :mongrel_count, 3
7
- set :haproxy_port, 9000
8
- set :haproxy_password, nil # If you set this, you can view stats on /_haproxy
4
+ set :app_type, :passenger
9
5
 
10
6
  # You need to give the public key from the server to the git repository if the application is not public
11
7
  set :scm, 'git'
data/config/gems.yml CHANGED
@@ -18,9 +18,9 @@ gem_plugin: # upload progress
18
18
  simple_xlsx_writer: # spreadsheet
19
19
  lib: 'simple_xlsx'
20
20
 
21
- querybuilder: '= 1.1.3'
21
+ querybuilder: '= 1.2.1'
22
22
  yamltest: '= 0.7.0'
23
- rubyless: '= 0.8.6'
23
+ rubyless: '= 0.8.8'
24
24
  property: '= 2.3.2'
25
25
  versions: '= 0.3.1'
26
26
 
@@ -58,9 +58,12 @@
58
58
  <li do='add_document'></li>
59
59
  </ol>
60
60
  </r:documents>
61
- <r:pages name='pages'><h3 do='trans'>pages</h3>
61
+
62
+ <div id='pages' do='block' do='pages'>
63
+ <h3 do='t'>pages</h3>
62
64
  <ol>
63
- <li do='each' class='li_s#{v.status}' do='link'/>
65
+ <li do='reset_sort'/>
66
+ <li do='each' sortable='true' class='li_s#{v.status}' do='link'/>
64
67
  <li do='add' before='self'/>
65
68
  <li class='inline_form' do='form'>
66
69
  <p class='node_klass'> <r:select name='klass' root_class='Page'/></p>
@@ -68,7 +71,8 @@
68
71
  <p class='btn_validate'><r:input type="submit" value='#{trans("validate")}'/></p>
69
72
  </li>
70
73
  </ol>
71
- </r:pages>
74
+ </div>
75
+
72
76
  <r:nodes where='kpath not like "ND%" and kpath not like "NP%"'><h3 do='trans'>references</h3>
73
77
  <ol>
74
78
  <li do='each' class='li_s#{v.status}' do='link'/>
@@ -1,4 +1,5 @@
1
- <div id='notes' do='posts' in='project' limit='10' order='date desc'>
1
+ <r:cache allow_query='p=\d'/>
2
+ <div id='notes' do='posts in project order by date desc limit 10 paginate p'>
2
3
  <ul class='note_list'>
3
4
  <li do='add' after='self' klass='Post' done='focus' focus='title'/>
4
5
  <li class='inline_form' do='form'>
@@ -16,5 +17,6 @@
16
17
  <r:zazen attr='text' live='true'/>
17
18
  <div class='clear'></div>
18
19
  </li>
20
+ <li><r:link page='next' do='t' text='older posts'/></li>
19
21
  </ul>
20
22
  </div>
data/lib/zafu/all.rb CHANGED
@@ -1,12 +1,3 @@
1
- require 'zafu/parsing_rules'
2
- require 'zafu/process/ajax'
3
- require 'zafu/process/html'
4
- require 'zafu/process/ruby_less_processing'
5
- require 'zafu/process/context'
6
- require 'zafu/process/conditional'
7
- require 'zafu/process/forms'
8
- require 'zafu/security'
9
-
10
1
  module Zafu
11
2
  All = [
12
3
  Zafu::ParsingRules,
data/lib/zafu/compiler.rb CHANGED
@@ -1,7 +1,3 @@
1
- require 'zafu/parser'
2
- require 'zafu/node_context'
3
- require 'zafu/all'
4
-
5
1
  module Zafu
6
2
  Compiler = Zafu.parser_with_rules(Zafu::All)
7
3
  end
@@ -1,5 +1,3 @@
1
- require 'zafu/node_context'
2
-
3
1
  module Zafu
4
2
  module ControllerMethods
5
3
  def self.included(base)
data/lib/zafu/handler.rb CHANGED
@@ -1,8 +1,3 @@
1
- require 'zafu/parser'
2
- require 'zafu/markup'
3
- require 'zafu/node_context'
4
- require 'zafu/template'
5
-
6
1
  module Zafu
7
2
  class Handler < ActionView::TemplateHandler
8
3
  include ActionView::TemplateHandlers::Compilable
data/lib/zafu/markup.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'zafu/ordered_hash'
2
-
3
1
  module Zafu
4
2
  # A Markup object is used to hold information on the tag used (<li>), it's parameters (.. class='xxx') and
5
3
  # indentation.
@@ -32,9 +30,9 @@ module Zafu
32
30
  # Parse parameters into a hash. This parsing supports multiple values for one key by creating additional keys:
33
31
  # <tag do='hello' or='goodbye' or='gotohell'> creates the hash {:do=>'hello', :or=>'goodbye', :or1=>'gotohell'}
34
32
  def parse_params(text)
35
- return OrderedHash.new unless text
33
+ return Zafu::OrderedHash.new unless text
36
34
  return text if text.kind_of?(Hash)
37
- params = OrderedHash.new
35
+ params = Zafu::OrderedHash.new
38
36
  rest = text.strip
39
37
  while (rest != '')
40
38
  if rest =~ /(.+?)=/
@@ -72,9 +70,9 @@ module Zafu
72
70
  if params
73
71
  self.params = params
74
72
  else
75
- @params = OrderedHash.new
73
+ @params = Zafu::OrderedHash.new
76
74
  end
77
- @dyn_params = OrderedHash.new
75
+ @dyn_params = Zafu::OrderedHash.new
78
76
  end
79
77
 
80
78
  # Set params either using a string (like "alt='time passes' class='zen'")
@@ -2,7 +2,7 @@ module Zafu
2
2
 
3
3
  if RUBY_VERSION.split('.')[0..1].join('.').to_f > 1.8
4
4
  OrderedHash = Hash
5
- else
5
+ elsif !defined?(OrderedHash)
6
6
  class OrderedHash < Hash
7
7
 
8
8
  def []=(k, v)
@@ -22,8 +22,9 @@ module Zafu
22
22
  res.merge!(hash)
23
23
  res
24
24
  end
25
-
25
+
26
26
  alias o_keys keys
27
+
27
28
  def get_keys
28
29
  @keys ||= o_keys
29
30
  end
@@ -1,5 +1,3 @@
1
- require 'zafu/markup'
2
-
3
1
  module Zafu
4
2
  PARAM_KEY_REGEXP = %r{^\s+([\w_\-\[\]:]+)=}m
5
3
  PARAM_VALUE_REGEXP = %r{('|")(|[^\1]*?[^\\])\1}m
@@ -26,7 +24,7 @@ module Zafu
26
24
  # This callback is run just after the block is initialized (Parser#initialize).
27
25
  def start(mode)
28
26
  # tag_context
29
- @markup = Markup.new(@options.delete(:html_tag))
27
+ @markup = Zafu::Markup.new(@options.delete(:html_tag))
30
28
 
31
29
  # html_tag
32
30
  if html_params = @options.delete(:html_tag_params)
@@ -140,7 +140,9 @@ module Zafu
140
140
  #node.dom_prefix = dom_name
141
141
  @markup.set_id(node.dom_id(:list => false))
142
142
  @markup.set_dyn_param(:"data-z", "<%= #{node}.zip %>")
143
- expand_with
143
+ # Elements inside the block should render as normal (not transforming forms into remote
144
+ # forms or things like this).
145
+ expand_with(:template_url => nil)
144
146
  elsif @context[:saved_template]
145
147
  # already in a parent's store operation. Reset scope and simply render inline elements
146
148
  # reset scope
@@ -368,7 +370,7 @@ module Zafu
368
370
 
369
371
  # Return true if we need to insert the dom id for this element.
370
372
  def need_dom_id?
371
- @context[:form] || child['unlink'] || (single_child_method && single_child_method == child['drop'])
373
+ @context[:form] || @params[:sortable] || child['unlink'] || (single_child_method && single_child_method == child['drop'])
372
374
  end
373
375
 
374
376
  # Unique template_url, ending with dom_id
@@ -6,7 +6,8 @@ module Zafu
6
6
  module Context
7
7
  def r_each
8
8
  if node.list_context?
9
- if @params[:alt_class] || @params[:join]
9
+
10
+ if @params[:alt_class] || @params[:join] || @params[:sortable]
10
11
  out "<% #{var}_max_index = #{node}.size - 1 %>" if @params[:alt_reverse]
11
12
  out "<% #{node}.each_with_index do |#{var},#{var}_index| %>"
12
13
 
@@ -34,11 +35,30 @@ module Zafu
34
35
  end
35
36
 
36
37
  raw_dom_prefix = node.raw_dom_prefix
38
+ query = node.opts[:query]
37
39
 
38
40
  with_context(:node => node.move_to(var, node.klass.first, :query => node.opts[:query])) do
39
41
  # We pass the :query option for RubyLess resolution by using the QueryBuilder finder
42
+
43
+ before_wrap = ''
40
44
 
41
45
  steal_and_eval_html_params_for(@markup, @params)
46
+ if s = @params[:sortable]
47
+ unless sort_attr = @params.delete(:sort_attr)
48
+ if query
49
+ sort_attr = query.select_keys.include?('l_status') ? 'l_status' : 'position'
50
+ else
51
+ sort_attr = 'position'
52
+ end
53
+ end
54
+ @markup.set_param(:'data-a', sort_attr)
55
+ @markup.set_dyn_param(:'data-p', "<%= #{node}.#{RubyLess.translate(node.klass, sort_attr)} %>")
56
+ s = 'drag_handle' if s == 'true'
57
+ unless s == 'all' || @blocks.detect{|b| b.kind_of?(String) ? b =~ /class=.#{s}/ : (b.params[:class] == s || (b.markup && b.markup.params[:class] == s))}
58
+ before_wrap << "<span class='#{s}'>&nbsp;</span>"
59
+ end
60
+ end
61
+
42
62
  # The id set here should be used as prefix for sub-nodes to ensure uniqueness of generated DOM ids
43
63
  if node.list_context?
44
64
  # we are still in a list (example: previous context was [[Node]], current is [Node])
@@ -47,12 +67,22 @@ module Zafu
47
67
  node.dom_prefix = dom_name unless raw_dom_prefix
48
68
  node.propagate_dom_scope!
49
69
 
50
- if need_dom_id?
70
+ if need_dom_id? || @params[:sortable]
51
71
  @markup.set_id(node.dom_id)
52
72
  end
53
73
  end
54
-
55
- out wrap(expand_with)
74
+
75
+ if s = @params[:sortable]
76
+ if s == 'all'
77
+ # drag full element
78
+ before_wrap << %Q{<% if #{var}_index == 0; js_data << "Zena.sortable('#{node.dom_id(:erb => false)}')" end %>}
79
+ else
80
+ # drag element with given class
81
+ s = 'drag_handle' if s == 'true'
82
+ before_wrap << %Q{<% if #{var}_index == 0; js_data << "Zena.sortable('#{node.dom_id(:erb => false)}', {handle:'#{s}'})" end %>}
83
+ end
84
+ end
85
+ out wrap(before_wrap + expand_with)
56
86
  end
57
87
  out "<% end %>"
58
88
  else
@@ -73,7 +73,7 @@ module Zafu
73
73
  # Return id, style, form and cancel parts of the form.
74
74
  def form_options
75
75
  opts = {}
76
-
76
+
77
77
  # Do we need this ?
78
78
  # opts[:klass] = node.master_class(ActiveRecord::Base).to_s
79
79
 
@@ -85,7 +85,7 @@ module Zafu
85
85
  opts[:id] = "#{node.dom_prefix}_tbl"
86
86
  form_id = node.dom_prefix
87
87
  end
88
-
88
+
89
89
  form_id ||= "#{node.dom_prefix}_form_t"
90
90
  if @context[:template_url]
91
91
  opts[:form_tag] = "<% remote_form_for(:#{node.form_name}, #{node}, :html => {:id => #{form_id.inspect}}) do |f| %>"
@@ -3,6 +3,7 @@ require 'rubyless'
3
3
  module Zafu
4
4
  module Process
5
5
  module RubyLessProcessing
6
+ EXCLUDE_KEYS_IN_ARGS = [:h]
6
7
  include RubyLess
7
8
 
8
9
  def self.included(base)
@@ -211,6 +212,7 @@ module Zafu
211
212
  hash_arguments = []
212
213
  arguments = []
213
214
  params.keys.sort {|a,b| a.to_s <=> b.to_s}.each do |k|
215
+ next if EXCLUDE_KEYS_IN_ARGS.include?(k)
214
216
  if k =~ /\A_/
215
217
  arguments << "%Q{#{params[k]}}"
216
218
  else
@@ -238,19 +240,12 @@ module Zafu
238
240
  end
239
241
 
240
242
  def rubyless_expand(res)
241
- if res.klass == String && !@blocks.detect {|b| !b.kind_of?(String)}
242
- if lit = res.literal
243
- out erb_escape(lit)
244
- # TODO: Enable this when we have time to ensure tests/functionality work correctly.
245
- #elsif res.opts[:h]
246
- # show_string(res)
247
- else
248
- out "<%= #{res} %>"
249
- end
243
+ if res.klass == String && !(@blocks.detect {|b| !b.kind_of?(String)})
244
+ r_show(res)
250
245
  elsif res.klass == Boolean
251
246
  expand_if(res)
252
247
  elsif @blocks.empty?
253
- out "<%= #{res} %>"
248
+ r_show(res)
254
249
  else
255
250
  expand_with_finder(:method => res, :class => res.klass, :query => res.opts[:query], :nil => res.could_be_nil?)
256
251
  end
data/lib/zafu/template.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'zafu/compiler'
2
-
3
1
  module Zafu
4
2
  class Template
5
3
  def initialize(template, src_helper = nil, compiler = Zafu::Compiler)
@@ -1,5 +1,3 @@
1
- require 'zafu/template'
2
-
3
1
  module Zafu
4
2
  module TestHelper
5
3
  include RubyLess::SafeClass
@@ -1,4 +1,3 @@
1
- require 'zafu/controller_methods'
2
1
  module Zafu
3
2
  module ViewMethods
4
3
  include Zafu::ControllerMethods::Common
data/lib/zafu.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'zafu/all'
1
+ require 'zafu/parser'
2
2
 
3
3
  if defined?(ActionView)
4
4
  require 'zafu/handler'
@@ -44,7 +44,8 @@ module Zena
44
44
 
45
45
  # Return true if the node can be viewed by all (public)
46
46
  def public?
47
- can_read?(visitor.site.anon,visitor.site.anon.group_ids) # visible by anonymous
47
+ anon = visitor.site.anon
48
+ can_read?(anon, anon.group_ids) # visible by anonymous
48
49
  end
49
50
 
50
51
  # Return true if the node is properly secured (was loaded with secure)
@@ -77,12 +78,12 @@ module Zena
77
78
  # Returns true if the current visitor can see redactions (unpublished versions)
78
79
  # of the node.
79
80
  def can_see_redactions?(ugps = visitor.group_ids)
80
- visitor.group_ids.include?(wgroup_id)
81
+ ugps.include?(wgroup_id)
81
82
  end
82
83
 
83
84
  # The node has just been created so the creator can still delete it
84
85
  # or move it around.
85
- def draft?(vis=visitor)
86
+ def draft?
86
87
  !publish_from && visitor.id == user_id &&
87
88
  visitor.user? && visitor.id == version.user_id &&
88
89
  versions.count == 1
@@ -90,7 +91,7 @@ module Zena
90
91
 
91
92
  # The node has just been created so the creator can still delete it
92
93
  # or move it around.
93
- def draft_was_true?(vis=visitor)
94
+ def draft_was_true?
94
95
  !publish_from_was && visitor.id == user_id_was &&
95
96
  visitor.user? && visitor.id == version.user_id_was &&
96
97
  versions.count == 1
data/lib/zena/console.rb CHANGED
@@ -20,23 +20,6 @@ module Zena
20
20
  secure(Node) { Node.create_node(Node.transform_attributes(attrs)) }
21
21
  end
22
22
 
23
- def rename_prop(list, old_key, new_key)
24
- list = find(list) if list.kind_of?(String)
25
- if list.first.kind_of?(Node)
26
- list = list.map(&:visible_versions).flatten
27
- end
28
-
29
- list.each do |rec|
30
- prop = rec.prop
31
- value = prop.delete(old_key)
32
- if !value.blank?
33
- prop[new_key] = value
34
- Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
35
- end
36
- end
37
- "Renamed '#{old_key}' to '#{new_key}' in #{list.size} #{list.first.class.to_s.downcase.pluralize}"
38
- end
39
-
40
23
  def field_to_prop(list, native_key, prop_key)
41
24
  list = find(list) if list.kind_of?(String)
42
25
  list.each do |rec|
@@ -70,15 +53,33 @@ module Zena
70
53
  end
71
54
  end
72
55
 
56
+ def rename_prop(pseudo_sql, old_key, new_key)
57
+ count = 0
58
+ foreach(pseudo_sql) do |node|
59
+ node.versions.each do |rec|
60
+ count += 1
61
+ prop = rec.prop
62
+ value = prop.delete(old_key)
63
+ if !value.blank?
64
+ prop[new_key] = value
65
+ Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
66
+ end
67
+ end
68
+ end
69
+ "Renamed '#{old_key}' to '#{new_key}' in #{count} versions"
70
+ end
71
+
73
72
  # Transform every value of a given property by using a block with |node, old_value| and
74
73
  # returning the new value.
75
74
  def change_prop(pseudo_sql, key)
75
+ count = 0
76
76
  unless block_given?
77
77
  puts "You need to provide a block |node, old_value| and return the new value"
78
78
  return
79
79
  end
80
80
  foreach(pseudo_sql) do |node|
81
81
  node.versions.each do |v|
82
+ count += 1
82
83
  prop = v.prop
83
84
  val = prop[key]
84
85
  new_val = yield(node, val)
@@ -92,6 +93,7 @@ module Zena
92
93
  end
93
94
  end
94
95
  end
96
+ "Changed '#{key}' prop in #{count} versions"
95
97
  end
96
98
 
97
99
  def login(name, host = nil)
@@ -100,9 +100,10 @@ class String
100
100
  # of the readmore argument.
101
101
  def limit(size, readmore = '…')
102
102
  if self.size > size
103
- self[0..(size-1)] + readmore
103
+ # readmore can contain a link: <a...> but this is defined in the zafu template.
104
+ ::ERB::Util.html_escape(self[0..(size-1)]) + readmore
104
105
  else
105
- self
106
+ ::ERB::Util.html_escape(self)
106
107
  end
107
108
  end
108
109
 
@@ -16,9 +16,9 @@ def run(cmd)
16
16
  end
17
17
 
18
18
  operations = [
19
- 'ruby lib/upload_progress_server.rb ',
20
19
  'rake worker:',
21
20
  <% if config[:app_type] == :mongrel %>
21
+ 'ruby lib/upload_progress_server.rb ',
22
22
  'mongrel_rails cluster::',
23
23
  <% end %>
24
24
  # 'rake sphinx:',
@@ -53,6 +53,11 @@ if %w{start restart}.include?(cmd)
53
53
  operations.each do |op|
54
54
  run "cd #{APP_ROOT} && #{op}start"
55
55
  end
56
+
57
+ <% if config[:app_type] == :passenger %>
58
+ # Restart Passenger
59
+ run "cd #{APP_ROOT} && touch tmp/restart.txt"
60
+ <% end %>
56
61
  end
57
62
 
58
63
  unless %w{start stop restart}.include?(cmd)