zafu 0.8.5 → 0.8.6
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.
- data/History.txt +2 -1
- data/lib/zafu/info.rb +1 -1
- data/lib/zafu/node_context.rb +5 -0
- data/lib/zafu/process/ajax.rb +51 -33
- data/lib/zafu/process/context.rb +5 -3
- data/lib/zafu/process/forms.rb +2 -2
- data/lib/zafu/process/ruby_less_processing.rb +6 -2
- data/zafu.gemspec +2 -2
- metadata +4 -4
data/History.txt
CHANGED
data/lib/zafu/info.rb
CHANGED
data/lib/zafu/node_context.rb
CHANGED
|
@@ -112,6 +112,11 @@ module Zafu
|
|
|
112
112
|
@dom_prefix || (@up ? @up.dom_prefix : nil)
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
# Return dom_prefix without looking up.
|
|
116
|
+
def raw_dom_prefix
|
|
117
|
+
@dom_prefix
|
|
118
|
+
end
|
|
119
|
+
|
|
115
120
|
# Mark the current context as being a looping element (each) whose DOM id needs to be propagated to sub-nodes
|
|
116
121
|
# in order to ensure uniqueness of the dom_id (loops in loops problem).
|
|
117
122
|
def propagate_dom_scope!
|
data/lib/zafu/process/ajax.rb
CHANGED
|
@@ -36,8 +36,6 @@ module Zafu
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
if need_ajax?(each_block)
|
|
39
|
-
node.dom_prefix = dom_name
|
|
40
|
-
|
|
41
39
|
# 1. Render inline
|
|
42
40
|
# assign [] to var
|
|
43
41
|
out "<% if (#{var} = #{finder[:method]}) || (#{node}.#{finder[:class].first <= Comment ? "can_comment?" : "can_write?"} && #{var}=[]) %>"
|
|
@@ -48,7 +46,9 @@ module Zafu
|
|
|
48
46
|
# Pagination count and other contextual variables exist here.
|
|
49
47
|
|
|
50
48
|
tmplt_node = self.node.move_to(var, finder[:class])
|
|
51
|
-
|
|
49
|
+
# Own scope
|
|
50
|
+
node.dom_prefix = dom_name
|
|
51
|
+
tmplt_node.dom_prefix = dom_name
|
|
52
52
|
|
|
53
53
|
# INLINE ==========
|
|
54
54
|
out wrap(
|
|
@@ -133,42 +133,60 @@ module Zafu
|
|
|
133
133
|
return expand_with
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
# Since we are using ajax, we will need this object to have an ID set.
|
|
137
|
-
node.dom_prefix = dom_name
|
|
138
|
-
|
|
139
136
|
@markup.done = false
|
|
140
137
|
|
|
141
138
|
if @context[:block] == self
|
|
142
|
-
# Storing
|
|
143
|
-
#
|
|
139
|
+
# Storing our block template
|
|
140
|
+
#node.dom_prefix = dom_name
|
|
144
141
|
@markup.set_id(node.dom_id(:list => false))
|
|
145
142
|
expand_with
|
|
143
|
+
elsif @context[:saved_template]
|
|
144
|
+
# already in a parent's store operation. Reset scope and simply render inline elements
|
|
145
|
+
# reset scope
|
|
146
|
+
with_context(:node => node.dup, :saved_template => nil) do
|
|
147
|
+
node.saved_dom_id = nil
|
|
148
|
+
node.dom_prefix = dom_name
|
|
149
|
+
@markup.set_id(node.dom_id(:list => false))
|
|
150
|
+
expand_with
|
|
151
|
+
end
|
|
146
152
|
else
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
# Since we are using ajax, we will need this object to have an ID set and
|
|
154
|
+
# have its own template_url and such.
|
|
155
|
+
with_context(:node => node.dup, :saved_template => nil) do
|
|
156
|
+
# reset scope. We only keep current id when we are called from
|
|
157
|
+
# r_drop.
|
|
158
|
+
@markup = @markup.dup
|
|
159
|
+
@markup.set_id(nil)
|
|
160
|
+
node.saved_dom_id = nil
|
|
161
|
+
# our own domain
|
|
162
|
+
node.dom_prefix = dom_name
|
|
163
|
+
|
|
164
|
+
# 1. inline
|
|
165
|
+
# Set id with the current node context (<%= var1.zip %>).
|
|
166
|
+
@markup.set_id(node.dom_id(:list => false))
|
|
167
|
+
|
|
168
|
+
out expand_with
|
|
169
|
+
# 2. store template
|
|
170
|
+
# will wrap with @markup
|
|
171
|
+
store_block(self, :ajax_action => 'show')
|
|
172
|
+
|
|
173
|
+
if edit_block = descendant('edit')
|
|
174
|
+
form_block = descendant('form') || self
|
|
175
|
+
|
|
176
|
+
publish_after_save = form_block.params[:publish] ||
|
|
177
|
+
(edit_block && edit_block.params[:publish])
|
|
178
|
+
|
|
179
|
+
# 3. store form
|
|
180
|
+
cont = {
|
|
181
|
+
:saved_template => form_url(node.dom_prefix),
|
|
182
|
+
:make_form => self == form_block,
|
|
183
|
+
:publish_after_save => publish_after_save,
|
|
184
|
+
:ajax_action => 'edit',
|
|
185
|
+
}
|
|
164
186
|
|
|
165
|
-
|
|
187
|
+
store_block(form_block, cont)
|
|
188
|
+
end
|
|
166
189
|
end
|
|
167
|
-
|
|
168
|
-
# 3. render
|
|
169
|
-
# Set id with the current node context (<%= var1.zip %>).
|
|
170
|
-
@markup.set_id(node.dom_id(:list => false))
|
|
171
|
-
out expand_with
|
|
172
190
|
end
|
|
173
191
|
end
|
|
174
192
|
|
|
@@ -304,14 +322,14 @@ module Zafu
|
|
|
304
322
|
def r_add_btn
|
|
305
323
|
default = node.will_be?(Comment) ? _("btn_add_comment") : _("btn_add")
|
|
306
324
|
|
|
307
|
-
out "<a href='
|
|
325
|
+
out "<a href='javascript:void(0)' onclick='#{@context[:onclick]}'>#{text_for_link(default)}</a>"
|
|
308
326
|
end
|
|
309
327
|
|
|
310
328
|
def r_each
|
|
311
329
|
if @context[:saved_template]
|
|
312
330
|
# render to start a saved template
|
|
313
331
|
node.saved_dom_id = "\#{ndom_id(#{node})}"
|
|
314
|
-
node.dom_prefix
|
|
332
|
+
node.dom_prefix = dom_name unless node.raw_dom_prefix
|
|
315
333
|
node.propagate_dom_scope!
|
|
316
334
|
@markup.set_id(node.dom_id)
|
|
317
335
|
|
data/lib/zafu/process/context.rb
CHANGED
|
@@ -39,6 +39,7 @@ module Zafu
|
|
|
39
39
|
out "<% #{node}.each do |#{var}| %>"
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
raw_dom_prefix = node.raw_dom_prefix
|
|
42
43
|
|
|
43
44
|
with_context(:node => node.move_to(var, node.klass.first, :query => node.opts[:query])) do
|
|
44
45
|
# We pass the :query option for RubyLess resolution by using the QueryBuilder finder
|
|
@@ -48,7 +49,8 @@ module Zafu
|
|
|
48
49
|
if node.list_context?
|
|
49
50
|
# we are still in a list (example: previous context was [[Node]], current is [Node])
|
|
50
51
|
else
|
|
51
|
-
|
|
52
|
+
# Change dom_prefix if it isn't our own (inherited).
|
|
53
|
+
node.dom_prefix = dom_name unless raw_dom_prefix
|
|
52
54
|
node.propagate_dom_scope!
|
|
53
55
|
|
|
54
56
|
if need_dom_id?
|
|
@@ -165,9 +167,9 @@ module Zafu
|
|
|
165
167
|
# Change context for a given scope.
|
|
166
168
|
def with_context(cont, merge = true)
|
|
167
169
|
raise "Block missing" unless block_given?
|
|
168
|
-
cont_bak = @context
|
|
170
|
+
cont_bak = @context
|
|
169
171
|
if merge
|
|
170
|
-
@context.merge
|
|
172
|
+
@context = @context.merge(cont)
|
|
171
173
|
else
|
|
172
174
|
@context = cont
|
|
173
175
|
end
|
data/lib/zafu/process/forms.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Zafu
|
|
|
19
19
|
|
|
20
20
|
if descendant('form_tag')
|
|
21
21
|
# We have a specific place to insert our form
|
|
22
|
-
out expand_with(:form_options => options, :form => self)
|
|
22
|
+
out expand_with(:form_options => options, :form => self, :form_prefix => dom_name)
|
|
23
23
|
else
|
|
24
24
|
r_form_tag(options)
|
|
25
25
|
end
|
|
@@ -31,7 +31,7 @@ module Zafu
|
|
|
31
31
|
form_error_messages(opts[:form_helper])
|
|
32
32
|
|
|
33
33
|
# Render form elements
|
|
34
|
-
out expand_with(opts)
|
|
34
|
+
out expand_with(opts.merge(:form_prefix => dom_name))
|
|
35
35
|
|
|
36
36
|
# Render hidden fields (these must go after normal elements so that focusFirstElement works)
|
|
37
37
|
hidden_fields = form_hidden_fields(options)
|
|
@@ -174,15 +174,16 @@ module Zafu
|
|
|
174
174
|
elsif node && !node.list_context? && type = safe_method_from(node.klass, signature, node)
|
|
175
175
|
# not a list_contex
|
|
176
176
|
# Resolve node context methods: xxx.foo, xxx.bar
|
|
177
|
+
# All direct methods from nodes should be html escaped:
|
|
177
178
|
type = type[:class].call(self, node.klass, signature) if type[:class].kind_of?(Proc)
|
|
178
|
-
type.merge(:receiver => RubyLess::TypedString.new(node.name, :class => node.klass))
|
|
179
|
+
type.merge(:receiver => RubyLess::TypedString.new(node.name, :class => node.klass, :h => true))
|
|
179
180
|
elsif node && node.list_context? && type = safe_method_from(Array, signature, node)
|
|
180
181
|
# FIXME: why do we need this here ? Remove with related code in zafu_safe_definitions ?
|
|
181
182
|
type = type[:class].call(self, node.klass, signature) if type[:class].kind_of?(Proc)
|
|
182
183
|
type.merge(:receiver => RubyLess::TypedString.new(node.name, :class => Array, :elem => node.klass.first))
|
|
183
184
|
elsif node && node.list_context? && type = safe_method_from(node.klass.first, signature, node)
|
|
184
185
|
type = type[:class].call(self, node.klass, signature) if type[:class].kind_of?(Proc)
|
|
185
|
-
type.merge(:receiver => RubyLess::TypedString.new("#{node.name}.first", :class => node.klass.first))
|
|
186
|
+
type.merge(:receiver => RubyLess::TypedString.new("#{node.name}.first", :class => node.klass.first, :h => true))
|
|
186
187
|
elsif @rendering_block_owner && @blocks.first.kind_of?(String) && !added_options
|
|
187
188
|
# Insert the block content into the method: <r:trans>blah</r:trans> becomes trans("blah")
|
|
188
189
|
signature_with_block = signature.dup
|
|
@@ -240,6 +241,9 @@ module Zafu
|
|
|
240
241
|
if res.klass == String && !@blocks.detect {|b| !b.kind_of?(String)}
|
|
241
242
|
if lit = res.literal
|
|
242
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)
|
|
243
247
|
else
|
|
244
248
|
out "<%= #{res} %>"
|
|
245
249
|
end
|
data/zafu.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{zafu}
|
|
8
|
-
s.version = "0.8.
|
|
8
|
+
s.version = "0.8.6"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Gaspard Bucher"]
|
|
12
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2012-05-01}
|
|
13
13
|
s.description = %q{Provides a powerful templating language based on xhtml for rails}
|
|
14
14
|
s.email = %q{gaspard@teti.ch}
|
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zafu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 51
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 8
|
|
9
|
-
-
|
|
10
|
-
version: 0.8.
|
|
9
|
+
- 6
|
|
10
|
+
version: 0.8.6
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Gaspard Bucher
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2012-05-01 00:00:00 +02:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|