mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: improve no-js topic list information
- Provide links to pages - Provied link to last topic
This commit is contained in:
parent
e3f31da861
commit
5db768b69f
2 changed files with 22 additions and 1 deletions
20
app/helpers/list_helper.rb
Normal file
20
app/helpers/list_helper.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module ListHelper
|
||||
def page_links(topic)
|
||||
posts = topic.posts_count
|
||||
max_pages = 10
|
||||
total_pages = (posts / TopicView.chunk_size) + (posts == TopicView.chunk_size ? 0 : 1)
|
||||
|
||||
return if total_pages < 2
|
||||
|
||||
page = [total_pages - (max_pages+1), 2].max
|
||||
|
||||
result = "("
|
||||
while page <= total_pages
|
||||
result << " <a href='#{topic.relative_url}?page=#{page}'>#{page}</a> "
|
||||
page += 1
|
||||
end
|
||||
|
||||
result << ")"
|
||||
result.html_safe
|
||||
end
|
||||
end
|
|
@ -21,10 +21,11 @@
|
|||
<a href='<%= t.relative_url %>' itemprop='item'>
|
||||
<span itemprop='name'><%= t.title %></span>
|
||||
</a>
|
||||
<%= page_links(t) %>
|
||||
<% if !@category && t.category %>
|
||||
<span>[<a href='<%= t.category.url %>'><%= t.category.name %></a>]</span>
|
||||
<% end %>
|
||||
<span title='<%= t 'posts' %>'>(<%= t.posts_count %>)</span>
|
||||
<span title='<%= t 'posts' %>'>(<a href="<%=t.last_post_url%>"><%= t.posts_count %></a>)</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue