Fix templates in virtualenv
This commit is contained in:
parent
e158a0b8d8
commit
6c589a7dca
9 changed files with 75 additions and 21 deletions
6
MANIFEST.in
Normal file
6
MANIFEST.in
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
graft templates
|
||||||
|
include LICENSE
|
||||||
|
include README.md
|
||||||
|
include podman_build.sh
|
||||||
|
include podman_run.sh
|
||||||
|
include Dockerfile
|
45
README.md
45
README.md
|
@ -1,23 +1,50 @@
|
||||||
# mastodon_email_bridge
|
# mastodon_email_bridge
|
||||||
|
|
||||||
|
Simple script to forward your Mastodon Home timeline to your email.
|
||||||
|
|
||||||
## Requirements
|
## 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
|
## Installation
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo python3 setup.py install
|
python -m venv "${HOME}/pyenvs/mastodon_email_bridge"
|
||||||
```
|
source "${HOME}/pyenvs/mastodon_email_bridge/bin/activate"
|
||||||
|
pip install .
|
||||||
### Windows (from PowerShell)
|
mkdir -p "${HOME}/.config/mastodon_email_bridge"
|
||||||
|
cp -r templates "${HOME}/.config/mastodon_email_bridge/"
|
||||||
```powershell
|
|
||||||
& $(where.exe python).split()[0] setup.py install
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## 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.
|
||||||
```
|
```
|
||||||
|
|
|
@ -18,7 +18,7 @@ import sqlite3
|
||||||
import click
|
import click
|
||||||
import click_config_file
|
import click_config_file
|
||||||
import requests
|
import requests
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader
|
||||||
|
|
||||||
class MastodonEmailBridge:
|
class MastodonEmailBridge:
|
||||||
'''CLass to redirect the Mastodon home timeline to email'''
|
'''CLass to redirect the Mastodon home timeline to email'''
|
||||||
|
@ -50,8 +50,24 @@ class MastodonEmailBridge:
|
||||||
)
|
)
|
||||||
self._init_log()
|
self._init_log()
|
||||||
self._get_sent_posts()
|
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(
|
self.j2env = Environment(
|
||||||
loader=PackageLoader("mastodon_email_bridge"),
|
#loader=PackageLoader("mastodon_email_bridge"),
|
||||||
|
loader=FileSystemLoader(templates_folder, followlinks=True),
|
||||||
autoescape=select_autoescape()
|
autoescape=select_autoescape()
|
||||||
)
|
)
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|
|
@ -3,12 +3,12 @@ requires = ["setuptools", "wheel"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = ""
|
Homepage = "https://codeberg.org/adelgado/mastodon_email_bridge"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "mastodon_email_bridge"
|
name = "mastodon_email_bridge"
|
||||||
version = "0.0.1"
|
version = "0.0.3"
|
||||||
description = "Redirect the home timeline to email"
|
description = "Redirect your Mastodon Home timeline to your email"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
|
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
|
@ -17,9 +17,11 @@ classifiers = [
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
]
|
]
|
||||||
#keywords = ["vCard", "contacts", "duplicates"]
|
keywords = ["Mastodon", "email", "fediverse", "ActivityPub"]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"click",
|
"click",
|
||||||
"click_config_file",
|
"click_config_file",
|
||||||
|
"requests",
|
||||||
|
"jinja2",
|
||||||
]
|
]
|
||||||
requires-python = ">=3"
|
requires-python = ">=3"
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
click
|
click
|
||||||
click_config_file
|
click_config_file
|
||||||
|
requests
|
||||||
|
jinja2
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = mastodon_email_bridge
|
name = mastodon_email_bridge
|
||||||
version = 0.0.1
|
version = 0.0.3
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = mastodon_email_bridge
|
packages = mastodon_email_bridge
|
||||||
|
|
7
setup.py
7
setup.py
|
@ -14,10 +14,11 @@ setuptools.setup(
|
||||||
version=config['metadata']['version'],
|
version=config['metadata']['version'],
|
||||||
name=config['metadata']['name'],
|
name=config['metadata']['name'],
|
||||||
author_email="ad@susurrando.com",
|
author_email="ad@susurrando.com",
|
||||||
url="",
|
url="https://codeberg.org/adelgado/mastodon_email_bridge",
|
||||||
description="Redirect the home timeline to email",
|
description="Redirect your Mastodon Home timeline to your email",
|
||||||
long_description="README.md",
|
long_description="README.md",
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
# keywords=["my", "script", "does", "things"]
|
keywords=["Mastodon", "email", "fediverse", "ActivityPub"],
|
||||||
|
include_package_data=True,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue