summaryrefslogtreecommitdiff
path: root/app/views/forumthreads/index.html.erb
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/forumthreads/index.html.erb')
-rw-r--r--app/views/forumthreads/index.html.erb84
1 files changed, 84 insertions, 0 deletions
diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb
new file mode 100644
index 0000000..d765cda
--- /dev/null
+++ b/app/views/forumthreads/index.html.erb
@@ -0,0 +1,84 @@
+<%= link_to "Forums", forums_path %> →
+<% if params.to_hash.slice("label", "title", "content", "author", "reply").size > 0 %>
+ <%= link_to "All Threads", forumthreads_path %> → Search Results
+<% else %>
+ <%= "All Threads" %>
+<% end %>
+<% params_list = params.to_hash.slice("id", "query", "label", "title", "content", "author", "reply") %>
+<h1>
+ <% if params[:id] %>
+ <% text = "forum '#{Forum.find(params[:id]).name}'" %>
+ <% else %>
+ <% text = "all threads" %>
+ <% end %>
+ <% if params_list.size > 0 %>
+ <%= title "Search results in #{text} (#{@threads.length})" %>
+ <% else %>
+ <% if params[:id] %>
+ <%= title "All threads in #{text}" %>
+ <% else %>
+ <%= title "All Threads" %>
+ <% end %>
+ <% end %>
+ <br>
+ <%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %>
+ <% if params_list.size > 0 && params[:id] %>
+ <%= link_to "Show All Threads", forumthreads_path(params_list.except("id")), class: "btn right blue" %>
+ <% elsif params_list.size > 0 && !params[:id] %>
+ <%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %>
+ <% end %>
+ <% if params[:id] %>
+ <%= link_to "Go to Forum", forum_path(params[:id]), class: "btn right blue" %>
+ <% end %>
+</h1>
+<br>
+<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post, style: "margin:0px;height:40px") do %>
+ <%= text_field_tag "query", nil, placeholder: "Search...", style: "margin:0px;height:40px;width:300px" %>
+ <% params.each do |key, value| %>
+ <%= hidden_field_tag key, params[key] if params[key] && params[key] != params[:query] %>
+ <% end %>
+ <%= submit_tag "Go", class: "btn blue", style: "margin:0px;height:40px;width:40px" %>
+<% end %>
+</h1>
+<div id="forum_groups">
+ <% counter = 0 %>
+ <% @threads.each do |thread| %>
+ <% counter += 1 %>
+ <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.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 counter == 0 %>
+ <h3>No results found</h3>
+ <% end %>
+ <%= paginate @threads %>
+</div>