Sha256: b64df177eafa22bada3e886e129d82d3ff2f207ac8b5663a260fb55e041cc430
Contents?: true
Size: 757 Bytes
Versions: 3
Compression:
Stored size: 757 Bytes
Contents
description 'Tag to redirect to other pages' Application.hook :render do |name, xml, layout| if params[:redirect] && layout links = [params[:redirect]].flatten.map do |link| %{<a href="#{escape_html build_path(link, :action => :edit)}">#{escape_html link}</a>} end.join(' → ') xml.sub!(/<div id="menu">.*?<\/ul>/m, "\\0Redirected from #{links} → ◎ ") end end Tag.define :redirect, :requires => 'to', :dynamic => true do |context, attrs| list = context.params[:redirect] || [] to = attrs['to'] if list.include?(to) raise "Invalid redirect to #{to}" else list << context.page.path throw :redirect, build_path(to, 'redirect[]' => list, :version => !context.page.head? && context.page) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
olelo-0.9.3 | plugins/tags/redirect.rb |
olelo-0.9.2 | plugins/tags/redirect.rb |
olelo-0.9.1 | plugins/tags/redirect.rb |