book_utils 0.0.1 → 0.1.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.
- data/README.md +10 -0
- data/Rakefile +1 -1
- data/bin/dir2html +115 -0
- data/book_utils.gemspec +5 -7
- data/lib/{book_utils/version.rb → version.rb} +1 -1
- metadata +14 -53
- data/README +0 -0
- data/assets/META-INF/container.xml +0 -7
- data/assets/OEBPS/fonts/BergamoStd-Bold.otf +0 -0
- data/assets/OEBPS/fonts/BergamoStd-BoldItalic.otf +0 -0
- data/assets/OEBPS/fonts/BergamoStd-Italic.otf +0 -0
- data/assets/OEBPS/fonts/BergamoStd-Regular.otf +0 -0
- data/assets/OEBPS/fonts/OFLGoudyStM-Italic.otf +0 -0
- data/assets/OEBPS/fonts/OFLGoudyStM.otf +0 -0
- data/assets/OEBPS/fonts/licenses.txt +0 -158
- data/assets/OEBPS/fonts/texgyrepagella-bold.otf +0 -0
- data/assets/OEBPS/fonts/texgyrepagella-bolditalic.otf +0 -0
- data/assets/OEBPS/fonts/texgyrepagella-italic.otf +0 -0
- data/assets/OEBPS/fonts/texgyrepagella-regular.otf +0 -0
- data/assets/OEBPS/fonts/texgyretermes-bold.otf +0 -0
- data/assets/OEBPS/fonts/texgyretermes-bolditalic.otf +0 -0
- data/assets/OEBPS/fonts/texgyretermes-italic.otf +0 -0
- data/assets/OEBPS/fonts/texgyretermes-regular.otf +0 -0
- data/assets/OEBPS/fonts.css +0 -127
- data/assets/OEBPS/print.css +0 -4
- data/assets/OEBPS/stylesheet.css +0 -82
- data/assets/mimetype +0 -1
- data/assets/templates/content.opf.erb +0 -64
- data/assets/templates/title.html.erb +0 -12
- data/assets/templates/wrapper.html.erb +0 -12
- data/bin/dir2epub +0 -17
- data/lib/book_utils/convert.rb +0 -94
- data/lib/book_utils.rb +0 -5
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Create big html file/files from ruby src files. I convert these files to epub with calibre and read
|
2
|
+
them on my Sony Reader or iPod.
|
3
|
+
|
4
|
+
Usage:
|
5
|
+
|
6
|
+
```
|
7
|
+
dir2html /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.9
|
8
|
+
```
|
9
|
+
|
10
|
+
It creates actionpack-3.0.9-\*.html file/files in current directory.
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/dir2html
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
# File activesupport/lib/active_support/core_ext/array/grouping.rb, line 19
|
6
|
+
class Array
|
7
|
+
def in_groups_of(number, fill_with = nil)
|
8
|
+
if fill_with == false
|
9
|
+
collection = self
|
10
|
+
else
|
11
|
+
# size % number gives how many extra we have;
|
12
|
+
# subtracting from number gives how many to add;
|
13
|
+
# modulo number ensures we don't add group of just fill.
|
14
|
+
padding = (number - size % number) % number
|
15
|
+
collection = dup.concat([fill_with] * padding)
|
16
|
+
end
|
17
|
+
|
18
|
+
if block_given?
|
19
|
+
collection.each_slice(number) { |slice| yield(slice) }
|
20
|
+
else
|
21
|
+
groups = []
|
22
|
+
collection.each_slice(number) { |group| groups << group }
|
23
|
+
groups
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module BookUtils
|
29
|
+
class Convert
|
30
|
+
def initialize(dir)
|
31
|
+
@dir = File.expand_path(dir)
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
lines = []
|
36
|
+
|
37
|
+
files = Dir[File.expand_path("**/*", @dir)].
|
38
|
+
sort.
|
39
|
+
reject{|a| File.directory?(a)}.
|
40
|
+
reject{|a| rejected_extentions.include? File.extname(a)}.
|
41
|
+
reject{|a| reject_file? a.gsub(@dir, '')}.
|
42
|
+
each do |file|
|
43
|
+
text = File.read(file)
|
44
|
+
next if text.index("\0")
|
45
|
+
lines << "<h1>#{file.sub(@dir + '/', '')}</h1>"
|
46
|
+
lines += process(text)
|
47
|
+
end
|
48
|
+
|
49
|
+
lines.in_groups_of(2000).each_with_index do |group, index|
|
50
|
+
file_name = File.basename(@dir) + "-%03d.html"%index
|
51
|
+
puts "#{file_name} ..."
|
52
|
+
File.open(file_name, "w") do |out|
|
53
|
+
out.puts "<html>"
|
54
|
+
out.puts "<head>"
|
55
|
+
out.puts "<title>#{File.basename(file_name, '.html')}</title>"
|
56
|
+
out.puts %(<meta http-equiv="content-type" content="text/html; charset=utf-8" />)
|
57
|
+
out.puts "<style>body{font-family: Courier New; font-size: 12px;}</style>"
|
58
|
+
out.puts "<meta name=\"author\" content=\"source\" />"
|
59
|
+
out.puts "</head>"
|
60
|
+
out.puts "<body>"
|
61
|
+
out.puts group.join("<br>\n")
|
62
|
+
out.puts "</body>"
|
63
|
+
out.puts "</html>"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def rejected_extentions
|
70
|
+
%w(.png .csv .jpg .erb~ .bac .rxml .lock .gif .tt .ico .mab .directory .dat)
|
71
|
+
end
|
72
|
+
|
73
|
+
def reject_file?(file)
|
74
|
+
!!file.index('/actionmailer/test/fixtures')
|
75
|
+
end
|
76
|
+
|
77
|
+
def process(text)
|
78
|
+
out = []
|
79
|
+
CGI::escapeHTML(text).split("\n").each_with_index do |line, index|
|
80
|
+
out << line_number(index) + html_indent(line)
|
81
|
+
end
|
82
|
+
out
|
83
|
+
end
|
84
|
+
|
85
|
+
def html_indent(text, half = true)
|
86
|
+
if text =~ /^\s+/
|
87
|
+
if half
|
88
|
+
" "*($&.size/2) + $'
|
89
|
+
else
|
90
|
+
" "*$&.size + $'
|
91
|
+
end
|
92
|
+
else
|
93
|
+
text
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def line_number(index)
|
98
|
+
"<small>" + html_indent((index + 1).to_s.rjust(3), false) + '</small> '
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if ARGV.empty?
|
104
|
+
puts "Usage: "
|
105
|
+
puts " dir2html <folder>"
|
106
|
+
puts ""
|
107
|
+
puts "Your GEM paths:"
|
108
|
+
Gem.path.each do |path|
|
109
|
+
puts " " + path
|
110
|
+
end
|
111
|
+
elsif File.directory?(ARGV[0])
|
112
|
+
BookUtils::Convert.new(ARGV[0]).run
|
113
|
+
else
|
114
|
+
puts "Error: #{ARGV[0]} is not directory."
|
115
|
+
end
|
data/book_utils.gemspec
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "
|
3
|
+
require "version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "book_utils"
|
7
7
|
s.version = BookUtils::VERSION
|
8
8
|
s.authors = ["Alexey Vakhov"]
|
9
9
|
s.email = ["vakhov@gmail.com"]
|
10
|
-
s.homepage = "
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Book Utils}
|
12
|
+
s.description = %q{Book Utils: render ruby source to html}
|
13
13
|
|
14
|
-
|
14
|
+
s.rubyforge_project = "book_utils"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
-
|
21
|
-
s.add_dependency('coderay', '~> 0.9')
|
22
20
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: book_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Vakhov
|
@@ -15,29 +15,15 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-02-12 00:00:00 +04:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 25
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 9
|
33
|
-
version: "0.9"
|
34
|
-
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
description: my ebooks utils
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: "Book Utils: render ruby source to html"
|
37
23
|
email:
|
38
24
|
- vakhov@gmail.com
|
39
25
|
executables:
|
40
|
-
-
|
26
|
+
- dir2html
|
41
27
|
extensions: []
|
42
28
|
|
43
29
|
extra_rdoc_files: []
|
@@ -45,38 +31,13 @@ extra_rdoc_files: []
|
|
45
31
|
files:
|
46
32
|
- .gitignore
|
47
33
|
- Gemfile
|
48
|
-
- README
|
34
|
+
- README.md
|
49
35
|
- Rakefile
|
50
|
-
-
|
51
|
-
- assets/OEBPS/fonts.css
|
52
|
-
- assets/OEBPS/fonts/BergamoStd-Bold.otf
|
53
|
-
- assets/OEBPS/fonts/BergamoStd-BoldItalic.otf
|
54
|
-
- assets/OEBPS/fonts/BergamoStd-Italic.otf
|
55
|
-
- assets/OEBPS/fonts/BergamoStd-Regular.otf
|
56
|
-
- assets/OEBPS/fonts/OFLGoudyStM-Italic.otf
|
57
|
-
- assets/OEBPS/fonts/OFLGoudyStM.otf
|
58
|
-
- assets/OEBPS/fonts/licenses.txt
|
59
|
-
- assets/OEBPS/fonts/texgyrepagella-bold.otf
|
60
|
-
- assets/OEBPS/fonts/texgyrepagella-bolditalic.otf
|
61
|
-
- assets/OEBPS/fonts/texgyrepagella-italic.otf
|
62
|
-
- assets/OEBPS/fonts/texgyrepagella-regular.otf
|
63
|
-
- assets/OEBPS/fonts/texgyretermes-bold.otf
|
64
|
-
- assets/OEBPS/fonts/texgyretermes-bolditalic.otf
|
65
|
-
- assets/OEBPS/fonts/texgyretermes-italic.otf
|
66
|
-
- assets/OEBPS/fonts/texgyretermes-regular.otf
|
67
|
-
- assets/OEBPS/print.css
|
68
|
-
- assets/OEBPS/stylesheet.css
|
69
|
-
- assets/mimetype
|
70
|
-
- assets/templates/content.opf.erb
|
71
|
-
- assets/templates/title.html.erb
|
72
|
-
- assets/templates/wrapper.html.erb
|
73
|
-
- bin/dir2epub
|
36
|
+
- bin/dir2html
|
74
37
|
- book_utils.gemspec
|
75
|
-
- lib/
|
76
|
-
- lib/book_utils/convert.rb
|
77
|
-
- lib/book_utils/version.rb
|
38
|
+
- lib/version.rb
|
78
39
|
has_rdoc: true
|
79
|
-
homepage:
|
40
|
+
homepage: ""
|
80
41
|
licenses: []
|
81
42
|
|
82
43
|
post_install_message:
|
@@ -104,10 +65,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
65
|
version: "0"
|
105
66
|
requirements: []
|
106
67
|
|
107
|
-
rubyforge_project:
|
68
|
+
rubyforge_project: book_utils
|
108
69
|
rubygems_version: 1.5.2
|
109
70
|
signing_key:
|
110
71
|
specification_version: 3
|
111
|
-
summary:
|
72
|
+
summary: Book Utils
|
112
73
|
test_files: []
|
113
74
|
|
data/README
DELETED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,158 +0,0 @@
|
|
1
|
-
Bergamo-Std:
|
2
|
-
|
3
|
-
This typeface software ("SOFTWARE") is the property of FontSite Inc. Its
|
4
|
-
use by you is covered under the terms of an End-User License Agreement
|
5
|
-
("EULA"). By exercising your rights to make and use copies of this SOFTWARE,
|
6
|
-
you agree to be bound by the terms of this EULA. If you do not agree to the
|
7
|
-
terms of this EULA, you may not use the SOFTWARE.
|
8
|
-
|
9
|
-
This SOFTWARE is a valuable asset of FontSite Inc. which is protected by
|
10
|
-
copyright laws and international copyright treaties, as well as other
|
11
|
-
intellectual property laws and treaties. The typeface software is licensed,
|
12
|
-
not sold.
|
13
|
-
|
14
|
-
This EULA grants you the following rights:
|
15
|
-
|
16
|
-
You may install and use an unlimited number of copies of this SOFTWARE.
|
17
|
-
|
18
|
-
You may reproduce and distribute an unlimited number of copies of this
|
19
|
-
SOFTWARE, provided that each copy shall be a true and complete copy,
|
20
|
-
including all copyright and trademark notices, electronic documentation
|
21
|
-
(user guide in PDF format, etc.), and shall be accompanied by a copy of this
|
22
|
-
EULA. Copies of the SOFTWARE may not be distributed for profit either on a
|
23
|
-
standalone basis or included as part of your own product.
|
24
|
-
|
25
|
-
|
26
|
-
-----
|
27
|
-
|
28
|
-
OFL-Sorts-Mill-Goudy:
|
29
|
-
|
30
|
-
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
31
|
-
This license is copied below, and is also available with a FAQ at:
|
32
|
-
http://scripts.sil.org/OFL
|
33
|
-
|
34
|
-
|
35
|
-
-----------------------------------------------------------
|
36
|
-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
37
|
-
-----------------------------------------------------------
|
38
|
-
|
39
|
-
PREAMBLE
|
40
|
-
The goals of the Open Font License (OFL) are to stimulate worldwide
|
41
|
-
development of collaborative font projects, to support the font creation
|
42
|
-
efforts of academic and linguistic communities, and to provide a free and
|
43
|
-
open framework in which fonts may be shared and improved in partnership
|
44
|
-
with others.
|
45
|
-
|
46
|
-
The OFL allows the licensed fonts to be used, studied, modified and
|
47
|
-
redistributed freely as long as they are not sold by themselves. The
|
48
|
-
fonts, including any derivative works, can be bundled, embedded,
|
49
|
-
redistributed and/or sold with any software provided that any reserved
|
50
|
-
names are not used by derivative works. The fonts and derivatives,
|
51
|
-
however, cannot be released under any other type of license. The
|
52
|
-
requirement for fonts to remain under this license does not apply
|
53
|
-
to any document created using the fonts or their derivatives.
|
54
|
-
|
55
|
-
DEFINITIONS
|
56
|
-
"Font Software" refers to the set of files released by the Copyright
|
57
|
-
Holder(s) under this license and clearly marked as such. This may
|
58
|
-
include source files, build scripts and documentation.
|
59
|
-
|
60
|
-
"Reserved Font Name" refers to any names specified as such after the
|
61
|
-
copyright statement(s).
|
62
|
-
|
63
|
-
"Original Version" refers to the collection of Font Software components as
|
64
|
-
distributed by the Copyright Holder(s).
|
65
|
-
|
66
|
-
"Modified Version" refers to any derivative made by adding to, deleting,
|
67
|
-
or substituting -- in part or in whole -- any of the components of the
|
68
|
-
Original Version, by changing formats or by porting the Font Software to a
|
69
|
-
new environment.
|
70
|
-
|
71
|
-
"Author" refers to any designer, engineer, programmer, technical
|
72
|
-
writer or other person who contributed to the Font Software.
|
73
|
-
|
74
|
-
PERMISSION & CONDITIONS
|
75
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
76
|
-
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
77
|
-
redistribute, and sell modified and unmodified copies of the Font
|
78
|
-
Software, subject to the following conditions:
|
79
|
-
|
80
|
-
1) Neither the Font Software nor any of its individual components,
|
81
|
-
in Original or Modified Versions, may be sold by itself.
|
82
|
-
|
83
|
-
2) Original or Modified Versions of the Font Software may be bundled,
|
84
|
-
redistributed and/or sold with any software, provided that each copy
|
85
|
-
contains the above copyright notice and this license. These can be
|
86
|
-
included either as stand-alone text files, human-readable headers or
|
87
|
-
in the appropriate machine-readable metadata fields within text or
|
88
|
-
binary files as long as those fields can be easily viewed by the user.
|
89
|
-
|
90
|
-
3) No Modified Version of the Font Software may use the Reserved Font
|
91
|
-
Name(s) unless explicit written permission is granted by the corresponding
|
92
|
-
Copyright Holder. This restriction only applies to the primary font name as
|
93
|
-
presented to the users.
|
94
|
-
|
95
|
-
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
96
|
-
Software shall not be used to promote, endorse or advertise any
|
97
|
-
Modified Version, except to acknowledge the contribution(s) of the
|
98
|
-
Copyright Holder(s) and the Author(s) or with their explicit written
|
99
|
-
permission.
|
100
|
-
|
101
|
-
5) The Font Software, modified or unmodified, in part or in whole,
|
102
|
-
must be distributed entirely under this license, and must not be
|
103
|
-
distributed under any other license. The requirement for fonts to
|
104
|
-
remain under this license does not apply to any document created
|
105
|
-
using the Font Software.
|
106
|
-
|
107
|
-
TERMINATION
|
108
|
-
This license becomes null and void if any of the above conditions are
|
109
|
-
not met.
|
110
|
-
|
111
|
-
DISCLAIMER
|
112
|
-
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
113
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
114
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
115
|
-
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
116
|
-
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
117
|
-
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
118
|
-
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
119
|
-
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
120
|
-
OTHER DEALINGS IN THE FONT SOFTWARE.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
-----
|
125
|
-
|
126
|
-
TeX Gyre (Pagella and Termes):
|
127
|
-
|
128
|
-
|
129
|
-
This is a preliminary version (2006-09-30), barring acceptance from
|
130
|
-
the LaTeX Project Team and other feedback, of the GUST Font License.
|
131
|
-
(GUST is the Polish TeX Users Group, http://www.gust.org.pl)
|
132
|
-
|
133
|
-
For the most recent version of this license see
|
134
|
-
http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
|
135
|
-
or
|
136
|
-
http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
|
137
|
-
|
138
|
-
This work may be distributed and/or modified under the conditions
|
139
|
-
of the LaTeX Project Public License, either version 1.3c of this
|
140
|
-
license or (at your option) any later version.
|
141
|
-
|
142
|
-
Please also observe the following clause:
|
143
|
-
1) it is requested, but not legally required, that derived works be
|
144
|
-
distributed only after changing the names of the fonts comprising this
|
145
|
-
work and given in an accompanying "manifest", and that the
|
146
|
-
files comprising the Work, as listed in the manifest, also be given
|
147
|
-
new names. Any exceptions to this request are also given in the
|
148
|
-
manifest.
|
149
|
-
|
150
|
-
We recommend the manifest be given in a separate file named
|
151
|
-
MANIFEST-<fontid>.txt, where <fontid> is some unique identification
|
152
|
-
of the font family. If a separate "readme" file accompanies the Work,
|
153
|
-
we recommend a name of the form README-<fontid>.txt.
|
154
|
-
|
155
|
-
The latest version of the LaTeX Project Public License is in
|
156
|
-
http://www.latex-project.org/lppl.txt and version 1.3c or later
|
157
|
-
is part of all distributions of LaTeX version 2006/05/20 or later.
|
158
|
-
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/assets/OEBPS/fonts.css
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
/* A Few Fonts
|
2
|
-
* -----------
|
3
|
-
*
|
4
|
-
* There are many ways to embed fonts for different browsers.
|
5
|
-
* For the sake of simplicity, I'm including the most correct way. As such,
|
6
|
-
* these, fonts might not work for all browsers, but they should fall back
|
7
|
-
* properly.
|
8
|
-
*
|
9
|
-
* See: http://www.metaltoad.com/blog/how-use-font-face-avoid-faux-italic-and-bold-browser-styles
|
10
|
-
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
/* OFL Sorts Mill Goudy */
|
15
|
-
|
16
|
-
@font-face {
|
17
|
-
font-family: 'OFL Sorts Mill Goudy';
|
18
|
-
font-style: normal;
|
19
|
-
font-weight: normal;
|
20
|
-
src: url("fonts/OFL Sorts Mill GoudyStM.otf");
|
21
|
-
}
|
22
|
-
|
23
|
-
@font-face {
|
24
|
-
font-family: 'OFL Sorts Mill Goudy';
|
25
|
-
font-style: italic;
|
26
|
-
font-weight: normal;
|
27
|
-
src: url("fonts/OFL Sorts Mill GoudyStM-Italic.otf");
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
/* Bergamo Std */
|
33
|
-
|
34
|
-
@font-face {
|
35
|
-
font-family: 'Bergamo Std';
|
36
|
-
font-style: normal;
|
37
|
-
font-weight: normal;
|
38
|
-
src: url("fonts/BergamoStd-Regular.otf");
|
39
|
-
}
|
40
|
-
|
41
|
-
@font-face {
|
42
|
-
font-family: 'Bergamo Std';
|
43
|
-
font-style: italic;
|
44
|
-
font-weight: normal;
|
45
|
-
src: url("fonts/BergamoStd-Italic.otf");
|
46
|
-
}
|
47
|
-
|
48
|
-
@font-face {
|
49
|
-
font-family: 'Bergamo Std';
|
50
|
-
font-style: normal;
|
51
|
-
font-weight: bold;
|
52
|
-
src: url("fonts/BergamoStd-Bold.otf");
|
53
|
-
}
|
54
|
-
|
55
|
-
@font-face {
|
56
|
-
font-family: 'Bergamo Std';
|
57
|
-
font-style: italic;
|
58
|
-
font-weight: bold;
|
59
|
-
src: url("fonts/BergamoStd-BoldItalic.otf");
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
/* TeX Gyre Pagella */
|
67
|
-
|
68
|
-
@font-face {
|
69
|
-
font-family: 'TeX Gyre Pagella';
|
70
|
-
font-style: normal;
|
71
|
-
font-weight: normal;
|
72
|
-
src: url("fonts/texgyrepagella-regular.otf");
|
73
|
-
}
|
74
|
-
|
75
|
-
@font-face {
|
76
|
-
font-family: 'TeX Gyre Pagella';
|
77
|
-
font-style: italic;
|
78
|
-
font-weight: normal;
|
79
|
-
src: url("fonts/texgyrepagella-italic.otf");
|
80
|
-
}
|
81
|
-
|
82
|
-
@font-face {
|
83
|
-
font-family: 'TeX Gyre Pagella';
|
84
|
-
font-style: normal;
|
85
|
-
font-weight: bold;
|
86
|
-
src: url("fonts/texgyrepagella-bold.otf");
|
87
|
-
}
|
88
|
-
|
89
|
-
@font-face {
|
90
|
-
font-family: 'TeX Gyre Pagella';
|
91
|
-
font-style: italic;
|
92
|
-
font-weight: bold;
|
93
|
-
src: url("fonts/texgyrepagella-bolditalic.otf");
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
/* TeX Gyre Termes */
|
99
|
-
|
100
|
-
@font-face {
|
101
|
-
font-family: 'TeX Gyre Termes';
|
102
|
-
font-style: normal;
|
103
|
-
font-weight: normal;
|
104
|
-
src: url("fonts/texgyretermes-regular.otf");
|
105
|
-
}
|
106
|
-
|
107
|
-
@font-face {
|
108
|
-
font-family: 'TeX Gyre Termes';
|
109
|
-
font-style: italic;
|
110
|
-
font-weight: normal;
|
111
|
-
src: url("fonts/texgyretermes-italic.otf");
|
112
|
-
}
|
113
|
-
|
114
|
-
@font-face {
|
115
|
-
font-family: 'TeX Gyre Termes';
|
116
|
-
font-style: normal;
|
117
|
-
font-weight: bold;
|
118
|
-
src: url("fonts/texgyretermes-bold.otf");
|
119
|
-
}
|
120
|
-
|
121
|
-
@font-face {
|
122
|
-
font-family: 'TeX Gyre Termes';
|
123
|
-
font-style: italic;
|
124
|
-
font-weight: bold;
|
125
|
-
src: url("fonts/texgyretermes-bolditalic.otf");
|
126
|
-
}
|
127
|
-
|
data/assets/OEBPS/print.css
DELETED
data/assets/OEBPS/stylesheet.css
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
/* Most of this CSS is by Jason LaPier:
|
2
|
-
* http://openbookfiction.com
|
3
|
-
*
|
4
|
-
* other great resources:
|
5
|
-
* http://epubzengarden.com/
|
6
|
-
* http://www.fontsquirrel.com/
|
7
|
-
* http://blog.threepress.org/
|
8
|
-
*/
|
9
|
-
|
10
|
-
#content {
|
11
|
-
background-color: white;
|
12
|
-
color: black;
|
13
|
-
font-family: 'TeX Gyre Termes', serif;
|
14
|
-
text-align: justify;
|
15
|
-
}
|
16
|
-
|
17
|
-
#content h1, #content h2, #content h3 {
|
18
|
-
text-align: right;
|
19
|
-
font-family: sans-serif;
|
20
|
-
}
|
21
|
-
|
22
|
-
#content h1 {
|
23
|
-
border-bottom: 1px solid black;
|
24
|
-
margin: 2em 0em;
|
25
|
-
font-variant: small-caps;
|
26
|
-
}
|
27
|
-
|
28
|
-
/*
|
29
|
-
#content h1 { text-transform:uppercase }
|
30
|
-
*/
|
31
|
-
|
32
|
-
#content h3 {
|
33
|
-
font-style: italic;
|
34
|
-
}
|
35
|
-
|
36
|
-
blockquote {
|
37
|
-
margin-left: 5em;
|
38
|
-
margin-right: 5em;
|
39
|
-
}
|
40
|
-
|
41
|
-
blockquote .attribution {
|
42
|
-
display: block;
|
43
|
-
text-align: right;
|
44
|
-
}
|
45
|
-
|
46
|
-
p {
|
47
|
-
text-indent: 1em;
|
48
|
-
text-align: justify;
|
49
|
-
margin: 0;
|
50
|
-
clear:both;
|
51
|
-
}
|
52
|
-
|
53
|
-
p.first, p.noindent, blockquote p, h1 + p, h2 + p, h3 + p {
|
54
|
-
text-indent: 0;
|
55
|
-
margin-top: 1em;
|
56
|
-
clear:both;
|
57
|
-
}
|
58
|
-
|
59
|
-
h1 + p:first-line, h2 + p:first-line, h3 + p:first-line {
|
60
|
-
font-variant: small-caps;
|
61
|
-
}
|
62
|
-
|
63
|
-
/*
|
64
|
-
h2 + p:first-letter, h1 + p:first-letter {
|
65
|
-
font-size: 2.5em;
|
66
|
-
font-weight: bold;
|
67
|
-
}
|
68
|
-
*/
|
69
|
-
|
70
|
-
em { font-style: italic; }
|
71
|
-
em em { font-style: normal; }
|
72
|
-
|
73
|
-
strong { font-weight: bold; }
|
74
|
-
strong strong { font-weight: normal; }
|
75
|
-
|
76
|
-
.smaller p {
|
77
|
-
font-size: 8pt;
|
78
|
-
text-indent: 0;
|
79
|
-
text-align:left;
|
80
|
-
margin-bottom: 1em;
|
81
|
-
font-family: 'TeX Gyre Termes', serif;
|
82
|
-
}
|
data/assets/mimetype
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
application/epub+zip
|
@@ -1,64 +0,0 @@
|
|
1
|
-
<?xml version='1.0' encoding='utf-8'?>
|
2
|
-
<package xmlns="http://www.idpf.org/2007/opf"
|
3
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
-
unique-identifier="bookid" version="2.0">
|
5
|
-
<metadata>
|
6
|
-
<dc:title><%= title %></dc:title>
|
7
|
-
<dc:creator>Alex Vakhov</dc:creator>
|
8
|
-
<dc:identifier id="bookid">urn:uuid:a4ea6f00-8bcd-012e-1448-0013a97f1781</dc:identifier>
|
9
|
-
<dc:language>en-US</dc:language>
|
10
|
-
<dc:date>2011-07-09</dc:date>
|
11
|
-
<dc:rights>http://creativecommons.org/licenses/by-nc-nd/3.0/</dc:rights>
|
12
|
-
<meta name="cover" content="cover-image" />
|
13
|
-
</metadata>
|
14
|
-
<manifest>
|
15
|
-
<item id="cover" href="title.html" media-type="application/xhtml+xml"/>
|
16
|
-
<% files.each do |file| %>
|
17
|
-
<item id="<%= file.gsub(".", "_") %>" href="<%= file %>.html" media-type="application/xhtml+xml"/>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<item id="css_print.css" href="print.css" media-type="text/css"/>
|
21
|
-
|
22
|
-
<item id="css_stylesheet.css" href="stylesheet.css" media-type="text/css"/>
|
23
|
-
|
24
|
-
<item id="css_fonts.css" href="fonts.css" media-type="text/css"/>
|
25
|
-
|
26
|
-
|
27
|
-
<item id="font_BergamoStd-Regular.otf" href="fonts/BergamoStd-Regular.otf" media-type="application/x-font-opentype"/>
|
28
|
-
|
29
|
-
<item id="font_texgyrepagella-regular.otf" href="fonts/texgyrepagella-regular.otf" media-type="application/x-font-opentype"/>
|
30
|
-
|
31
|
-
<item id="font_licenses.txt" href="fonts/licenses.txt" media-type="application/x-font-opentype"/>
|
32
|
-
|
33
|
-
<item id="font_texgyretermes-bolditalic.otf" href="fonts/texgyretermes-bolditalic.otf" media-type="application/x-font-opentype"/>
|
34
|
-
|
35
|
-
<item id="font_texgyrepagella-bold.otf" href="fonts/texgyrepagella-bold.otf" media-type="application/x-font-opentype"/>
|
36
|
-
|
37
|
-
<item id="font_texgyretermes-bold.otf" href="fonts/texgyretermes-bold.otf" media-type="application/x-font-opentype"/>
|
38
|
-
|
39
|
-
<item id="font_OFLGoudyStM.otf" href="fonts/OFLGoudyStM.otf" media-type="application/x-font-opentype"/>
|
40
|
-
|
41
|
-
<item id="font_BergamoStd-Italic.otf" href="fonts/BergamoStd-Italic.otf" media-type="application/x-font-opentype"/>
|
42
|
-
|
43
|
-
<item id="font_texgyrepagella-italic.otf" href="fonts/texgyrepagella-italic.otf" media-type="application/x-font-opentype"/>
|
44
|
-
|
45
|
-
<item id="font_texgyrepagella-bolditalic.otf" href="fonts/texgyrepagella-bolditalic.otf" media-type="application/x-font-opentype"/>
|
46
|
-
|
47
|
-
<item id="font_texgyretermes-italic.otf" href="fonts/texgyretermes-italic.otf" media-type="application/x-font-opentype"/>
|
48
|
-
|
49
|
-
<item id="font_BergamoStd-Bold.otf" href="fonts/BergamoStd-Bold.otf" media-type="application/x-font-opentype"/>
|
50
|
-
|
51
|
-
<item id="font_OFLGoudyStM-Italic.otf" href="fonts/OFLGoudyStM-Italic.otf" media-type="application/x-font-opentype"/>
|
52
|
-
|
53
|
-
<item id="font_texgyretermes-regular.otf" href="fonts/texgyretermes-regular.otf" media-type="application/x-font-opentype"/>
|
54
|
-
|
55
|
-
<item id="font_BergamoStd-BoldItalic.otf" href="fonts/BergamoStd-BoldItalic.otf" media-type="application/x-font-opentype"/>
|
56
|
-
|
57
|
-
</manifest>
|
58
|
-
<spine toc="ncx">
|
59
|
-
<itemref idref="cover" linear="yes"/>
|
60
|
-
<% files.each do |file| %>
|
61
|
-
<itemref idref="<%= file.gsub(".", "_") %>"/>
|
62
|
-
<% end %>
|
63
|
-
</spine>
|
64
|
-
</package>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
2
|
-
<head>
|
3
|
-
<title></title>
|
4
|
-
<link rel="stylesheet" href="stylesheet.css" type="text/css" media="all" />
|
5
|
-
<link rel="stylesheet" href="fonts.css" type="text/css" media="all" />
|
6
|
-
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<h1><%= title %></h1>
|
10
|
-
<h2>Alex Vakhov</h2>
|
11
|
-
</body>
|
12
|
-
</html>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
2
|
-
<head>
|
3
|
-
<title></title>
|
4
|
-
<link rel="stylesheet" href="stylesheet.css" type="text/css" media="all" />
|
5
|
-
<link rel="stylesheet" href="fonts.css" type="text/css" media="all" />
|
6
|
-
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<h2><%= file_name %></h2>
|
10
|
-
<%= body %>
|
11
|
-
</body>
|
12
|
-
</html>
|
data/bin/dir2epub
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$: << File.expand_path("../../lib", __FILE__)
|
4
|
-
require 'rubygems'
|
5
|
-
require 'book_utils/convert'
|
6
|
-
|
7
|
-
if ARGV.empty?
|
8
|
-
puts "Usage: "
|
9
|
-
puts " dir2epub <folder>"
|
10
|
-
puts ""
|
11
|
-
puts "GEM paths:"
|
12
|
-
Gem.path.each do |path|
|
13
|
-
puts " " + path
|
14
|
-
end
|
15
|
-
else
|
16
|
-
BookUtils::Convert.new(ARGV[0]).run
|
17
|
-
end
|
data/lib/book_utils/convert.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'tmpdir'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'erb'
|
4
|
-
require 'coderay'
|
5
|
-
|
6
|
-
module BookUtils
|
7
|
-
class Convert
|
8
|
-
def initialize(dir)
|
9
|
-
@dir = dir
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
files = Dir[File.expand_path("**/*", @dir)].sort.reject{|a| File.directory?(a)}
|
14
|
-
|
15
|
-
Dir.mktmpdir do |path|
|
16
|
-
assets_dir = File.expand_path("../../../assets/", __FILE__)
|
17
|
-
|
18
|
-
# copy system files
|
19
|
-
FileUtils.cp_r("#{assets_dir}/META-INF", path)
|
20
|
-
FileUtils.cp_r("#{assets_dir}/OEBPS", path)
|
21
|
-
FileUtils.cp("#{assets_dir}/mimetype", path)
|
22
|
-
|
23
|
-
# colorize files
|
24
|
-
files = files.select do |file|
|
25
|
-
File.extname(file) == '.rb'
|
26
|
-
end
|
27
|
-
|
28
|
-
files.each do |file|
|
29
|
-
File.open(path + "/OEBPS/" + file_basename(file) + ".html", "w") do |f|
|
30
|
-
f.write colorize(file_basename(file), File.read(file))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# process ERB templates
|
35
|
-
%w(title.html.erb content.opf.erb).each do |template_name|
|
36
|
-
template = "#{assets_dir}/templates/#{template_name}"
|
37
|
-
File.open(path + "/OEBPS/" + File.basename(template, '.erb'), "w") do |f|
|
38
|
-
f.write process_template(File.read(template), File.basename(@dir), files.map{|f| file_basename(f)})
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# zip book
|
43
|
-
Dir.chdir path do
|
44
|
-
system "zip -0Xq ebook.epub mimetype"
|
45
|
-
system "zip -Xr9Dq ebook.epub *"
|
46
|
-
end
|
47
|
-
|
48
|
-
# move to work directory
|
49
|
-
FileUtils.mv(path + "/ebook.epub", File.basename(@dir) + ".epub")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
def process_template(template, title_, files_)
|
55
|
-
title = title_
|
56
|
-
files = files_
|
57
|
-
|
58
|
-
ERB.new(template).result(binding)
|
59
|
-
end
|
60
|
-
|
61
|
-
def colorize(file_name_, code)
|
62
|
-
wrapper = File.read(File.expand_path("../../../assets/templates/wrapper.html.erb", __FILE__))
|
63
|
-
body = CodeRay.
|
64
|
-
scan(code, :ruby).
|
65
|
-
html(:css => :style).
|
66
|
-
split("\n").
|
67
|
-
map{|line| "<div>" + indent(line) + "</div>"}.
|
68
|
-
join("\n")
|
69
|
-
file_name = file_name_
|
70
|
-
|
71
|
-
ERB.new(wrapper).result(binding)
|
72
|
-
end
|
73
|
-
|
74
|
-
def indent(line)
|
75
|
-
out = ""
|
76
|
-
while line[0..0] == ' '
|
77
|
-
out << ' '*1
|
78
|
-
line = line[1..-1]
|
79
|
-
end
|
80
|
-
|
81
|
-
out += line
|
82
|
-
|
83
|
-
if out.empty?
|
84
|
-
' '
|
85
|
-
else
|
86
|
-
out
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def file_basename(file)
|
91
|
-
file.sub(@dir, '').gsub("/", "_")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|