Skip to content

Commit

Permalink
Fixed bug in [find] RubyLess method when using a literal number.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Jun 7, 2011
1 parent 3e07763 commit 677199b
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 12 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Fixed a bug where cached_role_ids would not be recalculated on rebuild rebuild.
* Fixed type_cast bug on Time value.
* Fixed a bug in 'is_ancestor?' where it would be confused by similar ids.
* Fixed a bug with 'find(22)' (find by literal zip).

== 1.0.0.rc3 2011-05-26

Expand Down
2 changes: 1 addition & 1 deletion bricks/uv/lib/bricks/uv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_html(opts = {})
res.gsub(/\A<pre class=.#{theme}.>/,"<pre class='#{code_class}'>").gsub(%r{</pre>\Z}, '</pre>')
end
else
basic_to_html(opts[:inline], code_class)
super
end
end
end # SyntaxMethods
Expand Down
23 changes: 18 additions & 5 deletions lib/zena/use/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,23 @@ module ZafuMethods
QB_KEYS = [:find, :from, :else, :in, :where, :or, :limit, :order]

include RubyLess
# The :class argument in this method is only used when the String is not a literal value
safe_method [:find, String] => {:method => 'nil', :pre_processor => :get_type_for_find, :class => NilClass}
safe_method [:count, String] => {:method => '0', :pre_processor => :get_type_for_count, :class => Number }
safe_method [:find, Number] => {:method => :find_node_by_zip, :class => Node, :nil => true, :accept_nil => true}
safe_method [:find, String] => :get_find_type
safe_method [:count, String] => :get_find_type
safe_method [:find, Number] => :get_find_type

def get_find_type(signature)
if signature == ['find', Number]
{:method => :find_node_by_zip, :class => VirtualClass['Node'], :nil => true, :accept_nil => true}
elsif signature == ['find', String]
# TODO: support dynamic strings ?
{:method => 'nil', :pre_processor => :get_type_for_find, :class => NilClass}
elsif signature == ['count', String]
# TODO: support dynamic strings ?
{:method => '0', :pre_processor => :get_type_for_count, :class => Number }
else
nil
end
end

def self.included(base)
base.process_unknown :querybuilder_eval
Expand Down Expand Up @@ -215,7 +228,7 @@ def querybuilder_eval(method = @method)
node = single_node

if method =~ /^\d+$/
finder = {:method => "find_node_by_zip(#{method})", :class => Node, :nil => true}
finder = {:method => "find_node_by_zip(#{method})", :class => VirtualClass['Node'], :nil => true}
else
count = get_count(method, @params)
finder = build_finder(count, method, @params)
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def make_href(remote_target = nil, opts = {})
else
next
end
when :encode_params, :format, :mode
when :encode_params, :format, :mode, :insert
# Force string interpolation
value = "%Q{#{value}}"
else
Expand Down
5 changes: 5 additions & 0 deletions lib/zena/use/zafu_safe_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def self.join_proc
{:method => 'nil', :nil => true, :pre_processor => join_proc}
safe_method_for Array, [:map, Symbol] => # supports map(:name)
{:method => 'nil', :nil => true, :pre_processor => map_proc}
safe_method_for Array, [:include?, String] =>
{:method => 'include?', :accept_nil => true, :pre_processor => true, :class => Boolean}
safe_method_for Array, [:include?, Number] =>
{:method => 'include?', :accept_nil => true, :pre_processor => true, :class => Boolean}

safe_method [:min, Number, Number] => {:method => 'zafu_min', :class => Number}
safe_method [:max, Number, Number] => {:method => 'zafu_max', :class => Number}
# Returns the smallest of two values.
Expand Down
1 change: 0 additions & 1 deletion locale/de/zena.po
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,6 @@ msgid "template_tab"
msgstr "Template"

#: lib/gettext_strings.rb:22
#, fuzzy
msgid "text_document_tab"
msgstr "Text Dok."

Expand Down
1 change: 0 additions & 1 deletion locale/en/zena.po
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,6 @@ msgid "template_tab"
msgstr "template"

#: lib/gettext_strings.rb:22
#, fuzzy
msgid "text_document_tab"
msgstr "text doc."

Expand Down
10 changes: 9 additions & 1 deletion test/integration/zafu_compiler/display.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,12 @@ default_host:

zazen_without_markup:
src: "<r:void do='zazen(title)'/>"
res: "<p>status title</p>"
res: "<p>status title</p>"

comment:
src: "this that //! blah blah"
tem: "this that"

insert_slash_slash_exclam:
src: "this that <r:show text='//!'/> blah blah"
res: "this that //! blah blah"
4 changes: 4 additions & 0 deletions test/integration/zafu_compiler/query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,7 @@ query_errors:
find_with_rubyless:
src: "<b do='find(\"images in site limit 2\")' do='each' join=',' do='title'/>"
res: "<b>Autumn Tree,bird</b>"

find_loads_class:
src: "<div do='find(11)'><r:origin/></div>"
tem: "<% if var1 = find_node_by_zip(11) %><div><%= var1.prop['origin'] %></div><% end %>"
6 changes: 5 additions & 1 deletion test/integration/zafu_compiler/safe_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ time_advance:
context:
date: '2011-02-03'
src: "<b do='date.advance(:months =&gt; 1).strftime(\"%Y-%m-%d\")'/>"
res: "<b>2011-03-03</b>"
res: "<b>2011-03-03</b>"

array_include:
src: "<b do='[1,2,3].include?(2)'/>"
tem: "<% if [1,2,3].include?(2) %><b></b><% end %>"
23 changes: 22 additions & 1 deletion zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
s.date = %q{2011-06-06}
s.date = %q{2011-06-07}
s.default_executable = %q{zena}
s.description = %q{zena is a Ruby on Rails CMS (content managment system) with a focus on usability, ease of customization and web 2.0 goodness (application like behaviour).}
s.email = %q{gaspard@teti.ch}
Expand Down Expand Up @@ -1753,6 +1753,27 @@ Gem::Specification.new do |s|
"public/stylesheets/reset.css",
"public/stylesheets/search.css",
"public/stylesheets/upload-progress.css",
"public/stylesheets/uv/active4d.css",
"public/stylesheets/uv/all_hallows_eve.css",
"public/stylesheets/uv/amy.css",
"public/stylesheets/uv/blackboard.css",
"public/stylesheets/uv/brilliance_black.css",
"public/stylesheets/uv/brilliance_dull.css",
"public/stylesheets/uv/cobalt.css",
"public/stylesheets/uv/dawn.css",
"public/stylesheets/uv/eiffel.css",
"public/stylesheets/uv/espresso_libre.css",
"public/stylesheets/uv/idle.css",
"public/stylesheets/uv/iplastic.css",
"public/stylesheets/uv/lazy.css",
"public/stylesheets/uv/mac_classic.css",
"public/stylesheets/uv/magicwb_amiga.css",
"public/stylesheets/uv/pastels_on_dark.css",
"public/stylesheets/uv/slush_poppies.css",
"public/stylesheets/uv/spacecadet.css",
"public/stylesheets/uv/sunburst.css",
"public/stylesheets/uv/twilight.css",
"public/stylesheets/uv/zenburnesque.css",
"public/stylesheets/wiki.css",
"public/stylesheets/window.css",
"public/stylesheets/zen.css",
Expand Down

0 comments on commit 677199b

Please sign in to comment.