add dedicated wiki page search
This commit is contained in:
@@ -105,7 +105,12 @@ module ApplicationHelper
|
|||||||
|
|
||||||
def search_field(method, options = {})
|
def search_field(method, options = {})
|
||||||
name = options[:label] || method.titleize
|
name = options[:label] || method.titleize
|
||||||
raw '<div class="input"><label for="search_' + method + '">' + name + '</label><input type="text" name="search[' + method + ']" id="search_' + method + '"></div>'
|
string = '<div class="input"><label for="search_' + method + '">' + name + '</label><input type="text" name="search[' + method + ']" id="search_' + method + '">'
|
||||||
|
if options[:hint]
|
||||||
|
string += '<p class="hint">' + options[:hint] + '</p>'
|
||||||
|
end
|
||||||
|
string += '</div>'
|
||||||
|
string.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class WikiPage < ActiveRecord::Base
|
|||||||
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].downcase)
|
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].downcase)
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:sort] == "time"
|
if params[:sort] == "time" || params[:sort] == "Date"
|
||||||
q = q.order("updated_at desc")
|
q = q.order("updated_at desc")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", wiki_pages_path %></li>
|
<li><%= link_to "Listing", wiki_pages_path %></li>
|
||||||
|
<li><%= link_to "Search", search_wiki_pages_path %></li>
|
||||||
<li><%= link_to "New", new_wiki_page_path %></li>
|
<li><%= link_to "New", new_wiki_page_path %></li>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:wiki"}) %></li>
|
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:wiki"}) %></li>
|
||||||
<% if @wiki_page %>
|
<% if @wiki_page %>
|
||||||
|
|||||||
22
app/views/wiki_pages/search.html.erb
Normal file
22
app/views/wiki_pages/search.html.erb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<div id="c-wiki-pages">
|
||||||
|
<div id="a-search">
|
||||||
|
<%= form_tag(wiki_pages_path, :method => :get, :class => "simple_form") do %>
|
||||||
|
<%= search_field "title", :hint => "Use * for wildcard searches" %>
|
||||||
|
<%= search_field "creator_name" %>
|
||||||
|
<%= search_field "body_matches", :label => "Body" %>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label for="search_sort">Sort</label>
|
||||||
|
<%= select "search", "sort", ["Name", "Date"] %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "secondary_links" %>
|
||||||
|
|
||||||
|
<% content_for(:page_title) do %>
|
||||||
|
Search Wiki - <%= Danbooru.config.app_name %>
|
||||||
|
<% end %>
|
||||||
@@ -183,6 +183,7 @@ Danbooru::Application.routes.draw do
|
|||||||
put :revert
|
put :revert
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
|
get :search
|
||||||
get :show_or_new
|
get :show_or_new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user