mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FEATURE: embed topic with detailed metadata (#8062)
This commit is contained in:
@ -186,6 +186,7 @@ div.lightbox-wrapper {
|
|||||||
border-bottom: 1px solid $primary-low;
|
border-bottom: 1px solid $primary-low;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: $primary;
|
color: $primary;
|
||||||
@ -195,5 +196,37 @@ div.lightbox-wrapper {
|
|||||||
color: $primary-medium;
|
color: $primary-medium;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.topic-title-link {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-featured-image {
|
||||||
|
float: right;
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-last-posted-at, .topic-author-avatar-timestamp, .topic-stats {
|
||||||
|
clear: left;
|
||||||
|
float: left;
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-author-avatar-timestamp img {
|
||||||
|
max-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-created-at {
|
||||||
|
padding-left: 5px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-last-posted-at, .topic-created-at, .topic-stats {
|
||||||
|
color: $primary-medium;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,12 @@ class EmbedController < ApplicationController
|
|||||||
raise Discourse::InvalidParameters.new(:embed_id) unless @embed_id =~ /^de\-[a-zA-Z0-9]+$/
|
raise Discourse::InvalidParameters.new(:embed_id) unless @embed_id =~ /^de\-[a-zA-Z0-9]+$/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params.has_key?(:template)
|
||||||
|
@template = params[:template]
|
||||||
|
else
|
||||||
|
@template = "basic"
|
||||||
|
end
|
||||||
|
|
||||||
list_options = build_topic_list_options
|
list_options = build_topic_list_options
|
||||||
list_options[:per_page] = params[:per_page].to_i if params.has_key?(:per_page)
|
list_options[:per_page] = params[:per_page].to_i if params.has_key?(:per_page)
|
||||||
topic_query = TopicQuery.new(current_user, list_options)
|
topic_query = TopicQuery.new(current_user, list_options)
|
||||||
|
@ -2,9 +2,45 @@
|
|||||||
<div class='topics-list' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
|
<div class='topics-list' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
|
||||||
<%- @list.topics.each do |t| %>
|
<%- @list.topics.each do |t| %>
|
||||||
<div class='topic-list-item'>
|
<div class='topic-list-item'>
|
||||||
|
<%- if @template == "complete" %>
|
||||||
|
<div class='main-link'>
|
||||||
|
<div class='topic-title-link'>
|
||||||
|
<a target="_parent" href="<%= t.url %>" class="title raw-link raw-topic-link" data-topic-id="<%= t.id %>"><%= t.title %></a>
|
||||||
|
</div>
|
||||||
|
<%- if t.image_url.present? %>
|
||||||
|
<div class='topic-featured-image'>
|
||||||
|
<img src="<%= t.image_url %>">
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
||||||
|
<%- if t.posts_count > 1 %>
|
||||||
|
<div class="topic-last-posted-at" title="<%= t.last_posted_at.strftime("%B %e, %Y %l:%M%P") %>">
|
||||||
|
<%= "#{I18n.t('embed.last_reply')} #{time_ago_in_words(t.last_posted_at, scope: :'datetime.distance_in_words_verbose')}" %>
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
||||||
|
<div class='topic-author-avatar-timestamp'>
|
||||||
|
<img src="<%= t.user.avatar_template.gsub('{size}', '20') %>">
|
||||||
|
<span class="topic-created-at" title="<%= t.created_at.strftime("%B %e, %Y %l:%M%P") %>">
|
||||||
|
<%= "#{I18n.t('embed.created')} #{time_ago_in_words(t.created_at, scope: :'datetime.distance_in_words_verbose')}" %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class='topic-stats'>
|
||||||
|
<%- if t.like_count > 0 %>
|
||||||
|
<div class='topic-like-count'>
|
||||||
|
<%= I18n.t('embed.likes', count: t.like_count) %>
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
||||||
|
<%- if t.posts_count > 1 %>
|
||||||
|
<div class='topic-post-count'>
|
||||||
|
<%= I18n.t('embed.replies', count: (t.posts_count - 1)) %>
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%- else %>
|
||||||
<div class='main-link'>
|
<div class='main-link'>
|
||||||
<a target="_parent" href="<%= t.url %>" class="title raw-link raw-topic-link" data-topic-id="<%= t.id %>"><%= t.title %></a>
|
<a target="_parent" href="<%= t.url %>" class="title raw-link raw-topic-link" data-topic-id="<%= t.id %>"><%= t.title %></a>
|
||||||
</div>
|
</div>
|
||||||
|
<%- end %>
|
||||||
</div>
|
</div>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -283,6 +283,11 @@ en:
|
|||||||
replies:
|
replies:
|
||||||
one: "%{count} reply"
|
one: "%{count} reply"
|
||||||
other: "%{count} replies"
|
other: "%{count} replies"
|
||||||
|
likes:
|
||||||
|
one: "%{count} like"
|
||||||
|
other: "%{count} likes"
|
||||||
|
last_reply: "Last reply"
|
||||||
|
created: "Created"
|
||||||
|
|
||||||
no_mentions_allowed: "Sorry, you can't mention other users."
|
no_mentions_allowed: "Sorry, you can't mention other users."
|
||||||
too_many_mentions:
|
too_many_mentions:
|
||||||
|
Reference in New Issue
Block a user