diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 41e1117..7269bb6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,7 +43,7 @@ jobs: - name: Build the site with RenderEngine working-directory: site - run: python __init__.py + run: render-engine build __init__:site - name: Upload artifact uses: actions/upload-pages-artifact@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82fb95e..3deb1b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,4 +20,4 @@ jobs: - name: Build the site with RenderEngine working-directory: site - run: python __init__.py + run: render-engine build __init__:site diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b993f1..432d2ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,11 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks +default_language_version: + python: python3.10 + repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -11,14 +14,13 @@ repos: files: requirements.*.in - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.1.0 hooks: - id: black name: Format Python - language_version: python3.10 - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort name: Format Python imports @@ -26,11 +28,13 @@ repos: - --profile=black - repo: https://github.com/jazzband/pip-tools - rev: 6.9.0 + rev: 6.12.3 hooks: - id: pip-compile name: Compile site requirements files: requirements.(in|txt) + args: + - --resolver=backtracking - id: pip-compile name: Compile automation requirements @@ -38,6 +42,7 @@ repos: args: - requirements-automate.in - --output-file=requirements-automate.txt + - --resolver=backtracking - id: pip-compile alias: pip-compile-upgrade @@ -46,6 +51,7 @@ repos: stages: [manual] args: - --upgrade + - --resolver=backtracking - id: pip-compile alias: pip-compile-upgrade @@ -56,9 +62,10 @@ repos: - requirements-automate.in - --upgrade - --output-file=requirements-automate.txt + - --resolver=backtracking - repo: https://github.com/Riverside-Healthcare/djlint - rev: v1.19.3 + rev: v1.19.16 hooks: - id: djlint-jinja name: Autoformat jinja files diff --git a/requirements-automate.in b/requirements-automate.in index 150bdb3..faecdf3 100644 --- a/requirements-automate.in +++ b/requirements-automate.in @@ -1,5 +1,5 @@ # These are the requirements to run the automation tasks -r requirements.txt -gh-issues +gh-issues==0.0.3.dev16 typer diff --git a/requirements-automate.txt b/requirements-automate.txt index 3f7ce0c..314e1df 100644 --- a/requirements-automate.txt +++ b/requirements-automate.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # -# pip-compile --output-file=requirements-automate.txt requirements-automate.in +# pip-compile --output-file=requirements-automate.txt --resolver=backtracking requirements-automate.in # anyio==3.6.2 # via httpcore @@ -11,14 +11,28 @@ certifi==2022.12.7 # httpcore # httpx click==8.1.3 - # via typer + # via + # -r requirements.txt + # typer +dtyper==2.1.0 + # via + # -r requirements.txt + # render-engine gh-issues==0.0.3.dev16 # via -r requirements-automate.in +gitdb==4.0.10 + # via + # -r requirements.txt + # gitpython +gitpython==3.1.31 + # via + # -r requirements.txt + # render-engine h11==0.14.0 # via httpcore httpcore==0.16.3 # via httpx -httpx==0.23.1 +httpx==0.23.3 # via gh-issues idna==3.4 # via @@ -28,56 +42,75 @@ jinja2==3.1.2 # via # -r requirements.txt # render-engine -markdown-it-py==2.1.0 - # via gh-issues -markdown2==2.4.6 +markdown-it-py==2.2.0 + # via + # -r requirements.txt + # gh-issues + # rich +markdown2==2.4.8 # via # -r requirements.txt # render-engine -markupsafe==2.1.1 +markupsafe==2.1.2 # via # -r requirements.txt # jinja2 mdurl==0.1.2 - # via markdown-it-py -more-itertools==9.0.0 + # via + # -r requirements.txt + # markdown-it-py +more-itertools==9.1.0 # via # -r requirements.txt # render-engine -pendulum==2.1.2 +pluggy==1.0.0 # via # -r requirements.txt # render-engine +pygments==2.14.0 + # via + # -r requirements.txt + # rich pytailwindcss==0.1.4 - # via -r requirements.txt -python-dateutil==2.8.2 # via # -r requirements.txt - # pendulum -python-frontmatter==1.0.0 + # render-engine-tailwindcss +python-dateutil==2.8.2 # via # -r requirements.txt # render-engine -python-slugify==7.0.0 +python-frontmatter==1.0.0 # via # -r requirements.txt # render-engine -pytzdata==2020.1 +python-slugify==8.0.1 # via # -r requirements.txt - # pendulum + # render-engine pyyaml==6.0 # via # -r requirements.txt # python-frontmatter -render-engine==2022.12.5 +render-engine==2023.3.1b14 + # via + # -r requirements.txt + # render-engine-tailwindcss +render-engine-tailwindcss==2023.1.1 # via -r requirements.txt rfc3986[idna2008]==1.5.0 # via httpx +rich==13.3.2 + # via + # -r requirements.txt + # render-engine six==1.16.0 # via # -r requirements.txt # python-dateutil +smmap==5.0.0 + # via + # -r requirements.txt + # gitdb sniffio==1.3.0 # via # anyio @@ -88,4 +121,8 @@ text-unidecode==1.3 # -r requirements.txt # python-slugify typer==0.7.0 - # via -r requirements-automate.in + # via + # -r requirements-automate.in + # -r requirements.txt + # dtyper + # render-engine diff --git a/requirements.in b/requirements.in index c1bfeee..9e5cd78 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,4 @@ # These are the packages needed to build the website -pytailwindcss -render-engine +render-engine-tailwindcss +render_engine==2023.3.1b14 diff --git a/requirements.txt b/requirements.txt index 1df2f2b..5e292c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,34 +1,58 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # -# pip-compile +# pip-compile --resolver=backtracking # +click==8.1.3 + # via typer +dtyper==2.1.0 + # via render-engine +gitdb==4.0.10 + # via gitpython +gitpython==3.1.31 + # via render-engine jinja2==3.1.2 # via render-engine -markdown2==2.4.6 +markdown-it-py==2.2.0 + # via rich +markdown2==2.4.8 # via render-engine -markupsafe==2.1.1 +markupsafe==2.1.2 # via jinja2 -more-itertools==9.0.0 +mdurl==0.1.2 + # via markdown-it-py +more-itertools==9.1.0 # via render-engine -pendulum==2.1.2 +pluggy==1.0.0 # via render-engine +pygments==2.14.0 + # via rich pytailwindcss==0.1.4 - # via -r requirements.in + # via render-engine-tailwindcss python-dateutil==2.8.2 - # via pendulum + # via render-engine python-frontmatter==1.0.0 # via render-engine -python-slugify==7.0.0 +python-slugify==8.0.1 # via render-engine -pytzdata==2020.1 - # via pendulum pyyaml==6.0 # via python-frontmatter -render-engine==2022.12.5 +render-engine==2023.3.1b14 + # via + # -r requirements.in + # render-engine-tailwindcss +render-engine-tailwindcss==2023.1.1 # via -r requirements.in +rich==13.3.2 + # via render-engine six==1.16.0 # via python-dateutil +smmap==5.0.0 + # via gitdb text-unidecode==1.3 # via python-slugify +typer==0.7.0 + # via + # dtyper + # render-engine diff --git a/site/__init__.py b/site/__init__.py index 2c28b36..ced1cb2 100644 --- a/site/__init__.py +++ b/site/__init__.py @@ -5,11 +5,15 @@ from render_engine.blog import Blog from render_engine.feeds import RSSFeed from render_engine.page import Page +from render_engine.parsers.markdown import MarkdownPageParser +from render_engine.plugins import CleanOutput from render_engine.site import Site +from render_engine_tailwindcss import TailwindCSS class Site(Site): output_path = "output" + static_path = "static" site_vars: dict = { # TODO: add a new page type that will pull this content in on # build and render it as part of the site. @@ -21,51 +25,51 @@ class Site(Site): "YOUTUBE_URL": "https://www.youtube.com/channel/UCA8N-T_aEhHLzwwn47K-UFw", } - engine = Environment( - loader=FileSystemLoader(["site/templates", "templates"]), - undefined=StrictUndefined, - ) - - def render_static(self, directory): - super().render_static(directory) - for file in Path(directory).glob("**/*.css"): - pytailwindcss.run( - auto_install=True, - tailwindcss_cli_args=[ - "--input", - f"{file.absolute()}", - "--output", - f"{(self.path / file).absolute()}", - ], - ) + plugins = [ + CleanOutput, + TailwindCSS, + ] + + @property + def engine(self) -> Environment: + env = super().engine + env.loader.loaders.insert( + 0, FileSystemLoader(["website/templates", "templates"]) + ) + # NOTE: it seems that setting StrictUndefined now breaks the + # rss rendering. This is temporarily disabled for the sake of + # development until it can be fixed properly. + # env.undefined = StrictUndefined + return env class Feed(RSSFeed): - extension = "xml" + extension = ".xml" + + +site = Site() -if __name__ == "__main__": - site = Site(static="static") +@site.page +class index(Page): + template = "index.html" - @site.page - class index(Page): - template = "index.html" - @site.page - class rss_redirect_notice(Page): - template = "python-community-news-archive.rss" +@site.page +class rss_redirect_notice(Page): + template = "python-community-news-archive.rss" - @property - def url(self): - return Path("python-community-news-archive.rss") + @property + def url(self): + return Path("python-community-news-archive.rss") - @site.collection - class archive(Blog): - has_archive = True - output_path = "./" - content_path = "./content" - template = "new_post.html" - archive_template: str = "archive.html" - feed = Feed - site.render() +@site.collection +class archive(Blog): + PageParser = MarkdownPageParser + has_archive = True + output_path = "./" + content_path = "content" + template = "new_post.html" + archive_template: str = "archive.html" + Feed = Feed diff --git a/site/templates/archive.html b/site/templates/archive.html index bcdf66d..79e2c7d 100644 --- a/site/templates/archive.html +++ b/site/templates/archive.html @@ -5,7 +5,7 @@ {% for post in pages %}
  • - {{ post.title }} + {{ post.title }}

  • {% endfor %} diff --git a/site/templates/base.html b/site/templates/base.html index 368fd88..00289cc 100644 --- a/site/templates/base.html +++ b/site/templates/base.html @@ -7,7 +7,7 @@ {% block header %}{% endblock %} {{ SITE_TITLE }} - +