prettier identation in html, added a comment

master
Ondřej Hruška 6 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. 4
      web/templates/_thumb.html
  6. 12
      web/templates/detail.html
  7. 16
      web/templates/index.html

@ -102,8 +102,10 @@ fn main() {
let mut main_tpl = String::new();
let mut thumb_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("_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();
let mut thumbs = String::new();
@ -173,22 +175,24 @@ fn main() {
// generate the detail page
{
let detail = detail_tpl
.replace("{head}", &head_tpl.replace("{title}", &format!("Bread from {}", date)).trim())
.replace("{title}", &date)
.replace("{note}", note);
.replace("{note}", note.trim());
let mut pics = String::new();
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();
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();

@ -29,7 +29,8 @@
<title>2018/09/30</title>
<link>https://www.ondrovo.com/bread/2018-09-30.html</link>
<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>
<guid>https://www.ondrovo.com/bread/2018-09-30.html</guid>
<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>
<img src="{img_src}" alt="{img_alt}">
</section>
</section>

@ -1,19 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<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>
<h1>{title}</h1>
<section class="BreadDetail">
<div class="note">{note}</div>
<div class="note">
{note}
</div>
<div class="images">
{images}

@ -1,15 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<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>
<body>
<head>
{head}
</head>
<body>
<h1>Piggo's Bread Gallery</h1>
<p id="crumb">Like and <a href="feed.xml">subscribe</a></p>
@ -17,5 +11,5 @@
<div class="MainGallery">
{breads}
</div>
</body>
</body>
</html>

Loading…
Cancel
Save