Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ __pycache__/
# Django
/db.sqlite3
/static

/jssg/settings.py
16 changes: 16 additions & 0 deletions jssg/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@

import importlib



from django_jinja_markdown.extensions import MarkdownExtension

class JFMEMarkdownExtension(MarkdownExtension):
def _markdown_support(self, caller):
"""
Parse template with markdown.

:param caller: - caller of method;
:return: - parsed template.
"""
from textwrap import dedent # this import should be in the file head, of course
return self.environment.markdowner.convert(dedent(caller())).strip()


def environment(**options):
env = Environment(**options)
env.globals.update(
Expand Down
12 changes: 8 additions & 4 deletions jssg/settings.py → jssg/settings.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

from django.core.management.commands.runserver import Command as runserver

from os import environ
from pathlib import Path
Expand All @@ -40,8 +39,12 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = environ.get("DJANGO_DEBUG", "false") == "true"

ALLOWED_HOSTS = ["example.org", "localhost"]
DEBUG = False
if environ.get("DJANGO_DEBUG"):
DEBUG = True
ALLOWED_HOSTS = ["exemple.org", "localhost"]
# runserver.default_port = '8000'
# runserver.default_addr = '127.0.0.1'

# JSSG
JFME_DOMAIN = "www.exemple.com"
Expand Down Expand Up @@ -91,7 +94,7 @@
"APP_DIRS": True,
"OPTIONS": {
"environment": "jssg.jinja2.environment",
"extensions": ["django_jinja_markdown.extensions.MarkdownExtension"]
"extensions": ["jssg.jinja2.JFMEMarkdownExtension"]
},
},
{
Expand Down Expand Up @@ -168,3 +171,4 @@
DJANGO_VITE_PLUGIN = {
"MANIFEST": VITE_MANIFEST_FILE,
}

Loading