verku 0.8.0.p
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 +7 -0
- data/.document +5 -0
- data/.gitignore +49 -0
- data/BUILD.md +6 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.md +22 -0
- data/README.md +149 -0
- data/Rakefile +72 -0
- data/VERSION +1 -0
- data/bin/verku +5 -0
- data/lib/verku.rb +56 -0
- data/lib/verku/adapters/markdown.rb +44 -0
- data/lib/verku/cli.rb +93 -0
- data/lib/verku/dependency.rb +19 -0
- data/lib/verku/exporter.rb +77 -0
- data/lib/verku/extensions/string.rb +19 -0
- data/lib/verku/generator.rb +55 -0
- data/lib/verku/parser.rb +85 -0
- data/lib/verku/parser/epub.rb +187 -0
- data/lib/verku/parser/html.rb +245 -0
- data/lib/verku/parser/mobi.rb +17 -0
- data/lib/verku/parser/pdf.rb +54 -0
- data/lib/verku/parser/txt.rb +1 -0
- data/lib/verku/stats.rb +114 -0
- data/lib/verku/stream.rb +27 -0
- data/lib/verku/toc.rb +6 -0
- data/lib/verku/toc/epub.rb +41 -0
- data/lib/verku/toc/html.rb +78 -0
- data/lib/verku/version.rb +10 -0
- data/templates/config.erb +80 -0
- data/templates/cover.jpg +0 -0
- data/templates/dp-logo.png +0 -0
- data/templates/epub/back.erb +22 -0
- data/templates/epub/copyright.erb +46 -0
- data/templates/epub/cover.erb +12 -0
- data/templates/epub/cover.html +12 -0
- data/templates/epub/page.erb +15 -0
- data/templates/epub/user.css +500 -0
- data/templates/extras.tex +1 -0
- data/templates/html/copyright.erb +46 -0
- data/templates/html/layout.css +352 -0
- data/templates/html/layout.erb +45 -0
- data/templates/html/syntax.css +58 -0
- data/templates/html/thanks.erb +21 -0
- data/templates/html/user.css +7 -0
- data/templates/latex.erb +416 -0
- data/templates/merovex-logo.jpg +0 -0
- data/templates/merovex-logo.png +0 -0
- data/templates/pdf/layout.erb +418 -0
- data/templates/rakefile.rb +103 -0
- data/templates/readme.erb +3 -0
- data/templates/text/01-Getting-Started.md +27 -0
- data/templates/text/02-Creating-Chapters.md +22 -0
- data/templates/text/03-Generating-Output.md +2 -0
- data/templates/text/10-Test-Markdown.md +157 -0
- data/test/helper.rb +34 -0
- data/test/test_bookmaker.rb +7 -0
- data/verku.gemspec +142 -0
- metadata +317 -0
@@ -0,0 +1,418 @@
|
|
1
|
+
\NeedsTeXFormat{LaTeX2e}[1996/06/01]
|
2
|
+
\documentclass[11pt,twoside,makeidx,hidelinks,<%= (status == 'final') ? '' : 'showtrims' %>]{memoir}
|
3
|
+
\usepackage{layouts}[2001/04/29]
|
4
|
+
<%= (status == 'final') ? '\def\isfinal{1}' : '' %>
|
5
|
+
|
6
|
+
% Packages
|
7
|
+
%=========
|
8
|
+
\usepackage{verbatim}
|
9
|
+
\usepackage[colorlinks=false]{hyperref}
|
10
|
+
% \usepackage[utf8x]{inputenc}
|
11
|
+
\usepackage{listings}
|
12
|
+
\usepackage{
|
13
|
+
fancyvrb,
|
14
|
+
graphics,
|
15
|
+
url,
|
16
|
+
rotating,
|
17
|
+
lipsum,
|
18
|
+
microtype,
|
19
|
+
fancybox,
|
20
|
+
glossaries,
|
21
|
+
titling,
|
22
|
+
xspace,
|
23
|
+
}
|
24
|
+
\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
|
25
|
+
|
26
|
+
% Boolean-ness
|
27
|
+
%=============
|
28
|
+
\newcommand{\onlyfinal}[1]{\ifdefined\isfinal{#1}\fi}%
|
29
|
+
\newcommand{\notfinal}[1]{\ifdefined\isfinal\else{#1}\fi}%
|
30
|
+
\newcommand{\whenfinal}[2]{%
|
31
|
+
\ifdefined\isfinal%
|
32
|
+
#1%
|
33
|
+
\else%
|
34
|
+
#2%
|
35
|
+
\fi}%
|
36
|
+
|
37
|
+
%
|
38
|
+
% Page Layout
|
39
|
+
%============
|
40
|
+
<%
|
41
|
+
if status == 'final'
|
42
|
+
stock_size = [9, 6]
|
43
|
+
trims = [0, 0]
|
44
|
+
else
|
45
|
+
stock_size = [11 , 8.5]
|
46
|
+
trims = [0.8, 0.5]
|
47
|
+
end
|
48
|
+
ul_margin = [0.8, 0.5]
|
49
|
+
lr_margin = [0.8, 0.6]
|
50
|
+
type_block = [(9 - ul_margin.sum), (6 - lr_margin.sum)]
|
51
|
+
|
52
|
+
%>
|
53
|
+
<%= (status == 'final') ? '' : '\trimFrame' %>
|
54
|
+
\setstocksize{<%=stock_size[0]%>in}{<%=stock_size[1]%>in}
|
55
|
+
\setulmarginsandblock{0.8in}{0.5in}{*}
|
56
|
+
\settrims{<%=trims[0]%>in}{<%=trims[1]%>in}
|
57
|
+
\setlrmarginsandblock{0.8in}{0.5in}{*}
|
58
|
+
\settrimmedsize{9in}{6in}{*}
|
59
|
+
\settypeblocksize{<%=type_block[0]%>in}{<%=type_block[1]%>in}{*}
|
60
|
+
|
61
|
+
\setmarginnotes{0.1pt}{0.2in}{\onelineskip}
|
62
|
+
\setheadfoot{\onelineskip}{2\onelineskip}
|
63
|
+
\setheaderspaces{*}{2\onelineskip}{*}
|
64
|
+
\linespread{1.15}
|
65
|
+
|
66
|
+
\checkandfixthelayout
|
67
|
+
|
68
|
+
\setlength{\headsep}{8pt}
|
69
|
+
|
70
|
+
\newlength{\AfterFancyBreakMin}
|
71
|
+
\setlength{\AfterFancyBreakMin}{3\baselineskip}
|
72
|
+
\setlength{\parindent}{1.5 em}
|
73
|
+
\makeatletter
|
74
|
+
\g@addto@macro\quote{\linespread{1}\small{}}
|
75
|
+
\g@addto@macro\quotation{\linespread{1}\small{}}
|
76
|
+
\g@addto@macro\caption{\linespread{1}\footnotesize{}}
|
77
|
+
\makeatother
|
78
|
+
\tolerance 1414
|
79
|
+
\hbadness 1414
|
80
|
+
\setlength{\emergencystretch}{3em}
|
81
|
+
\righthyphenmin 62
|
82
|
+
\emergencystretch 1.5em
|
83
|
+
\hfuzz 0.3pt
|
84
|
+
\widowpenalty=10000
|
85
|
+
\clubpenalty=10000
|
86
|
+
\setlength{\parindent}{1.5 em}
|
87
|
+
|
88
|
+
% Page Heading
|
89
|
+
%-------------
|
90
|
+
\makepagestyle{ebook}
|
91
|
+
\makeoddhead{ebook}{}{\textsf\theauthor}{\normalfont\thepage}
|
92
|
+
\makeevenhead{ebook}{\normalfont\thepage}{\textsf \thetitle}{}
|
93
|
+
|
94
|
+
\aliaspagestyle{title}{empty}
|
95
|
+
|
96
|
+
% Text Tweaks
|
97
|
+
%-------------
|
98
|
+
\def\thinspace{\kern .16667em }
|
99
|
+
\newcommand{\ellip}{\ldots}
|
100
|
+
\newcommand{\Dash}{\thinspace---\thinspace}
|
101
|
+
\newcommand{\dash}{\tk{--Wrong Dash--}}
|
102
|
+
|
103
|
+
% Fonts
|
104
|
+
%------
|
105
|
+
\usepackage{fontspec}
|
106
|
+
\usepackage{xunicode}
|
107
|
+
\usepackage{xltxtra}
|
108
|
+
\defaultfontfeatures{Mapping=tex-text}
|
109
|
+
\setmainfont{<%= fonts['serif'] %>}
|
110
|
+
\setsansfont{<%= fonts['sans'] %>}
|
111
|
+
\setmonofont{<%= fonts['mono'] %>}
|
112
|
+
\newfontinstance\scshape[Letters=SmallCaps, Numbers=Uppercase]{<%= fonts['small_caps'] || fonts['mono'] %>}
|
113
|
+
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
|
114
|
+
\ifdefined\disableligature
|
115
|
+
\DisableLigatures[f]{encoding = *, family = * }
|
116
|
+
\fi
|
117
|
+
|
118
|
+
% Dates
|
119
|
+
%-------
|
120
|
+
\usepackage{datetime}
|
121
|
+
\newdateformat{yearonly}{\THEYEAR}
|
122
|
+
\newdateformat{usmonthyear}{\monthname[\THEMONTH], \THEYEAR}
|
123
|
+
\newcommand{\monthyear}{%
|
124
|
+
\ifcase\month\or January\or February\or March\or April\or May\or June\or
|
125
|
+
July\or August\or September\or October\or November\or
|
126
|
+
December\fi\space\number\year
|
127
|
+
}
|
128
|
+
|
129
|
+
% Document Headings
|
130
|
+
%==================
|
131
|
+
|
132
|
+
% Chapter
|
133
|
+
%-----------
|
134
|
+
\setsecheadstyle{\bfseries\large\centering}
|
135
|
+
\newcounter{renewsection}
|
136
|
+
\newcommand{\Chapter}[1]{
|
137
|
+
\setcounter{renewsection}{\value{section}}
|
138
|
+
<% if type == 'fiction' %>
|
139
|
+
\chapter{}
|
140
|
+
<% else %>
|
141
|
+
%\chapter{#1}
|
142
|
+
<% end %>
|
143
|
+
\setcounter{section}{\value{renewsection}}
|
144
|
+
}
|
145
|
+
\chapterstyle{<%= chapter_style || 'ell'%>}
|
146
|
+
|
147
|
+
|
148
|
+
% Section
|
149
|
+
%---------
|
150
|
+
\renewcommand{\thesection}{\arabic{section}.}
|
151
|
+
|
152
|
+
% Novel Tweaks
|
153
|
+
%=============
|
154
|
+
|
155
|
+
\newenvironment{xdedication}%
|
156
|
+
{\vspace*{6ex}\begin{quotation}\begin{center}\begin{em}}%
|
157
|
+
{\par\end{em}\end{center}\end{quotation}}%
|
158
|
+
|
159
|
+
\newenvironment{dedication}
|
160
|
+
{\clearpage % we want a new page
|
161
|
+
\thispagestyle{empty}% no header and footer
|
162
|
+
\vspace*{\stretch{1}}% some space at the top
|
163
|
+
\itshape % the text is in italics
|
164
|
+
\raggedleft % flush to the right margin
|
165
|
+
}
|
166
|
+
{\par % end the paragraph
|
167
|
+
\vspace{\stretch{3}} % space at bottom is three times that at the top
|
168
|
+
\clearpage % finish off the page
|
169
|
+
}
|
170
|
+
|
171
|
+
% Scene Formatting
|
172
|
+
%-----------------
|
173
|
+
|
174
|
+
\newcommand*\thoughtbreak{
|
175
|
+
\begin{center}
|
176
|
+
\vspace{1cm}
|
177
|
+
\noindent\rule{0.5\textwidth}{0.4pt}
|
178
|
+
\vspace{1cm}
|
179
|
+
\end{center}
|
180
|
+
}
|
181
|
+
|
182
|
+
\newcommand{\thought}[1]{\emph{#1}}
|
183
|
+
\newcommand{\email}[1]{\texttt{#1}}
|
184
|
+
\newcommand{\status}[1]{\notfinal{\textbf{Status:} #1\newline}}
|
185
|
+
\newcommand{\synopsis}[1]{\notfinal{\line(1,0){320}\newline\textbf{What's going on here?} #1\newline
|
186
|
+
\line(1,0){320}\newline}}
|
187
|
+
\newcommand{\slug}[1]{\notfinal{\MakeUppercase{#1}\newline\newline}}
|
188
|
+
\newcommand{\slugline}[2]{\notfinal{\section{#1}}\onlyfinal{\section{}}\slug{#2}}
|
189
|
+
\newcommand{\interlude}[1]{\plainfancybreak{\AfterFancyBreakMin}{1}{#1}}
|
190
|
+
|
191
|
+
% \newcommand{\scene}[3]{%
|
192
|
+
% \notfinal{\section{#1}\slug{#2}}
|
193
|
+
% \input{#3}
|
194
|
+
% \pbreak
|
195
|
+
% }%
|
196
|
+
|
197
|
+
\newcommand{\smee}[1]{\${-} \textsc{\small#1}}
|
198
|
+
\whenfinal%
|
199
|
+
{\newcommand{\pbreak}{\pfbreak}}%
|
200
|
+
{\newcommand{\pbreak}{\begin{center} \# \# \# \end{center}}}
|
201
|
+
|
202
|
+
% \renewcommand{\pbreak}{\thoughtbreak}
|
203
|
+
% Series Title Page
|
204
|
+
%==================
|
205
|
+
\def\seriestitle#1{\def\theseriestitle{\uppercase{#1}}}
|
206
|
+
\def\seriespage{\thispagestyle{empty}
|
207
|
+
\begin{center}
|
208
|
+
\noindent{\large\theseriestitle}
|
209
|
+
\vskip10.5pt
|
210
|
+
\noindent Other Books in the series:
|
211
|
+
\vskip4pt
|
212
|
+
\theseriesbooks
|
213
|
+
\end{center}\cleardoublepage}
|
214
|
+
\def\seriesbook#1{\vskip.5pt{\noindent\hskip8pt\emph{#1}}\vskip1sp}
|
215
|
+
\def\seriesbooks#1\endseriesbooks{\def\theseriesbooks{\let\book\seriesbook{#1}}}
|
216
|
+
|
217
|
+
% Indices
|
218
|
+
%=========
|
219
|
+
\makeglossary
|
220
|
+
\makeindex
|
221
|
+
\let\oldindex\index{}%
|
222
|
+
\newcommand{\marked}[1]{\whenfinal{#1}{\underline{#1}}}%
|
223
|
+
\renewcommand{\index}[1]{\oldindex{#1}\marked{#1}}%
|
224
|
+
\newcommand{\Index}[2]{\oldindex{#1}\marked{#2}}%
|
225
|
+
\newcommand{\orbital}[1]{\oldindex{Orbital!#1}\marked{#1}}%
|
226
|
+
\newcommand{\equipment}[1]{\oldindex{Equipment!#1}\marked{#1}}%
|
227
|
+
\newcommand{\Equipment}[2]{\oldindex{Equipment!#1}\marked{#2}}%
|
228
|
+
\newcommand{\System}[2]{\oldindex{System!#1}\marked{#2}}%
|
229
|
+
\newcommand{\system}[1]{\oldindex{System!#1}\marked{#1}}%
|
230
|
+
\newcommand{\character}[1]{\oldindex{Character!#1}\marked{#1}}%
|
231
|
+
\newcommand{\Character}[2]{\oldindex{Character!#1}\marked{#2}}%
|
232
|
+
\newcommand{\ship}[1]{\oldindex{Ship!#1}\marked{\emph{#1}}}%
|
233
|
+
\newcommand{\Ship}[1]{\oldindex{Ship!#1}\marked{\emph{#1}}}%
|
234
|
+
\newcommand{\location}[1]{\oldindex{Location!#1}\marked{#1}}%
|
235
|
+
\newcommand{\Location}[2]{\oldindex{Location!#1}\marked{#2}}%
|
236
|
+
\newcommand{\clin}[1]{\oldindex{Clin!#1}Clin \marked{#1}}%
|
237
|
+
|
238
|
+
% Book-Specific Metadata
|
239
|
+
%========================
|
240
|
+
|
241
|
+
\def\NextBook{<%=next_book%>}
|
242
|
+
\def\ReturningCharacters{<%=returning_characters%>}
|
243
|
+
\title{<%= title %>}
|
244
|
+
\author{<%= authors.join(', ') %>}
|
245
|
+
\date{<%= published_at %>}
|
246
|
+
\newdate{firstprint}{<%= published_at.split('-')[2]%>}{<%= published_at.split('-')[1]%>}{<%= published_at.split('-')[0]%>}
|
247
|
+
|
248
|
+
<% unless series.nil? or series['books'].nil? %>
|
249
|
+
\seriestitle{<%= series['title'] %>}
|
250
|
+
\seriesbooks
|
251
|
+
<%= series['books'].map{ |b| "\\book{#{b}}" }.join("\n ") %>
|
252
|
+
\endseriesbooks
|
253
|
+
<% end %>
|
254
|
+
|
255
|
+
% Drafting Help
|
256
|
+
%==============
|
257
|
+
\newcommand{\tk}[1]{%
|
258
|
+
\ifdefined\isdraft%
|
259
|
+
% \textbf{TK-#1}
|
260
|
+
\todo{#1}\textbf{TK-#1}%
|
261
|
+
\else%
|
262
|
+
\textbf{TK-#1}%
|
263
|
+
% \todo{#1}\textbf{TK-#1}
|
264
|
+
\fi%
|
265
|
+
}%
|
266
|
+
\newcommand{\TK}[1]{\tk{BAD-TK--#1}}
|
267
|
+
|
268
|
+
% Document
|
269
|
+
%========================
|
270
|
+
\begin{document}
|
271
|
+
|
272
|
+
% Frontmatter
|
273
|
+
%-------------
|
274
|
+
\frontmatter
|
275
|
+
% r.1 - Half-Title
|
276
|
+
\begin{titlingpage}
|
277
|
+
\pagestyle{empty}
|
278
|
+
\begin{center}
|
279
|
+
\vspace*{2in}
|
280
|
+
|
281
|
+
\Huge\textbf{\textsf\thetitle}
|
282
|
+
|
283
|
+
\vspace*{0.75in}
|
284
|
+
|
285
|
+
\Large\textsf\theauthor
|
286
|
+
|
287
|
+
\vspace*{\fill}
|
288
|
+
\end{center}
|
289
|
+
\end{titlingpage}
|
290
|
+
|
291
|
+
% r.2 - Series Title Page
|
292
|
+
<%= "\\seriespage" unless series.nil? %>
|
293
|
+
\newpage
|
294
|
+
% r.3 Titlepage
|
295
|
+
\begin{titlingpage}
|
296
|
+
\pagestyle{empty}
|
297
|
+
\begin{center}
|
298
|
+
\vspace*{\fill}
|
299
|
+
|
300
|
+
\HUGE\textbf{\textsf\thetitle}
|
301
|
+
|
302
|
+
\vspace*{0.25in}
|
303
|
+
\line(1,0){150}
|
304
|
+
\vspace*{0.25in}
|
305
|
+
|
306
|
+
\Large\textsf\theauthor
|
307
|
+
|
308
|
+
\vspace*{\fill}
|
309
|
+
|
310
|
+
\vspace*{\fill}
|
311
|
+
\includegraphics[width=2in]{_images/logo.png}\\[0cm]
|
312
|
+
%\hspace*{\fill}\textsf{Dausha}\hspace*{\fill}\newline%
|
313
|
+
%\textsf{Publishing}
|
314
|
+
\end{center}
|
315
|
+
\end{titlingpage}
|
316
|
+
|
317
|
+
% r.4 Copyright Page
|
318
|
+
\vspace*{\fill}
|
319
|
+
\pagestyle{empty}
|
320
|
+
|
321
|
+
\par\noindent\emph{\thetitle}
|
322
|
+
\newline
|
323
|
+
|
324
|
+
<% if type == 'fiction' %>
|
325
|
+
|
326
|
+
\par\noindent This is a work of fiction. Names, characters, places and incidents are either
|
327
|
+
the product of the author's imagination or are used fictitiously, and any resemblance to
|
328
|
+
actual persons, living or dead, business establishments, events or locales is entirely
|
329
|
+
coincidental.\newline
|
330
|
+
<% end %>
|
331
|
+
|
332
|
+
\par\noindent\emph{<%= copyright %>}\newline
|
333
|
+
|
334
|
+
<% unless designer['cover'].nil? || designer['cover'].empty? %>
|
335
|
+
\par\noindent Cover Design by <%= designer['cover'] %>\newline
|
336
|
+
<% end %>
|
337
|
+
|
338
|
+
<% unless designer['book'].nil? || designer['book'].empty? %>
|
339
|
+
\par\noindent Book Design by <%= designer['book'] %>\newline
|
340
|
+
<% end %>
|
341
|
+
|
342
|
+
<% unless editors['text'].nil? || editors['text'].empty? %>
|
343
|
+
\par\noindent Book Design by <%= editors['text'].join(',') %>\newline
|
344
|
+
<% end %>
|
345
|
+
|
346
|
+
|
347
|
+
\par\noindent All rights reserved.\newline
|
348
|
+
|
349
|
+
\par\noindent No part of this publication may be reproduced, stored in a retrieval system, posted on the Internet, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission from the author. The only exception is by a reviewer, who may quote short excerpts in a review.\newline
|
350
|
+
|
351
|
+
\par\noindent \theauthor
|
352
|
+
\par\noindent Visit my website at \url{<%= base_url %>}\newline
|
353
|
+
|
354
|
+
\par\noindent Printed in the United States of America
|
355
|
+
\newline
|
356
|
+
|
357
|
+
\par\noindent\textit{First Printing, \usmonthyear\displaydate{firstprint}}
|
358
|
+
\newline
|
359
|
+
|
360
|
+
\par\noindent <%= identifier['type'] %> <%= identifier['id'] %>
|
361
|
+
\vspace*{\fill}
|
362
|
+
|
363
|
+
% r.5 - Dedication
|
364
|
+
<%= "\\begin{dedication}\n#{File.open('_extras/dedication.tex').read}\\end{dedication}" if File.exist?('_extras/dedication.tex')
|
365
|
+
%>
|
366
|
+
<%= (status != 'final') ? '\tableofcontents' : '' %>
|
367
|
+
|
368
|
+
|
369
|
+
\newpage
|
370
|
+
\mainmatter
|
371
|
+
\pagestyle{ebook}
|
372
|
+
\sloppy
|
373
|
+
|
374
|
+
<%= contents %>
|
375
|
+
|
376
|
+
% Back Matter
|
377
|
+
%-------------
|
378
|
+
\backmatter
|
379
|
+
|
380
|
+
%% Bibliography
|
381
|
+
% \bibliographystyle{\mybibliostyle}
|
382
|
+
% \bibliocommand
|
383
|
+
% \pagestyle{empty}
|
384
|
+
\begin{center}
|
385
|
+
\vspace*{\fill}
|
386
|
+
|
387
|
+
{\Large \par
|
388
|
+
\noindent Thank you for reading
|
389
|
+
|
390
|
+
\vspace*{0.125in}
|
391
|
+
{\LARGE\textbf{\textsf{\thetitle}}}
|
392
|
+
\vspace*{0.125in}
|
393
|
+
|
394
|
+
\ifdefined\ReturningCharacters
|
395
|
+
\par
|
396
|
+
\noindent\ReturningCharacters{} will return in \emph{\NextBook}.} \vspace*{\fill}
|
397
|
+
\fi
|
398
|
+
|
399
|
+
{\LARGE\textbf{\textsf{Follow Me}}}
|
400
|
+
|
401
|
+
\vspace*{0.125in}
|
402
|
+
|
403
|
+
\textbf{\theauthor{}} can be followed on Twitter and Facebook.
|
404
|
+
\newline Visit his web site at http://dausha.net for more information. You can also sign up for announcements of other books in this series at http://dausha.net.
|
405
|
+
|
406
|
+
\vspace*{\fill}
|
407
|
+
\end{center}
|
408
|
+
|
409
|
+
<% if (type == 'fiction' and status != 'final') or type == 'nonfiction' %>
|
410
|
+
|
411
|
+
%% Glossary
|
412
|
+
\printglossaries
|
413
|
+
|
414
|
+
%% Index
|
415
|
+
\printindex
|
416
|
+
<% end %>
|
417
|
+
|
418
|
+
\end{document}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require 'json'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
if true
|
6
|
+
require 'cli-colorize'
|
7
|
+
cli = true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Make copies via git to remote Repositories"
|
11
|
+
task :archive do
|
12
|
+
puts "## Archival Branch to Repositories!"
|
13
|
+
system "git add -A ."
|
14
|
+
puts "\n## Commiting: Site updated at #{Time.now.utc}"
|
15
|
+
message = "Project updated at #{Time.now.utc}"
|
16
|
+
system "git commit -m \"#{message}\""
|
17
|
+
["github", "bitbucket"].each do |remote|
|
18
|
+
puts "\n## Pushing to **#{remote}** website"
|
19
|
+
system "git push #{remote} master"
|
20
|
+
end
|
21
|
+
puts "\n## Archival complete"
|
22
|
+
end
|
23
|
+
desc "Find a word in the text files. Good for error finding.."
|
24
|
+
task :find, :item do |t, args|
|
25
|
+
c = "find text -type f |xargs grep -l '#{args[:item]}'"
|
26
|
+
system c
|
27
|
+
end
|
28
|
+
desc "Show a word in context. Good for error finding.."
|
29
|
+
task :show, :item do |t, args|
|
30
|
+
c = "find text -type f |xargs grep --color=auto '#{args[:item]}'"
|
31
|
+
system c
|
32
|
+
end
|
33
|
+
task :findc, :item do |t, args|
|
34
|
+
c = "find text -type f -name \"*#{args[:item]}*\""
|
35
|
+
system c
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Compile PDF and display."
|
39
|
+
task :preview do
|
40
|
+
puts "## Creating another craptacular preview for your viewing pleasure."
|
41
|
+
puts "## Give me a second to start as looking at this stuff makes me puke."
|
42
|
+
system "verku compile --only pdf;"
|
43
|
+
pdf = Dir.glob("output/*.pdf").first
|
44
|
+
system "open #{pdf}" unless pdf.nil?
|
45
|
+
end
|
46
|
+
task :progress do
|
47
|
+
log_file = "../../writing.log"
|
48
|
+
if (!File.exist?(log_file))
|
49
|
+
puts "You don't have a log file."
|
50
|
+
return
|
51
|
+
end
|
52
|
+
j = JSON.parse(File.open(log_file,'r').read)
|
53
|
+
# puts j.inspect
|
54
|
+
s = j[Date.today.prev_day.strftime('%Y-%m-%d')]
|
55
|
+
progress = s[File.basename(Dir.pwd)]
|
56
|
+
text = Dir["text/**/[0-9]*.tex"].map{|f| File.open(f,'r').read}.join("\n\n\n")
|
57
|
+
|
58
|
+
file = Tempfile.new('foo.tex')
|
59
|
+
file.write(text)
|
60
|
+
file.close
|
61
|
+
today = `detex #{file.path}| wc -w`.to_i
|
62
|
+
file.unlink
|
63
|
+
target = (500.0 * (300.0 / 365.0)).to_i
|
64
|
+
delta = today - progress
|
65
|
+
puts "So far today: #{today} - #{progress} = #{delta} (#{delta / 333} & #{progress/333} pages) (Target: #{delta - target}) - #{Time.now}}"
|
66
|
+
end
|
67
|
+
task :wc, :target do |t, args|
|
68
|
+
files = Dir["text/**/[0-9]*.tex"]
|
69
|
+
detex = "/usr/texbin/detex"
|
70
|
+
|
71
|
+
counts = {}
|
72
|
+
total = 0
|
73
|
+
sections = 0
|
74
|
+
chapters = {}
|
75
|
+
files.each do |f|
|
76
|
+
next if !args[:target].nil? and !f.include?(args[:target])
|
77
|
+
counts[f] = `detex #{f} | wc -w`.to_i
|
78
|
+
chapter = File.dirname(f)
|
79
|
+
chapters[chapter] = chapters.fetch(chapter,0) + counts[f]
|
80
|
+
total += counts[f]
|
81
|
+
if cli
|
82
|
+
case
|
83
|
+
when counts[f] == 0 then
|
84
|
+
next
|
85
|
+
when counts[f] > 1500 then
|
86
|
+
puts CLIColorize.safe_colorize("...counting #{f} : #{counts[f]}", :yellow)
|
87
|
+
when counts[f] < 1000 then
|
88
|
+
puts CLIColorize.safe_colorize("...counting #{f} : #{counts[f]}", :red)
|
89
|
+
else
|
90
|
+
puts CLIColorize.safe_colorize("...counting #{f} : #{counts[f]}", :green)
|
91
|
+
end
|
92
|
+
else
|
93
|
+
next if counts[f] == 0
|
94
|
+
puts "...counting #{f} : #{counts[f]}"
|
95
|
+
end
|
96
|
+
sections += 1
|
97
|
+
end
|
98
|
+
# sections = 1 if sections == 0
|
99
|
+
puts "Total: #{total} (#{sections} sections). Average #{total/(sections || 1)}"
|
100
|
+
|
101
|
+
# chapters.keys.each {|k| chapters[k] /= 1}
|
102
|
+
# ap chapters
|
103
|
+
end
|