mirror of
https://github.com/Such-Software/adaptive-multi-protocol-gateway.git
synced 2026-11-14 12:14:02 +01:00
Add Micron renderer and AMPGateway site target
This commit is contained in:
@@ -65,6 +65,61 @@ max_asset_bytes = 1024
|
||||
self.assertIn("daemon = agate", agate_plan)
|
||||
self.assertIn("content_root =", agate_plan)
|
||||
|
||||
def test_existing_html_source_can_build_only_reticulum(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
source = root / "source"
|
||||
source.mkdir()
|
||||
(source / "index.html").write_text(
|
||||
'<h1>Home</h1><p><a href="about.html">About</a></p><script>bad()</script>',
|
||||
encoding="utf-8",
|
||||
)
|
||||
(source / "about.html").write_text("<h1>About</h1>", encoding="utf-8")
|
||||
(source / "app.js").write_text("bad()", encoding="utf-8")
|
||||
(source / "styles.css").write_text("body {}", encoding="utf-8")
|
||||
config_path = root / "gateway.toml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
[[site]]
|
||||
id = "reticulum_only"
|
||||
domain = "example.test"
|
||||
|
||||
[site.source]
|
||||
kind = "static-html"
|
||||
path = "./source"
|
||||
|
||||
[site.outputs]
|
||||
root = "./out"
|
||||
plan_root = "./plan"
|
||||
|
||||
[site.protocols.reticulum]
|
||||
enabled = true
|
||||
renderer = "micron"
|
||||
daemon = "rnsd"
|
||||
daemon_policy = "auto"
|
||||
aspect = "web"
|
||||
max_asset_bytes = 1024
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
config = load_config(config_path)
|
||||
plan = plan_gateway(config)
|
||||
artifacts = write_plan_artifacts(config)
|
||||
results = build_gateway(config)
|
||||
|
||||
self.assertEqual([line.protocol for line in plan], ["reticulum"])
|
||||
self.assertEqual([result.protocol for result in results], ["reticulum"])
|
||||
self.assertEqual(len(artifacts), 0)
|
||||
self.assertTrue((root / "out/reticulum/index.mu").exists())
|
||||
self.assertTrue((root / "out/reticulum/about.mu").exists())
|
||||
self.assertFalse((root / "out/reticulum/app.js").exists())
|
||||
self.assertFalse((root / "out/reticulum/styles.css").exists())
|
||||
micron = (root / "out/reticulum/index.mu").read_text(encoding="utf-8")
|
||||
self.assertIn("# Home", micron)
|
||||
self.assertIn("=> about.mu About", micron)
|
||||
self.assertNotIn("bad", micron)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from ampg.renderers import render_gemtext
|
||||
from ampg.renderers import render_gemtext, render_micron
|
||||
|
||||
|
||||
class GemtextRendererTest(unittest.TestCase):
|
||||
@@ -31,6 +31,27 @@ class GemtextRendererTest(unittest.TestCase):
|
||||
self.assertIn("=> logo.png Image: Logo", gemtext)
|
||||
self.assertNotIn("ignored", gemtext)
|
||||
|
||||
def test_converts_basic_html_to_micron(self):
|
||||
html = """
|
||||
<html>
|
||||
<body>
|
||||
<h1>Hello</h1>
|
||||
<p>Read the <a href="about.html">about page</a>.</p>
|
||||
<script>ignored()</script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
micron = render_micron(
|
||||
html,
|
||||
rewrite_link=lambda href: href.replace(".html", ".mu"),
|
||||
)
|
||||
|
||||
self.assertIn("# Hello", micron)
|
||||
self.assertIn("Read the about page.", micron)
|
||||
self.assertIn("=> about.mu about page", micron)
|
||||
self.assertNotIn("ignored", micron)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -154,7 +154,7 @@ daemon_policy = "auto"
|
||||
"""
|
||||
[site.protocols.tor]
|
||||
enabled = true
|
||||
renderer = "micron"
|
||||
renderer = "unbuilt-renderer"
|
||||
daemon = "tor"
|
||||
daemon_policy = "adopt"
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user