Adds way of kings prime

This commit is contained in:
Nemo 2017-09-25 15:15:39 +05:30
parent c335bc97a1
commit bb7700198e
6 changed files with 77 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
/wok/*.html
/wor/*.html
/oathbringer/*.html
/wok-prime/*.html
/edgedancer/*.html
/books/*

View File

@ -8,6 +8,7 @@ Scripts to generate books from the [Cosmere]() using various public sources. Cur
2. Way of Kings Reread
3. Words of Radiance Reread
4. Edgedancer Reread
5. Way of Kings Prime
For obvious reasons, the converted ebooks are not part of this repo. You must download
and run the script on your own machine to generate the copies.
@ -40,6 +41,14 @@ Join Alice Arneson and Lyndsey Luther for a reread of Brandon Sandersons Cosm
More details at https://www.tor.com/series/edgedancer-reread-brandon-sanderson/
## Way of Kings: Prime
>For it([Altered Perceptions anthology](https://www.indiegogo.com/projects/altered-perceptions)), Im letting people see—for the first time—a large chunk of the original version of The Way of Kings, which I wrote in 20022003. This version is very different, and involves a different course in life for Kaladin as a character—all due to a simple decision he makes one way in this book, but a completely different way in the published novel.
>These chapters are quite fun, as I consider what happened in The Way of Kings Prime (as I now call it) to be an "alternate reality" version of the events in the published books. The characters are almost all exactly the same people, but their backstories are different, and that has transformed who they are and how they react to the world around them. Roshar is similar, yet wildly different, as this was before I brought in the spren as a major world element.
You can read more at the announcement at [BrandonSanderson.com](https://brandonsanderson.com/chapters-from-the-original-draft-of-the-way-of-kings-available-in-anthology-to-benefit-robison-wells/)
## Requirements
- Ruby
@ -87,7 +96,13 @@ To generate the book:
ruby edgedancer-reread.rb
All the generated files will be saved with the filename `books/edgedan-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.
All the generated files will be saved with the filename `books/edgedancer-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.
## Way of Kings Prime
ruby wok-prime.rb
All the generated files will be saved with the filename `books/wok-prime.{epub|pdf|mobi|html}`. This generation might take a while the script attempts to strip out unnecessary HTML.
## Extra

BIN
covers/wok-prime.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
covers/wok-prime.pdf Normal file

Binary file not shown.

4
metadata/wok-prime.xml Normal file
View File

@ -0,0 +1,4 @@
<dc:title id="epub-title-1">The Way of Kings Prime</dc:title>
<dc:date>2017-09-18</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">Brandon Sanderson</dc:creator>

56
wok-prime.rb Normal file
View File

@ -0,0 +1,56 @@
require 'date'
require 'fileutils'
require 'nokogiri'
require_relative './methods'
FileUtils.mkdir_p('wok-prime')
BASE = 'https://brandonsanderson.com/'.freeze
links = [
'the-way-of-kings-prime-jeksonsonvallano/',
'altered-perceptions/',
'way-of-kings-prime-chapter-1-dalenar-1/',
'way-of-kings-prime-chapter-3-merin-1/',
'way-of-kings-prime-chapter-5-merin-2/'
]
episode = 1
links.each do |link|
url = BASE + link
puts "Download #{url}"
unless File.exist? "wok-prime/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "wok-prime/#{episode}.html" -o /dev/null`
end
episode += 1
end
html = ''
for i in 1..(links.length)
complete_html = Nokogiri::HTML(open("wok-prime/#{i}.html"))
page = complete_html.css('article')[0]
ending = false
page.traverse do |e|
whitelist = ['p', 'div', 'span', 'article', 'h1', 'h2', 'h3', 'h4', 'a', 'h5', 'h6', 'i', 'text']
blacklist = ['.post-meta', '.addthis_toolbox', '.book-links', 'post-nav']
if (whitelist.include?(e.name) == false)
e.remove
end
blacklist.each do |selector|
page.css(selector).each do |e|
e.remove
end
end
end
html += page.inner_html
end
File.open('books/wok-prime.html', 'w') { |file| file.write(html) }
puts '[html] Generated HTML file'
generate('wok-prime', :all)