add dedicated wiki page search

This commit is contained in:
albert
2013-02-21 13:27:01 -05:00
parent b071cabc76
commit fef8597564
5 changed files with 31 additions and 2 deletions

View File

@@ -105,7 +105,12 @@ module ApplicationHelper
def search_field(method, options = {})
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
protected

View File

@@ -44,7 +44,7 @@ class WikiPage < ActiveRecord::Base
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].downcase)
end
if params[:sort] == "time"
if params[:sort] == "time" || params[:sort] == "Date"
q = q.order("updated_at desc")
end

View File

@@ -1,6 +1,7 @@
<% content_for(:secondary_links) do %>
<menu>
<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 "Help", wiki_pages_path(:search => {:title => "help:wiki"}) %></li>
<% if @wiki_page %>

View 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 %>

View File

@@ -183,6 +183,7 @@ Danbooru::Application.routes.draw do
put :revert
end
collection do
get :search
get :show_or_new
end
end