epub-directory 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/README.md +15 -16
- data/epub-directory.gemspec +4 -4
- data/lib/epub/directory.rb +23 -1
- data/lib/epub/directory/version.rb +1 -1
- metadata +19 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d83e49433eee1d1357877c6c404a7ed2a93f1f9012c66a65d3529386bb94031
|
4
|
+
data.tar.gz: '086df1667ae891d439f111f845babab261b175bec614de5541e70bcacdebdac1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4266ab4400740c4ac3e7ac6bc8eb498eb141b573baa56ee75589adac1f2cfa7f4ea859380694882375d9ff98b6036f386235e52033b3fc9ab53d0f12af6762
|
7
|
+
data.tar.gz: 2e350c916c92b079301a5ca7cf390b9005ab45b2fe389fc4611a416894b58b632cb96e0b49c1d39e66825d19be8c3c8e1e0436544d07a09c637d00492793b4ad
|
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -39,19 +39,18 @@ This command builds EPUB directory site to `build` directory.
|
|
39
39
|
|
40
40
|
## Copyright
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#
|
42
|
+
|
43
|
+
Copyright (c) 2018 Kitaiti Makoto
|
44
|
+
|
45
|
+
EPUB Directory is free software: you can redistribute it and/or modify
|
46
|
+
it under the terms of the GNU Affero General Public License as published
|
47
|
+
by the Free Software Foundation, either version 3 of the License, or
|
48
|
+
(at your option) any later version.
|
49
|
+
|
50
|
+
EPUB Directory is distributed in the hope that it will be useful,
|
51
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
52
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
53
|
+
GNU Affero General Public License for more details.
|
54
|
+
|
55
|
+
You should have received a copy of the GNU Affero General Public License
|
56
|
+
along with EPUB Directory. If not, see <http://www.gnu.org/licenses/>.
|
data/epub-directory.gemspec
CHANGED
@@ -34,10 +34,10 @@ Gem::Specification.new do |gem|
|
|
34
34
|
gem.add_runtime_dependency "haml"
|
35
35
|
gem.add_runtime_dependency "rss-opds"
|
36
36
|
|
37
|
-
gem.add_development_dependency 'bundler'
|
38
|
-
gem.add_development_dependency 'rake'
|
39
|
-
gem.add_development_dependency 'rubygems-tasks'
|
40
|
-
gem.add_development_dependency 'yard'
|
37
|
+
gem.add_development_dependency 'bundler'
|
38
|
+
gem.add_development_dependency 'rake'
|
39
|
+
gem.add_development_dependency 'rubygems-tasks'
|
40
|
+
gem.add_development_dependency 'yard'
|
41
41
|
gem.add_development_dependency "test-unit"
|
42
42
|
gem.add_development_dependency "test-unit-notify"
|
43
43
|
end
|
data/lib/epub/directory.rb
CHANGED
@@ -34,14 +34,19 @@ module EPUB
|
|
34
34
|
|
35
35
|
def build
|
36
36
|
DEST_DIR.mkpath
|
37
|
+
opfs = []
|
37
38
|
Pathname.glob("#{SRC_DIR}/**/*.opf").each do |opf_path|
|
38
39
|
make_destination_directory opf_path
|
39
40
|
build_opf opf_path
|
40
41
|
build_html opf_path
|
41
42
|
build_opds opf_path
|
43
|
+
|
44
|
+
opfs << opf_path.to_path.sub(SRC_DIR.to_path, DEST_DIR.to_path)
|
42
45
|
rescue => error
|
43
46
|
warn "Error occurred while processing #{opf_path}"
|
47
|
+
raise if $DEBUG
|
44
48
|
end
|
49
|
+
build_indices opfs
|
45
50
|
end
|
46
51
|
|
47
52
|
def make_destination_directory(opf_path)
|
@@ -78,11 +83,13 @@ module EPUB
|
|
78
83
|
entry.updated = rendition.metadata.modified.to_s
|
79
84
|
entry.title = rendition.metadata.title
|
80
85
|
# TODO: Filter authors by refines
|
81
|
-
rendition.metadata.creators.
|
86
|
+
creators = rendition.metadata.creators + rendition.metadata.metas.select {|meta| ["dc:publisher", "dcterms:creator"].include? meta.property}
|
87
|
+
creators.each do |creator|
|
82
88
|
entry.authors.new_author do |author|
|
83
89
|
author.name = creator.to_s
|
84
90
|
end
|
85
91
|
end
|
92
|
+
entry.author = "Unknown"
|
86
93
|
entry.summary = rendition.metadata.description
|
87
94
|
entry.links.new_link do |link|
|
88
95
|
link.rel = RSS::OPDS::RELATIONS["acquisition"] # TODO: Arrange by info.toml
|
@@ -98,6 +105,21 @@ module EPUB
|
|
98
105
|
raise NotImplementedError
|
99
106
|
end
|
100
107
|
|
108
|
+
def build_indices(opfs)
|
109
|
+
dest_path = DEST_DIR/"index.html"
|
110
|
+
page_title = "EPUB Directory"
|
111
|
+
items = opfs.lazy.collect {|path|
|
112
|
+
{
|
113
|
+
"uri" => Pathname.new(path).sub_ext(".html").to_path.sub(DEST_DIR.to_path, ""),
|
114
|
+
"metadata" => EPUB::Parser::Publication.new(File.read(path)).parse.metadata
|
115
|
+
}
|
116
|
+
}
|
117
|
+
template_path = File.join(__dir__, "../../templates/index.haml")
|
118
|
+
engine = Haml::Engine.new(File.read(template_path))
|
119
|
+
engine.options[:format] = :html5
|
120
|
+
dest_path.write engine.render(binding)
|
121
|
+
end
|
122
|
+
|
101
123
|
class Rendition
|
102
124
|
class << self
|
103
125
|
def add(rendition)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epub-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KITAITI Makoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: epub-parser
|
@@ -70,58 +70,58 @@ dependencies:
|
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubygems-tasks
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: yard
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: test-unit
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
|
199
|
-
rubygems_version: 2.7.6
|
198
|
+
rubygems_version: 3.1.2
|
200
199
|
signing_key:
|
201
200
|
specification_version: 4
|
202
201
|
summary: EPUB directory builder
|