|
|
@ -41,16 +41,16 @@ pub struct BreadLink { |
|
|
|
impl Bread { |
|
|
|
impl Bread { |
|
|
|
pub fn compile(&mut self, config: &mut GalleryInfo, prev : Option<BreadLink>, next : Option<BreadLink>) -> Fallible<()> { |
|
|
|
pub fn compile(&mut self, config: &mut GalleryInfo, prev : Option<BreadLink>, next : Option<BreadLink>) -> Fallible<()> { |
|
|
|
let date = self.date.format("%Y/%m/%d").to_string(); |
|
|
|
let date = self.date.format("%Y/%m/%d").to_string(); |
|
|
|
let date_slug = &self.slug; |
|
|
|
let slug = &self.slug; |
|
|
|
let detail_file = date_slug.clone() + ".html"; |
|
|
|
let detail_file = slug.clone() + ".html"; |
|
|
|
println!("+ {}", date_slug); |
|
|
|
println!("+ {}", slug); |
|
|
|
|
|
|
|
|
|
|
|
self.rendered.title = date.clone(); |
|
|
|
self.rendered.title = date.clone(); |
|
|
|
self.rendered.detail_fname = detail_file.clone(); |
|
|
|
self.rendered.detail_fname = detail_file.clone(); |
|
|
|
|
|
|
|
|
|
|
|
// figure out the thumbnail pic
|
|
|
|
// figure out the thumbnail pic
|
|
|
|
let (img_path, img_alt) = { |
|
|
|
let (img_path, img_alt) = { |
|
|
|
let mut first_img: &PathBuf = self.images.get(0).expect(&format!("No images for bread {}", date_slug)); |
|
|
|
let mut first_img: &PathBuf = self.images.get(0).expect(&format!("No images for bread {}", slug)); |
|
|
|
for im in &self.images { |
|
|
|
for im in &self.images { |
|
|
|
if im.file_name().unwrap().to_string_lossy().contains("cover") { |
|
|
|
if im.file_name().unwrap().to_string_lossy().contains("cover") { |
|
|
|
first_img = im; |
|
|
|
first_img = im; |
|
|
@ -69,7 +69,7 @@ impl Bread { |
|
|
|
(Cow::Borrowed(&self.note), format!(r#"<div class="note">{}</div>"#, self.note.trim())) |
|
|
|
(Cow::Borrowed(&self.note), format!(r#"<div class="note">{}</div>"#, self.note.trim())) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let thumb_fname = date_slug.clone() + "." + Path::new(&img_path).extension().unwrap().to_str().unwrap(); |
|
|
|
let thumb_fname = slug.clone() + "." + Path::new(&img_path).extension().unwrap().to_str().unwrap(); |
|
|
|
let thumb_path = config.thumbs_path.join(&thumb_fname); |
|
|
|
let thumb_path = config.thumbs_path.join(&thumb_fname); |
|
|
|
let thumb_relpath = thumb_path.strip_prefix(&config.web_path)?; |
|
|
|
let thumb_relpath = thumb_path.strip_prefix(&config.web_path)?; |
|
|
|
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ impl Bread { |
|
|
|
.template("detail.html")? |
|
|
|
.template("detail.html")? |
|
|
|
.replace("{head}", &head_tpl.replace("{title}", &win_title)) |
|
|
|
.replace("{head}", &head_tpl.replace("{title}", &win_title)) |
|
|
|
.replace("{title}", &win_title) |
|
|
|
.replace("{title}", &win_title) |
|
|
|
.replace("{date}", &date_slug); |
|
|
|
.replace("{date}", &slug); |
|
|
|
|
|
|
|
|
|
|
|
let detail = if byear == config.latest_year { |
|
|
|
let detail = if byear == config.latest_year { |
|
|
|
detail.replace("{gallery_url}", "index.html") |
|
|
|
detail.replace("{gallery_url}", "index.html") |
|
|
@ -258,16 +258,16 @@ impl Bread { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
|
|
|
let bname = bpath.file_name().unwrap().to_string_lossy(); |
|
|
|
let slug = bpath.file_name().unwrap().to_string_lossy(); |
|
|
|
let date = if bname.chars().nth(10) == Some('-') { |
|
|
|
let date = if slug.chars().nth(10) == Some('-') { |
|
|
|
&bname[0..10] |
|
|
|
&slug[0..10] |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
&bname |
|
|
|
&slug |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return Ok(Bread { |
|
|
|
return Ok(Bread { |
|
|
|
date: NaiveDate::parse_from_str(&date, "%Y-%m-%d").expect("malformed date"), |
|
|
|
date: NaiveDate::parse_from_str(&date, "%Y-%m-%d").expect("malformed date"), |
|
|
|
slug: bname.to_string(), |
|
|
|
slug: slug.to_string(), |
|
|
|
rel_path: bpath.strip_prefix(base_dir)?.to_path_buf(), |
|
|
|
rel_path: bpath.strip_prefix(base_dir)?.to_path_buf(), |
|
|
|
path: bpath, |
|
|
|
path: bpath, |
|
|
|
note, |
|
|
|
note, |
|
|
|