[Groonga-commit] ranguba/epub-searcher at 9b5bfd1 [master] Add book list page

アーカイブの一覧に戻る

KITAITI Makoto null+****@clear*****
Thu Dec 25 05:16:11 JST 2014


KITAITI Makoto	2014-12-25 05:16:11 +0900 (Thu, 25 Dec 2014)

  New Revision: 9b5bfd1d80aeaba6c97861002f3e7f6e0b331cc5
  https://github.com/ranguba/epub-searcher/commit/9b5bfd1d80aeaba6c97861002f3e7f6e0b331cc5

  Message:
    Add book list page

  Added files:
    app/views/_book.haml
    app/views/books.haml
  Modified files:
    app/app.rb
    app/controllers/main-controller.rb

  Modified: app/app.rb (+17 -0)
===================================================================
--- app/app.rb    2014-12-25 04:37:31 +0900 (515440b)
+++ app/app.rb    2014-12-25 05:16:11 +0900 (e26e3ef)
@@ -76,6 +76,23 @@ module EPUBSearcher
         db.close
       end
     end
+
+    def books_from_groonga
+      options = {
+        protocol: :http,
+        host: settings.droonga_host,
+        port: settings.droonga_port
+      }
+      db = RemoteDatabase.new(options)
+      begin
+        db.select(
+          :table => :Books,
+          :output_columns => 'author,title,file_path'
+        )
+      ensure
+        db.close
+      end
+    end
   end
 
 end

  Modified: app/controllers/main-controller.rb (+6 -0)
===================================================================
--- app/controllers/main-controller.rb    2014-12-25 04:37:31 +0900 (b81b84c)
+++ app/controllers/main-controller.rb    2014-12-25 05:16:11 +0900 (5d90f56)
@@ -12,4 +12,10 @@ EPUBSearcher::App.controllers do
     render 'index'
   end
 
+  get :books do
+    @books = books_from_groonga
+
+    render 'books'
+  end
+
 end

  Added: app/views/_book.haml (+4 -0) 100644
===================================================================
--- /dev/null
+++ app/views/_book.haml    2014-12-25 05:16:11 +0900 (958d42f)
@@ -0,0 +1,4 @@
+%li{:class => 'media'}
+  %div{:class => 'media-body'}
+    %h4{:class => 'media-heading'}== #{book['title']} - #{book['author']}
+    = book['file_path']

  Added: app/views/books.haml (+11 -0) 100644
===================================================================
--- /dev/null
+++ app/views/books.haml    2014-12-25 05:16:11 +0900 (1fa8fc9)
@@ -0,0 +1,11 @@
+%div{:class => 'container'}
+
+  %div{:class => 'page-header'}
+    %h1= link_to 'EPUB Searcher', url_for(:index)
+
+  %div{:class => 'row'}
+    %div{:class => 'col-md-2'}
+    %div{:class => 'col-md-8'}
+      %ul{:class => 'media-list'}
+        = partial 'book', :collection => @books if @books
+    %div{:class => 'col-md-2'}
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る