Add config for folders
This commit is contained in:
parent
273200f8a4
commit
d5aac011a1
3 changed files with 39 additions and 22 deletions
|
@ -51,18 +51,21 @@ class MastodonEmailBridge:
|
|||
)
|
||||
self._init_log()
|
||||
self._get_sent_posts()
|
||||
templates_folder = os.path.join(
|
||||
os.environ.get(
|
||||
'HOME',
|
||||
if 'templates_folder' in self.config:
|
||||
templates_folder=self.config['templates_folder']
|
||||
else:
|
||||
templates_folder = os.path.join(
|
||||
os.environ.get(
|
||||
'USERPROFILE',
|
||||
os.getcwd()
|
||||
)
|
||||
),
|
||||
'.config',
|
||||
'mastodon_email_bridge',
|
||||
'templates'
|
||||
)
|
||||
'HOME',
|
||||
os.environ.get(
|
||||
'USERPROFILE',
|
||||
os.getcwd()
|
||||
)
|
||||
),
|
||||
'.config',
|
||||
'mastodon_email_bridge',
|
||||
'templates'
|
||||
)
|
||||
if not os.path.exists(templates_folder):
|
||||
os.mkdir(templates_folder)
|
||||
|
||||
|
@ -187,16 +190,19 @@ class MastodonEmailBridge:
|
|||
data=data,
|
||||
json_raw=json.dumps(data, indent=2)
|
||||
)
|
||||
sent_folder = os.path.join(
|
||||
os.environ.get(
|
||||
'HOME',
|
||||
if 'sent_folder' not in self.config:
|
||||
sent_folder = os.path.join(
|
||||
os.environ.get(
|
||||
'USERPROFILE',
|
||||
os.getcwd()
|
||||
)
|
||||
),
|
||||
'.mastodon_email_bridge_sent_items'
|
||||
)
|
||||
'HOME',
|
||||
os.environ.get(
|
||||
'USERPROFILE',
|
||||
os.getcwd()
|
||||
)
|
||||
),
|
||||
'.mastodon_email_bridge_sent_items'
|
||||
)
|
||||
else:
|
||||
sent_folder = self.config['sent_folder']
|
||||
if not os.path.exists(sent_folder):
|
||||
os.mkdir(sent_folder)
|
||||
sent_file = os.path.join(sent_folder, data['id'] + '.html')
|
||||
|
@ -328,6 +334,17 @@ class MastodonEmailBridge:
|
|||
default='{{ data["account"]["display_name"] }} ({{ data["account"]["username"] }}) {% if data["in_reply_to_id"] %}replied {% else %}posted{% endif %}{% for tag in data["tags"] %} #{{ tag["name"] }}{% endfor %}',
|
||||
help='Jinja2 template for the subject of the emails.'
|
||||
)
|
||||
@click.option(
|
||||
'--sent-folder',
|
||||
'-F',
|
||||
help='Folder to store generated HTML files to be sent.'
|
||||
)
|
||||
@click.option(
|
||||
'--templates-folder',
|
||||
'-T',
|
||||
help='Folder with the templates to generate HTML and text files to be sent.'
|
||||
)
|
||||
|
||||
@click.option('--log-file', '-l', help="File to store all debug messages.")
|
||||
# @click.option("--dummy","-n", is_flag=True,
|
||||
# help="Don't do anything, just show what would be done.")
|
||||
|
|
|
@ -7,7 +7,7 @@ Homepage = "https://codeberg.org/adelgado/mastodon_email_bridge"
|
|||
|
||||
[project]
|
||||
name = "mastodon_email_bridge"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
description = "Redirect your Mastodon Home timeline to your email"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = mastodon_email_bridge
|
||||
version = 1.0.0
|
||||
version = 1.0.1
|
||||
|
||||
[options]
|
||||
packages = mastodon_email_bridge
|
||||
|
|
Loading…
Reference in a new issue