FEATURE: improve no-js topic list information

- Provide links to pages
- Provied link to last topic
This commit is contained in:
Sam Saffron 2015-06-10 00:28:01 +10:00
parent e3f31da861
commit 5db768b69f
2 changed files with 22 additions and 1 deletions

View 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

View file

@ -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>