xpub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,139 @@
1
+ module Xpub
2
+ class CallBook
3
+
4
+ class CallSrcFile
5
+ attr_reader :file
6
+
7
+ def initialize file
8
+ @file = file
9
+ end
10
+
11
+ def full_path
12
+ "#{Dir::getwd}/src/#{@file}"
13
+ end
14
+
15
+ def validate
16
+ if !File.exist? full_path
17
+ raise "File does not exist.#{full_path}"
18
+ end
19
+ end
20
+
21
+ def debug
22
+ p full_path
23
+ end
24
+ end
25
+
26
+ class CallMdFile < CallSrcFile
27
+ def initialize file
28
+ if !file.match "\.md$"
29
+ file = file + ".md"
30
+ end
31
+ super file
32
+ end
33
+ end
34
+
35
+ class CallImgFile < CallSrcFile
36
+ def validate
37
+ super
38
+ if !@file.match "\.(jpeg|jpg|png|bmp|pdf)$"
39
+ raise "Image File Ext is not Image Ext. #{@file}"
40
+ end
41
+ end
42
+ end
43
+
44
+
45
+ class CallImgFiles
46
+ attr_reader :dir
47
+
48
+ def initialize dir
49
+ @dir = dir
50
+ end
51
+
52
+ def full_path
53
+ "#{Dir::getwd}/src/#{@dir}"
54
+ end
55
+
56
+ def validate
57
+ if !Dir.exist? full_path
58
+ raise "Image Dir does not exist.#{full_path}"
59
+ end
60
+ end
61
+
62
+ def img_files
63
+ validate
64
+ Dir.glob("#{full_path}/**/*.{jpeg,jpg,png,bmp,pdf}").sort.map { |path|
65
+ img = CallImgFile.new path.sub(full_path + "/", "")
66
+ img.validate
67
+ img
68
+ }
69
+ end
70
+ end
71
+
72
+ class CallMdFiles
73
+ attr_reader :dir
74
+
75
+ def initialize dir
76
+ @dir = dir
77
+ end
78
+
79
+ def full_path
80
+ "#{Dir::getwd}/src/#{@dir}"
81
+ end
82
+
83
+ def validate
84
+ if !Dir.exist? full_path
85
+ raise "Markdown Dir does not exist.#{full_path}"
86
+ end
87
+ end
88
+
89
+ def md_files
90
+ validate
91
+ Dir.glob("#{full_path}/**/*.md").sort.map { |path|
92
+ mf = CallMdFile.new path.sub(full_path + "/", "")
93
+ mf.validate
94
+ mf
95
+ }
96
+ end
97
+
98
+ def debug
99
+ p full_path
100
+ end
101
+ end
102
+
103
+ def md_file file, &block
104
+ call = CallMdFile.new file
105
+ if block
106
+ call.instance_eval &block
107
+ end
108
+ call.validate
109
+ @src_files << call
110
+ end
111
+
112
+ def md_files dir, &block
113
+ call = CallMdFiles.new dir
114
+ if block
115
+ call.instance_eval &block
116
+ end
117
+ call.validate
118
+ @src_files.concat call.md_files
119
+ end
120
+
121
+ def img_file file, &block
122
+ call = CallImgFile.new file
123
+ if block
124
+ call.instance_eval &block
125
+ end
126
+ call.validate
127
+ @resource_files << call
128
+ end
129
+
130
+ def img_files dir, &block
131
+ call = CallImgFiles.new dir
132
+ if block
133
+ call.instance_eval &block
134
+ end
135
+ call.validate
136
+ @resource_files.concat call.img_files
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,3 @@
1
+ module Xpub
2
+ VERSION = "0.0.1"
3
+ end
data/skel/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ output/*.*
2
+ tmp/*.*
data/skel/Xpub ADDED
@@ -0,0 +1,68 @@
1
+ Xpub::book "sample" do
2
+ # identifier "urn:uuid:c12fdf58-6f2b-4a77-bd58-186b3192b52a" do
3
+ # scheme "UUID"
4
+ # end
5
+ title "サンプル"
6
+ # subtitle "サブタイトル"
7
+ # short "短縮タイトル"
8
+ # collection "コレクションタイトル"
9
+ # edition "エディションタイトル"
10
+ # extended "エクステンドタイトル"
11
+
12
+ # publisher "○○出版社"
13
+ creator "電書 電子" do
14
+ # role "aut"
15
+ end
16
+ # contributor "コントリビュータの名前" do
17
+ # role "ill"
18
+ # end
19
+ description "テストのアブストラクトです。長い文のアブストラクトだとどういう表示になるのかをテストしています。"
20
+ # rights "権利表記"
21
+ # publication "2015/01/22 18:10:00"
22
+ # modification Time.now.to_s
23
+
24
+ md_file "sample"
25
+ # md_files "."
26
+
27
+ img_file "sample1.jpg"
28
+ # img_file "hyoushi.png"
29
+ # img_file "urahyoushi.png"
30
+
31
+ latex_builder "latex" do
32
+ documentclass "utbook"
33
+ classoption "11pt"
34
+ classoption "twocolumn"
35
+ classoption "twoside"
36
+ classoption "a5j"
37
+ # prepartname "第"
38
+ # postpartname "部"
39
+ # prechaptername "第"
40
+ # postchaptername "章"
41
+ # output "sample"
42
+ # theme "default"
43
+ # template "template.tex"
44
+ # filter "pandoc-filter.rb"
45
+
46
+ hyoushi_image_page "h01" do
47
+ file "sample1.jpg"
48
+ topoffset "-0.8mm"
49
+ leftoffset "2.1mm"
50
+ end
51
+ hyoushi_empty_page "h02" do
52
+ no_page_number
53
+ end
54
+ hyoushi_inner_title_page "title"
55
+ urahyoushi_empty_page "h03" do
56
+ no_page_number
57
+ end
58
+ urahyoushi_image_page "h04" do#
59
+ file "sample1.jpg"
60
+ topoffset "-0.8mm"
61
+ leftoffset "-5mm"
62
+ end
63
+ end
64
+
65
+ epub_builder "epub" do
66
+ cover_image "sample1.jpg"
67
+ end
68
+ end
File without changes
data/skel/src/.gitkeep ADDED
File without changes
@@ -0,0 +1,47 @@
1
+ <!-- %%toc%% -->
2
+
3
+ # チャプター
4
+
5
+ {グループルビ|ぐるーぷるび}のテストです。{熟語ルビ|じゅく|ご|る|び}のテストです。
6
+
7
+ ![サンプル](sample1.jpg)
8
+
9
+ ## セクション
10
+
11
+ 空行を作成しない段落は、単なる改行になります。
12
+  段落の最初に全角スペースをいれることで、段落の最初を表現します。
13
+
14
+ 空行を開けた場合はこうなります。
15
+
16
+ ### サブセクション
17
+
18
+ 縦書き^横書き^縦書き
19
+
20
+ <!-- 改ページ(newpage) -->
21
+
22
+ ===
23
+
24
+ <!-- 改ページ(clearpage) -->
25
+
26
+ ====
27
+
28
+ <!-- 改ページ(cleardoublepage) -->
29
+
30
+ =====
31
+
32
+ # 番号なしチャプター {-}
33
+
34
+ <!-- %%onecolumn%% -->
35
+
36
+ ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。ここは一カラムになります。
37
+
38
+ <!-- %%twocolumn%% -->
39
+
40
+ ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。
41
+
42
+ ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。
43
+
44
+ ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。ここは二カラムになります。
45
+
46
+
47
+
Binary file
@@ -0,0 +1,204 @@
1
+ /* This defines styles and classes used in the book */
2
+ code { font-family: monospace; }
3
+ h1.title { }
4
+ h2.author { }
5
+ h3.date { }
6
+ ol.toc { padding: 0; margin-left: 1em; }
7
+ ol.toc li { list-style-type: none; margin: 0; padding: 0; }
8
+
9
+ html {
10
+ -epub-writing-mode: vertical-rl;
11
+ }
12
+
13
+ body {
14
+ text-align: justify;
15
+ text-justify: inter-ideograph;
16
+ font-family: serif, sans-serif;
17
+ }
18
+
19
+ h1, h2, h3, h4, h5, h6 {
20
+ font-family: serif, sans-serif;
21
+ font-weight: normal;
22
+ color: inherit;
23
+ }
24
+
25
+ h1 {
26
+ font-size: 1.25em;
27
+ margin-right: 0.625em;
28
+ margin-left: 0.625em;
29
+ }
30
+
31
+ h2 {
32
+ font-size: 1.2em;
33
+ margin-right: 0.83333em;
34
+ margin-left: 0.83333em;
35
+ }
36
+
37
+ h3 {
38
+ font-size: 1.125em;
39
+ margin-right: 1.11111em;
40
+ margin-left: 1.11111em;
41
+ }
42
+
43
+ h4 {
44
+ font-size: 1em;
45
+ margin-right: 1.25em;
46
+ margin-left: 1.25em;
47
+ }
48
+
49
+ h5 {
50
+ font-size: 0.875em;
51
+ margin-right: 1.42857em;
52
+ margin-left: 1.42857em;
53
+ }
54
+
55
+ h6 {
56
+ font-size: 0.75em;
57
+ margin-right: 1.66667em;
58
+ margin-left: 1.66667em;
59
+ }
60
+
61
+ p {
62
+ margin-right: 1.25em;
63
+ margin-left: 1.25em;
64
+ line-height: 1.8;
65
+ }
66
+
67
+ p, li, dt, dd {
68
+ line-height: 1.8;
69
+ }
70
+
71
+ b, strong, dt, caption, figcaption, th {
72
+ font-family: sans-serif, serif;
73
+ }
74
+
75
+ blockquote, ul,
76
+ fieldset, form,
77
+ ol, dl, menu {
78
+ margin-right: 1.25em;
79
+ margin-left: 1.25em;
80
+ padding: 0;
81
+ }
82
+
83
+ blockquote blockquote, blockquote ol, blockquote ul, blockquote dl, ol blockquote, ol ol, ol ul, ol dl, ul blockquote, ul ol, ul ul, ul dl, dl blockquote, dl ol, dl ul, dl dl {
84
+ margin-right: 0em;
85
+ margin-left: 0em;
86
+ }
87
+
88
+ ol, ul, menu, dd {
89
+ margin-top: 2em;
90
+ }
91
+
92
+ a {
93
+ color: #0538b2;
94
+ }
95
+ a:hover {
96
+ color: #b2058e;
97
+ }
98
+ a:active {
99
+ color: #b27f05;
100
+ }
101
+
102
+ pre {
103
+ white-space: pre-wrap;
104
+ }
105
+
106
+ img {
107
+ width: auto;
108
+ height: auto;
109
+ max-width: 100%;
110
+ max-height: 100%;
111
+ }
112
+
113
+ hr {
114
+ margin-right: 1.25em;
115
+ margin-left: 1.25em;
116
+ }
117
+
118
+ table {
119
+ border-collapse: collapse;
120
+ border-spacing: 0;
121
+ }
122
+
123
+ rt {
124
+ font-family: serif, sans-serif;
125
+ }
126
+
127
+ .tcy {
128
+ -epub-text-combine: horizontal;
129
+ }
130
+
131
+ .sideways {
132
+ -epub-text-orientation: sideways;
133
+ }
134
+
135
+ .upright {
136
+ /* -epub-text-orientation: upright; */
137
+ -epub-text-combine: horizontal;
138
+ }
139
+
140
+ .pagenum {
141
+ color: gray;
142
+ font-size: 0.8em;
143
+ }
144
+
145
+ .footnotes hr {
146
+ margin-right: 1.25em;
147
+ margin-left: 1.25em;
148
+ }
149
+ .footnotes ol {
150
+ margin-top: 2em;
151
+ }
152
+ .footnotes li {
153
+ font-size: 0.875em;
154
+ }
155
+
156
+ a.noteref {
157
+ display: inline-block;
158
+ border: none;
159
+ font-size: 0.75em;
160
+ line-height: 1;
161
+ vertical-align: super;
162
+ -epub-text-combine: horizontal;
163
+ }
164
+ a.noteref:before {
165
+ content: "[";
166
+ }
167
+ a.noteref:after {
168
+ content: "]";
169
+ }
170
+
171
+ h2 {
172
+ margin-top: 0.66667em;
173
+ }
174
+
175
+ h3 {
176
+ margin-top: 1.77778em;
177
+ }
178
+
179
+ blockquote {
180
+ margin-top: 1em;
181
+ }
182
+
183
+ p {
184
+ margin: 0;
185
+ }
186
+
187
+ a {
188
+ text-decoration: overline;
189
+ }
190
+
191
+ @media print {
192
+ h1 {
193
+ page-break-before: always;
194
+ }
195
+
196
+ h1, h2, h3,
197
+ h4, h5, h6 {
198
+ page-break-after: avoid;
199
+ }
200
+
201
+ ul, ol, dl {
202
+ page-break-before: avoid;
203
+ }
204
+ }