honyomi 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f785777fac05f71e8de95f2a030a5da69b791a4d
4
- data.tar.gz: fbe61872b4dff870f4699de33df9a1278fbaa8e9
3
+ metadata.gz: 6ad0374652cee2d4647368aa26cd8bd5111793af
4
+ data.tar.gz: 65dad1ff0f27924e91e440d2ba6e48baa7742a66
5
5
  SHA512:
6
- metadata.gz: dfbec7c05b178b935ae27189c276382b9f7f67e1f46cf519609cb1b47a73f99dc08b45e1dffc68e734a59b6610fe511a0ef68fc8b7663d9c626f2a7481c121bc
7
- data.tar.gz: 11d2d1af46f7515451e04c8bfd90983cca3c11245889423979ca13d9f055eb989bf4c3dad31be50686eb5881a953301738798b1077684cff16b483e241db07d3
6
+ metadata.gz: 5a90676167abf1530f3decc4280fdbced75cce1c5dfd723845b5e3682e6292aa243820032382a730bff97ed692d97af4dbbec14486acd19005464c61e6c16398
7
+ data.tar.gz: fbc928917670e98ad08970850f9ce133bd70339a8f5a896768508acdc08624087cbf3cee4b3491a899fc9ab102f47edcf83e45a7da2aed39ed76a84eb1fabb1a
data/HISTORY.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # HISTORY - Honyomi
2
2
 
3
+ ## 1.3 - 2015-07-24
4
+
5
+ - Run the image command with the add command if there is 'pdftoppm'
6
+ - Also when you add from web
7
+ - Reduce the movement amount when you press the 'Prev' button (5 -> 1)
8
+ - Support docker container
9
+ - [ongaeshi/honyomi Repository | Docker Hub Registry](https://registry.hub.docker.com/u/ongaeshi/honyomi/)
10
+
3
11
  ## 1.2 - 2015-07-03
4
12
 
5
13
  * Add image command
data/README.md CHANGED
@@ -10,6 +10,12 @@ Honyomi is "本読み". "Read a book" is meaning.
10
10
 
11
11
  ## Installation
12
12
 
13
+ You can use the Docker container.
14
+
15
+ - [ongaeshi/honyomi Repository | Docker Hub Registry](https://registry.hub.docker.com/u/ongaeshi/honyomi/)
16
+
17
+ or
18
+
13
19
  $ gem install honyomi
14
20
 
15
21
  When you faild to install Rroonga, Please refer.
@@ -44,6 +50,17 @@ $ honyomi add /path/to/this_is_book.pdf
44
50
  A 1 this_is_book (10 pages)
45
51
  ```
46
52
 
53
+ ### Add book's image
54
+
55
+ You can be inline display of the page on the browser.
56
+
57
+ Need `pdftoppm` command.
58
+
59
+ ```
60
+ $ honyomi image 1
61
+ Generated images to '/Users/ongaeshi/.honyomi/image/1'
62
+ ```
63
+
47
64
  ### Edit book
48
65
 
49
66
  Change title. Specify book id.
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'sinatra'
26
26
  spec.add_dependency 'thin', "< 1.7"
27
27
  spec.add_dependency 'thor'
28
+ spec.add_dependency 'whichr', '~> 0.3'
28
29
 
29
30
  spec.add_development_dependency "bundler", "~> 1.3"
30
31
  spec.add_development_dependency "rake"
@@ -23,7 +23,9 @@ module Honyomi
23
23
  end
24
24
 
25
25
  def add(filename, options = {})
26
- @database.add_from_pdf(filename, options)
26
+ book, status = @database.add_from_pdf(filename, home_dir, options)
27
+
28
+ return book, status
27
29
  end
28
30
 
29
31
  def update(book_id, options)
@@ -121,9 +123,7 @@ EOF
121
123
  end
122
124
 
123
125
  def image(id, options = {})
124
- pdf = Pdf.new(@database.books[id].path)
125
- output_dir = File.join(image_dir, id.to_s)
126
- pdf.generate_images(output_dir)
126
+ output_dir = @database.add_image(id, home_dir)
127
127
  puts "Generated images to '#{output_dir}'" if options[:verbose]
128
128
  end
129
129
 
@@ -145,9 +145,5 @@ EOF
145
145
 
146
146
  @home_dir
147
147
  end
148
-
149
- def image_dir
150
- File.join(home_dir, "image")
151
- end
152
148
  end
153
149
  end
@@ -33,19 +33,32 @@ module Honyomi
33
33
  )
34
34
  end
35
35
 
36
- def add_from_pdf(filename, options = {})
36
+ def add_from_pdf(filename, home_dir, options = {})
37
37
  if File.exist?(filename)
38
38
  filename = File.expand_path(filename)
39
39
  options = options.dup
40
40
  pages = Pdf.new(filename).pages
41
41
  pages = pages.map { |page| Util.strip_page(page) } if options[:strip]
42
42
  options[:timestamp] = File.stat(filename).mtime
43
- add_book(filename, pages, options)
43
+ book, status = add_book(filename, pages, options)
44
+
45
+ add_image(book.id, home_dir) if Util.exist_command?('pdftoppm')
46
+
47
+ return book, status
44
48
  else
45
49
  nil
46
50
  end
47
51
  end
48
52
 
53
+ def add_image(id, home_dir)
54
+ output_dir = File.join(home_dir, "image", id.to_s)
55
+
56
+ pdf = Pdf.new(books[id].path)
57
+ pdf.generate_images(output_dir)
58
+
59
+ output_dir
60
+ end
61
+
49
62
  def add_book(path, pages, options = {})
50
63
  book = book_from_path(path)
51
64
 
@@ -1,4 +1,5 @@
1
1
  require 'kconv'
2
+ require 'whichr'
2
3
 
3
4
  module Honyomi
4
5
  module Util
@@ -110,5 +111,9 @@ module Honyomi
110
111
  zerofill = format("%0#{count_digit(page.book.page_num)}d", page.page_no)
111
112
  "#{home_dir}/image/#{page.book.id}/book-#{zerofill}.jpg"
112
113
  end
114
+
115
+ def exist_command?(command)
116
+ !(RubyWhich.new.which(command).empty?)
117
+ end
113
118
  end
114
119
  end
@@ -1,3 +1,3 @@
1
1
  module Honyomi
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -57,7 +57,7 @@ post '/upload' do
57
57
  f.write file[:tempfile].read
58
58
  end
59
59
 
60
- @database.add_from_pdf(save_path)
60
+ @database.add_from_pdf(save_path, Util.home_dir)
61
61
  end
62
62
 
63
63
  @message = "Upload Success"
@@ -221,7 +221,7 @@ EOF
221
221
  if page_index > 0
222
222
  prev_link = <<EOF
223
223
  <ul class="pager">
224
- <li><a href='#{url + "?page=#{[page_no - PAGE_SIZE, 1].max}"}' >Prev</a></li>
224
+ <li><a href='#{url + "?page=#{[page_no - 1, 1].max}"}' >Prev</a></li>
225
225
  </ul>
226
226
  EOF
227
227
  end
@@ -17,4 +17,9 @@ class TestUtil < MiniTest::Test
17
17
  assert_equal 3, Util::count_digit(100)
18
18
  assert_equal 4, Util::count_digit(9999)
19
19
  end
20
+
21
+ def test_exist_command?
22
+ assert_equal true, Util::exist_command?('pdftotext')
23
+ assert_equal false, Util::exist_command?('pdftotexts')
24
+ end
20
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honyomi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ongaeshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grn_mini
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: whichr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement