Adds Words of Radiance re-read support

This commit is contained in:
Nemo 2017-09-15 13:58:26 +05:30
parent 20bd3390f7
commit 07d923d8ca
14 changed files with 199 additions and 29 deletions

14
.gitignore vendored
View File

@ -1,10 +1,4 @@
/Oathbringer.*
/Oathbringer_*
html/
cover.pdf
wok/
/wok-reread_*
/wok-reread.epub
/wok-reread.html
/wok-reread.mobi
/wok-reread.pdf
/wok/*.html
/wor/*.html
/oathbringer/*.html
/books/*

View File

@ -22,6 +22,12 @@ epub, mobi, pdf and html. You can find the tor.com announcement at https://www.t
>Join Michael Pye (aka The Mad Hatter) and Carl Engle-Laird as they dive into the details of Sandersons complex new world of Roshar. Find out more at https://www.tor.com/features/series/the-way-of-kings-reread-on-torcom/
## Words of Radiance Reread
Welcome to the reread of Brandon Sandersons second Stormlight Archive series book Words of Radiance! This reread will be a collaborative effort between Tor.coms own editorial assistant Carl Engle-Laird and long-time Tor.com commenter and Sanderson beta-reader Alice Arneson. This new partnership promises to be as potent as that between spren and Radiant. Join them in the Storm Cellar as they evaluate, discuss, question, and generally kibitz their way through the Words of Radiance.
More details at https://www.tor.com/series/words-of-radiance-reread-on-torcom/
## Requirements
- Ruby
@ -34,7 +40,7 @@ epub, mobi, pdf and html. You can find the tor.com announcement at https://www.t
- The final 2 tools can be skipped if you don't care about the PDF generation.
- You can also skip calibre if you only want the EPUB file.
- Edit the last line in `setup.rb` to `:epub` / `:mobi`, `:pdf` to only trigger the specific builds
- Edit the last line in `*.rb` to `:epub` / `:mobi`, `:pdf` to only trigger the specific builds
## Generation
@ -42,19 +48,26 @@ epub, mobi, pdf and html. You can find the tor.com announcement at https://www.t
After downloading the repo and installing the requirements, just run
ruby setup.rb
ruby oathbringer.rb
All the generated files will be saved with the filename `Oathbringer.{epub|pdf|mobi|html}`
## Way of Kings Reread
To generate the book:
ruby wok-reread.rb
All the generated files will be saved with the filename `wok-reread.{epub|pdf|mobi|html}`
## Words of Radiance Reread
To generate the book:
ruby wor-reread.rb
All the generated files will be saved with the filename `books/wok-reread.{epub|pdf|mobi|html}`. This generation might take a while because it contains a lot of images. It doesn't have the best possible index either, but is still pretty readable.
# LICENSE
This is licensed under WTFPL. See COPYING file for the full text.

2
books/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

BIN
covers/wor-reread.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
covers/wor-reread.pdf Normal file

Binary file not shown.

View File

@ -1,6 +1,5 @@
<dc:identifier id="epub-id-1" opf:scheme="ISBN-10">076532637X</dc:identifier>
<dc:identifier id="epub-id-2" opf:scheme="ISBN-13">978-0765326379</dc:identifier>
<dc:title id="epub-title-1">Oathbringer: Book Three of the Stormlight Archive</dc:title>
<dc:date>2017-11-14</dc:date>
<dc:title id="epub-title-1">The Way of Kings Reread</dc:title>
<dc:date>2014-06-10</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">Brandon Sanderson</dc:creator>
<dc:creator id="epub-creator-1" opf:role="aut">Michael Pye</dc:creator>
<dc:creator id="epub-creator-1" opf:role="aut">Carl Engle-Lair</dc:creator>

5
metadata/wor-reread.xml Normal file
View File

@ -0,0 +1,5 @@
<dc:title id="epub-title-1">Words of Radiance Reread</dc:title>
<dc:date>2016-08-04</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">Alice Arneson</dc:creator>
<dc:creator id="epub-creator-1" opf:role="aut">Carl Engle-Laird</dc:creator>

View File

@ -17,7 +17,7 @@ end
def generate(name, format=:all)
if command? 'pandoc' and format_match(:epub)
# Convert it to epub
`pandoc -S -o #{name}.epub --epub-metadata=metadata/#{name}.xml --epub-cover-image=covers/#{name}.jpg #{name}.html`
`pandoc -S -o books/#{name}.epub --epub-metadata=metadata/#{name}.xml --epub-cover-image=covers/#{name}.jpg books/#{name}.html`
puts "[epub] Generated EPUB file"
else
puts "[error] Can't generate EPUB without pandoc"
@ -25,7 +25,7 @@ def generate(name, format=:all)
if command? 'ebook-convert' and format_match(:mobi)
# Convert epub to a mobi
`ebook-convert #{name}.epub #{name}.mobi`
`ebook-convert books/#{name}.epub books/#{name}.mobi`
puts "[mobi] Generated MOBI file"
else
puts "[error] Can't generate MOBI without ebook-convert"
@ -34,15 +34,15 @@ def generate(name, format=:all)
if commands? ['pandoc', 'convert', 'wkhtmltopdf', 'pdftk'] and format_match(:pdf)
# Generate PDF as well
# First, lets make a better css version of the html
`pandoc #{name}.html -s -c style.css -o #{name}_pdf.html`
`pandoc books/#{name}.html -s -c style.css -o books/#{name}_pdf.html`
puts "[pdf] Generated html for pdf"
# Print the pdf_html file to pdf
`wkhtmltopdf #{name}_pdf.html /tmp/#{name}.pdf`
`wkhtmltopdf #{name}_pdf.html books/#{name}-nocover.pdf`
puts "[pdf] Generated PDF without cover"
# Join the cover and pdf together
`pdftk covers/#{name}.pdf /tmp/#{name}.pdf cat output #{name}.pdf`
`pdftk covers/#{name}.pdf books/#{name}-nocover.pdf cat output books/#{name}.pdf`
puts "[pdf] Generated PDF file"
else
puts "[error] Please check README for PDF dependencies"

View File

@ -2,7 +2,7 @@ require 'date'
require 'fileutils'
require 'nokogiri'
require_relative './methods'
FileUtils.mkdir_p("html")
FileUtils.mkdir_p("oathbringer")
BASE = 'https://www.tor.com/2017/'
@ -25,8 +25,8 @@ episode = 1
for link in links
url = BASE + link
puts "Download #{url}"
if !File.exists? "html/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "html/#{episode}.html" -o /dev/null`
if !File.exists? "oathbringer/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "oathbringer/#{episode}.html" -o /dev/null`
end
episode +=1
end
@ -34,7 +34,7 @@ end
# Now we have all the files
html = ""
for i in 1..(links.length)
page = Nokogiri::HTML(open("html/#{i}.html")).css('.entry-content')
page = Nokogiri::HTML(open("oathbringer/#{i}.html")).css('.entry-content')
start = ending = false
page.children.each do |e|
if e.name == 'h3'
@ -58,7 +58,7 @@ end
html += "<p>~fin\~<br>Next 3 chapters out on #{next_date.to_s}</p>"
File.open("Oathbringer.html", 'w') { |file| file.write(html) }
File.open("books/Oathbringer.html", 'w') { |file| file.write(html) }
puts "[html] Generated HTML file"
generate("Oathbringer", :all)

0
oathbringer/.gitkeep Normal file
View File

View File

@ -105,7 +105,7 @@ for i in 1..(links.length)
html += "<p>Visit <a href='#{url}'>tor.com</a> for discussion.</p>"
end
File.open("wok-reread.html", 'w') { |file| file.write(html) }
File.open("books/wok-reread.html", 'w') { |file| file.write(html) }
puts "[html] Generated HTML file"
generate("wok-reread", :all)

0
wok/gitkeep Normal file
View File

157
wor-reread.rb Normal file
View File

@ -0,0 +1,157 @@
require 'date'
require 'fileutils'
require 'nokogiri'
require_relative './methods'
FileUtils.mkdir_p("wor")
BASE = 'https://www.tor.com'
links = [
"/2014/06/12/introducing-the-words-of-radiance-reread/",
"/2014/06/12/words-of-radiance-reread-prologue/",
"/2014/06/19/words-of-radiance-reread-chapter-1/",
"/2014/06/26/words-of-radiance-reread-chapter-2/",
"/2014/07/03/words-of-radiance-reread-chapter-three/",
"/2014/07/10/words-of-radiance-reread-chapter-4/",
"/2014/07/17/words-of-radiance-reread-chapter-5/",
"/2014/07/24/words-of-radiance-reread-chapter-6/",
"/2014/07/31/words-of-radiance-reread-chapter-7/",
"/2014/08/07/words-of-radiance-reread-chapter-8/",
"/2014/08/14/words-of-radiance-reread-chapter-9/",
"/2014/08/21/words-of-radiance-reread-chapter-10/",
"/2014/08/28/words-of-radiance-reread-chapter-11/",
"/2014/09/04/words-of-radiance-reread-chapter-12/",
"/2014/09/11/words-of-radiance-reread-interlude-1/",
"/2014/09/18/words-of-radiance-reread-interlude-2/",
"/2014/09/25/words-of-radiance-reread-interlude-3/",
"/2014/10/02/words-of-radiance-reread-interlude-4/",
"/2014/10/09/words-of-radiance-reread-chapter-13/",
"/2014/10/16/words-of-radiance-reread-chapter-14/",
"/2014/10/23/words-of-radiance-reread-chapter-15/",
"/2014/10/30/words-of-radiance-reread-chapter-16/",
"/2014/11/06/words-of-radiance-reread-chapter-17/",
"/2014/11/13/words-of-radiance-reread-chapter-18/",
"/2014/11/20/words-of-radiance-reread-chapter-19/",
"/2014/12/04/words-of-radiance-reread-chapter-20/",
"/2014/12/11/words-of-radiance-reread-chapter-21/",
"/2014/12/18/words-of-radiance-reread-chapter-22/",
"/2015/01/08/words-of-radiance-reread-chapter-23/",
"/2015/01/15/words-of-radiance-reread-chapter-24/",
"/2015/01/22/words-of-radiance-reread-chapter-25/",
"/2015/01/29/words-of-radiance-reread-chapter-26/",
"/2015/02/05/words-of-radiance-reread-chapter-27/",
"/2015/02/12/words-of-radiance-reread-chapter-28/",
"/2015/02/19/words-of-radiance-reread-chapter-29/",
"/2015/02/26/words-of-radiance-reread-chapter-30/",
"/2015/03/05/words-of-radiance-reread-chapter-31/",
"/2015/03/12/words-of-radiance-reread-chapter-32/",
"/2015/03/19/words-of-radiance-reread-chapter-33/",
"/2015/03/26/words-of-radiance-reread-chapter-34/",
"/2015/04/02/words-of-radiance-reread-part-2-epigraphs/",
"/2015/04/09/words-of-radiance-reread-interludes-5-and-6/",
"/2015/04/16/words-of-radiance-reread-interludes-7-and-8/",
"/2015/04/23/words-of-radiance-reread-chapter-35/",
"/2015/04/30/words-of-radiance-reread-chapter-36/",
"/2015/05/07/words-of-radiance-reread-chapter-37/",
"/2015/05/14/words-of-radiance-reread-chapter-38/",
"/2015/05/21/words-of-radiance-reread-chapter-39/",
"/2015/05/28/words-of-radiance-reread-chapter-40/",
"/2015/06/04/words-of-radiance-reread-chapter-41/",
"/2015/06/11/words-of-radiance-reread-chapter-42/",
"/2015/06/18/words-of-radiance-reread-chapter-43/",
"/2015/06/25/words-of-radiance-reread-chapter-44/",
"/2015/07/02/words-of-radiance-reread-chapter-45/",
"/2015/07/09/words-of-radiance-reread-chapter-46/",
"/2015/07/23/words-of-radiance-reread-chapter-47/",
"/2015/07/30/words-of-radiance-reread-chapter-48/",
"/2015/08/06/words-of-radiance-reread-chapter-49/",
"/2015/08/13/words-of-radiance-reread-chapter-50/",
"/2015/08/20/words-of-radiance-reread-chapter-51/",
"/2015/08/27/words-of-radiance-reread-chapter-52/",
"/2015/09/03/words-of-radiance-reread-chapter-53/",
"/2015/09/10/words-of-radiance-reread-chapter-54/",
"/2015/09/17/words-of-radiance-reread-chapter-55/",
"/2015/09/24/words-of-radiance-reread-chapter-56/",
"/2015/10/01/words-of-radiance-reread-chapter-57/",
"/2015/10/08/words-of-radiance-reread-chapter-58/",
"/2015/10/15/words-of-radiance-reread-interlude-9/",
"/2015/10/22/words-of-radiance-reread-interlude-10/",
"/2015/10/29/words-of-radiance-reread-interlude-11/",
"/2015/11/05/words-of-radiance-reread-chapter-59/",
"/2015/11/12/words-of-radiance-reread-chapter-60/",
"/2015/11/19/words-of-radiance-reread-chapter-61/",
"/2015/12/03/words-of-radiance-reread-chapter-62/",
"/2015/12/10/words-of-radiance-reread-chapter-63/",
"/2015/12/17/words-of-radiance-reread-chapter-64/",
"/2016/01/07/words-of-radiance-reread-chapter-65/",
"/2016/01/14/words-of-radiance-reread-chapter-66/",
"/2016/01/21/words-of-radiance-reread-chapter-67/",
"/2016/01/28/words-of-radiance-reread-chapter-68/",
"/2016/02/04/words-of-radiance-reread-chapter-69/",
"/2016/02/11/words-of-radiance-reread-chapter-70/",
"/2016/02/18/words-of-radiance-reread-chapter-71/",
"/2016/02/25/words-of-radiance-reread-chapter-72/",
"/2016/03/03/words-of-radiance-reread-chapter-73/",
"/2016/03/10/words-of-radiance-reread-chapter-74/",
"/2016/03/17/words-of-radiance-reread-chapter-75/",
"/2016/03/24/words-of-radiance-reread-part-4-epigraphs/",
"/2016/03/31/words-of-radiance-reread-interludes-12-and-13/",
"/2016/04/07/words-of-radiance-reread-interlude-14/",
"/2016/04/14/words-of-radiance-reread-chapter-76/",
"/2016/04/21/words-of-radiance-reread-chapter-77/",
"/2016/04/28/words-of-radiance-reread-chapter-78/",
"/2016/05/05/words-of-radiance-reread-chapter-79/",
"/2016/05/12/words-of-radiance-reread-chapter-80/",
"/2016/05/19/words-of-radiance-reread-chapter-81/",
"/2016/05/26/words-of-radiance-reread-chapter-82/",
"/2016/06/02/words-of-radiance-reread-chapter-83/",
"/2016/06/09/words-of-radiance-reread-chapter-84/",
"/2016/06/16/words-of-radiance-reread-chapter-85/",
"/2016/06/23/words-of-radiance-reread-chapter-86/",
"/2016/06/30/words-of-radiance-reread-chapter-87/",
"/2016/07/14/words-of-radiance-reread-chapter-88/",
"/2016/07/28/words-of-radiance-reread-chapter-89/",
"/2016/08/04/words-of-radiance-reread-epilogue-and-what-comes-next/"
]
episode = 1
for link in links
url = BASE + link
puts "Download #{url}"
if !File.exists? "wor/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "wor/#{episode}.html" -o /dev/null`
end
episode +=1
end
# Now we have all the files
html = ""
for i in 1..(links.length)
complete_html = Nokogiri::HTML(open("wor/#{i}.html"))
page = complete_html.css('.entry-content')
title = complete_html.css('.entry-title>a').inner_html
ending = false
page.children.each do |e|
if e.attribute('class') and (e['class'].include? 'squib' or e['class'].include? 'post-end-spacer')
ending = true
end
if ending
e.remove
end
end
html += "<h1>#{title}</h1>"
html += page.inner_html
url = links[i-1]
html += "<p>Visit <a href='#{url}'>tor.com</a> for discussion.</p>"
end
File.open("books/wor-reread.html", 'w') { |file| file.write(html) }
puts "[html] Generated HTML file"
generate("wor-reread", :all)

0
wor/.gitkeep Normal file
View File