Kouhei Sutou
null+****@clear*****
Wed Feb 22 00:09:09 JST 2017
Kouhei Sutou 2017-02-22 00:09:09 +0900 (Wed, 22 Feb 2017) New Revision: 89f63f2922a7a0dcbb0bce22141884a7235347c8 https://github.com/ranguba/ranguba-server/commit/89f63f2922a7a0dcbb0bce22141884a7235347c8 Message: Keep extracted texts as is Modified files: app/assets/stylesheets/application.scss app/models/scraping.rb app/views/entries/_entry.json.jbuilder app/views/entries/index.html.erb app/views/entries/show.html.erb db/schema.grn Modified: app/assets/stylesheets/application.scss (+41 -0) =================================================================== --- app/assets/stylesheets/application.scss 2017-02-20 23:44:14 +0900 (6ba08de) +++ app/assets/stylesheets/application.scss 2017-02-22 00:09:09 +0900 (80e80d4) @@ -39,6 +39,47 @@ header { div.content { @extend .container; + + section.entries { + @extend .list-group; + + section.entry { + @extend .list-group-item; + @extend .list-group-item-action; + + h2 { + @extend .list-group-item-heading; + + a { + } + + p.url { + @extend .text-muted; + } + } + + pre { + @extend .container; + } + } + } + + div.entry-detail { + @extend .card; + + section.entry-attributes { + @extend .card-block; + + h2 { + @extend .card-title; + } + + p, + pre { + @extend .card-text; + } + } + } } #notice { Modified: app/models/scraping.rb (+7 -3) =================================================================== --- app/models/scraping.rb 2017-02-20 23:44:14 +0900 (9491b57) +++ app/models/scraping.rb 2017-02-22 00:09:09 +0900 (e1ad13e) @@ -17,13 +17,17 @@ class Scraping data.body = body data.size = body.bytesize texts = [] + size = 0 extractor.extract(data) do |extracted_data| - texts << extracted_data.body + text = extracted_data.body + texts << text + size += text.bytesize end @entry._key = data.uri.to_s + @entry.title = data[:title] || data[:subject] || @entry._key @entry.mime_type = data.mime_type - @entry.body = texts.join("\n") - @entry.size =****@entry***** + @entry.texts = texts + @entry.size = size @entry.save end end Modified: app/views/entries/_entry.json.jbuilder (+1 -1) =================================================================== --- app/views/entries/_entry.json.jbuilder 2017-02-20 23:44:14 +0900 (8bc949f) +++ app/views/entries/_entry.json.jbuilder 2017-02-22 00:09:09 +0900 (9853f46) @@ -1,2 +1,2 @@ -json.extract! entry, :id, :_key, :title, :body, :size#, :created_at, :updated_at +json.extract! entry, :id, :_key, :title, :texts, :size#, :created_at, :updated_at json.url entry_url(entry, format: :json) Modified: app/views/entries/index.html.erb (+12 -30) =================================================================== --- app/views/entries/index.html.erb 2017-02-20 23:44:14 +0900 (ceb4440) +++ app/views/entries/index.html.erb 2017-02-22 00:09:09 +0900 (86cbac9) @@ -1,33 +1,15 @@ <p id="notice"><%= notice %></p> -<h1>Entries</h1> - -<table> - <thead> - <tr> - <th>Key</th> - <th>Title</th> - <th>Body</th> - <th>Size</th> - <th colspan="3"></th> - </tr> - </thead> - - <tbody> - <% @entries.each do |entry| %> - <tr> - <td><%= entry._key %></td> - <td><%= entry.title %></td> - <td><%= entry.body %></td> - <td><%= entry.size %></td> - <td><%= link_to 'Show', entry %></td> - <td><%= link_to 'Edit', edit_entry_path(entry) %></td> - <td><%= link_to 'Destroy', entry, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> +<section class="entries"> + <h1>Entries</h1> + + <% @entries.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> <% end %> - </tbody> -</table> - -<br> - -<%= link_to 'New Entry', new_entry_path %> + </section> + <% end %> +</section> Modified: app/views/entries/show.html.erb (+9 -22) =================================================================== --- app/views/entries/show.html.erb 2017-02-20 23:44:14 +0900 (20eda88) +++ app/views/entries/show.html.erb 2017-02-22 00:09:09 +0900 (8623db0) @@ -1,24 +1,11 @@ <p id="notice"><%= notice %></p> -<p> - <strong>Key:</strong> - <%= @entry._key %> -</p> - -<p> - <strong>Title:</strong> - <%=****@entry***** %> -</p> - -<p> - <strong>Body:</strong> - <%=****@entry***** %> -</p> - -<p> - <strong>Size:</strong> - <%=****@entry***** %> -</p> - -<%= link_to 'Edit', edit_entry_path(@entry) %> | -<%= link_to 'Back', entries_path %> +<div class="entry-detail"> + <section class="entry-attributes"> + <h1><%=****@entry***** %></h1> + <p><%= @entry._key %></p> + <% @entry.texts.each do |text| %> + <pre><%= text %></pre> + <% end %> + </div> +</section> Modified: db/schema.grn (+3 -3) =================================================================== --- db/schema.grn 2017-02-20 23:44:14 +0900 (f72189f) +++ db/schema.grn 2017-02-22 00:09:09 +0900 (7266c67) @@ -4,7 +4,7 @@ column_create mime_types label ShortText table_create entries TABLE_HASH_KEY ShortText column_create entries mime_type COLUMN_SCALAR mime_types column_create entries title COLUMN_SCALAR ShortText -column_create entries body COLUMN_SCALAR|COMPRESS_ZSTD LongText +column_create entries texts COLUMN_VECTOR LongText column_create entries size COLUMN_SCALAR UInt64 table_create terms TABLE_PAT_KEY ShortText \ @@ -13,6 +13,6 @@ table_create terms TABLE_PAT_KEY ShortText \ column_create terms entries_title \ COLUMN_INDEX|WITH_POSITION \ entries title -column_create terms entries_body \ +column_create terms entries_texts \ COLUMN_INDEX|WITH_POSITION \ - entries body + entries texts -------------- next part -------------- HTML����������������������������...Download