instead of parsing category line by markup engine etc, convert it to /list/?category=XYZ hyperlinks
This commit is contained in:
parent
dfde41e63e
commit
dc6c455426
|
@ -18,14 +18,18 @@ class Category < Chunk::Abstract
|
||||||
@list = match_data[2].split(',').map { |c| c.strip }
|
@list = match_data[2].split(',').map { |c| c.strip }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Mark this chunk's start and end points but allow the terms
|
|
||||||
# after the ':' to be marked up.
|
|
||||||
def mask(content) pre_mask + list.join(', ') + post_mask end
|
|
||||||
|
|
||||||
# If the chunk is hidden, erase the mask and return this chunk
|
# If the chunk is hidden, erase the mask and return this chunk
|
||||||
# otherwise, surround it with a 'div' block.
|
# otherwise, surround it with a 'div' block.
|
||||||
def unmask(content)
|
def unmask(content)
|
||||||
replacement = ( hidden ? '' : '<div class="property">category:\1</div>' )
|
return '' if hidden
|
||||||
self if content.sub!( Regexp.new( pre_mask+'(.*)?'+post_mask ), replacement )
|
|
||||||
|
category_urls = @list.map{|category| url(category) }.join(', ')
|
||||||
|
replacement = '<div class="property"> category: ' + category_urls + '</div>'
|
||||||
|
self if content.sub!(mask(content), replacement)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO move presentation of page metadata to controller/view
|
||||||
|
def url(category)
|
||||||
|
%{<a class="category_link" href="../list/?category=#{category}">#{category}</a>}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue