diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
| commit | 683526b38442a9873d83a542b5cba1d15efc14d5 (patch) | |
| tree | 5cdf7d762d829d328e3c6437318d20af72bc65bf /app/controllers | |
| parent | 464af1625349d557f688da9f845471ef8b80a5f9 (diff) | |
Bind aggregates over scoped tags to their subtree
CccConventions::TAG_SCOPES maps "update" and "pressemitteilung" to /updates
and "disclosure" to /disclosure. Page.aggregate applies the mapping, so an
aggregate over one of those tags is bounded by its subtree regardless of what
the shortcode says. Tags stay unrestricted; positions are publish-gated.
Both RSS actions call Page.aggregate rather than repeating its tag join.
Empty feeds no longer crash: Atom falls back to the current time for the
required <updated>, and the optional dc:date is omitted.
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/rss_controller.rb | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb index 655ccba4..c2149d90 100644 --- a/app/controllers/rss_controller.rb +++ b/app/controllers/rss_controller.rb | |||
| @@ -1,19 +1,12 @@ | |||
| 1 | class RssController < ApplicationController | 1 | class RssController < ApplicationController |
| 2 | 2 | ||
| 3 | before_action :get_host | 3 | before_action :get_host |
| 4 | 4 | ||
| 5 | def updates | 5 | def updates |
| 6 | expires_in 31.minutes, :public => true | 6 | expires_in 31.minutes, :public => true |
| 7 | |||
| 8 | I18n.locale = I18n.default_locale | 7 | I18n.locale = I18n.default_locale |
| 9 | 8 | ||
| 10 | @items = Page.heads | 9 | @items = feed_items("update") |
| 11 | .joins("JOIN taggings ON taggings.taggable_id = pages.id | ||
| 12 | AND taggings.taggable_type = 'Page' | ||
| 13 | AND taggings.context = 'tags'") | ||
| 14 | .joins("JOIN tags ON tags.id = taggings.tag_id") | ||
| 15 | .where("LOWER(tags.name) = ?", "update") | ||
| 16 | .order("published_at DESC").limit(20) | ||
| 17 | 10 | ||
| 18 | respond_to do |format| | 11 | respond_to do |format| |
| 19 | format.xml {} | 12 | format.xml {} |
| @@ -23,16 +16,10 @@ class RssController < ApplicationController | |||
| 23 | 16 | ||
| 24 | def tag_updates | 17 | def tag_updates |
| 25 | expires_in 31.minutes, :public => true | 18 | expires_in 31.minutes, :public => true |
| 26 | |||
| 27 | I18n.locale = I18n.default_locale | 19 | I18n.locale = I18n.default_locale |
| 28 | @tag = params[:tag] | 20 | |
| 29 | @items = Page.heads | 21 | @tag = params[:tag] |
| 30 | .joins("JOIN taggings ON taggings.taggable_id = pages.id | 22 | @items = feed_items(@tag) |
| 31 | AND taggings.taggable_type = 'Page' | ||
| 32 | AND taggings.context = 'tags'") | ||
| 33 | .joins("JOIN tags ON tags.id = taggings.tag_id") | ||
| 34 | .where("LOWER(tags.name) = ?", @tag.downcase) | ||
| 35 | .order("published_at DESC").limit(20) | ||
| 36 | 23 | ||
| 37 | respond_to do |format| | 24 | respond_to do |format| |
| 38 | format.xml {} | 25 | format.xml {} |
| @@ -40,7 +27,14 @@ class RssController < ApplicationController | |||
| 40 | end | 27 | end |
| 41 | 28 | ||
| 42 | protected | 29 | protected |
| 43 | 30 | ||
| 31 | def feed_items tag | ||
| 32 | Page.aggregate(:tags => tag.to_s.downcase, | ||
| 33 | :limit => 20, | ||
| 34 | :order_by => "published_at", | ||
| 35 | :order_direction => "DESC") | ||
| 36 | end | ||
| 37 | |||
| 44 | def get_host | 38 | def get_host |
| 45 | @host = request.protocol + request.host_with_port | 39 | @host = request.protocol + request.host_with_port |
| 46 | end | 40 | end |
