tikz-gallery-generator

Custum build of stapix for tikz.pablopie.xyz

Commit
1cc6d7021a3bc4b263413a56ade4aa680a0d8572
Parent
51e2f3a082190a149940d1ac17141337a7b440d2
Author
Pablo <pablo-pie@riseup.net>
Date

Cleaned the page visuals

Changed the page visuals to match the style of my academic website

Also replaced absolute paths with relative ones to facilitate hosting the pages on a subdirectory of the endpoint root

Diffstats

5 files changed, 47 insertions, 81 deletions

Status Name Changes Insertions Deletions
Modified TODO.md 2 files changed 0 2
Modified src/intro.html 2 files changed 1 1
Added src/license.html 1 file changed 12 0
Modified src/main.rs 2 files changed 28 72
Modified src/outro.html 2 files changed 6 6
diff --git a/TODO.md b/TODO.md
@@ -1,6 +1,4 @@
 # TODO
 
-* refactor the page visuals
-  * Also make the page root configurable
 * add a flag to configure the size of the thread pool
 * introduce a static configuration file?
diff --git a/src/intro.html b/src/intro.html
@@ -1,4 +1,4 @@
-<h1>TikZ Gallery</h1>
+<h1>TikZ gallery</h1>
 <p>
 A gallery with ready-made mathematical drawings for use in LaTeX documents and
 Beamer presentations &mdash; as well as their source code! Other than a
diff --git /dev/null b/src/license.html
@@ -0,0 +1,12 @@
+<!-- This program is free software: you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation, either version 3 of the License, or
+     (at your option) any later version.
+
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with this program. If not, see <https://www.gnu.org/licenses/>. -->
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} &dash; {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")?,
diff --git a/src/outro.html b/src/outro.html
@@ -1,5 +1,5 @@
 <section id="using">
-<h2>Using This Gallery</h2>
+<h2>using this gallery</h2>
 <p>
 For details on a figure in this gallery please access its entry page, where you
 will find information such as captions and pointers the original source, if
@@ -11,22 +11,22 @@ Most (but not all) of the drawings in here are
 licensed under free <a href="https://creativecommons.org/">Creative Commons</a>
 licenses, allowing users to modify and distribute their source code. Please
 verify the license terms of each specific figure before using it in your
-documents. See <a href="/include.html">Including the Figures</a> for
+documents. See <a href="/include.html">including the figures</a> for
 instructions on how to include a given picture in your documents.
 </p>
 </section>
 
 <section id="contributing">
-<h2>Contributing</h2>
+<h2>contributing</h2>
 <p>
-As of now, this gallery is run by <a href="https://pablopie.xyz">@pablo</a>. If
+As of now, this gallery is run by <a href="https://https://www.math.univ-toulouse.fr/~tbrevide/">Thiago Brevidelli</a>. If
 you would like to add your drawings to here please contact
-<a href="mailto:&#112;&#97;&#98;&#108;&#111;-&#112;&#105;&#101;@&#114;&#105;&#115;&#101;&#117;&#112;.&#110;&#101;&#116;">&#112;&#97;&#98;&#108;&#111;-&#112;&#105;&#101; [&#97;&#116;] &#114;&#105;&#115;&#101;&#117;&#112;.&#110;&#101;&#116;</a>.
+<a href="&#109;&#97;&#105;&#108;&#116;&#111;:&#116;&#104;&#105;&#97;&#103;&#111;.&#98;&#114;&#101;&#118;&#105;&#100;&#101;&#108;&#108;&#105;_&#103;&#97;&#114;&#99;&#105;&#97;@&#109;&#97;&#116;&#104;.&#117;&#110;&#105;&#118;-&#116;&#111;&#117;&#108;&#111;&#117;&#115;&#101;.&#102;&#114;">&#116;&#104;&#105;&#97;&#103;&#111;.&#98;&#114;&#101;&#118;&#105;&#100;&#101;&#108;&#108;&#105;_&#103;&#97;&#114;&#99;&#105;&#97;@&#109;&#97;&#116;&#104;.&#117;&#110;&#105;&#118;-&#116;&#111;&#117;&#108;&#111;&#117;&#115;&#101;.&#102;&#114;</a>.
 </p>
 </section>
 
 <section id="other-galleries">
-<h2>Other Galleries</h2>
+<h2>other galleries</h2>
 <ul>
 <li><a href="https://texample.net/tikz/examples/">TeXample.net</a></li>
 <li><a href="https://tikz.net/">TikZ.net</a></li>