OSDN Git Service

Revises display of search results of explanations
authornangxiang <nangxiang@users.sourceforge.jp>
Wed, 14 Sep 2011 07:29:20 +0000 (16:29 +0900)
committernangxiang <nangxiang@users.sourceforge.jp>
Wed, 14 Sep 2011 07:29:20 +0000 (16:29 +0900)
daxu/app/controllers/daxu_controller.rb
daxu/app/views/daxu/index.html.erb
daxu/app/views/daxu/radical.html.erb
daxu/app/views/daxu/word.html.erb

index 4bf166e..6f8b971 100644 (file)
@@ -5,9 +5,10 @@ class DaxuController < ApplicationController
     vols = DxVolume.find(:all)
     @vols = Array.new
     vols.each do |vol|
+      voltitle = get_voltitle(vol)
       radicals = DxRadical.find(:all, :conditions =>
                                 ["volume_id = ?", vol.id])
-      @vols.push([vol, radicals])
+      @vols.push([voltitle, radicals])
     end
   end
   def radical
@@ -40,10 +41,14 @@ class DaxuController < ApplicationController
       wordid = word.wordid
       rad = DxRadical.find(:first, :conditions => ["id = ?", word.radical_id])
       vol = DxVolume.find(:first, :conditions => ["id = ?", rad.volume_id])
+      voltitle = get_voltitle(vol)
       exp = hilighted_exp(word.exp, @extext)
-      @dxexp_words.push([vol, rad, word, exp])
+      @dxexp_words.push([voltitle, rad, word, exp])
     end
   end
+  def get_voltitle(vol)
+    return vol.title.sub(/說文解字第/u, "")
+  end
   def hilighted_exp(exp, pattern)
 #    span = "<span style='background-color:peachpuff;'>%s</span>"
     span = "<span style='background-color:lightpink;'>%s</span>"
index 6ee5d61..f242cc1 100644 (file)
@@ -5,36 +5,21 @@
 </div>
 
 <div id="sidebar">
-  <h3>検索</h3>
-  <ul>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= label_tag(:char, "親字検索:") %>
-        <%= text_field_tag(:char, "", :size => "5") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= hidden_field_tag(:char, @char) %>
-        <%= label_tag(:extext, "説解検索:") %>
-        <%= text_field_tag(:extext, "", :size => "20") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-  </ul>
+  <%= render :partial => "dxsearch" %>
 </div>
 
 <div id="content">
-  <h2>部首</h2>
+  <h2>説文解字 部首</h2>
   <ul>
     <% @vols.each do |volinfo|%>
-      <% (vol, radicals) = volinfo %>
+      <% (voltitle, radicals) = volinfo %>
       <li>
-       <%= vol.title %>
+       <%= voltitle %>
        <% radicals.each do |rad| %>
-       <%= link_to(rad.name, :controller => "daxu",
-          :action => "radical", :id => rad.id) %>
+         <span style="font-size: 120%">
+            <%= link_to(rad.name, :controller => "daxu",
+              :action => "radical", :id => rad.id) %>
+         </span>
        <% end %>
       </li>
    <% end %>
index ef536b7..f56a35c 100644 (file)
@@ -5,24 +5,7 @@
 </div>
 
 <div id="sidebar">
-  <h3>検索</h3>
-  <ul>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= label_tag(:char, "親字検索:") %>
-        <%= text_field_tag(:char, "", :size => "5") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= hidden_field_tag(:char, @char) %>
-        <%= label_tag(:extext, "説解検索:") %>
-        <%= text_field_tag(:extext, "", :size => "20") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-  </ul>
+  <%= render :partial => "dxsearch" %>
 </div>
 
 <div id="content">
index cc7c254..25ea1e4 100644 (file)
@@ -5,25 +5,7 @@
 </div>
 
 <div id="sidebar">
-  <h3>検索</h3>
-  <ul>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= label_tag(:char, "親字検索:") %>
-        <%= text_field_tag(:char, "", :size => "5") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-    <li>
-      <% form_tag(:controller => "daxu", :action => "word", :method => "get") do %>
-        <%= hidden_field_tag(:char, @char) %>
-        <%= label_tag(:extext, "説解検索:") %>
-        <%= text_field_tag(:extext, "", :size => "20") %>
-        <%= submit_tag("Search") %>
-      <% end %>
-    </li>
-  </ul>
-
+  <%= render :partial => "dxsearch" %>
   <h3>
     説文解字(大徐本)
     <%= link_to_function "▲▼", "new Effect.toggle('sw', 'blind')" %>
   <div id="result">
     <ol>
       <% @dxexp_words.each do |wordinfo|%>
-        <li><% (vol, rad, word, exp) = wordinfo %>
-          <%= vol.title %>
+        <li><% (voltitle, rad, word, exp) = wordinfo %>
+          <%= voltitle %>
          <%= link_to(rad.name + "部", :controller => "daxu",
             :action => "radical", :id => rad.id) %>
           <span class="swlist"><%= word.sw %></span>
-         <span style="font-size: 80%">(<%= word.name %>)</span>
+         <span style="font-size: 100%">
+           (<%= link_to(word.name, :controller => "daxu",
+             :action => "word", :char => word.name) %>)
+         </span>
          <span style="font-size: 110%"><%= exp %></span>
          [<%= word.fanqie %> <%= word.pinyin %>]
         </li>