skrift 0.1.0a13__py3-none-any.whl → 0.1.0a14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
skrift/asgi.py CHANGED
@@ -44,6 +44,7 @@ from skrift.db.services.setting_service import (
44
44
  SETUP_COMPLETED_AT_KEY,
45
45
  )
46
46
  from skrift.lib.exceptions import http_exception_handler, internal_server_error_handler
47
+ from skrift.lib.markdown import render_markdown
47
48
 
48
49
 
49
50
  def load_controllers() -> list:
@@ -423,16 +424,20 @@ def create_app() -> Litestar:
423
424
  # Search working directory first for user overrides, then package directory
424
425
  working_dir_templates = Path(os.getcwd()) / "templates"
425
426
  template_dir = Path(__file__).parent / "templates"
426
- template_config = TemplateConfig(
427
- directory=[working_dir_templates, template_dir],
428
- engine=JinjaTemplateEngine,
429
- engine_callback=lambda engine: engine.engine.globals.update({
427
+ def configure_template_engine(engine):
428
+ engine.engine.globals.update({
430
429
  "now": datetime.now,
431
430
  "site_name": get_cached_site_name,
432
431
  "site_tagline": get_cached_site_tagline,
433
432
  "site_copyright_holder": get_cached_site_copyright_holder,
434
433
  "site_copyright_start_year": get_cached_site_copyright_start_year,
435
- }),
434
+ })
435
+ engine.engine.filters.update({"markdown": render_markdown})
436
+
437
+ template_config = TemplateConfig(
438
+ directory=[working_dir_templates, template_dir],
439
+ engine=JinjaTemplateEngine,
440
+ engine_callback=configure_template_engine,
436
441
  )
437
442
 
438
443
  # Static files - working directory first for user overrides, then package directory
@@ -498,16 +503,21 @@ def create_setup_app() -> Litestar:
498
503
  # Search working directory first for user overrides, then package directory
499
504
  working_dir_templates = Path(os.getcwd()) / "templates"
500
505
  template_dir = Path(__file__).parent / "templates"
501
- template_config = TemplateConfig(
502
- directory=[working_dir_templates, template_dir],
503
- engine=JinjaTemplateEngine,
504
- engine_callback=lambda engine: engine.engine.globals.update({
506
+
507
+ def configure_setup_template_engine(engine):
508
+ engine.engine.globals.update({
505
509
  "now": datetime.now,
506
510
  "site_name": lambda: "Skrift",
507
511
  "site_tagline": lambda: "Setup",
508
512
  "site_copyright_holder": lambda: "",
509
513
  "site_copyright_start_year": lambda: None,
510
- }),
514
+ })
515
+ engine.engine.filters.update({"markdown": render_markdown})
516
+
517
+ template_config = TemplateConfig(
518
+ directory=[working_dir_templates, template_dir],
519
+ engine=JinjaTemplateEngine,
520
+ engine_callback=configure_setup_template_engine,
511
521
  )
512
522
 
513
523
  # Static files - working directory first for user overrides, then package directory
skrift/lib/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
+ from skrift.lib.markdown import render_markdown
1
2
  from skrift.lib.template import Template
2
3
 
3
- __all__ = ["Template"]
4
+ __all__ = ["Template", "render_markdown"]
skrift/lib/markdown.py ADDED
@@ -0,0 +1,37 @@
1
+ """Markdown rendering utilities for page content."""
2
+
3
+ from markdown_it import MarkdownIt
4
+ from mdit_py_plugins.footnote import footnote_plugin
5
+
6
+
7
+ def create_markdown_renderer() -> MarkdownIt:
8
+ """Create a configured markdown renderer with standard plugins."""
9
+ md = MarkdownIt("commonmark", {"typographer": True})
10
+ md.enable("table")
11
+ footnote_plugin(md)
12
+ return md
13
+
14
+
15
+ _renderer: MarkdownIt | None = None
16
+
17
+
18
+ def get_renderer() -> MarkdownIt:
19
+ """Get the singleton markdown renderer, creating it if needed."""
20
+ global _renderer
21
+ if _renderer is None:
22
+ _renderer = create_markdown_renderer()
23
+ return _renderer
24
+
25
+
26
+ def render_markdown(content: str) -> str:
27
+ """Render markdown content to HTML.
28
+
29
+ Args:
30
+ content: Markdown text to render.
31
+
32
+ Returns:
33
+ Rendered HTML string. Returns empty string for empty/None input.
34
+ """
35
+ if not content:
36
+ return ""
37
+ return get_renderer().render(content)
@@ -14,7 +14,7 @@
14
14
  </header>
15
15
 
16
16
  <div class="page-content">
17
- {{ page.content | safe }}
17
+ {{ page.content | markdown | safe }}
18
18
  </div>
19
19
 
20
20
  {% if not page.is_published %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skrift
3
- Version: 0.1.0a13
3
+ Version: 0.1.0a14
4
4
  Summary: A lightweight async Python CMS for crafting modern websites
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: advanced-alchemy>=0.26.0
@@ -9,6 +9,8 @@ Requires-Dist: alembic>=1.14.0
9
9
  Requires-Dist: asyncpg>=0.30.0
10
10
  Requires-Dist: httpx>=0.28.0
11
11
  Requires-Dist: litestar[cryptography,jinja,standard]>=2.14.0
12
+ Requires-Dist: markdown-it-py>=3.0.0
13
+ Requires-Dist: mdit-py-plugins>=0.4.0
12
14
  Requires-Dist: pydantic-settings>=2.7.0
13
15
  Requires-Dist: python-dotenv>=1.0.0
14
16
  Requires-Dist: pyyaml>=6.0.0
@@ -1,7 +1,7 @@
1
1
  skrift/__init__.py,sha256=eXE5PFVkJpH5XsV_ZlrTIeFPUPrmcHYAj4GpRS3R5PY,29
2
2
  skrift/__main__.py,sha256=wt6JZL9nBhKU36vdyurhOEtWy7w3C9zohyy24PLcKho,164
3
3
  skrift/alembic.ini,sha256=mYguI6CbMCTyfHctsGiTyf9Z5gv21FdeI3qtfgOHO3A,1815
4
- skrift/asgi.py,sha256=qtP0aq9C6-bIZgbXiwJeF_3dY8O0cM2U_5hkajKMjBc,23032
4
+ skrift/asgi.py,sha256=7uPvgsGMpZJyPOjIGxL9QlXTRLWh9uRAhcg-RdBS1c8,23355
5
5
  skrift/cli.py,sha256=aT-7pXvOuuZC-Eypx1h-xCiqaBKhIFjSqd5Ky_dHna0,4214
6
6
  skrift/config.py,sha256=ZDOrYgp6gC6fE1nEZgrAOouoykhRo2NZo5U1-WLdDSc,7862
7
7
  skrift/admin/__init__.py,sha256=x81Cj_ilVmv6slaMl16HHyT_AgrnLxKEWkS0RPa4V9s,289
@@ -35,8 +35,9 @@ skrift/db/services/__init__.py,sha256=qAC24IPOYg6AampUWonmLeajljQRMwUw0lgXksQG6N
35
35
  skrift/db/services/oauth_service.py,sha256=1065tYGvrSer0X28GblibrSz2BjwVjl3tndXk1plthE,5208
36
36
  skrift/db/services/page_service.py,sha256=cXJ-urV7LjUDoVsT1P52f6wcOsur3T-pvqKkGG4xlvI,5246
37
37
  skrift/db/services/setting_service.py,sha256=eqFxukn8QFrDHQbaBILOLjP1nr34JPIPFT_NnhmeaTY,5613
38
- skrift/lib/__init__.py,sha256=PL66bS4_-90zJDMsQSnzqkkxwkO_3aLcYl9l9cDrE2Y,65
38
+ skrift/lib/__init__.py,sha256=Ew53SFcJcoohNF_FEDoDXsrks9cKZQonoaJAWyjXWMs,132
39
39
  skrift/lib/exceptions.py,sha256=p8ceLIQCc7agCwW6-mhBDAuMAMxZDcf9TDLC6PfztU4,5803
40
+ skrift/lib/markdown.py,sha256=fPLUIAsmFXC64Os2RngQG7P2xRKBd1RO8fh7b5_gV1U,950
40
41
  skrift/lib/template.py,sha256=4_urkRfvth75yNeQ5TyGTHvkvs3vVef7TcwZx0k285k,4226
41
42
  skrift/setup/__init__.py,sha256=3VjFPMES5y0M5cQ9R4C1xazqiEPEDqTPjX9-3rBMXnA,478
42
43
  skrift/setup/config_writer.py,sha256=YFH3FVjXN7Rum2fzGVPAQRkjdc9b0bHECDqMKYiEkhg,6347
@@ -50,7 +51,7 @@ skrift/templates/error-404.html,sha256=sJrDaF3Or3Nyki8mxo3wBxLLzgy4wkB9p9wdS8pRA
50
51
  skrift/templates/error-500.html,sha256=MR0wJ1JKLqdmdvsoJbQnZxLkxDPE59LrlbtVPKLM8-A,401
51
52
  skrift/templates/error.html,sha256=tg45Hj0wNc9QiZKBVVQ2WsqDiAkByXZnuehTdJPclXc,415
52
53
  skrift/templates/index.html,sha256=lzZlnoZ2luY__OtRVa61mpQIgcopAbkKa2rS9XRfRlI,172
53
- skrift/templates/page.html,sha256=kY1j7TH6dFnvWnYwBEGCIEvardjLhnFMnM3NbAnKszQ,759
54
+ skrift/templates/page.html,sha256=aSTypibx86SzIhO7GTff8XXVrW8D-XbHNaTo_UT31oc,770
54
55
  skrift/templates/admin/admin.html,sha256=8sErpGKedl7Hf_CMeu53bUEHptH1FqdBX9LT3z-1HcU,454
55
56
  skrift/templates/admin/base.html,sha256=JX1MPw9XTY8jCT2M6iHUwEj8NPNOdZPca2cDUEs9kfQ,659
56
57
  skrift/templates/admin/pages/edit.html,sha256=s-uZ4BYG7BdnWYTBSS1mr5aFL8XfT8h-KNiSIraWmHw,1322
@@ -68,7 +69,7 @@ skrift/templates/setup/configuring.html,sha256=2KHW9h2BrJgL_kO5IizbAYs4pnFLyRf76
68
69
  skrift/templates/setup/database.html,sha256=gU4-315-QraHa2Eq4Fh3b55QpOM2CkJzh27_Yz13frA,5495
69
70
  skrift/templates/setup/restart.html,sha256=GHg31F_e2uLFhWUzJoalk0Y0oYLqsFWyZXWKX3mblbY,1355
70
71
  skrift/templates/setup/site.html,sha256=PSOH-q1-ZBl47iSW9-Ad6lEfJn_fzdGD3Pk4vb3xgK4,1680
71
- skrift-0.1.0a13.dist-info/METADATA,sha256=cNzAjQrohmMJZJv-euANW_JjoWI5Lm6KSzG0daFjT7o,6436
72
- skrift-0.1.0a13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
73
- skrift-0.1.0a13.dist-info/entry_points.txt,sha256=uquZ5Mumqr0xwYTpTcNiJtFSITGfF6_QCCy2DZJSZig,42
74
- skrift-0.1.0a13.dist-info/RECORD,,
72
+ skrift-0.1.0a14.dist-info/METADATA,sha256=unD0pS4u31RZprH6rOeGVZJ_zA565aw7wTFxXzG91Go,6511
73
+ skrift-0.1.0a14.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
74
+ skrift-0.1.0a14.dist-info/entry_points.txt,sha256=uquZ5Mumqr0xwYTpTcNiJtFSITGfF6_QCCy2DZJSZig,42
75
+ skrift-0.1.0a14.dist-info/RECORD,,