Skip to main content

Minimalistic CMS in Python with Markdown content

Project description

Minimalistic CMS in Python with Markdown content

Features

  • No storages, simple file structure

  • Markdown content with images

  • Static auto-collection

  • Simple pagination

Requirements

  • Python 3.12

  • FastAPI 0.111.0

  • Jinja2 3.1.4

  • Markdown 3.6

  • PyYAML 6.0.1

  • python-slugify 8.0.4

  • pydantic 2.8.2

Install

python3.12 -m venv venv
source venv/bin/activate
pip install lazycms

Usage

Example project structure:

  • project/
    • static/
      • content/ - empty directory, static content will be collected here

      • theme/ - your theme css/js

    • storage/ - your file storage directory
      • article-1/ - entity (article) directory
        • content.md - your article

        • meta.yml - entity metadata

        • picture.jpeg - picture for your article

        • preview.md - entity article miniature for index page

      • article-2/
        • content.md

        • meta.yml

        • picture.jpeg

        • preview.md

    • templates/ - Jinja2 templates directory
      • index.html - entity index template with entity and paginator context objects

      • entity.html - entity template with entity context object

    • app.py - CMS code

    • app.yml - CMS config

project/storage/article-1/content.md:

# Article 1

![Article 1]({{slug_url}}/picture.jpeg "Article 1")

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

project/storage/article-1/preview.md:

![Article 1]({{slug_url}}/picture.jpeg "Article 1")

# Article 1

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam...

project/storage/article-1/meta.yml:

timestamp: !!timestamp 2024-01-01T17:00:00Z
title: Article 1
content: content.md
preview: preview.md
images:
    - picture.jpeg
tags:
    - article
    - test

project/templates/index.html:

{% for entity in entities %}
    <article>
        {{ entity.preview|safe }}
    </article>
{% endfor %}

{% if paginator.page > 1 %}
    <a href="/?page={{ paginator.page - 1 }}">Prev</a>
{% else %}
    Prev
{% endif %}
{% if paginator.page < paginator.page_count %}
    <a href="/?page={{ paginator.page + 1 }}">Next</a>
{% else %}
    Next
{% endif %}

project/templates/entity.html:

<article>
    {{ entity.content|safe }}
</article>

project/app.yml:

# Storage config
storage_type: FILE
storage_path: ./storage
storage_meta: meta.yml
# Static config
static_path: ./static
static_url: /static
# Static collected content config
collect_path: ./static/content
collect_url: /static/content
# Templates
templates_path: ./templates
# Pagination
paginate: 10

project/app.py:

from lazycms import LazyCMS


cms = LazyCMS(config_path='app.yml')

Run:

uvicorn app:cms.app --reload

http://localhost:8000 - index page

http://localhost:8000/2024-01-01-article-1 - Article 1 page

http://localhost:8000/2024-01-02-article-2 - Article 2 page

Tests

TBD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lazycms-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

lazycms-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file lazycms-0.1.0.tar.gz.

File metadata

  • Download URL: lazycms-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for lazycms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 788d88a209957e42d131e206c022cdd89f0518e4c95e2439c2bd642ed11d0e6c
MD5 7239d4942a0c638f35c6086c982709b1
BLAKE2b-256 31c634d63c4044674d561907e72b86c84f139c05d0e2cde76c9fa2fb604117da

See more details on using hashes here.

File details

Details for the file lazycms-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lazycms-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for lazycms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 083947b2d50dbda7296bc445ada8fe2060113313fe7ce4db4cbc3c92fcf44e2e
MD5 eda295e67b1dc0cbac17dfff1e9be5d3
BLAKE2b-256 b8ad17f05010aaafb1e006cc85109c4df22b7c25c59d1af80d796505d6a10825

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page