Skip to content

Commit 24fc03b

Browse files
author
Nico Hickman
committed
Fix glow-worm and Ward covers, fix twig 8.3 crash
1 parent 90e8495 commit 24fc03b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ fn get_info(key:&str) -> Book{
7272
start:String::from("parahumans.wordpress.com/2017/10/21/glowworm-p-1/"),
7373
desc:String::from("The bridge between Worm and Ward, Glow-worm introduces readers to the characters of Ward, and the consequences of Gold Morning"),
7474
date:String::from("Sat, 11 Nov 2017 00:00:00 +0100"),
75-
cover:Some("https://demenses.net/cdn/6dd5e7ce1474c55ecc758304e6131451824855e3.png".to_string()),
75+
cover:None,
7676
},
7777
"ward" => Book {
7878
title:String::from("Ward"),
7979
start:String::from("parahumans.net/2017/09/11/daybreak-1-1/"),
8080
desc:String::from("The unwritten rules that govern the fights and outright wars between ‘capes’ have been amended: everyone gets their second chance. It’s an uneasy thing to come to terms with when notorious supervillains and even monsters are playing at being hero. The world ended two years ago, and as humanity straddles the old world and the new, there aren’t records, witnesses, or facilities to answer the villains’ past actions in the present. One of many compromises, uneasy truces and deceptions that are starting to splinter as humanity rebuilds. None feel the injustice of this new status quo or the lack of established footing more than the past residents of the parahuman asylums. The facilities hosted parahumans and their victims, but the facilities are ruined or gone; one of many fragile ex-patients is left to find a place in a fractured world. She’s perhaps the person least suited to have anything to do with this tenuous peace or to stand alongside these false heroes. She’s put in a position to make the decision: will she compromise to help forge what they call, with dark sentiment, a second golden age? Or will she stand tall as a gilded dark age dawns?"),
8181
date:String::from("Sat, 11 Nov 2017 00:00:00 +0100"),
82-
cover:Some("https://demenses.net/cdn/883d4f706e3267a540585e86dec494f8f1ea3f05.jpg".to_string()),
82+
cover:None,
8383
},
8484
_ => Book {
8585
title:String::from("Worm"),
@@ -179,24 +179,28 @@ fn download_iter( tup: &mut (String, Vec<BookElement>, Client)) -> (String, Vec<
179179
let to_sp = arr.len() -1;
180180
arr.truncate(to_sp);
181181
let num = tup.1.len().clone().to_string();
182+
let cont = arr.into_iter().fold("<?xml version='1.0' encoding='utf-8' ?><html xmlns='http://www.w3.org/1999/xhtml'><head><title>".to_string()+&title+"</title><meta http-equiv='Content-Type' content ='text/html'></meta><!-- ePub title: \"" +&title+ "\" -->\n</head><body><h1>"+&title+"</h1>\n", |acc, x|{
183+
acc + "<p>"+ &x.inner_html().replace("&nbsp;","&#160;").replace("<br>","<br></br>").replace("& ", "&amp;").replace("<Walk or->","&lt;Walk or-&gt;").replace("<Walk!>","&lt;Walk!&gt;")+"</p>\n"
184+
})+"</body></html>";
182185
if FILE_USE {
183186
let mut file = OpenOptions::new()
184187
.create(true)
185188
.write(true)
186189
.open("content/".to_string()+&num+".html")
187190
.unwrap();
188-
file.write_all((arr.into_iter().fold("<?xml version='1.0' encoding='utf-8' ?><html xmlns='http://www.w3.org/1999/xhtml'><head><title>".to_string()+&title+"</title><meta http-equiv='Content-Type' content ='text/html'></meta><!-- ePub title: \"" +&title+ "\" -->\n</head><body><h1>"+&title+"</h1>\n", |acc, x|{
189-
acc + "<p>"+ &x.inner_html().replace("&nbsp;","&#160;").replace("<br>","<br></br>").replace("& ", "&amp;").replace("<Walk or->","&lt;Walk or-&gt;").replace("<Walk!>","&lt;Walk!&gt;")+"</p>\n"
190-
})+"</body></html>")
191+
file.write_all((cont)
191192
.as_bytes()).unwrap();
192193
tup.1.push(BookElement::Content(PathBuf::from("content/".to_string()+&num+".html")));
193194
} else {
194-
// tup.1.push(BookElement::StringContent(content));
195+
tup.1.push(BookElement::StringContent(cont));
195196
}
196197
if check.is_none() || title == "P.9" {
197198
return tup.clone();
198199
} else {
199200
tup.0 = check.unwrap().attr("href").unwrap().to_string();
201+
if !tup.0.contains("https") {
202+
tup.0 = "https:".to_string()+&tup.0;
203+
}
200204
return download_iter(tup);
201205
}
202206
}

0 commit comments

Comments
 (0)