From fadac669a6b5d1e5ed0bab83337c23d6a736a9a3 Mon Sep 17 00:00:00 2001 From: aey Date: Mon, 6 Apr 2026 12:21:04 +0200 Subject: [PATCH] Hello, World! --- .gitignore | 6 ++++ LICENSE | 23 +++++++++++++++ README.md | 8 ++++++ pyproject.toml | 30 +++++++++++++++++++ setup.py | 5 ++++ src/smed_vaktis/__init__.py | 5 ++++ src/smed_vaktis/plugin.py | 57 +++++++++++++++++++++++++++++++++++++ tests/__init__.py | 0 tests/test_vaktis.py | 22 ++++++++++++++ 9 files changed, 156 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 src/smed_vaktis/__init__.py create mode 100644 src/smed_vaktis/plugin.py create mode 100644 tests/__init__.py create mode 100644 tests/test_vaktis.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54013a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +__pycache__ +.venv +.ropeproject +build +.coverage +src/*.egg-info diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a105396 --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +MIT License + +Copyright (c) 2026 Anders Englöf Ytterström +Copyright (c) 2021 webketje +Copyright (c) 2014-2021 Segment + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e2dc7fe --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Smed vaktis plugin + +## Acknowledgments + +smed_vaktis started as a (limited) Python port of metalsmith/vaktis. + +Thank you Segment.io for creating it, and Thank you webketje for keeping +up the excellent work. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cc162cb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,30 @@ +[build-system] +requires = ["setuptools >= 77.0.3"] +build-backend = "setuptools.build_meta" + +[project] +name = "smed_vaktis" +version = "1.0.0" +dependencies = [] +requires-python = ">=3.12" +authors = [ + { name="Anders Englöf Ytterström", email="yttan@fastmail.se" }, +] +maintainers = [ + { name="Anders Englöf Ytterström", email="yttan@fastmail.se" }, +] +description = "Plugin for Smed" +readme = "README.md" +license = "MIT" +license-files = ["LICEN[CS]E*"] +keywords = ["ssg", "static site generator", "plugin"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3.12", + "Environment :: Plugins", + "Topic :: Software Development :: Static Site Generators", +] + +[project.urls] +Homepage = "https://kod.madr.se/aey/smed-vaktis" +Repository = "https://kod.madr.se/aey/smed-vaktis/issues" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ad1ad5d --- /dev/null +++ b/setup.py @@ -0,0 +1,5 @@ +# setup.py + +from setuptools import setup + +setup() diff --git a/src/smed_vaktis/__init__.py b/src/smed_vaktis/__init__.py new file mode 100644 index 0000000..873ddb2 --- /dev/null +++ b/src/smed_vaktis/__init__.py @@ -0,0 +1,5 @@ +from .plugin import vaktis + +__version__ = "1.0.0" + +__all__ = [vaktis] diff --git a/src/smed_vaktis/plugin.py b/src/smed_vaktis/plugin.py new file mode 100644 index 0000000..bdb0aa1 --- /dev/null +++ b/src/smed_vaktis/plugin.py @@ -0,0 +1,57 @@ +from pathlib import Path + + +def vaktis(): + def callback(items, _metadata): + items = list(items) + items.append( + ( + Path("/index.md"), + { + "template": "home.html.j2", + "_destination": Path("/index.md"), + }, + ) + ) + items.append( + ( + Path("/webblogg.md"), + { + "template": "blog.html.j2", + "_destination": Path("/webblogg/index.md"), + }, + ) + ) + items.append( + ( + Path("/inlagg.md"), + { + "template": "blog.html.j2", + "select": "articles", + "_destination": Path("/inlagg/index.md"), + }, + ) + ) + items.append( + ( + Path("/lanktips.md"), + { + "template": "blog.html.j2", + "select": "links", + "_destination": Path("/lanktips/index.md"), + }, + ) + ) + items.append( + ( + Path("/evenemang.html"), + { + "template": "blog.html.j2", + "select": "events", + "_destination": Path("/evenemang/index.md"), + }, + ) + ) + return map(lambda i: i, items), _metadata + + return callback diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_vaktis.py b/tests/test_vaktis.py new file mode 100644 index 0000000..3f8618c --- /dev/null +++ b/tests/test_vaktis.py @@ -0,0 +1,22 @@ +import unittest +from pathlib import Path +from src.smed_vaktis import vaktis + + +class TestSmedvaktis(unittest.TestCase): + def test_return_map(self): + fixture = [ + Path("smed/events.md"), + ] + items = [(f, {"_destination": f}) for f in fixture] + metadata = {"sitename": "Some site"} + + callback = vaktis() + modified = callback(items, metadata) + + self.assertIsInstance(modified, map) + self.assertEqual(list(modified), items) + + +if __name__ == "__main__": + unittest.main()