From 10e217841ef07f3cdf1ed1c595893b0b40ebb197 Mon Sep 17 00:00:00 2001 From: aifeelit Date: Mon, 7 Nov 2022 21:36:29 -0600 Subject: [PATCH] badge --- app/views/badges/show.html.erb | 4 ++++ app/views/badges/show.rss.erb | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 app/views/badges/show.html.erb create mode 100644 app/views/badges/show.rss.erb diff --git a/app/views/badges/show.html.erb b/app/views/badges/show.html.erb new file mode 100644 index 00000000..1022d59a --- /dev/null +++ b/app/views/badges/show.html.erb @@ -0,0 +1,4 @@ +<% content_for :head do %> + <%= raw crawlable_meta_data(title: I18n.t('badges.badge_title_metadata', display_name: @badge.display_name, site_title: SiteSetting.title), description: @badge.long_description) %> + <%= auto_discovery_link_tag(:rss, "#{@rss_link}.rss", title: @rss_title) %> +<% end %> diff --git a/app/views/badges/show.rss.erb b/app/views/badges/show.rss.erb new file mode 100644 index 00000000..23428f6f --- /dev/null +++ b/app/views/badges/show.rss.erb @@ -0,0 +1,21 @@ + + + + <% lang = SiteSetting.find_by_name('default_locale').try(:value) %> + <% site_email = SiteSetting.find_by_name('contact_email').try(:value) %> + <%= @rss_title %> + <%= @rss_link %> + ]]> + <% if @badge.user_badges.first.present? %> + " rel="self" type="application/rss+xml" /> + <% @badge.user_badges.joins(:user).last(50).reverse_each do |user_badge| %> + + <![CDATA[<%= "@#{user_badge.user.username}#{" #{user_badge.user.name}" if (user_badge.user.name.present? && SiteSetting.enable_names?)}" -%>]]> + <%= user_badge.granted_at.rfc2822 %> + ]]> + <%= "#{@rss_link}?username=#{user_badge.user.username}" %> + + <% end %> + <% end %> + +