diff --git a/src/gallery_entry.rs b/src/gallery_entry.rs
@@ -44,6 +44,7 @@ pub struct GalleryEntry {
pub alt: String,
pub caption: Option<String>,
pub license: Option<LicenseType>,
+ pub source: Option<String>,
pub author: String,
pub author_url: Option<String>,
}
@@ -351,6 +352,7 @@ impl<'de> Deserialize<'de> for GalleryEntry {
caption: Option<String>,
license: String,
author: String,
+ source: Option<String>,
#[serde(alias = "author-url")]
author_url: Option<String>,
}
@@ -362,6 +364,7 @@ impl<'de> Deserialize<'de> for GalleryEntry {
license,
author,
author_url,
+ source,
} = Info::deserialize(deserializer)?;
let license = LicenseType::parse(&license)
@@ -389,6 +392,7 @@ impl<'de> Deserialize<'de> for GalleryEntry {
path: path.clone(),
alt: alt.trim().to_string(),
file_name: String::from(file_name),
+ source,
file_format,
caption,
author: author.trim().to_string(),
diff --git a/src/main.rs b/src/main.rs
@@ -316,7 +316,6 @@ fn render_index(pics: &Vec<GalleryEntry>) -> io::Result<()> {
writeln!(f, "</html>")
}
-// TODO: Render the image source somehow if possible
fn render_pic_page(pic: &GalleryEntry) -> io::Result<()> {
let mut path = PathBuf::from(".");
path.push(TARGET_PATH);
@@ -358,11 +357,12 @@ fn render_pic_page(pic: &GalleryEntry) -> io::Result<()> {
)?;
if pic.caption.is_some() {
- writeln!(f, "<figure id=\"picture\">")?;
+ writeln!(f, "<figure>")?;
} else {
- writeln!(f, "<figure id=\"picture\" aria-label=\"File {name}\">",
+ writeln!(f, "<figure aria-label=\"File {name}\">",
name = Escaped(&pic.file_name))?;
}
+ writeln!(f, "<div id=\"picture\">")?;
writeln!(f, "<div class=\"picture-container\">")?;
writeln!(
f,
@@ -377,11 +377,17 @@ fn render_pic_page(pic: &GalleryEntry) -> io::Result<()> {
)?;
writeln!(f, "</a>")?;
writeln!(f, "</div>")?;
+ writeln!(f, "</div>")?;
if let Some(caption) = &pic.caption {
writeln!(f, "<figcaption>")?;
writeln!(f, "{}", Escaped(caption))?;
writeln!(f, "</figcaption>")?;
}
+ if let Some(src) = &pic.source {
+ writeln!(f, "<figcaption class=\"image-source\">")?;
+ writeln!(f, "original source: <a href=\"{src}\">{src}</a>")?;
+ writeln!(f, "</figcaption>")?;
+ }
writeln!(f, "</figure>")?;
writeln!(f, "</main>")?;