|
|
|
@ -41,16 +41,16 @@ pub struct BreadLink { |
|
|
|
|
impl Bread { |
|
|
|
|
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_slug = &self.slug; |
|
|
|
|
let detail_file = date_slug.clone() + ".html"; |
|
|
|
|
println!("+ {}", date_slug); |
|
|
|
|
let slug = &self.slug; |
|
|
|
|
let detail_file = slug.clone() + ".html"; |
|
|
|
|
println!("+ {}", slug); |
|
|
|
|
|
|
|
|
|
self.rendered.title = date.clone(); |
|
|
|
|
self.rendered.detail_fname = detail_file.clone(); |
|
|
|
|
|
|
|
|
|
// figure out the thumbnail pic
|
|
|
|
|
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 { |
|
|
|
|
if im.file_name().unwrap().to_string_lossy().contains("cover") { |
|
|
|
|
first_img = im; |
|
|
|
@ -69,7 +69,7 @@ impl Bread { |
|
|
|
|
(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_relpath = thumb_path.strip_prefix(&config.web_path)?; |
|
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ impl Bread { |
|
|
|
|
.template("detail.html")? |
|
|
|
|
.replace("{head}", &head_tpl.replace("{title}", &win_title)) |
|
|
|
|
.replace("{title}", &win_title) |
|
|
|
|
.replace("{date}", &date_slug); |
|
|
|
|
.replace("{date}", &slug); |
|
|
|
|
|
|
|
|
|
let detail = if byear == config.latest_year { |
|
|
|
|
detail.replace("{gallery_url}", "index.html") |
|
|
|
@ -258,16 +258,16 @@ impl Bread { |
|
|
|
|
}) |
|
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
|
let bname = bpath.file_name().unwrap().to_string_lossy(); |
|
|
|
|
let date = if bname.chars().nth(10) == Some('-') { |
|
|
|
|
&bname[0..10] |
|
|
|
|
let slug = bpath.file_name().unwrap().to_string_lossy(); |
|
|
|
|
let date = if slug.chars().nth(10) == Some('-') { |
|
|
|
|
&slug[0..10] |
|
|
|
|
} else { |
|
|
|
|
&bname |
|
|
|
|
&slug |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return Ok(Bread { |
|
|
|
|
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(), |
|
|
|
|
path: bpath, |
|
|
|
|
note, |
|
|
|
|