honyomi 1.3.0 → 1.4.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: 6ad0374652cee2d4647368aa26cd8bd5111793af
4
- data.tar.gz: 65dad1ff0f27924e91e440d2ba6e48baa7742a66
3
+ metadata.gz: 685d64724a342464a595155d65a219387bfb707e
4
+ data.tar.gz: baa05b5545b476237f482499d90f8f2fc7334d52
5
5
  SHA512:
6
- metadata.gz: 5a90676167abf1530f3decc4280fdbced75cce1c5dfd723845b5e3682e6292aa243820032382a730bff97ed692d97af4dbbec14486acd19005464c61e6c16398
7
- data.tar.gz: fbc928917670e98ad08970850f9ce133bd70339a8f5a896768508acdc08624087cbf3cee4b3491a899fc9ab102f47edcf83e45a7da2aed39ed76a84eb1fabb1a
6
+ metadata.gz: c469791cfe13da613deafd5eeadc10f4b7855d92c1b95823e58cdd626ba69cab932e27c81bf0a63d3ef819b4328021267cdd928f61e1d307f8029ee95cf7882d
7
+ data.tar.gz: 4a7440312e418348b4a36e335252369d63fd4d8fe70c6e39182086a6efd0a9156c8c7daded9aa9588461b9f2029a94f12060261934a90bf540d44358c3b36631
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # HISTORY - Honyomi
2
2
 
3
+ ## 1.4 - 2015-08-05
4
+
5
+ - Add basic authorization
6
+ - Add 'honyomi move' command
7
+
3
8
  ## 1.3 - 2015-07-24
4
9
 
5
10
  - Run the image command with the add command if there is 'pdftoppm'
data/README.md CHANGED
@@ -110,4 +110,20 @@ $ honyomi web
110
110
 
111
111
  ![honyomi-03.gif](images/honyomi-03.gif)
112
112
 
113
+ ### Basic authorization
114
+
115
+ 1. Get the SHA-2 Hash
116
+
117
+ ```
118
+ $ ruby -r 'digest/sha2' -e 'puts Digest::SHA256.hexdigest("this_is_password")'
119
+ a6a27374ec8f49426e8ee6249125369e8c529f361ffa20ace73de0b92514bb0f
120
+ ```
121
+
122
+ 2. It pass to the environment variable
123
+
124
+ ```
125
+ $ HONYOMI_AUTH_USERNAME=ongaeshi HONYOMI_AUTH_PASSWORD=a6a27374ec8f49426e8ee6249125369e8c529f361ffa20ace73de0b92514bb0f honyomi web
126
+ ```
127
+
128
+
113
129
 
data/lib/honyomi/cli.rb CHANGED
@@ -140,6 +140,14 @@ module Honyomi
140
140
  end
141
141
  end
142
142
 
143
+ desc "move old_path new_path", "Move the book path"
144
+ def move(old_path, new_path)
145
+ core = Core.new
146
+ core.load_database
147
+
148
+ core.move(old_path, new_path)
149
+ end
150
+
143
151
  no_tasks do
144
152
  # Override method for support -h
145
153
  # defined in /lib/thor/invocation.rb
data/lib/honyomi/core.rb CHANGED
@@ -127,6 +127,10 @@ EOF
127
127
  puts "Generated images to '#{output_dir}'" if options[:verbose]
128
128
  end
129
129
 
130
+ def move(old_path, new_path)
131
+ @database.move(old_path, new_path)
132
+ end
133
+
130
134
  def db_dir
131
135
  File.join(home_dir, 'db')
132
136
  end
@@ -187,5 +187,16 @@ module Honyomi
187
187
  def books_bookmark(book)
188
188
  @bookmarks.select { |record| record.page.book == book }
189
189
  end
190
+
191
+ def move(old_path, new_path)
192
+ @books.each do |book|
193
+ new_book_path = book.path.gsub(old_path.sub(/\/\Z/, ""), new_path.sub(/\/+\Z/, ""))
194
+
195
+ if book.path != new_book_path
196
+ book.path = new_book_path
197
+ puts "#{book.path} -> #{new_book_path}"
198
+ end
199
+ end
200
+ end
190
201
  end
191
202
  end
@@ -1,3 +1,3 @@
1
1
  module Honyomi
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -4,6 +4,7 @@ require 'honyomi/core'
4
4
  require 'honyomi/database'
5
5
  require 'honyomi/util'
6
6
  require 'sinatra'
7
+ require 'digest/sha2'
7
8
  if ENV['SINATRA_RELOADER']
8
9
  require 'sinatra/reloader'
9
10
  also_reload '../../**/*.rb'
@@ -19,6 +20,12 @@ include Honyomi
19
20
  set :haml, :format => :html5
20
21
 
21
22
  configure do
23
+ if ENV['HONYOMI_AUTH_USERNAME'] && ENV['HONYOMI_AUTH_PASSWORD']
24
+ use Rack::Auth::Basic do |username, password|
25
+ username == ENV['HONYOMI_AUTH_USERNAME'] && Digest::SHA256.hexdigest(password) == ENV['HONYOMI_AUTH_PASSWORD']
26
+ end
27
+ end
28
+
22
29
  $database = Database.new
23
30
  end
24
31
 
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.3.0
4
+ version: 1.4.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-23 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grn_mini