mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 16:23:43 +08:00
e2154b3d59
* FEATURE: Small improvements to the topic list embed - Ability to wrap the list in a custom class so you can styles different lists using specific CSS - Adds a topic link to the thumbnail when using the complete template * FIX: Be more strict about allowed chars in class name
69 lines
3.1 KiB
Plaintext
69 lines
3.1 KiB
Plaintext
<%- if @list && @list.topics.present? %>
|
|
<%- if @allow_create %>
|
|
<%= link_to @create_url, target: "_blank" do |link| %>
|
|
<button class="new-topic-btn btn btn-primary">
|
|
<span class="new-topic-btn__icon"></span>
|
|
<span class="new-topic-btn__text"><%= I18n.t('embed.new_topic') %></span>
|
|
</button>
|
|
<%- end %>
|
|
<%- end %>
|
|
<div class='topics-list <%= @embed_class %>' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
|
|
<%- @list.topics.each do |t| %>
|
|
<div class='topic-list-item'>
|
|
<%- if @template == "complete" %>
|
|
<div class='main-link'>
|
|
<div class="topic-column-wrapper">
|
|
<div class='topic-column details-column'>
|
|
<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.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}', '40') %>">
|
|
<span class="topic-author-username">
|
|
<%= t.user.username %>
|
|
</span>
|
|
<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>
|
|
|
|
<div class='topic-column featured-image-column'>
|
|
<%- if t.image_url.present? %>
|
|
<div class='topic-featured-image'>
|
|
<a target="_parent" href="<%= t.url %>" class="title raw-link raw-topic-link" data-topic-id="<%= t.id %>">
|
|
<img src="<%= t.image_url %>">
|
|
</a>
|
|
</div>
|
|
<%- end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<%- else %>
|
|
<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>
|
|
</div>
|
|
<%- end %>
|
|
</div>
|
|
<%- end %>
|
|
</div>
|
|
<%- end %>
|