lib/zena/use/urls.rb in zena-0.15.2 vs lib/zena/use/urls.rb in zena-0.16.0
- old
+ new
@@ -15,24 +15,26 @@
# ex '/en/document34_print.html'
def zen_path(node, options={})
return '#' unless node
-
- if sharp = options.delete(:sharp)
- if sharp =~ /\[(.+)\]/
- sharp_value = node.safe_read($1)
- elsif sharp == 'true'
- sharp_value = "node#{node[:zip]}"
+ if anchor = options.delete(:anchor)
+ if anchor =~ /\[(.+)\]/
+ anchor_value = node.safe_read($1)
+ elsif anchor == 'true'
+ anchor_value = "node#{node[:zip]}"
else
- sharp_value = sharp
+ fixed = true
+ anchor_value = anchor
end
- if sharp_in = options.delete(:sharp_in)
- sharp_node = sharp_in.kind_of?(Node) ? sharp_in : (node.find(:first, [sharp_in]) || node)
- return "#{zen_path(sharp_node, options)}##{sharp_value}"
+ if anchor_in = options.delete(:anchor_in)
+ anchor_node = anchor_in.kind_of?(Node) ? anchor_in : (node.find(:first, [anchor_in]) || node)
+ return "#{zen_path(anchor_node, options)}##{anchor_value}"
+ elsif fixed
+ return "#{zen_path(node, options)}##{anchor_value}"
else
- return "##{sharp_value}"
+ return "##{anchor_value}"
end
end
opts = options.dup
format = opts.delete(:format)
@@ -41,11 +43,11 @@
mode = opts.delete(:mode)
host = opts.delete(:host)
abs_url_prefix = host ? "http://#{host}" : ''
if node.kind_of?(Document) && format == node.version.content.ext
- if node.public? && !current_site.authentication?
+ if node.public? && !visitor.site.authentication?
# force the use of a cacheable path for the data, even when navigating in '/oo'
pre = node.version.lang
end
end
@@ -58,11 +60,11 @@
opts[:cachestamp] = make_cachestamp(node, mode)
else
opts.delete(:cachestamp) # cachestamp
end
- path = if !asset && node[:id] == current_site[:root_id] && mode.nil? && format == 'html'
+ path = if !asset && node[:id] == visitor.site[:root_id] && mode.nil? && format == 'html'
"#{abs_url_prefix}/#{pre}" # index page
elsif node[:custom_base]
"#{abs_url_prefix}/#{pre}/" +
node.basepath +
(mode ? "_#{mode}" : '') +
@@ -107,10 +109,10 @@
end
# Url for a node. Options are 'mode' and 'format'
# ex 'http://test.host/en/document34_print.html'
def zen_url(node, opts={})
- zen_path(node,opts.merge(:host => current_site[:host]))
+ zen_path(node,opts.merge(:host => visitor.site[:host]))
end
# Return the path to a document's data
def data_path(node, opts={})
if node.kind_of?(Document)
\ No newline at end of file