Skip to content

Commit

Permalink
Open source emark package
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Oct 1, 2022
1 parent 8a43349 commit 4b97d7e
Show file tree
Hide file tree
Showing 30 changed files with 1,765 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf
max_line_length = 88

[*.{json,yml,yaml,js,jsx,vue,toml}]
indent_size = 2

[*.{html,htm,svg,xml}]
indent_size = 2
max_line_length = 120

[LICENSE]
insert_final_newline = false

[*.{md,markdown}]
indent_size = 2
max_line_length = 80

[Makefile]
indent_style = tab
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github:
- amureki
- codingjoe
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:

dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: sudo apt install gettext -y
- run: python -m pip install --upgrade pip build wheel twine
- run: make gettext
- run: python -m build --sdist --wheel
- run: python -m twine check dist/*
- uses: actions/upload-artifact@v3
with:
path: dist/*

lint:
runs-on: ubuntu-latest
strategy:
matrix:
lint-command:
- bandit -r . -x ./tests
- black --check --diff .
- flake8 .
- isort --check-only --diff .
- pydocstyle .
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'linter-requirements.txt'
- run: python -m pip install -r linter-requirements.txt
- run: ${{ matrix.lint-command }}

pytest:
needs:
- lint
strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
- "3.10"
django-version:
- "3.2" # LTS
- "4.0"
- "4.1"
extras:
- "test"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install .[${{ matrix.extras }}]
- run: python -m pip install django~=${{ matrix.django-version }}.0
- run: python -m pytest
- uses: codecov/codecov-action@v3
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
release:
types: [published]

jobs:
PyPi:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: sudo apt install gettext -y
- run: python -m pip install --upgrade pip build wheel twine
- run: make gettext
- run: python -m build --sdist --wheel
- run: python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# flit
emark/_version.py
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MSGLANGS = $(wildcard emark/locale/*/LC_MESSAGES/*.po)
MSGOBJS = $(MSGLANGS:.po=.mo)

.PHONY: translations gettext gettext-clean

gettext: $(MSGOBJS)

gettext-clean:
-rm $(MSGOBJS)

%.mo: %.po
msgfmt --check-format --check-domain --statistics -o $@ $*.po
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# emark
Markdown template based HTML and text emails for Django.

* simple email templates with markdown
* support for HTML and text emails
* i18n support
* built-in UTM tracking

[![PyPi Version](https://img.shields.io/pypi/v/emark.svg)](https://pypi.python.org/pypi/emark/)
[![Test Coverage](https://codecov.io/gh/voiio/emark/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/emark)
[![GitHub License](https://img.shields.io/github/license/voiio/emark)](https://raw.githubusercontent.com/voiio/emark/master/LICENSE)

## Setup

```shell
python3 -m pip install emark
```

```python
# settings.py
INSTALLED_APPS = [
'emark',
# ...
]
```

```shell
python3 manage.py migrate
```

## Usage

```markdown
<!-- myapp/email.md -->
# Hello World

Hi {{ user.short_name }}!
```

```python
# myapp/emails.py
from emark.message import MarkdownEmail

class MyMessage(MarkdownEmail):
subject = "Hello World"
template_name = "myapp/email.md"


# render and send the email
MyMessage(language="en", to=["peter.parker@avengers.com"]).send()
```
6 changes: 6 additions & 0 deletions emark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Markdown template based HTML and text emails for Django."""

from . import _version

__version__ = _version.version
VERSION = _version.version_tuple
43 changes: 43 additions & 0 deletions emark/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Markdown template based HTML and text emails for Django.
# Copyright (C) 2022 voiio GmbH
# This file is distributed under the same license as the PACKAGE package.
# Johannes Maorn <johannes@maron.family>, 2022.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-01 17:27+0200\n"
"PO-Revision-Date: 2022-10-01 17:28+0200\n"
"Last-Translator: Johannes Maron <johannes@maron.family>\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.1.1\n"

#: models.py:7
msgid "amount sent"
msgstr "gesendete Anzahl"

#: models.py:9
msgid "utm campaign name"
msgstr "UTM-Kampagnenname"

#: models.py:11
msgid "UTM campaign name matches the email class name."
msgstr "Der Name der UTM-Kampagne stimmt mit dem Namen der E-Mail-Klasse überein."

#: models.py:15
msgid "modified"
msgstr "geändert"

#: models.py:21
msgid "created"
msgstr "erstellt"

#: models.py:35
msgid "language"
msgstr "Sprache"
Loading

0 comments on commit 4b97d7e

Please sign in to comment.