full site search with google

This commit is contained in:
Matthew K. Fu JuYuan 2012-07-25 17:20:25 +08:00
parent 25f4e292e6
commit 97b4eee798
6 changed files with 29 additions and 4 deletions

View File

@ -18,6 +18,8 @@ class Site
field :school
field :department
field :search,:type => Hash
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :sub_menu, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy

View File

@ -33,6 +33,15 @@
</div>
<% end %>
<% end %>
<div class="control-group">
<label class="control-label"><%= t 'search.site_search' %></label>
<div class="controls">
<%= text_field_tag 'site[search][domains]',@site.search["domains"], {:class => "input-xxlarge" ,:placeholder => t("search.domains") }%>
<%= text_field_tag 'site[search][sitesearch]',@site.search["sitesearch"],{ :class => "input-xxlarge" ,:placeholder => t("search.sitesearch") }%>
<p class="help-block"><%= (t 'search.site_setting_help').html_safe %></p>
</div>
</div>
<% @site_valid_locales.each do |locale|%>
<%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
<div class="control-group">

View File

@ -34,8 +34,14 @@
<li class="search clear" title="<%= t :search_nccu %>">
<a class="orbit-bar-search" href="#">search</a>
<form class="navbar-search" action="">
<input class="search-query span3" type="text" placeholder="<%= t(:search_nccu) %>">
<form class="navbar-search" method="get" action="http://www.google.com/custom">
<input type="hidden" name="client" value="pub-&amp" />
<input type="hidden" name="ie" id="ie" value="utf-8" />
<input type="hidden" name="oe" id="oe" value="utf-8" />
<input type="hidden" name="cof" id="cof" value="AH:center;AWFID:03de271f1940eea3;" />
<input type='hidden' name='domains' value='<%= @site.search["domains"] %>'>
<input type='hidden' name='sitesearch' value='<%= @site.search["sitesearch"] %>'>
<%= text_field_tag 'q','',{:class => "search-query span3",:placeholder=> t(:search_nccu) ,:disabled=> (@site.search["sitesearch"] || @site.search["domains"] ).blank?}%>
</form>
</li>
<% if user_signed_in? %>

View File

@ -0,0 +1 @@
<tr> <%= t("search.not_found") %> </tr>

View File

@ -294,4 +294,8 @@ en:
limit_of_upload_file_size: "Upload file must be less than: %{best_size}"
search:
not_found: "NOT FOUND"
not_found: "NOT FOUND"
domains: Google Search Domains
site_search: Site Search
sitesearch: Google Site Search
site_setting_help: Please Enter the search argument for Google search.

View File

@ -432,7 +432,10 @@ zh_tw:
search:
not_found: "沒有搜尋結果"
domains: Google Search Domains
site_search: "全站搜尋"
sitesearch: Google Site Search
site_setting_help: 請輸入送交Google搜尋的參數
activerecord:
errors:
template: # ~ 2.3.5 backward compatible