diff --git a/src/main.rs b/src/main.rs
@@ -33,13 +33,9 @@ const TARGET_PATH: &str = "./site";
const PAGES_PATH: &str = "figures";
const IMAGES_PATH: &str = "assets/images";
const THUMBS_PATH: &str = "assets/thumbs";
-const FAVICON_PATH: &str = "assets/favicon.svg";
-const FONTS_PATH: &str = "assets/fonts";
-const STYLES_PATH: &str = "assets/css/styles.css";
+const STYLES_PATH: &str = "assets/styles.css";
-const PAGE_TITLE: &str = "TikZ Gallery";
-const AUTHOR: &str = "Pablo";
-const LICENSE: &str = "GPLv3";
+const PAGE_TITLE: &str = "TikZ gallery";
fn main() -> ExitCode {
let mut args = env::args();
@@ -196,13 +192,13 @@ fn render_index(pics: &Vec) -> io::Result<()> {
writeln!(f, "<html lang=\"en\">")?;
writeln!(f, "<head>")?;
writeln!(f, "<title>{PAGE_TITLE}</title>")?;
- write_head(&mut f)?;
+ write_head(&mut f, false)?;
// preload the first 2 pictures in the gallery
- for pic in pics.iter().take(2) {
+ for pic in pics.iter().take(4) {
writeln!(
f,
- "<link rel=\"preload\" as=\"image\" href=\"{path}\">",
+ "<link rel=\"preload\" as=\"image\" href=\"./{path}\">",
path = ThumbPath(pic),
)?;
}
@@ -221,13 +217,13 @@ fn render_index(pics: &Vec) -> io::Result<()> {
writeln!(f, "<article class=\"picture-container\">")?;
writeln!(
f,
- "<a aria-label=\"{name}\" href=\"/{PAGES_PATH}/{name}.html\">",
+ "<a aria-label=\"{name}\" href=\"./{PAGES_PATH}/{name}.html\">",
name = Escaped(&pic.file_name)
)?;
writeln!(
f,
- "<img alt=\"{alt}\" src=\"{path}\">",
- alt = Escaped(&pic.alt),
+ "<img alt=\"{alt}\" src=\"./{path}\">",
+ alt = Escaped(&pic.alt),
path = ThumbPath(pic),
)?;
writeln!(f, "</a>\n</article>")?;
@@ -238,14 +234,6 @@ fn render_index(pics: &Vec) -> io::Result<()> {
const OUTRO_MSG: &str = include_str!("outro.html");
writeln!(f, "{}", OUTRO_MSG)?;
writeln!(f, "</main>")?;
-
- writeln!(f, "<footer>")?;
- writeln!(
- f,
- "made with 💚 by <a role=\"author\" href=\"https://pablopie.xyz\">@pablo</a>"
- )?;
- writeln!(f, "</footer>")?;
-
writeln!(f, "</body>")?;
writeln!(f, "</html>")
}
@@ -262,10 +250,10 @@ fn render_pic_page(pic: &GalleryEntry, path: &Path) -> io::Result<()> {
"<title>{PAGE_TITLE} ‐ {name}</title>",
name = Escaped(&pic.file_name)
)?;
- write_head(&mut f)?;
+ write_head(&mut f, true)?;
writeln!(
&mut f,
- "<link rel=\"preload\" as=\"image\" href=\"{path}\">",
+ "<link rel=\"preload\" as=\"image\" href=\"../{path}\">",
path = ThumbPath(pic),
)?;
writeln!(&mut f, "</head>")?;
@@ -290,7 +278,7 @@ fn render_pic_page(pic: &GalleryEntry, path: &Path) -> io::Result<()> {
writeln!(&mut f, "<div class=\"picture-container\">")?;
writeln!(
&mut f,
- "<img alt=\"{alt}\" src=\"{path}\">",
+ "<img alt=\"{alt}\" src=\"../{path}\">",
alt = Escaped(&pic.alt),
path = ThumbPath(pic),
)?;
@@ -300,7 +288,7 @@ fn render_pic_page(pic: &GalleryEntry, path: &Path) -> io::Result<()> {
writeln!(&mut f, "<ul>")?;
writeln!(
&mut f,
- "<li><a href=\"/{IMAGES_PATH}/{name}\">download</a></li>",
+ "<li><a href=\"../{IMAGES_PATH}/{name}\">download</a></li>",
name = Escaped(&pic.file_name),
)?;
if let Some(src) = &pic.source {
@@ -351,59 +339,27 @@ fn render_pic_page(pic: &GalleryEntry, path: &Path) -> io::Result<()> {
}
/// Prints the common head elements to a given file
-fn write_head(f: &mut File) -> io::Result<()> {
- writeln!(
- f,
- "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
- )?;
+fn write_head(f: &mut File, pic_page: bool) -> io::Result<()> {
+ const AUTHOR: &str = "Thiago Brevidelli";
+ const LICENSE: &str = "GPLv3";
+
+ writeln!(f, "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">")?;
writeln!(f, "<meta name=\"author\" content=\"{AUTHOR}\">")?;
writeln!(f, "<meta name=\"copyright\" content=\"{LICENSE}\">")?;
- writeln!(
- f,
- "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">"
- )?;
- writeln!(f,
- "<link rel=\"icon\" type=\"image/svg+xml\" sizes=\"16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512\" href=\"/{FAVICON_PATH}\">")?;
- writeln!(f, "<link rel=\"stylesheet\" href=\"/{STYLES_PATH}\">")?;
- writeln!(f, "<link rel=\"preload\" as=\"font\" href=\"/{FONTS_PATH}/alfa-slab.woff2\">")
+ writeln!(f, "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">")?;
+ if pic_page {
+ writeln!(f, "<link rel=\"stylesheet\" href=\"../{STYLES_PATH}\">")?;
+ } else {
+ writeln!(f, "<link rel=\"stylesheet\" href=\"./{STYLES_PATH}\">")?;
+ }
+
+ Ok(())
}
/// Prints a HTML comment with GPL licensing info
fn write_license(f: &mut File) -> io::Result<()> {
- writeln!(
- f,
- "<!-- This program is free software: you can redistribute it and/or modify"
- )?;
- writeln!(
- f,
- " it under the terms of the GNU General Public License as published by"
- )?;
- writeln!(
- f,
- " the Free Software Foundation, either version 3 of the License, or"
- )?;
- writeln!(f, " (at your option) any later version.\n")?;
- writeln!(
- f,
- " This program is distributed in the hope that it will be useful,"
- )?;
- writeln!(
- f,
- " but WITHOUT ANY WARRANTY; without even the implied warranty of"
- )?;
- writeln!(
- f,
- " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
- )?;
- writeln!(f, " GNU General Public License for more details.\n")?;
- writeln!(
- f,
- " You should have received a copy of the GNU General Public License"
- )?;
- writeln!(
- f,
- " along with this program. If not, see <https://www.gnu.org/licenses/>. -->"
- )
+ const LICENSE_COMMENT: &str = include_str!("license.html");
+ writeln!(f, "{}", LICENSE_COMMENT)
}
fn render_thumbnail(pic: &GalleryEntry, thumb_path: &Path) -> Result<(), ()> {
@@ -532,7 +488,7 @@ fn log_floor(n: usize) -> usize {
impl Display for ThumbPath<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
- write!(f, "/{THUMBS_PATH}/{name}", name = Escaped(&self.0.file_name))?;
+ write!(f, "{THUMBS_PATH}/{name}", name = Escaped(&self.0.file_name))?;
match self.0.file_format {
FileFormat::TeX => write!(f, ".svg")?,