Fix templates in virtualenv

This commit is contained in:
Antonio J. Delgado 2024-08-02 20:07:20 +03:00
parent e158a0b8d8
commit 6c589a7dca
9 changed files with 75 additions and 21 deletions

6
MANIFEST.in Normal file
View file

@ -0,0 +1,6 @@
graft templates
include LICENSE
include README.md
include podman_build.sh
include podman_run.sh
include Dockerfile

View file

@ -1,23 +1,50 @@
# mastodon_email_bridge
Simple script to forward your Mastodon Home timeline to your email.
## Requirements
You need to obtain an application token with read access and provide it with the --token parameter.
Check the requirements.txt file but the installation should take care of everything.
## Installation
### Linux
```bash
sudo python3 setup.py install
```
### Windows (from PowerShell)
```powershell
& $(where.exe python).split()[0] setup.py install
python -m venv "${HOME}/pyenvs/mastodon_email_bridge"
source "${HOME}/pyenvs/mastodon_email_bridge/bin/activate"
pip install .
mkdir -p "${HOME}/.config/mastodon_email_bridge"
cp -r templates "${HOME}/.config/mastodon_email_bridge/"
```
## Usage
```bash
mastodon_email_bridge.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters
```
Usage: mastodon_email_bridge.py [OPTIONS]
Options:
-d, --debug-level [CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET]
Set the debug level for the standard output.
-t, --token TEXT Mastodon token with read access. [required]
-s, --server TEXT Mastodon server full qualified name.
-L, --limit INTEGER Mastodon token with read access.
-w, --wait INTEGER Seconds to wait between requests to avoid
rate limits.
-r, --recipient TEXT Recipient email to get the posts.
[required]
-S, --sender TEXT Sender email thant send the posts.
-f, --sent-items-file TEXT File to store the IDs of post already sent
by email.
-m, --mail-server TEXT SMTP Mail server to send emails.
-u, --mail-user TEXT Username for SMTP Mail server to send
emails.
-P, --mail-pass TEXT User password for SMTP Mail server to send
emails.
-p, --mail-server-port INTEGER SMTP Mail server port to send emails.
-l, --log-file TEXT File to store all debug messages.
--config FILE Read configuration from FILE.
--help Show this message and exit.
```

View file

@ -18,7 +18,7 @@ import sqlite3
import click
import click_config_file
import requests
from jinja2 import Environment, PackageLoader, select_autoescape
from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader
class MastodonEmailBridge:
'''CLass to redirect the Mastodon home timeline to email'''
@ -50,8 +50,24 @@ class MastodonEmailBridge:
)
self._init_log()
self._get_sent_posts()
templates_folder = os.path.join(
os.environ.get(
'HOME',
os.environ.get(
'USERPROFILE',
os.getcwd()
)
),
'.config',
'mastodon_email_bridge',
'templates'
)
if not os.path.exists(templates_folder):
os.mkdir(templates_folder)
self.j2env = Environment(
loader=PackageLoader("mastodon_email_bridge"),
#loader=PackageLoader("mastodon_email_bridge"),
loader=FileSystemLoader(templates_folder, followlinks=True),
autoescape=select_autoescape()
)
self.session = requests.Session()

View file

@ -3,12 +3,12 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project.urls]
Homepage = ""
Homepage = "https://codeberg.org/adelgado/mastodon_email_bridge"
[project]
name = "mastodon_email_bridge"
version = "0.0.1"
description = "Redirect the home timeline to email"
version = "0.0.3"
description = "Redirect your Mastodon Home timeline to your email"
readme = "README.md"
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
license = { file = "LICENSE" }
@ -17,9 +17,11 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
#keywords = ["vCard", "contacts", "duplicates"]
keywords = ["Mastodon", "email", "fediverse", "ActivityPub"]
dependencies = [
"click",
"click_config_file",
"requests",
"jinja2",
]
requires-python = ">=3"
requires-python = ">=3"

View file

@ -1,2 +1,4 @@
click
click_config_file
click_config_file
requests
jinja2

View file

@ -1,6 +1,6 @@
[metadata]
name = mastodon_email_bridge
version = 0.0.1
version = 0.0.3
[options]
packages = mastodon_email_bridge

View file

@ -14,10 +14,11 @@ setuptools.setup(
version=config['metadata']['version'],
name=config['metadata']['name'],
author_email="ad@susurrando.com",
url="",
description="Redirect the home timeline to email",
url="https://codeberg.org/adelgado/mastodon_email_bridge",
description="Redirect your Mastodon Home timeline to your email",
long_description="README.md",
long_description_content_type="text/markdown",
license="GPLv3",
# keywords=["my", "script", "does", "things"]
keywords=["Mastodon", "email", "fediverse", "ActivityPub"],
include_package_data=True,
)