From dc6c45542654f11e28d12524fd907fa4c4555751 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Thu, 20 Jan 2005 13:34:15 +0000 Subject: [PATCH] instead of parsing category line by markup engine etc, convert it to /list/?category=XYZ hyperlinks --- app/models/chunks/category.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/chunks/category.rb b/app/models/chunks/category.rb index 7165a26f..95010d03 100755 --- a/app/models/chunks/category.rb +++ b/app/models/chunks/category.rb @@ -18,14 +18,18 @@ class Category < Chunk::Abstract @list = match_data[2].split(',').map { |c| c.strip } 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 # otherwise, surround it with a 'div' block. def unmask(content) - replacement = ( hidden ? '' : '
category:\1
' ) - self if content.sub!( Regexp.new( pre_mask+'(.*)?'+post_mask ), replacement ) + return '' if hidden + + category_urls = @list.map{|category| url(category) }.join(', ') + replacement = '
category: ' + category_urls + '
' + self if content.sub!(mask(content), replacement) + end + + # TODO move presentation of page metadata to controller/view + def url(category) + %{#{category}} end end