]> OzVa Git service - bread/commitdiff
Styling changes
authorMax Value <greenwoodw50@gmail.com>
Fri, 6 Jun 2025 13:11:13 +0000 (14:11 +0100)
committerMax Value <greenwoodw50@gmail.com>
Fri, 6 Jun 2025 13:11:13 +0000 (14:11 +0100)
+ dark mode rules
+ print rules
+ print prompt on page
+ sous regex to make hex codes show up as colors

sous.py
style.css
templates/template.html

diff --git a/sous.py b/sous.py
index 37f8df9eae2f632b74c9f2bde76fbbacadc4ac19..fdef8a7a9c0b4447feeee9d13811ebee860dc3f0 100755 (executable)
--- a/sous.py
+++ b/sous.py
@@ -5,6 +5,7 @@ from os import path, listdir, system
 from jinja2 import Environment, FileSystemLoader
 from datetime import datetime
 from tqdm import tqdm
+import re
 
 class RecipeBook:
        def __init__(self):
@@ -81,6 +82,12 @@ class Recipe:
        def render_html(self, environment: Environment):
                template = environment.get_template("template.html")
 
+               self.recipe['information']['notes'] = re.sub(
+                       r"(?P<color>#[\da-fA-F]{6})",
+                       r"<span style='background-color:\g<color>;color:white'>\g<color></span>",
+                       self.recipe['information']['notes']
+                       )
+
                with open(path.join("recipes", self.recipe["html"]), "w") as f:
                        f.write(template.render(recipe = self.recipe, time = datetime.now()))
 
index ad93b4811307fe1325d0ab55bd8ce1bf6db536ed..4f6c9e9c184ee5acb4f287c3cbc3f01d586eac26 100644 (file)
--- a/style.css
+++ b/style.css
@@ -15,9 +15,34 @@ th {
 img {
        width: 100%;
 }
+p {
+       text-align: justify;
+}
 p + p {
        text-indent: 1.5em;
 }
 dt {
        font-weight: bold;
 }
+
+@media (prefers-color-scheme: dark) {
+       body {
+               color: gray;
+               background-color: black;
+       }
+}
+
+@media print {
+       body {
+               font-size: 12px;
+       }
+       main {
+               width: 100%;
+       }
+       nav, a, p:last-of-type {
+               display: none;
+       }
+       p:first-of-type:after {
+               content: " Printed from https://bread.ozva.co.uk.";
+       }
+}
index 064336a5aad220ac5efc775a0a2341acf82e736a..720115570092e9f0ea2c7b25ae7e088922dd36f7 100644 (file)
@@ -9,8 +9,11 @@
                <main>
                <a href="../index.html">Back to main page</a>
                <h1>{{ recipe.information.title }}</h1>
+               <nav>
                <a href="https://git.ozva.co.uk/?p=bread;a=history;f=src/{{ recipe.filename }};">[History]</a> -
-               <a href="{{ recipe.pdf }}">[PDF]</a>
+               <a href="{{ recipe.pdf }}">[PDF]</a> -
+               <em>Printable with Ctrl+P</em>
+               </nav>
                <p>{{ recipe.information.description }}</p>
 
                <h2>Notes</h2>