FEATURE: add og tags to metadata in individual badges page

This commit is contained in:
Aashaka Shah 2017-04-06 09:32:53 +05:30 committed by Arpit Jalan
parent 5943543ec3
commit 402eaaa773
2 changed files with 7 additions and 4 deletions

View File

@ -38,20 +38,20 @@ class BadgesController < ApplicationController
raise Discourse::NotFound unless SiteSetting.enable_badges raise Discourse::NotFound unless SiteSetting.enable_badges
params.require(:id) params.require(:id)
badge = Badge.enabled.find(params[:id]) @badge = Badge.enabled.find(params[:id])
if current_user if current_user
user_badge = UserBadge.find_by(user_id: current_user.id, badge_id: badge.id) user_badge = UserBadge.find_by(user_id: current_user.id, badge_id: @badge.id)
if user_badge && user_badge.notification if user_badge && user_badge.notification
user_badge.notification.update_attributes read: true user_badge.notification.update_attributes read: true
end end
end end
serialized = MultiJson.dump(serialize_data(badge, BadgeSerializer, root: "badge", include_long_description: true)) serialized = MultiJson.dump(serialize_data(@badge, BadgeSerializer, root: "badge", include_long_description: true))
respond_to do |format| respond_to do |format|
format.html do format.html do
store_preloaded "badge", serialized store_preloaded "badge", serialized
render "default/empty" render :show
end end
format.json { render json: serialized } format.json { render json: serialized }
end end

View File

@ -0,0 +1,3 @@
<% content_for :head do %>
<%= raw crawlable_meta_data(title: "#{@badge.display_name} badge on #{SiteSetting.title}", description: @badge.long_description) %>
<% end %>