Hello, World!
This commit is contained in:
commit
fadac669a6
9 changed files with 156 additions and 0 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
__pycache__
|
||||||
|
.venv
|
||||||
|
.ropeproject
|
||||||
|
build
|
||||||
|
.coverage
|
||||||
|
src/*.egg-info
|
||||||
23
LICENSE
Normal file
23
LICENSE
Normal file
|
|
@ -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.
|
||||||
8
README.md
Normal file
8
README.md
Normal file
|
|
@ -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.
|
||||||
30
pyproject.toml
Normal file
30
pyproject.toml
Normal file
|
|
@ -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"
|
||||||
5
setup.py
Normal file
5
setup.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# setup.py
|
||||||
|
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup()
|
||||||
5
src/smed_vaktis/__init__.py
Normal file
5
src/smed_vaktis/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from .plugin import vaktis
|
||||||
|
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
__all__ = [vaktis]
|
||||||
57
src/smed_vaktis/plugin.py
Normal file
57
src/smed_vaktis/plugin.py
Normal file
|
|
@ -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
|
||||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
22
tests/test_vaktis.py
Normal file
22
tests/test_vaktis.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Reference in a new issue