adamghill / coltrane Goto Github PK
View Code? Open in Web Editor NEWA minimal app framework for content sites.
Home Page: https://coltrane.readthedocs.io/en/stable/
License: MIT License
A minimal app framework for content sites.
Home Page: https://coltrane.readthedocs.io/en/stable/
License: MIT License
https://github.com/executablebooks/markdown-it-py might be a faster alternative to the markdown2
package which would be helpful for sites with lots of content.
Maybe via https://lunr.readthedocs.io/?
Look through https://gohugo.io/content-management/front-matter/ and see what makes sense (and is easy) to support.
Some of these might not need explicit support, but could just be added to documentation.
After skimming the list:
datetime
, could be used by url?)bool
, respected by output command?)datetime
, respected by output command)It'd be nice to give an option so that the number of threads used could be tweaked if needed. If it's 1
, should it just use the single-threaded code path?
Management command to render all markdown to HTML for actually serving static HTML files.
Currently the exclude parameter only excludes a single file based on its slug, perhaps it could take a comma separated list of slugs to exclude ๐ค.
Use https://pypi.org/project/svgsprite/? Part of record
? Another CLI command? Should collectstatic
also be wrapped?
Hi @adamghill, hope you are doing great.
I'm trying to register custom template tags and I have no idea where to put the templatetags
directory, I tried to put in the directory configure as my BASE_DIR
but I'm getting this:
django.template.exceptions.TemplateSyntaxError: Invalid filter: 'test'
I tried with the test
filter from the docs.
Sphinx + MyST + django-docs?
I'm not sure where this is coming from, but it seems to be related to loading template tags from the templatetags
directory.
โฏ coltrane build
Module templatetags.__init__ does not have a variable named 'register'
Traceback (most recent call last):
File "/Users/tobi/Library/Caches/pypoetry/virtualenvs/coltrane-nNxGrMSQ-py3.10/lib/python3.10/site-packages/django/template/library.py", line 324, in import_library
return module.register
AttributeError: module 'templatetags.__init__' has no attribute 'register'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/tobi/Builds/coltrane/coltrane/__init__.py", line 101, in _get_default_template_settings
module_name = _get_template_tag_module_name(
File "/Users/tobi/Builds/coltrane/coltrane/__init__.py", line 83, in _get_template_tag_module_name
import_library(module_name)
File "/Users/tobi/Library/Caches/pypoetry/virtualenvs/coltrane-nNxGrMSQ-py3.10/lib/python3.10/site-packages/django/template/library.py", line 326, in import_library
raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Module templatetags.__init__ does not have a variable named 'register'
Start generating the static site...
โ Use output directory of /Users/tobi/Builds/coltrane/example_standalone/output
โ Load manifest
โ Copy 0 static files, 2 unmodified
โ Create 1 HTML files, 1 unmodified, 0 updated
โ Update sitemap.xml
โ Update rss.xml
โ Update output.json manifest
Static site output completed in 0.6806s
the culprit
def _get_template_tag_module_name(base_dir: Path, file: Path) -> str:
"""
Get a dot notation module name if a particular file path is a template tag.
"""
# TODO: Cleaner way to convert a string path to a module dot notation?
module_name = str(file)
if str(base_dir) != ".":
module_name = module_name.replace(str(base_dir), "")
module_name = module_name.replace("/", ".")
if module_name.startswith("."):
module_name = module_name[1:]
if module_name.endswith(".py"):
module_name = module_name[:-3]
else:
raise InvalidTemplateLibrary()
import_library(module_name)
return module_name
Building the static site works well except for this small error, already fixed in my fork but perhaps it was intentional?
โ Use output directory of /Users/tobi/Builds/coltrane/example_standalone/output
โ Load manifest
โ Copy 2 static files
โ Create 2 HTML files, 0 unmodified, 0 updated
โ Update sitemap.xml
โ Update rss.xml
โ Update output.json manifest
โ Rendering /Users/tobi/Builds/coltrane/example_standalone/content/index.md failed. 'debug' does not exist in template context. Available top level variables: False, None, STATIC_URL, True, csrf_token, data, h1, now, number, numbers, request, slug, template, test_string, toc
just a debug
variable missing in the context, I add it in the frontmatter to fix the error
Generate MD5 hashes or store the modified datetime of each file somewhere to prevent re-generating the files if at all possible.
Hi there, I'm getting a TemplateSyntaxError when I'm trying to use Django template tags in a code block in a markdown file, e.g.
```html
<!-- templates/home.html -->
{% extends 'base.html' %}
~```
Any ideas how I could escape the Django template tag, but still display the correct syntax in the resulting html file?
This would allow a markdown file to link to its parent directory.
I'm thinking this could just be a defined directory structure for templates + static assets?
Should django-compressor/libsass be available as an extra?
Hi, hope you are doing great, I really like the idea behind this package, always wanted a static site generator with django. I try to integrate coltrane to a simple django project (the project was generated with adamchainz simple-core template). The project is really simple, there is no custom code, I created the content directory at the root and add two simple markdown files (index.md and simple-text.md), when I try to visit the corresponding urls I get a 500 error (nothing in the console to help), coltrane seems to be working though, when I visit a non existent route I get a 404. The project code is here, I would love if you could help me solve this issue. Thanks
Convert markdown to html.
Either last_updated_date
or modified_date
.
Some more thoughts #29 (comment) and #29 (comment).
Hello, thanks for making this, I find Coltrane very useful in my current project.
I have an issue with the assumptions Coltrane makes about paths. I saved the *.md
files in the myrepo/coltrane
subfolder and have no problem serving it on the urls I want. But I also have a myrepo/data
subfolder that contains non-related .json files. It appears that retriever.py
on line 44 is reading in all json files in myrepo/data
and all its subfolders. I randomly had a few empty json files there and coltrane crashed on loading with a "JSONDecodeError".
It would be nice to be have the ability in settings.py
to overwrite the defaults that currently use settings.BASE_DIR / 'data'
and settings.BASE_DIR / 'content'
.
Maybe you could also catch the error when reading an empty json file.
Hi there! ๐๏ธ
I set COLTRANE_CONTENT_DIRECTORY to a different value (in my case, help_content
) and doing this doesn't change anything. Changing the environment variable to a non-existent directory does nothing, it still reads from content
, and renaming the content
directory, no matter what the environment variable is set to, makes things crash.
Wanted to make sure and file this bug. If I find time later, I might take a crack at fixing it myself. ๐ง๏ธ
The install instructions for static and standalone sites both ask the user to execute curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
, but this installer is deprecated and will be removed 'on or after January 2023.' The new suggested installation is curl -sSL https://install.python-poetry.org | python3 -
.
On WSL (Windows Subsystem for Linux) using Ubuntu, running that I received the output:
To get started you need Poetry's bin directory (/home/acmshar/.local/bin) in your
PATH
environment variable.
Add
export PATH="/home/acmshar/.local/bin:$PATH"
to your shell configuration file.
Alternatively, you can call Poetry explicitly with
/home/acmshar/.local/bin/poetry
.
It might be worth adding a note in the new instructions to follow the directions from that output so that new users know to look for it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.