86 lines
3.2 KiB
Plaintext
86 lines
3.2 KiB
Plaintext
<%= link_to "Forums", forums_path %> →
|
|
<% params_list = params.slice(:query, :title, :content, :author, :label, :reply) %>
|
|
<% if params_list.any? %>
|
|
<%= link_to "All Threads", forumthreads_path %> → Search Results
|
|
<% else %>
|
|
<%= "All Threads" %>
|
|
<% end %>
|
|
<h1>
|
|
<%
|
|
if params[:forum]
|
|
text = "forum '#{Forum.find(params[:forum]).name}'"
|
|
if params_list.except(:forum).any?
|
|
text = "Search Results in #{text} (#{@threads.total_count})"
|
|
else
|
|
text = text.capitalize
|
|
end
|
|
elsif params_list.any?
|
|
text = "Search Results (#{@threads.total_count})"
|
|
else
|
|
text = "All Threads"
|
|
end
|
|
%>
|
|
<%= title text %>
|
|
</h1>
|
|
<br>
|
|
<%= form_tag(forumthreads_path, method: :get) do %>
|
|
<%= text_field_tag "query", params[:query], placeholder: "Search...", class: "searchfield field" %>
|
|
<%= submit_tag "Go", class: "searchfield btn" %>
|
|
<%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %>
|
|
<% if params_list.any? %>
|
|
<% if params[:forum] %>
|
|
<%= link_to "Show All Threads", forumthreads_path(params_list.except("forum")), class: "btn right blue" %>
|
|
<% elsif params_list.except(:controller, :action).any? %>
|
|
<%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %>
|
|
<% end %>
|
|
<% end %>
|
|
<% if params[:forum] %>
|
|
<%= link_to "Go to Forum", forum_path(params[:forum]), class: "btn right blue" %>
|
|
<% end %>
|
|
<% params.slice(:forum, :title, :content, :reply, :label, :author).each do |key, value| %>
|
|
<%= hidden_field_tag key, params[key] %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<div id="forum_groups">
|
|
<% @threads.each do |thread| %>
|
|
<div class="item-group with-avatar" id="thread-<%= thread.id %>">
|
|
<div class="header">
|
|
<%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %>
|
|
<%= render partial: "users/username", locals: { user: thread.author } %>
|
|
<%= link_to thread do %>
|
|
<%= ago thread.created_at %>
|
|
<% end %>
|
|
<span class="comment-counter">
|
|
<%= link_to pluralize(thread.replies.count, "Reply"), thread %>
|
|
</span>
|
|
<div class="clear-right"></div>
|
|
</div>
|
|
<div class="items bold">
|
|
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
|
|
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
|
|
<div class="item-info">
|
|
<% if rpl = thread.replies.order(:id).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 %>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% if @threads.empty? %>
|
|
<br>
|
|
<h3>No results found</h3>
|
|
<% end %>
|
|
<%= paginate @threads %>
|
|
</div>
|