[Groonga-commit] ranguba/ranguba-server at 2d9dd67 [master] Support full text search

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Feb 22 00:37:56 JST 2017


Kouhei Sutou	2017-02-22 00:37:56 +0900 (Wed, 22 Feb 2017)

  New Revision: 2d9dd676b59a6c6ff99e322c5d78a0757dcff084
  https://github.com/ranguba/ranguba-server/commit/2d9dd676b59a6c6ff99e322c5d78a0757dcff084

  Message:
    Support full text search

  Modified files:
    app/assets/stylesheets/application.scss
    app/controllers/entries_controller.rb
    app/views/entries/index.html.erb

  Modified: app/assets/stylesheets/application.scss (+22 -0)
===================================================================
--- app/assets/stylesheets/application.scss    2017-02-22 00:21:25 +0900 (80e80d4)
+++ app/assets/stylesheets/application.scss    2017-02-22 00:37:56 +0900 (97bfb70)
@@ -40,9 +40,31 @@ header {
 div.content {
   @extend .container;
 
+  span.keyword {
+    @extend .bg-info;
+    @extend .text-white;
+  }
+
   section.entries {
     @extend .list-group;
 
+    form {
+      @extend .form-inline;
+
+      div {
+        @extend .input-group;
+
+        input[type="text"] {
+          @extend .form-control;
+        }
+
+        input[type="submit"] {
+          @extend .btn;
+          @extend .btn-primary;
+        }
+      }
+    }
+
     section.entry {
       @extend .list-group-item;
       @extend .list-group-item-action;

  Modified: app/controllers/entries_controller.rb (+8 -1)
===================================================================
--- app/controllers/entries_controller.rb    2017-02-22 00:21:25 +0900 (e4f0bab)
+++ app/controllers/entries_controller.rb    2017-02-22 00:37:56 +0900 (9e87927)
@@ -4,7 +4,14 @@ class EntriesController < ApplicationController
   # GET /entries
   # GET /entries.json
   def index
-    @request = Entry.all.
+    @query = params[:query]
+    @request = Entry.select.
+      query(@query).
+      output_columns([
+                       "_key",
+                       "*",
+                       "highlight_html(texts[0])",
+                     ]).
       paginate(params[:page], per_page: params[:per_page])
   end
 

  Modified: app/views/entries/index.html.erb (+19 -7)
===================================================================
--- app/views/entries/index.html.erb    2017-02-22 00:21:25 +0900 (200b00d)
+++ app/views/entries/index.html.erb    2017-02-22 00:37:56 +0900 (7ddfaaa)
@@ -1,18 +1,30 @@
 <p id="notice"><%= notice %></p>
 
-<div class="page-info">
-  <%= page_entries_info(@request.response) %>
-</div>
-
 <section class="entries">
   <h1>Entries</h1>
 
-  <% @request.response.entries.each do |entry| %>
+  <%= form_tag(entries_path,
+               method: :get) do %>
+    <div>
+      <%= text_field_tag("query", @query) %>
+      <%= submit_tag("Search") %>
+    </div>
+  <% end %>
+
+  <div class="page-info">
+    <%= page_entries_info(@request.response) %>
+  </div>
+
+  <% @request.response.records.each do |entry| %>
   <section class="entry">
     <h2><%= link_to(entry.title, entry) %></h2>
     <p class="url"><%= entry._key %></p>
-    <% entry.texts.each do |text| %>
-    <pre><%= text %></pre>
+    <% if entry.highlight_html.present? %>
+      <pre><%= entry.highlight_html.html_safe %></pre>
+    <% else %>
+      <% entry.texts.each do |text| %>
+      <pre><%= text %></pre>
+      <% end %>
     <% end %>
   </section>
   <% end %>
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index