%= link_to "Forums", forums_path %> →
<% params_list = params.to_hash %>
<% if params_list.any? %>
<%= link_to "All Threads", forumthreads_path %> → Search Results
<% else %>
<%= "All Threads" %>
<% end %>
<%
if params[:id]
text = "forum '#{Forum.find(params[:id]).name}'"
if params_list.any?
text = "Search results in #{text} (#{@threads.length})"
else
text = text.capitalize
end
elsif params_list.any?
text = "Search results (#{@threads.length})"
else
text = "All threads"
end
%>
<%= title text %>
<%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %>
<% if params_list.any? %>
<% if params[:id] %>
<%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %>
<% else %>
<%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %>
<% end %>
<% end %>
<% if params[:id] %>
<%= link_to "Go to Forum", forum_path(params[:id]), class: "btn right blue" %>
<% end %>
<%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: nil) do %>
<%= text_field_tag "query", params[:query], placeholder: "Search...", style: "width:300px" %>
<% params_list.compact.except("query").each do |key, value| %>
<%= hidden_field_tag key, params[key] %>
<% end %>
<%= submit_tag "Go", class: "searchfield btn", style: "width:40px", name: nil %>
<% end %>
<% @threads.each do |thread| %>
">
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
<% if rpl = thread.replies.last %>
<%= rpl.author.name %>
<%
position = thread.replies.count - 1
page = position / Kaminari.config.default_per_page + 1
%>
<%= link_to "replied", forumthread_path(thread, page: page) + "#reply-#{rpl.id}" %>
<%= ago rpl.created_at %>.
<% else %>
No replies yet.
<% end %>
<% end %>
<% if @threads.empty? %>
No results found
<% end %>
<%= paginate @threads %>