mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
UX: Add og metadata for groups.
https://meta.discourse.org/t/onebox-for-groups/79155
This commit is contained in:
parent
9d0807224b
commit
76a2fc3d07
@ -12,6 +12,7 @@ class GroupsController < ApplicationController
|
||||
]
|
||||
|
||||
skip_before_action :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
|
||||
skip_before_action :check_xhr, only: [:show]
|
||||
|
||||
def index
|
||||
unless SiteSetting.enable_group_directory?
|
||||
@ -48,7 +49,19 @@ class GroupsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
render_serialized(find_group(:id), GroupShowSerializer, root: 'basic_group')
|
||||
respond_to do |format|
|
||||
group = find_group(:id)
|
||||
|
||||
format.html do
|
||||
@title = group.full_name.present? ? group.full_name.capitalize : group.name
|
||||
@description_meta = group.bio_cooked.present? ? PrettyText.excerpt(group.bio_cooked, 300) : @title
|
||||
render :show
|
||||
end
|
||||
|
||||
format.json do
|
||||
render_serialized(group, GroupShowSerializer, root: 'basic_group')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
3
app/views/groups/show.html.erb
Normal file
3
app/views/groups/show.html.erb
Normal file
@ -0,0 +1,3 @@
|
||||
<% content_for :head do %>
|
||||
<%= raw crawlable_meta_data(title: @title, description: @description_meta) %>
|
||||
<% end %>
|
@ -57,6 +57,24 @@ describe GroupsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
it 'should respond to HTML' do
|
||||
group.update_attribute(:bio_cooked, 'testing group bio')
|
||||
|
||||
get "/groups/#{group.name}.html"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(response.body).to have_tag(:meta, with: {
|
||||
property: 'og:title', content: group.name
|
||||
})
|
||||
|
||||
expect(response.body).to have_tag(:meta, with: {
|
||||
property: 'og:description', content: group.bio_cooked
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe '#mentionable' do
|
||||
it "should return the right response" do
|
||||
sign_in(user)
|
||||
@ -226,7 +244,7 @@ describe GroupsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit" do
|
||||
describe "#edit" do
|
||||
let(:group) { Fabricate(:group) }
|
||||
|
||||
context 'when user is not signed in' do
|
||||
|
Loading…
Reference in New Issue
Block a user