Compare commits

..
25 Commits
Author SHA1 Message Date
retoor 568835855c chore: fix template variable assignment to use context dict instead of direct reference 2025-02-25 18:42:47 +00:00
retoor 4cc9224384 chore: remove trailing whitespace and unused imports from dreamii source files 2025-02-25 18:39:40 +00:00
retoor 10ebe3cc14 feat: fix indentation of file write block in TemplateView render method 2025-02-09 23:39:18 +00:00
retoor 2c17a7350c fix: move jinja2 globals assignment before markdown rendering to fix undefined request and context in python extension 2025-02-09 23:37:44 +00:00
retoor 20ac17c8e8 fix: register request and context as Jinja2 globals in TemplateView and Dreamii init 2025-02-09 23:34:17 +00:00
retoor 98b6c1ce26 fix: correct jinja2_env globals assignment syntax in TemplateView 2025-02-09 23:31:07 +00:00
retoor f450f40179 feat: expose request and context globals in jinja2 env and fix PythonExtension init
- Add request and context to jinja2_env.globals in TemplateView for template access
- Fix PythonExtension.__init__ to store environment as instance attribute instead of SimpleNamespace
- Remove unused SimpleNamespace import and commented-out context assignment
- Retrieve request and context from environment globals in _to_html method
2025-02-09 23:28:57 +00:00
retoor 0e0efe88e8 feat: expose environment variable in PythonExtension execute method for template access 2025-02-09 23:17:56 +00:00
retoor 966a72b708 fix: remove deleted base.html template and fix markdown rendering in app.py 2025-01-27 23:42:24 +00:00
retoor 3cba8b3cfb fix: fix typo in variable name and add debug prints in TemplateView
Correct the misspelled variable `reponse` to `response` in the `render_template` method of `TemplateView` class. Also add three debug print statements to log template path resolution results, including found paths, non-template paths, and missing paths for improved debugging during development.
2025-01-27 22:49:11 +00:00
retoor 7a7092b24a feat: remove extraneous context argument from MarkdownRenderer web.Response call 2025-01-27 22:45:30 +00:00
retoor 2ed73197a7 feat: add content type detection and validation for uploaded files 2025-01-27 22:41:49 +00:00
retoor f16ac21bbd feat: add charset utf-8 to html response and pass context to template renderer 2025-01-27 22:31:08 +00:00
retoor aaf5639826 feat: add content_type text/html to markdown renderer response in TemplateView 2025-01-27 18:48:29 +00:00
retoor c68a8e3217 fix: remove extraneous await from MarkdownRenderer.render() call in TemplateView 2025-01-27 18:45:55 +00:00
retoor daf2b06772 fix: convert template_path to pathlib.Path in MarkdownRenderer.render to fix attribute error 2025-01-27 18:44:10 +00:00
retoor 7331d6c1a7 fix: correct misspelling of 'recieve' to 'receive' in user registration handler error message string 2025-01-27 18:42:04 +00:00
retoor f1bfbad12b fix: correct typo in README shell command from 'echo >' to 'echo' for proper markdown file creation 2025-01-27 18:40:33 +00:00
retoor a0e762c41e fix: add markdown file detection and rendering in TemplateView before template fallback 2025-01-27 18:39:34 +00:00
retoor 0ce3bd9353 fix: add missing code block closing backticks in README example section 2025-01-27 18:33:54 +00:00
retoor 8378cde372 fix: add missing closing code fence to README example block
The diff adds a closing triple backtick to the Python example in the README, which was previously unterminated and would break markdown rendering of the code block.
2025-01-27 18:33:32 +00:00
retoor 46e5d21bc6 fix: switch run command from main.py to dreamii module and remove unused fetch module 2025-01-27 18:32:42 +00:00
retoor 5f3ddd15ba chore: add initial Dreamii CMS project scaffold with Jinja2 markdown and Python execution extensions 2025-01-27 18:27:26 +00:00
retoor 13cabb826e docs: update README with separate usage and development setup instructions 2025-01-27 17:29:53 +00:00
retoor 41d8f46b46 feat: initialize project structure with core application scaffolding
- Create README.md with project description, features, and usage examples
- Set up basic directory layout for template rendering engine
- Define core concepts: markdown-first resolution, dynamic Python support, and CVS integration
2025-01-27 17:25:40 +00:00
2 changed files with 10 additions and 14 deletions
+8 -6
View File
@@ -54,15 +54,17 @@ class TemplateView(BaseView):
context = {} context = {}
context['request'] = self.request context['request'] = self.request
context['post'] = await self.request.post() context['post'] = await self.request.post()
context["template"] = pathlib.Path(path)
if not context['post']: if not context['post']:
context['post'] = None context['post'] = None
try: try:
context['json'] = await self.request.json() context['json'] = await self.request.json()
except: except:
context['json'] = None context['json'] = None
pass pass
self.request.app.jinja2_env.globals["request"] = self.request self.request.app.jinja2_env.globals["request"] = self.request
self.request.app.jinja2_env.globals["context"] = context self.request.app.jinja2_env.globals["context"] = context
self.request.app.jinja2_env.globals["template"] = context["template"]
if str(path).endswith(".md"): if str(path).endswith(".md"):
renderer = MarkdownRenderer(self.request.app, path) renderer = MarkdownRenderer(self.request.app, path)
@@ -85,7 +87,7 @@ class TemplateView(BaseView):
"<body>{% markdown %}"+content+"{% endmarkdown %}</body>", "<body>{% markdown %}"+content+"{% endmarkdown %}</body>",
"</html>" "</html>"
]) ])
with open(".temp.html", "w+") as f: with open(".temp.html", "w+") as f:
f.write(markdown_default_page) f.write(markdown_default_page)
content = aiohttp_jinja2.render_string(".temp.html",self.request,context=context) content = aiohttp_jinja2.render_string(".temp.html",self.request,context=context)
pathlib.Path(".temp.html").unlink() pathlib.Path(".temp.html").unlink()
+2 -8
View File
@@ -22,10 +22,6 @@
from types import SimpleNamespace from types import SimpleNamespace
from mistune import Markdown
from pygments import highlight
from pygments.formatters import html
from pygments.lexers import get_lexer_by_name
from jinja2 import TemplateSyntaxError, nodes from jinja2 import TemplateSyntaxError, nodes
from jinja2.ext import Extension from jinja2.ext import Extension
from jinja2.nodes import Const from jinja2.nodes import Const
@@ -97,7 +93,6 @@ class PythonExtension(Extension):
] ]
) )
user_source = str(caller()).strip("\n").strip(" ") user_source = str(caller()).strip("\n").strip(" ")
print(user_source)
source = "\n".join([base_source, user_source]) source = "\n".join([base_source, user_source])
import sys import sys
import io import io
@@ -126,14 +121,13 @@ class PythonExtension(Extension):
return html.escape(result.stdout + result.stderr) if stderr else result.stdout return html.escape(result.stdout + result.stderr) if stderr else result.stdout
environment = self.environment environment = self.environment
request = self.environment.globals["request"] request = self.environment.globals["request"]
context = self.environment.globals["context"] context = self.environment.globals["context"]
template = self.environment.globals["template"]
db = self.app.db db = self.app.db
app = self.app app = self.app
dreamii = self.app dreamii = self.app
#context = self.context
exec(base_source) exec(base_source)
exec(user_source) exec(user_source)
result = sys.stdout.getvalue() result = sys.stdout.getvalue()