Skip to content

Commit

Permalink
[link] and other url related methods no longer consider params as Str…
Browse files Browse the repository at this point in the history
…ing. You have to use <r:link foo='%{bar}'/> if you want strings.
  • Loading branch information
gaspard committed Jun 1, 2011
1 parent 0d7e0c3 commit f4f4e49
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 81 deletions.
54 changes: 29 additions & 25 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
== 1.0.0

* minor changes
* Major changes
* [link] and other url related zafu tags *do not typecast to String* by default:
you need to use <r:link foo='%{baz}'/> for literal values.

* Minor changes
* Fixed login redirect to not leave ssh.
* Fixed 'root' scoping and custom urls with mode ('_' in url).
* Fixed 'host' option for zazen, link and img tags.
Expand All @@ -10,7 +14,7 @@

== 1.0.0.rc3 2011-05-26

* major changes
* Major changes
* Included tag in xml serialization (tag_names)
* Added export/import support for Roles/Columns and Relations.
* Fixed bugs when changing class hierarchy (move rename VirtualClass).
Expand All @@ -33,21 +37,21 @@

== 1.0.0.rc2 2011-02-14

* major changes
* Major changes
* Fixed Template bug with special '+' modes.
* Fixed migration bug (should use NULL as brick name for app).
* Fixed custom query loading bug (when brick is not activated).
* Fixed Mongrel bug (incompatibility with Rails 2.3.8).

== 1.0.0.rc1 2011-02-11

* major changes
* Major changes
* Changed 'date' for 'main_date'
* Added 'redir' option on node update/create (also added 'mode')

== 1.0.0.beta5

* major changes
* Major changes
* Using VirtualClass as proxy for type compilation (RubyLess, Zafu).
* Caching Roles and VirtualClass.
* Added 'integer' property with index.
Expand All @@ -61,7 +65,7 @@

== 1.0.0.beta4

* major changes
* Major changes
* Removed BaseContact and Reference classes.
* Removed super user (not needed anymore).
* Upgraded to Property 2.0 (should resolve memory leak)
Expand All @@ -70,7 +74,7 @@

== 1.0.0.beta3 2010-09-17

* major changes
* Major changes
* created Zena::Remote API
* fixed Ajax operations and tests
* fixed forms to create/update new objects
Expand All @@ -82,12 +86,12 @@

== 1.0.0.beta2 2010-07-24

* major changes
* Major changes
* fixed connection timezone with PostgreSQL

== 1.0.0.beta1 2010-07-23

* major changes
* Major changes
* complete rewrite of the storage engine (Property gem)
* rewrite of the template engine Zafu to use RubyLess
* rewrite of the query compilation engine to use RubyLess and offer better introspection
Expand All @@ -100,57 +104,57 @@

== 0.16.6 2010-04-23

* 1 minor enhancement
* 1 Minor enhancement
* fixed gem loading when brick is deactivated

== 0.16.5 2010-04-15

* 2 major enhancements
* 2 Major enhancements
* added a way to easily check duplicate names when adding documents
* ruby 1.9 compatibility fixes

* 3 minor enhancements
* 3 Minor enhancements
* better default +login mode
* fixed image cache stamp not always used
* some minor bug fixes

== 0.16.4 2010-02-22

* 3 major enhancements
* 3 Major enhancements
* fixed installation and runtime bugs on Windows
* moved ruby files in 'lib' into their Zena namespace
* german translations [Lars Kanis]

* 2 minor enhancements
* 2 Minor enhancements
* fixed edgy bug with name duplicates
* fixed bug that would show a 'site not found' error instead of a 404

== 0.16.3 2010-01-19

* 1 major enhancement
* 1 Major enhancement
* all gem dependencies are now using the default gem source

== 0.16.2 2010-01-17

* 1 minor enhancement
* 1 Minor enhancement
* fixed zena:assets task when used from 'zena' command

== 0.16.1 2010-01-16

* 3 minor enhancements
* 3 Minor enhancements
* rewrite of rake and capistrano tasks for sphinx brick
* rewrite of rake and capistrano tasks for worker brick
* fixed asset copying (should not overwrite without asking)

== 0.16.0 2010-01-15

* 3 major enhancements
* 3 Major enhancements
* Sphinx search support
* Authlogic authentification
* attachments can now be provided with an url
* added [node:attribute_name] to use in querybuilder

* 5 minor enhancements
* 5 Minor enhancements
* logrotate setup support with capistrano
* fixed contact content zip bug
* fixed fullpath set to NULL instead of kept in sync
Expand All @@ -159,16 +163,16 @@

== 0.15.2 2010-01-06

* 1 minor enhancement
* 1 Minor enhancement
* fixed app generation when rails >= 2.3.4 is installed

== 0.15.1 2009-10-27

* 2 major enhancements
* 2 Major enhancements
* Passenger support (deploy, upload progress)
* JS popup & gallery support (setting in image formats)

* 6 minor enhancements
* 6 Minor enhancements
* fixed some deployment tasks (capistrano)
* fixed zena:setup task to copy files instead of symlink
* better versions list and diff select
Expand All @@ -178,19 +182,19 @@

== 0.15.0 2009-10-16

* 5 major enhancements
* 5 Major enhancements
* running rails 2.3.4
* installable as gem without RMagick
* usable as gem with config.gem
* supports sqlite3
* 'zena' command to create app

* 3 minor enhancemnts
* 3 Minor enhancemnts
* huge speed improvement in version loading
* massive code cleanup
* better team workflow (reworked access rights)

== 0.11.1 2009-04-03

* minor enhancements
* Minor enhancements
* Better testing of custom queries using latest querybuilder (0.5.2)
6 changes: 3 additions & 3 deletions app/models/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def roles_for_form

def indices_for_form
[
['key/value',
INDICES_FOR_FORM.map {|i| [i, i]}],
['field',
FIELD_INDICES.map {|i| [i, ".#{i}"]}]
FIELD_INDICES.map {|i| [i, ".#{i}"]}],
['key/value',
INDICES_FOR_FORM.map {|i| [i, i]}]
]
end

Expand Down
2 changes: 1 addition & 1 deletion bricks/tags/zena/test/zafu/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ listing_no_tags:
res: ""

listing_with_link:
src: "<r:tags do='each' join=',' do='link' href='main' cat='#{name}'/>"
src: "<r:tags do='each' join=',' do='link' href='main' cat='name'/>"
res: "<a href='/en/projects-list/Clean-Water-project/page22.html?cat=blue'>blue</a>,<a href='/en/projects-list/Clean-Water-project/page22.html?cat=sky'>sky</a>"

tagged_query:
Expand Down
4 changes: 3 additions & 1 deletion lib/zena/use/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def r_swap
return parser_error("missing 'states' parameter") unless @params[:states]

# This will be RubyLess evaluated
query_params = {"node[#{@params[:attr]}]" => "\#{next_in_list(this.#{@params[:attr]}, %Q{#{@params[:states]}})}"}
query_params = @params.merge("node[#{@params[:attr]}]" => "next_in_list(this.#{@params[:attr]}, %Q{#{@params[:states]}})")
query_params.delete(:states)
query_params.delete(:attr)
out make_link(:update => block, :action => 'update', :query_params => query_params, :method => :put)
end
end # ZafuMethods
Expand Down
17 changes: 14 additions & 3 deletions lib/zena/use/ajax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,27 @@ def r_drop
markup.append_param(:class, 'drop') unless markup.params[:class] =~ /drop/

if hover = @params.delete(:hover)
query_params = ", :hover => #{hover.inspect}"
query_params = ", :hover => %{#{hover}}"
else
query_params = ""
end

if role = @params.delete(:set) || @params.delete(:add)
@params["node[#{role}_id]"] = '\\#{id}'
@params["node[#{role}_id]"] = "'\#{id}'"
end

query_params << ", :url => #{make_href(target, :action => 'drop')}"
url_params = {}
@params.each do |k,v|
case k
when :change, :done
# Force string interpolation
url_params[k] = "%{#{v}}"
else
url_params[k] = v
end
end

query_params << ", :url => #{make_href(target, :action => 'drop', :query_params => url_params)}"
markup.pre_wrap[:drop] = "<% add_drop_id(#{dom_id}#{query_params}) %>"
r_block
end
Expand Down
10 changes: 5 additions & 5 deletions lib/zena/use/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ def display_calendar
if header_block = descendant('header')
elsif @params[:type] == 'week'
add_block(%q{<h3 do='header'>
<r:link date='#{date.advance(:days =&gt; -1).strftime("%Y-%m-%d", tz)}' t='img_prev_page'/>
<r:link date='date.advance(:days =&gt; -1)' t='img_prev_page'/>
<r:date format='%B'/>
<r:link date='#{date.advance(:days =&gt; 1).strftime("%Y-%m-%d", tz)}' t='img_next_page'/>
<r:link date='date.advance(:days =&gt; 1)' t='img_next_page'/>
</h3>}, true)
header_block = descendant('header')
else
add_block(%q{<h3 do='header'>
<r:link date='#{date.advance(:months =&gt; -1).strftime("%Y-%m-%d", tz)}' t='img_prev_page'/>
<r:link date='date.advance(:months =&gt; -1)' t='img_prev_page'/>
<r:date format='%B'/>
<r:link date='#{date.advance(:months =&gt; 1).strftime("%Y-%m-%d", tz)}' t='img_next_page'/>
<r:link date='date.advance(:months =&gt; 1)' t='img_next_page'/>
</h3>}, true)
header_block = descendant('header')
end
Expand All @@ -215,7 +215,7 @@ def display_calendar
else
# add a default <r:link/> block
if opts[:size] == :tiny
add_block %Q{<r:cell><em do='link' date='#{format_date(date, "%Y-%m-%d")}' do='date' format='%e'/></r:cell>}
add_block %Q{<r:cell><em do='link' date='date' do='date' format='%e'/></r:cell>}
else
add_block "<r:cell><p do='date' format='%e'/><ol><li do='each' do='link' eval='title.limit(10)'/></ol></r:cell>"
end
Expand Down
29 changes: 20 additions & 9 deletions lib/zena/use/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ def append_query_params(path, opts)
end
elsif value = opts[k]
if value.respond_to?(:strftime)
# FIXME: I think this is not needed anymore (and removing time might not be a good idea).
"#{k}=#{value.strftime('%Y-%m-%d')}"
"#{k}=#{CGI.escape(value.strftime_tz(_('datetime')))}"
elsif value.kind_of?(Hash)
"#{k}=#{value.to_query}"
elsif !value.blank?
Expand All @@ -183,6 +182,8 @@ def append_query_params(path, opts)
result = path + "?#{cachestamp}" + (list.empty? ? '' : "&#{list.sort.join('&')}")
result
else
# TODO: replace '&' by '&amp;' ? Or escape later ? Use h before zen_path in templates ? What about css/xls/other stuff ?
# Best solution: use 'h' in template when set in default
path + (list.empty? ? '' : "?#{list.sort.join('&')}")
end
end
Expand Down Expand Up @@ -584,12 +585,22 @@ def make_href(remote_target = nil, opts = {})

(opts[:query_params] || @params).each do |key, value|
next if [:href, :eval, :text, :attr, :t, :host].include?(key)
if key == :anchor
value = get_anchor_name(value)
case key
when :anchor
# Get anchor and force string interpolation
value = "%Q{#{get_anchor_name(value)}}"
when :publish
if value == 'true'
key = 'v_status'
value = Zena::Status::Pub
else
next
end
when :encode_params, :format, :mode
# Force string interpolation
value = "%Q{#{value}}"
end

# FIXME: how to not force string interpolation ?
hash_params << "#{key.inspect} => %Q{#{value}}"
hash_params << "#{key.inspect} => #{value}"
end

if host = param(:host)
Expand Down Expand Up @@ -720,7 +731,7 @@ def pagination_links
link = {
:href => '@node',
:eval => "#{page_direction}_page",
pagination_key => "\#{#{page_direction}_page}",
pagination_key => "#{page_direction}_page",
}.merge(@params)
# <r:link href='@node' p='next_page' eval='next_page'/>
wrap_in_block :method => 'link', :params => link
Expand Down Expand Up @@ -752,7 +763,7 @@ def pagination_links
link[:html_tag] = tag if tag
link[:href] = '@node'
link[:eval] = 'page_name'
link[pagination_key.to_sym] = '#{this}'
link[pagination_key.to_sym] = 'this'

# <r:link href='@node' p='#{page_name}' ... eval='page_name'/>
add_block :method => 'link', :params => link
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/zafu_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def rebuild_template(template, opts = {})
def dev_box(template = nil)
used_nodes = self.asset_cache.used_assets

res = "<div id='dev'><ul>\n"
res = "<div id='dev' class='devb'><ul>\n"
used_nodes.each do |name, nodes|
next if nodes.empty?
res << " <li><a class='group' onclick='$(\"dev_#{name}\").toggle();' href='#'>#{name}</a>\n"
Expand Down
19 changes: 10 additions & 9 deletions public/stylesheets/zena.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ table.errors td { padding:2px 5px; background:inherit; border:none;}
.clear { clear:both;}

/* dev */
#dev { background:#eee; font-size:10px; position:fixed; bottom:0px; right:0px;
.devb, #dev { background:#eee; font-size:10px;
padding:5px; border:2px solid #222; text-align:left; color:#444; z-index:9999; border-width:2px 0 0 2px;}
#dev a { color:inherit; }
#dev ul, #dev li { margin:0; padding:0; list-style:none; background:none; list-style-image:none;}
#dev a.group { font-weight:bold; color:#222; display:block;}
#dev td.actions {width:40px;}
#dev li img { border:0; }
#dev li li { clear:both;}
#dev li .dev_pop { display:none;}
#dev:hover .dev_pop { display:block;}
#dev { position:fixed; bottom:0px; right:0px;}
.devb a { color:inherit; }
.devb ul, .devb li { margin:0; padding:0; list-style:none; background:none; list-style-image:none;}
.devb a.group { font-weight:bold; color:#222; display:block;}
.devb td.actions {width:40px;}
.devb li img { border:0; }
.devb li li { clear:both;}
.devb li .dev_pop { display:none;}
.devb:hover .dev_pop { display:block;}

/* table js */
.zazen .table_add a { visibility:hidden; padding:0 5px; text-decoration:none;}
Expand Down

0 comments on commit f4f4e49

Please sign in to comment.