mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-09 11:48:47 +00:00
Currently we're seeing 500s when related_topics are getting rendered. We should get the topic's category rather than on the array. ``` ActionView::Template::Error (undefined method `category' for [#<Topic id ... ] ```
72 lines
3.4 KiB
Plaintext
72 lines
3.4 KiB
Plaintext
<div id="related-topics" class="more-topics__list " role="complementary" aria-labelledby="related-topics-title">
|
|
<h3 id="related-topics-title" class="more-topics__list-title">
|
|
<%= t 'js.discourse_ai.related_topics.title' %>
|
|
</h3>
|
|
<div class="topic-list-container" itemscope itemtype='http://schema.org/ItemList'>
|
|
<meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'>
|
|
<table class='topic-list'>
|
|
<thead>
|
|
<tr>
|
|
<th><%= t 'js.topic.title' %></th>
|
|
<th></th>
|
|
<th class="replies"><%= t 'js.replies' %></th>
|
|
<th class="views"><%= t 'js.views' %></th>
|
|
<th><%= t 'js.activity' %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @list.each_with_index do |t,i| %>
|
|
<tr class="topic-list-item">
|
|
<td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
|
<meta itemprop='position' content='<%= i + 1 %>'>
|
|
<span class="link-top-line">
|
|
<a itemprop='url' href='<%= t.url %>' class='title raw-link raw-topic-link'><%= t.title %></a>
|
|
</span>
|
|
<div class="link-bottom-line">
|
|
<% if (!@category || @category.has_children?) && t.category && !t.category.uncategorized? %>
|
|
<a href='<%= t.category.url %>' class='badge-wrapper bullet'>
|
|
<span class='badge-category-bg' style='background-color: #<%= t.category.color %>'></span>
|
|
<span class='badge-category clear-badge'>
|
|
<span class='category-name'><%= t.category.name %></span>
|
|
</span>
|
|
</a>
|
|
<% end %>
|
|
<% if tags = t.visible_tags(guardian) %>
|
|
<div class="discourse-tags">
|
|
<% tags.each_with_index do |tag, index| %>
|
|
<a href='<%= tag.full_url %>' class='discourse-tag'><%= tag.name %></a>
|
|
<% if index < tags.size - 1 %>, <% end %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% if t.pinned_until && (t.pinned_until > Time.zone.now) && (t.pinned_globally || t.category) && t.excerpt %>
|
|
<p class='excerpt'>
|
|
<%= t.excerpt.html_safe %>
|
|
</p>
|
|
<% end %>
|
|
</td>
|
|
<td class='posters'>
|
|
<% t.posters.each do |poster| %>
|
|
<a href="<%= Discourse.base_url %>/u/<%= poster.user.username %>" class="<%= poster.extras %>">
|
|
<%- poster_name_and_description = h(poster.name_and_description) %>
|
|
<img width="25" height="25" src="<%= poster.user.avatar_template.gsub('{size}', '25') %>" class="avatar" title='<%= poster_name_and_description %>' aria-label='<%= poster_name_and_description %>'>
|
|
</a>
|
|
<% end %>
|
|
</td>
|
|
<td class="replies">
|
|
<span class='posts' title='<%= t 'posts' %>'><%= t.posts_count - 1 %></span>
|
|
</td>
|
|
<td class="views">
|
|
<span class='views' title='<%= t 'views' %>'><%= t.views %></span>
|
|
</td>
|
|
<td>
|
|
<%= I18n.l(t.last_posted_at || t.created_at, format: :date_only) %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|