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
@@ -18,7 +18,7 @@ module Zena
18
18
  next unless code = self[idx_group]
19
19
 
20
20
  begin
21
- ruby = RubyLess.translate_string(code, klass)
21
+ ruby = RubyLess.translate_string(klass, code)
22
22
 
23
23
  unless ruby.klass <= String
24
24
  errors.add(idx_group, _('Compilation should produce a String. Found %s.') % ruby.klass.name)
data/lib/zena/use/i18n.rb CHANGED
@@ -5,6 +5,67 @@ module Zena
5
5
  module I18n
6
6
  ::ENV['LANG'] = 'C'
7
7
 
8
+ class TranslationDict
9
+ attr_reader :last_error
10
+
11
+ include Zena::Acts::Secure
12
+ include RubyLess
13
+
14
+ # never returns nil
15
+ safe_method [:get, String] => {:class => String, :accept_nil => true}
16
+
17
+ def initialize(node_id)
18
+ @node_id = node_id
19
+ end
20
+
21
+ def get(key)
22
+ load!
23
+ get_without_loading(key)
24
+ end
25
+
26
+ def get_without_loading(key)
27
+ @dict[key] || ApplicationController.send(:_, key)
28
+ end
29
+
30
+ def load!(text = nil)
31
+ unless text
32
+ unless dict = secure(Node) { Node.find(:first, :conditions => {:id => @node_id}) }
33
+ return error("missing 'dictionary'")
34
+ end
35
+ text = dict.prop['text']
36
+ end
37
+
38
+ begin
39
+ definitions = YAML::load(text)
40
+ if translations = definitions['translations']
41
+ if translations.kind_of?(Hash)
42
+ # ok
43
+ @dict = translations
44
+ true
45
+ else
46
+ return error("bad 'translations' content (should be a dictionary)")
47
+ end
48
+ else
49
+ return error("missing 'translations' top-level key in dictionary")
50
+ end
51
+ rescue
52
+ return error("invalid dictionary content #{dict.inspect}")
53
+ end
54
+
55
+ class << self
56
+ alias get get_without_loading
57
+ end
58
+
59
+ true
60
+ end
61
+
62
+ private
63
+ def error(message)
64
+ @last_error = message
65
+ nil
66
+ end
67
+ end
68
+
8
69
  module FormatDate
9
70
 
10
71
  # display the time with the format provided by the translation of 'long_time'
@@ -125,12 +186,7 @@ module Zena
125
186
 
126
187
  module ViewMethods
127
188
  include RubyLess
128
- translate = { :class => String,
129
- :method => 'trans',
130
- :pre_processor => Proc.new {|str| self.rubyless_translate(str)}
131
- }
132
- safe_method [:trans, String] => translate
133
- safe_method [:t, String] => translate
189
+
134
190
  safe_method [:lang_links, {:wrap => String, :join => String}] => String
135
191
 
136
192
  def self.included(base)
@@ -144,11 +200,6 @@ module Zena
144
200
  will_paginate_without_i18n(collection, options.merge(:prev_label => _('img_prev_page'), :next_label => _('img_next_page')))
145
201
  end
146
202
 
147
- def self.rubyless_translate(str)
148
- str = str.kind_of?(Hash) ? str['text'] : str
149
- ApplicationController.send(:_, str)
150
- end
151
-
152
203
  # translation of static text using gettext
153
204
  # FIXME: I do not know why this is needed in order to have <%= _('blah') %> find the translations on some servers
154
205
  def _(str)
@@ -159,6 +210,9 @@ module Zena
159
210
  ApplicationController.send(:_, str)
160
211
  end
161
212
 
213
+ def load_dictionary(node_id)
214
+ Zena::Use::I18n::TranslationDict.new(node_id)
215
+ end
162
216
 
163
217
  # show language selector
164
218
  def lang_links(opts={})
@@ -189,13 +243,16 @@ module Zena
189
243
  end # ViewMethods
190
244
 
191
245
  module ZafuMethods
246
+ include RubyLess
247
+ safe_method [:trans, String] => :translate
248
+ safe_method [:t, String] => :translate
192
249
 
193
250
  # Show a little [xx] next to the title if the desired language could not be found. You can
194
251
  # use a :text => '(lang)' option. The word 'lang' will be replaced by the real value.
195
252
  def r_wrong_lang(params = @params)
196
253
  if @blocks.empty? || @method != 'wrong_lang'
197
254
  text = params[:text] || %q{<span class='wrong_lang'>[#{v.lang}]</span> }
198
- "<%= #{node}.version.lang == lang ? '' : #{::RubyLess.translate_string(text, self)} %>"
255
+ "<%= #{node}.version.lang == lang ? '' : #{::RubyLess.translate_string(self, text)} %>"
199
256
  else
200
257
  expand_if("#{node}.version.lang != lang")
201
258
  end
@@ -203,33 +260,59 @@ module Zena
203
260
 
204
261
  def r_load
205
262
  if dict = @params[:dictionary]
206
- dict_content, absolute_url, base_path = self.class.get_template_text(dict, @options[:helper], @options[:base_path])
263
+ dict_content, absolute_url, base_path, doc = @options[:helper].send(:get_template_text, dict, @options[:base_path])
207
264
  return parser_error("dictionary #{dict.inspect} not found") unless base_path
208
- # TODO: How to use dict offline ?
209
- # We could do:
210
- # dict_name = get_var_name('dict', 'dictionary')
211
- # set_context_var('set_var', 'dictionary', TypedString.new(dict_name, StringDictionary))
212
- # Load with <% #{dict_name} = load_dictionary(#{dict_zip}) -%>
213
- @context[:dict] ||= {}
214
- begin
215
- definitions = YAML::load(dict_content)
216
- definitions['translations'].each do |elem|
217
- @context[:dict][elem[0]] = elem[1]
218
- end
219
- rescue
220
- return parser_error("invalid dictionary content #{dict.inspect}")
265
+ # Lazy dictionary used for literal resolution
266
+ dict = TranslationDict.new(doc.id)
267
+
268
+ if dict.load!(dict_content)
269
+ # Save dictionary in template for dynamic uses
270
+ dict_name = get_var_name('dictionary', 'dict')
271
+
272
+ # This is to use in RubyLess translations and static translations in Zafu
273
+ set_context_var('set_var', 'dictionary', RubyLess::TypedString.new(dict_name, :class => TranslationDict, :literal => dict))
274
+
275
+ # Lazy loading (loads file on first request)
276
+ out "<% #{dict_name} = load_dictionary(#{doc.id}) -%>"
277
+ else
278
+ return parser_error(dict.last_error)
221
279
  end
222
280
  else
223
281
  return parser_error("missing 'dictionary'")
224
282
  end
283
+
225
284
  expand_with
226
285
  end
227
286
 
228
- def _(text)
229
- if @context[:dict]
230
- @context[:dict][text] || helper.send(:_,text)
287
+ # Resolve RubyLess 't' and 'trans' methods
288
+ def translate(signature, receiver = nil)
289
+ return nil unless signature.size == 2 && signature[1] <= String
290
+
291
+ dict = get_context_var('set_var', 'dictionary')
292
+
293
+ if dict && dict.klass <= TranslationDict
294
+ { :class => String,
295
+ :method => "#{dict}.get",
296
+ :accept_nil => true,
297
+ :pre_processor => Proc.new {|str| trans(str)}
298
+ }
231
299
  else
232
- helper.send(:_,text)
300
+ { :class => String,
301
+ :method => 'trans',
302
+ :accept_nil => true,
303
+ :pre_processor => Proc.new {|str| trans(str)}
304
+ }
305
+ end
306
+ end
307
+
308
+ def trans(text)
309
+ dict = get_context_var('set_var', 'dictionary')
310
+
311
+ if dict && dict.klass <= TranslationDict && lit = dict.literal
312
+ # will call ApplicationController(:_) if key is not found
313
+ lit.get(text)
314
+ else
315
+ helper.send(:_, text)
233
316
  end
234
317
  end
235
318
 
@@ -239,8 +322,12 @@ module Zena
239
322
  klass = method.klass
240
323
  return parser_error("Cannot translate a '#{klass}'.") unless klass <= String
241
324
 
325
+ dict = get_context_var('set_var', 'dictionary')
326
+
242
327
  if method.literal
243
- helper.send(:_, method.literal)
328
+ trans(method.literal)
329
+ elsif dict && dict.klass <= TranslationDict
330
+ "<%= #{dict}.get(#{method}) %>"
244
331
  else
245
332
  "<%= trans(#{method}) %>"
246
333
  end
@@ -30,10 +30,12 @@ module Zena
30
30
  # <r:images in='site'>
31
31
  #
32
32
  # 2. r_unknown
33
- # try RubyLess.translate(xxxxxx, node) <-- pass context
33
+ # try RubyLess.translate(node, xxxxxx) <-- pass context
34
34
  #
35
35
  # 3. helper (view) tries to resolve safe_method_type as RubyLess or PseudoSQL
36
36
  module ZafuMethods
37
+ QB_KEYS = [:find, :from, :else, :in, :where, :or, :limit, :order]
38
+
37
39
  include RubyLess
38
40
  # The :class argument in this method is only used when the String is not a literal value
39
41
  safe_method [:find, String] => {:method => 'nil', :pre_processor => :get_finder_type, :class => NilClass}
@@ -55,12 +57,12 @@ module Zena
55
57
  klass = [default_query.main_class]
56
58
 
57
59
  if sql = @params[:eval]
58
- sql = RubyLess.translate(sql, self)
60
+ sql = RubyLess.translate(self, sql)
59
61
  unless sql.klass <= String
60
62
  return parser_error("Invalid compilation result for #{sql.inspect} (#{sql.klass})")
61
63
  end
62
64
  elsif sql = @params[:text]
63
- sql = RubyLess.translate_string(sql, self)
65
+ sql = RubyLess.translate_string(self, sql)
64
66
  else
65
67
  sql = "params[:qb]"
66
68
  end
@@ -94,7 +96,7 @@ module Zena
94
96
 
95
97
  # Select the most pertinent error between RubyLess processing errors and QueryBuilder errors.
96
98
  def show_errors
97
- if @method =~ / in | where | from / || ([:find, :from, :else, :in, :where, :or, :limit, :order] & @params.keys != [])
99
+ if @method =~ / in | where | from / || (QB_KEYS & @params.keys != [])
98
100
  # probably a query
99
101
  @errors.detect {|e| e =~ /Syntax/} || @errors.last
100
102
  else
@@ -168,7 +170,7 @@ module Zena
168
170
  finder = get_finder(query, count)
169
171
 
170
172
  if count != :count && else_clause = @params[:else]
171
- else_clause = RubyLess.translate(else_clause, self)
173
+ else_clause = RubyLess.translate(self, else_clause)
172
174
 
173
175
  if else_clause.klass == Array
174
176
  else_klass = else_clause.opts[:array_content_class]
@@ -10,7 +10,6 @@ module Zena
10
10
  class StringDictionary
11
11
  include RubyLess
12
12
  safe_method ['[]', String] => {:class => String, :nil => true}
13
- disable_safe_read # ?
14
13
  end
15
14
 
16
15
  module ModelMethods
@@ -29,11 +28,24 @@ module Zena
29
28
  self.send(type[:method])
30
29
  else
31
30
  begin
32
- query = self.class.build_query(count, rel, :node_name => 'self', :main_class => Zena::Acts::Enrollable.make_class(self.vclass), :rubyless_helper => (opts[:rubyless_helper] || self))
31
+ query = self.class.build_query(count, rel,
32
+ :node_name => 'self',
33
+ :main_class => Zena::Acts::Enrollable.make_class(self.vclass),
34
+ :rubyless_helper => (opts[:rubyless_helper] || self),
35
+ :default => opts[:default]
36
+ )
37
+
38
+ if limit = opts[:limit]
39
+ query.limit = " LIMIT #{limit.to_i}"
40
+ query.offset = " OFFSET #{opts[:offset].to_i}"
41
+ end
33
42
  rescue ::QueryBuilder::Error => err
34
43
  return opts[:errors] ? err : nil
35
44
  end
36
- self.class.do_find(count, eval(query.to_s))
45
+
46
+ type = [:all, :first].include?(count) ? :find : count
47
+
48
+ self.class.do_find(count, eval(query.to_s(type)))
37
49
  end
38
50
  end
39
51
 
@@ -97,7 +109,14 @@ module Zena
97
109
  end
98
110
  end
99
111
 
100
- self.filter_fields = {'id' => {:key => 'zip'}}
112
+ # How to treat filters like "where id = 45" or "where parent_id = #{params[:parent_id]}"
113
+ self.filter_fields = {
114
+ 'id' => {:key => 'zip'},
115
+ 'parent_id' => {:key => 'zip', :join => ['nodes', 'nodes', 'TABLE2.id = TABLE1.parent_id AND TABLE2.site_id = TABLE1.site_id']},
116
+ 'project_id' => {:key => 'zip', :join => ['nodes', 'nodes', 'TABLE2.id = TABLE1.project_id AND TABLE2.site_id = TABLE1.site_id']},
117
+ 'section_id' => {:key => 'zip', :join => ['nodes', 'nodes', 'TABLE2.id = TABLE1.section_id AND TABLE2.site_id = TABLE1.site_id']}
118
+ }
119
+
101
120
  add_filter_field 'now', Zena::Db::NOW
102
121
 
103
122
  # Scope current context with previous context.
@@ -141,6 +160,13 @@ module Zena
141
160
  return map_def
142
161
  elsif table_def = map_def[:table]
143
162
  table_to_use = needs_join_table(*table_def)
163
+ elsif join_def = map_def[:join]
164
+ # current table
165
+ first_table = table(join_def[0])
166
+ # filter table
167
+ add_table('jnode', join_def[1]) # join node
168
+ table_to_use = table('jnode')
169
+ add_filter join_def[2].gsub('TABLE1', first_table).gsub('TABLE2', table_to_use)
144
170
  else
145
171
  table_to_use = table
146
172
  end
@@ -95,7 +95,7 @@ module Zena
95
95
  end
96
96
 
97
97
  def render_and_cache(options={})
98
- opts = {:skin=>@node[:skin], :cache=>true}.merge(options)
98
+ opts = {:skin => @node[:skin], :cache => true}.merge(options)
99
99
  opts[:mode ] ||= params[:mode]
100
100
  opts[:format] ||= params[:format].blank? ? 'html' : params[:format]
101
101
  # cleanup before rendering
@@ -44,10 +44,11 @@ module Zena
44
44
  page = 1 if page < 1
45
45
  search_records(query, options.merge(:offset => (page - 1) * per_page, :limit => per_page))
46
46
  else
47
- # Removed pagination clause
47
+ # Removed pagination clause or no pagination
48
48
  if query.kind_of?(Hash)
49
49
  search_index(query, options)
50
50
  else
51
+ # TODO: should we parse :_find (all, first, count) here ?
51
52
  search_text(query, options)
52
53
  end
53
54
  end
@@ -55,9 +56,9 @@ module Zena
55
56
 
56
57
  # Execute an index search using query builder. Either provide a full query with 'qb' or 'key'='value' parameters.
57
58
  def search_index(params, options = {})
58
- query = ::QueryBuilder::Query.new(Node.query_compiler)
59
- query.add_table(query.main_table)
60
- filters = []
59
+ count = (params.delete(:_find) || :all).to_sym
60
+ node = options.delete(:node) || current_site.root_node
61
+ default = options.delete(:default)
61
62
 
62
63
  unless query = params[:qb]
63
64
  query_args = []
@@ -69,10 +70,10 @@ module Zena
69
70
  query = "nodes where #{query_args.join(' and ')} in site"
70
71
  end
71
72
 
72
- res = current_site.root_node.find(:all, query, :errors => true, :rubyless_helper => self)
73
+ res = node.find(count, query, options.merge(:errors => true, :rubyless_helper => self, :default => default))
73
74
 
74
- if res.kind_of?(Exception)
75
- raise ActiveRecord::StatementInvalid.new("Error parsing query #{query.inspect} (#{res.message})")
75
+ if res.kind_of?(::QueryBuilder::Error)
76
+ raise ::QueryBuilder::Error.new("Error parsing query #{query.inspect} (#{res.message})")
76
77
  else
77
78
  return res
78
79
  end
@@ -84,6 +85,8 @@ module Zena
84
85
  limit = options[:limit] || 20
85
86
  Node.find(:all, match_query(query).merge(:offset => offset, :limit => limit))
86
87
  else
88
+ # :default argument not used here
89
+ options.delete(:default)
87
90
  Node.find(:all, match_query(query, options))
88
91
  end
89
92
  end
data/lib/zena/use/urls.rb CHANGED
@@ -421,7 +421,7 @@ module Zena
421
421
  # force compilation with Node context. Why ?
422
422
  #node_bak = @context[:node]
423
423
  #@context[:node] = node(Node)
424
- # anchor_name = ::RubyLess.translate_string(anchor_name, self)
424
+ # anchor_name = ::RubyLess.translate_string(self, anchor_name)
425
425
  #@context[:node] = node_bak
426
426
  end
427
427
  else
@@ -445,7 +445,7 @@ module Zena
445
445
  anchor = @params[:anchor]
446
446
  if anchor && !@params[:href]
447
447
  # Link on same page
448
- return ::RubyLess.translate_string("##{get_anchor_name(anchor)}", self)
448
+ return ::RubyLess.translate_string(self, "##{get_anchor_name(anchor)}")
449
449
  end
450
450
 
451
451
  # if opts[:action] == 'edit' && !remote_target
@@ -498,7 +498,7 @@ module Zena
498
498
 
499
499
  method = "#{method}(#{method_args.join(', ')})"
500
500
 
501
- ::RubyLess.translate(method, self)
501
+ ::RubyLess.translate(self, method)
502
502
  end
503
503
 
504
504
  def insert_ajax_args(target, hash_params, action)
@@ -69,7 +69,7 @@ module Zena
69
69
  var = $1
70
70
  code = params.delete(k)
71
71
  begin
72
- typed_string = ::RubyLess.translate(code, self)
72
+ typed_string = ::RubyLess.translate(self, code)
73
73
  set_context_var('set_var', var, typed_string)
74
74
  rescue RubyLess::NoMethodError => err
75
75
  parser_error(err.message, code)
@@ -86,7 +86,7 @@ module Zena
86
86
 
87
87
  @if_class_params.each do |class_name, code|
88
88
  begin
89
- typed_string = ::RubyLess.translate(code, self)
89
+ typed_string = ::RubyLess.translate(self, code)
90
90
  @markup.append_dyn_param(:class, "<%= (#{typed_string}) ? ' #{class_name}' : '' %>", true)
91
91
  rescue RubyLess::NoMethodError => err
92
92
  text += parser_error(err.message, code)
@@ -7,7 +7,7 @@ module Zena
7
7
  if !text.kind_of?(String) || @blocks.size > 1
8
8
  parser_error("Cannot evaluate RubyLess codes with zafu methods")
9
9
  else
10
- res = RubyLess.translate(text, self)
10
+ res = RubyLess.translate(self, text)
11
11
  if res.literal.kind_of?(String)
12
12
  res.literal
13
13
  else
@@ -12,6 +12,7 @@ module Zena
12
12
  safe_method :now => {:method => 'Time.now', :class => Time}
13
13
  safe_method_for String, [:gsub, Regexp, String] => {:class => String, :pre_processor => true}
14
14
  safe_method_for String, :upcase => {:class => String, :pre_processor => true}
15
+ safe_method_for Number, :to_s => {:class => String, :pre_processor => true}
15
16
  safe_method_for Object, :blank? => Boolean
16
17
 
17
18
  safe_method_for Node, [:kind_of?, String] => {:method => 'kpath_match?', :class => Boolean}