From 683526b38442a9873d83a542b5cba1d15efc14d5 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 31 Jul 2026 18:55:35 +0200 Subject: 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 , and the optional dc:date is omitted. --- app/controllers/rss_controller.rb | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'app/controllers/rss_controller.rb') 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 @@ class RssController < ApplicationController before_action :get_host - + def updates expires_in 31.minutes, :public => true - I18n.locale = I18n.default_locale - - @items = Page.heads - .joins("JOIN taggings ON taggings.taggable_id = pages.id - AND taggings.taggable_type = 'Page' - AND taggings.context = 'tags'") - .joins("JOIN tags ON tags.id = taggings.tag_id") - .where("LOWER(tags.name) = ?", "update") - .order("published_at DESC").limit(20) + + @items = feed_items("update") respond_to do |format| format.xml {} @@ -23,16 +16,10 @@ class RssController < ApplicationController def tag_updates expires_in 31.minutes, :public => true - I18n.locale = I18n.default_locale - @tag = params[:tag] - @items = Page.heads - .joins("JOIN taggings ON taggings.taggable_id = pages.id - AND taggings.taggable_type = 'Page' - AND taggings.context = 'tags'") - .joins("JOIN tags ON tags.id = taggings.tag_id") - .where("LOWER(tags.name) = ?", @tag.downcase) - .order("published_at DESC").limit(20) + + @tag = params[:tag] + @items = feed_items(@tag) respond_to do |format| format.xml {} @@ -40,7 +27,14 @@ class RssController < ApplicationController end protected - + + def feed_items tag + Page.aggregate(:tags => tag.to_s.downcase, + :limit => 20, + :order_by => "published_at", + :order_direction => "DESC") + end + def get_host @host = request.protocol + request.host_with_port end -- cgit v1.3