prettier identation in html, added a comment

master
Ondřej Hruška 5 years ago
parent e0de01dc05
commit 7d1d36ac8d
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 12
      src/main.rs
  2. 0
      web/data/2018-09-30/note.txt
  3. 3
      web/feed.xml
  4. 20
      web/templates/_head.html
  5. 8
      web/templates/_thumb.html
  6. 26
      web/templates/detail.html
  7. 26
      web/templates/index.html

@ -102,8 +102,10 @@ fn main() {
let mut main_tpl = String::new(); let mut main_tpl = String::new();
let mut thumb_tpl = String::new(); let mut thumb_tpl = String::new();
let mut detail_tpl = String::new(); let mut detail_tpl = String::new();
let mut head_tpl = String::new();
File::open(tpl_path.join("index.html")).unwrap().read_to_string(&mut main_tpl).unwrap(); File::open(tpl_path.join("index.html")).unwrap().read_to_string(&mut main_tpl).unwrap();
File::open(tpl_path.join("_thumb.html")).unwrap().read_to_string(&mut thumb_tpl).unwrap(); File::open(tpl_path.join("_thumb.html")).unwrap().read_to_string(&mut thumb_tpl).unwrap();
File::open(tpl_path.join("_head.html")).unwrap().read_to_string(&mut head_tpl).unwrap();
File::open(tpl_path.join("detail.html")).unwrap().read_to_string(&mut detail_tpl).unwrap(); File::open(tpl_path.join("detail.html")).unwrap().read_to_string(&mut detail_tpl).unwrap();
let mut thumbs = String::new(); let mut thumbs = String::new();
@ -173,22 +175,24 @@ fn main() {
// generate the detail page // generate the detail page
{ {
let detail = detail_tpl let detail = detail_tpl
.replace("{head}", &head_tpl.replace("{title}", &format!("Bread from {}", date)).trim())
.replace("{title}", &date) .replace("{title}", &date)
.replace("{note}", note); .replace("{note}", note.trim());
let mut pics = String::new(); let mut pics = String::new();
for img in &bread.images { for img in &bread.images {
pics.push_str(&format!("<a href=\"{src}\"><img src=\"{src}\"></a>", src=&utf8_percent_encode(img.to_str().unwrap(), DEFAULT_ENCODE_SET).to_string())) pics.push_str(&format!(" <a href=\"{src}\"><img src=\"{src}\"></a>\n", src=&utf8_percent_encode(img.to_str().unwrap(), DEFAULT_ENCODE_SET).to_string()))
} }
let detail = detail.replace("{images}", &pics); let detail = detail.replace("{images}", &pics.trim());
let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join(detail_file)).unwrap(); let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join(detail_file)).unwrap();
f.write(detail.as_bytes()).unwrap(); f.write(detail.as_bytes()).unwrap();
} }
} }
let main = main_tpl.replace("{breads}", &thumbs); let main = main_tpl.replace("{breads}", &thumbs.trim())
.replace("{head}", &head_tpl.replace("{title}", "Piggo's breads").trim());
{ {
let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join("index.html")).unwrap(); let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join("index.html")).unwrap();

@ -29,7 +29,8 @@
<title>2018/09/30</title> <title>2018/09/30</title>
<link>https://www.ondrovo.com/bread/2018-09-30.html</link> <link>https://www.ondrovo.com/bread/2018-09-30.html</link>
<description> <description>
<![CDATA[<i>There's no note about this bread.</i><img src="https://www.ondrovo.com/bread/thumbs/2018-09-30.jpg" alt="dgs - 7 sep 30 cover.jpg"><p>Open the link for more...</p>]]> <![CDATA[<p>nice crust, but it had huge holes in it. idk why</p>
<img src="https://www.ondrovo.com/bread/thumbs/2018-09-30.jpg" alt="dgs - 7 sep 30 cover.jpg"><p>Open the link for more...</p>]]>
</description> </description>
<guid>https://www.ondrovo.com/bread/2018-09-30.html</guid> <guid>https://www.ondrovo.com/bread/2018-09-30.html</guid>
<pubDate>Sun, 30 Sep 2018 12:00:00 +0000</pubDate> <pubDate>Sun, 30 Sep 2018 12:00:00 +0000</pubDate>

@ -0,0 +1,20 @@
<meta charset="utf-8">
<link rel="stylesheet" href="assets/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<!--
Generated by a hacky Rust script that you can find at
https://git.ondrovo.com/MightyPork/bread-gallery
Pictures are free to use for any purpose.
See my blog at www.ondrovo.com for contact & more
-->
<title>{title}</title>

@ -1,4 +1,4 @@
<section class="BreadThumb" onclick="location.href='{detail_url}'"> <section class="BreadThumb" onclick="location.href='{detail_url}'">
<header><a href="{detail_url}">{title}</a></header> <header><a href="{detail_url}">{title}</a></header>
<img src="{img_src}" alt="{img_alt}"> <img src="{img_src}" alt="{img_alt}">
</section> </section>

@ -1,25 +1,21 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> {head}
<title>Breads</title>
<link rel="stylesheet" href="assets/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
</head> </head>
<body> <body>
<h1>{title}</h1> <h1>{title}</h1>
<section class="BreadDetail"> <section class="BreadDetail">
<div class="note">{note}</div> <div class="note">
{note}
</div>
<div class="images"> <div class="images">
{images} {images}
</div> </div>
</section> </section>
<p id="crumb"><a href="index.html">Back to gallery</a></p> <p id="crumb"><a href="index.html">Back to gallery</a></p>
</body> </body>
</html> </html>

@ -1,21 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> {head}
<title>Breads</title> </head>
<link rel="stylesheet" href="assets/style.css"> <body>
<h1>Piggo's Bread Gallery</h1>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <p id="crumb">Like and <a href="feed.xml">subscribe</a></p>
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body>
<h1>Piggo's Bread Gallery</h1>
<p id="crumb">Like and <a href="feed.xml">subscribe</a></p> <div class="MainGallery">
{breads}
<div class="MainGallery"> </div>
{breads} </body>
</div>
</body>
</html> </html>

Loading…
Cancel
Save