mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:15:05 +08:00
FEATURE: better unfurling of Discourse topics on Slack
This commit is contained in:
parent
0fdac4fc42
commit
6ef1537ee0
|
@ -146,6 +146,16 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
if opts[:read_time]
|
||||
result << tag(:meta, name: 'twitter:label1', value: I18n.t("reading_time"))
|
||||
result << tag(:meta, name: 'twitter:data1', value: "#{opts[:read_time]} mins 🕑")
|
||||
end
|
||||
|
||||
if opts[:like_count]
|
||||
result << tag(:meta, name: 'twitter:label2', value: I18n.t("likes"))
|
||||
result << tag(:meta, name: 'twitter:data2', value: "#{opts[:like_count]} 💚")
|
||||
end
|
||||
|
||||
result.join("\n")
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title><%= @topic_view.topic.title %></title>
|
||||
<%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url) %>
|
||||
<%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url, read_time: @topic_view.read_time, like_count: @topic_view.like_count) %>
|
||||
</head>
|
||||
<body>
|
||||
<% @topic_view.posts.each do |post| %>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
<% content_for :head do %>
|
||||
<%= auto_discovery_link_tag(@topic_view, {action: :feed, slug: @topic_view.topic.slug, topic_id: @topic_view.topic.id}, title: t('rss_posts_in_topic', topic: @topic_view.title), type: 'application/rss+xml') %>
|
||||
<%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url) %>
|
||||
<%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url, read_time: @topic_view.read_time, like_count: @topic_view.like_count) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:title) { "#{@topic_view.page_title}" } %>
|
||||
|
|
|
@ -118,6 +118,9 @@ en:
|
|||
invalid_access: "You are not permitted to view the requested resource."
|
||||
read_only_mode_enabled: "The site is in read only mode. Interactions are disabled."
|
||||
|
||||
reading_time: "Reading time"
|
||||
likes: "Likes"
|
||||
|
||||
too_many_replies:
|
||||
one: "We're sorry, but new users are temporarily limited to 1 reply in the same topic."
|
||||
other: "We're sorry, but new users are temporarily limited to %{count} replies in the same topic."
|
||||
|
|
|
@ -159,6 +159,16 @@ class TopicView
|
|||
(excerpt || "").gsub(/\n/, ' ').strip
|
||||
end
|
||||
|
||||
def read_time
|
||||
return nil if @post_number.present? && @post_number.to_i != 1 # only show for topic URLs
|
||||
(@topic.word_count/500).floor if @topic.word_count
|
||||
end
|
||||
|
||||
def like_count
|
||||
return nil if @post_number.present? && @post_number.to_i != 1 # only show for topic URLs
|
||||
@topic.like_count
|
||||
end
|
||||
|
||||
def image_url
|
||||
@topic.image_url || SiteSetting.default_opengraph_image_url
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user