~robin_jadoul/blog

7e79974e2e79802c4420255c91fea7b47b0e5c65 — Robin Jadoul 8 months ago 0a38de8
More accurate 'this page's source' links
4 files changed, 10 insertions(+), 12 deletions(-)

M posts/2024-03-18-breakfaest.md
M site.py
M ssg.py
M templates/base.html
M posts/2024-03-18-breakfaest.md => posts/2024-03-18-breakfaest.md +1 -1
@@ 405,7 405,7 @@ fn main() {
        BASE64_STANDARD.encode(&serde_bare::to_vec(&pk.sign(b"Give me the flag!")).unwrap())
    );
}
````
```

Step 7: Script it in python because you really don't want to paste such
a large base64 blob into your terminal and risk messing it up

M site.py => site.py +0 -3
@@ 1,7 1,4 @@
# TODO:
#  - Improve templates
#    + https://indielogin.com/setup
#    + encrypted page: context/summary
#  - minimalist/gemini/text-only version??
#  - Turn it into a nix flake? :)


M ssg.py => ssg.py +8 -7
@@ 205,13 205,14 @@ class YamlFrontmatterLoader(Loader):
        return f.read().lstrip(b'\n')

    def load_metadata(self, path: pathlib.Path) -> t_Meta:
        relpath = path.relative_to(curdir)
        try:
            res = next(yaml.load_all(path.open("rb"), Loader=yaml.SafeLoader))
            if isinstance(res, dict):
                return res
            return {}
                return res | {"_sourcepath": relpath}
            return {"_sourcepath": relpath}
        except StopIteration:
            return {}
            return {"_sourcepath": relpath}

class YamlCompanionLoader(Loader):
    def __init__(self, extension: str = ".meta.yaml"):


@@ 221,13 222,13 @@ class YamlCompanionLoader(Loader):
        return path.read_bytes()

    def load_metadata(self, path: pathlib.Path) -> t_Meta:
        relpath = path.relative_to(curdir)
        meta_file = path.with_suffix(self._extension)
        print(meta_file)
        if meta_file.is_file():
            res = yaml.load(meta_file.open("rb"), Loader=yaml.SafeLoader)
            assert isinstance(res, dict)
            return res
        return {}
            if isinstance(res, dict):
                return res | {"_sourcepath": relpath}
        return {"_sourcepath": relpath}

def gather(path: pathlib.Path, glob: str) -> PageSet:
    return PageSet([Page.from_path(c) for c in path.glob(glob)])

M templates/base.html => templates/base.html +1 -1
@@ 62,7 62,7 @@
            <a href="https://git.sr.ht/~robin_jadoul" rel="me" title="Sourcehut">{% include "icons/sourcehut.svg" %}</a>
            <a href="https://bsky.app/profile/ur4ndom.dev" rel="me" title="Bluesky">{% include "icons/bsky.svg" %}</a>
            <a href="https://www.linkedin.com/in/robin-jadoul" rel="me" title="LinkedIn">{% include "icons/linkedin.svg" %}</a>
            <a href="https://git.sr.ht/~robin_jadoul/blog/tree" title="This page's source">{% include "icons/source.svg" %}</a>
            <a href="{% if metadata._sourcepath %}https://git.sr.ht/~robin_jadoul/blog/tree/master/item/{{ metadata._sourcepath }}?view-source{% else %}https://git.sr.ht/~robin_jadoul/blog/tree{% endif%}" title="This page's source">{% include "icons/source.svg" %}</a>
        </footer>
    </body>
</html>