moved all search styling to CSS, removed friendly (but slow) URLs, moved WHERE strings into an array

This commit is contained in:
MrYummy
2017-06-02 02:10:49 +02:00
parent 4619306744
commit d2de01100a
10 changed files with 164 additions and 56 deletions

View File

@@ -2,8 +2,7 @@
<h1>
<%= title @forum %>
<% params[:id] = @forum.id %>
<%= link_to "Search Threads", forumthreads_path(params.to_hash), class: "btn blue right" %>
<%= link_to "Search Threads", forumthreads_path(forum: @forum.id), class: "btn blue right" %>
</h1>
<% if @forum.can_write?(current_user) %>
<p>

View File

@@ -7,8 +7,8 @@
<% end %>
<h1>
<%
if params[:id]
text = "forum '#{Forum.find(params[:id]).name}'"
if params[:forum]
text = "forum '#{Forum.find(params[:forum]).name}'"
if params_list.any?
text = "Search results in #{text} (#{@threads.length})"
else
@@ -21,29 +21,27 @@
end
%>
<%= title text %>
<br>
<%= 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 %>
</h1>
<div class="searchfield">
<%= 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 %>
<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" %>
<% params.slice(:title, :content, :reply, :label, :author).each do |key, value| %>
<%= hidden_field_tag key, params[key] %>
<% end %>
</div>
</h1>
<% end %>
<%= 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 %>
<div id="forum_groups">
<% @threads.each do |thread| %>
<div class="item-group with-avatar" id="thread-<%= thread.id %>">

View File

@@ -4,7 +4,7 @@
<% label = Label.where(name: params[:label]).first %>
<table>
<tbody>
<%= form_tag({controller: "forumthreads", action: "index"}, method: :get, enforce_utf8: false) do %>
<%= form_tag(forumthreads_path, method: :get) do %>
<%
forums = []
Forum.select{|f| f.can_read?(current_user)}.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f|
@@ -14,7 +14,7 @@
<% label_list = Label.pluck(:name).prepend("No Label") %>
<tr>
<td>Forum</td>
<td><%= select_tag "id", options_for_select(forums, params[:id]), include_blank: "Search All Threads" %></td>
<td><%= select_tag "forum", options_for_select(forums, params[:forum]), include_blank: "Search All Threads" %></td>
</tr>
<tr>
<td>Label</td>