diff options
| author | hukl <hukl@eight.local> | 2009-02-02 21:12:50 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-02-02 21:12:50 +0100 |
| commit | a5d0690d323b2f45fb4210470461b35ebe31e826 (patch) | |
| tree | 25b4b6e709958ae3c4ad2d05e0f7e19af2ae2c8e /app/helpers | |
| parent | d7fbc1351dce84f27becd8b2d1cdb450ed94684b (diff) | |
| parent | d0c3cd743e8500f643ff54b93e4a599c7e16b9d1 (diff) | |
Merge branch 'aggregate_xml' into poc1
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/content_helper.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 0e1df66..3cf3488 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb | |||
| @@ -1,8 +1,34 @@ | |||
| 1 | module ContentHelper | 1 | module ContentHelper |
| 2 | 2 | ||
| 3 | # | ||
| 4 | def date_for_page page | 3 | def date_for_page page |
| 5 | page.published_at.to_s(:db) rescue page.created_at.to_s(:db) | 4 | page.published_at.to_s(:db) rescue page.created_at.to_s(:db) |
| 6 | end | 5 | end |
| 7 | 6 | ||
| 7 | def aggregate? content | ||
| 8 | options = {} | ||
| 9 | |||
| 10 | begin | ||
| 11 | if content =~ /<aggregate([^<>]*)>/ | ||
| 12 | tag = $~.to_s | ||
| 13 | matched_data = $1.scan(/\w+\=\"[a-zA-Z\s\/_\d]*\"/) | ||
| 14 | |||
| 15 | matched_data.each do |data| | ||
| 16 | splitted_data = data.split("=") | ||
| 17 | options[splitted_data[0].to_sym] = splitted_data[1].gsub(/\"/, "") | ||
| 18 | end | ||
| 19 | |||
| 20 | content.sub(tag, render_collection(options)) | ||
| 21 | end | ||
| 22 | |||
| 23 | rescue | ||
| 24 | content | ||
| 25 | end | ||
| 26 | end | ||
| 27 | |||
| 28 | def render_collection options | ||
| 29 | render( | ||
| 30 | :partial => 'content/article', | ||
| 31 | :collection => Page.aggregate(options) | ||
| 32 | ) | ||
| 33 | end | ||
| 8 | end | 34 | end |
