HTML output tweaks
This commit is contained in:
@ -162,6 +162,12 @@ def main():
|
|||||||
loader=FileSystemLoader(os.path.dirname(__file__)),
|
loader=FileSystemLoader(os.path.dirname(__file__)),
|
||||||
autoescape=select_autoescape(['html', 'xml'])
|
autoescape=select_autoescape(['html', 'xml'])
|
||||||
)
|
)
|
||||||
|
# Add markdown filter
|
||||||
|
try:
|
||||||
|
import markdown
|
||||||
|
env.filters['markdown'] = lambda text: markdown.markdown(text or "")
|
||||||
|
except ImportError:
|
||||||
|
env.filters['markdown'] = lambda text: text or ""
|
||||||
template = env.get_template("todoist_backup_template.html")
|
template = env.get_template("todoist_backup_template.html")
|
||||||
html_filename = f"Todoist-Actual-Backup-{today}.html"
|
html_filename = f"Todoist-Actual-Backup-{today}.html"
|
||||||
with open(html_filename, "w", encoding="utf-8") as f:
|
with open(html_filename, "w", encoding="utf-8") as f:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
todoist-api-python
|
todoist-api-python
|
||||||
Jinja2
|
Jinja2
|
||||||
requests
|
requests
|
||||||
|
markdown
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
.completed { color: #888; }
|
.completed { color: #888; }
|
||||||
.attachments { margin: 0.5em 0 0.5em 1em; }
|
.attachments { margin: 0.5em 0 0.5em 1em; }
|
||||||
.comments { margin: 0.5em 0 0.5em 1em; font-size: 0.95em; color: #444; }
|
.comments { margin: 0.5em 0 0.5em 1em; font-size: 0.95em; color: #444; }
|
||||||
.field { font-weight: bold; }
|
.task-name { font-weight: bold; }
|
||||||
|
.field-label { font-style: italic; }
|
||||||
a.attachment-link { color: #2d72d9; text-decoration: underline; }
|
a.attachment-link { color: #2d72d9; text-decoration: underline; }
|
||||||
.meta { color: #666; font-size: 0.95em; }
|
.meta { color: #666; font-size: 0.95em; }
|
||||||
</style>
|
</style>
|
||||||
@ -40,11 +41,42 @@
|
|||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
{% for task in project.tasks %}
|
{% for task in project.tasks %}
|
||||||
<div class="task">
|
<div class="task">
|
||||||
<span class="field">Content:</span> {{ task.content }}<br>
|
<span class="taskname">{{ task.content | markdown | safe }}</span><br>
|
||||||
<span class="meta">ID: {{ task.id }} | Due: {{ task.due }} | Priority: {{ task.priority }}</span><br>
|
{% if task.description %}
|
||||||
|
<div class="taskdesc">{{ task.description | markdown | safe }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<span class="meta">
|
||||||
|
{% set meta_fields = [] %}
|
||||||
|
{% if task.id is not none %}
|
||||||
|
{% set _ = meta_fields.append('ID: ' ~ task.id) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.due and task.due.date %}
|
||||||
|
{% set due_dt = task.due.date %}
|
||||||
|
{% if due_dt.__class__.__name__ == 'datetime' or due_dt.__class__.__name__ == 'date' %}
|
||||||
|
{% set due_fmt = due_dt.strftime('%Y-%m-%d') %}
|
||||||
|
{% else %}
|
||||||
|
{% set due_str = due_dt|string %}
|
||||||
|
{% if 'T' in due_str %}
|
||||||
|
{% set due_fmt = due_str[:10] %}
|
||||||
|
{% else %}
|
||||||
|
{% set due_fmt = due_str %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% set _ = meta_fields.append('Due: ' ~ due_fmt) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.due and task.due.is_recurring %}
|
||||||
|
{% if task.due.string %}
|
||||||
|
{% set _ = meta_fields.append('Recurring: ' ~ task.due.string) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.priority is not none %}
|
||||||
|
{% set _ = meta_fields.append('Priority: ' ~ task.priority) %}
|
||||||
|
{% endif %}
|
||||||
|
{{ meta_fields|join(' | ') }}
|
||||||
|
</span><br>
|
||||||
{% if task.attachments %}
|
{% if task.attachments %}
|
||||||
<div class="attachments">
|
<div class="attachments">
|
||||||
<span class="field">Attachments:</span>
|
<span class="field-name">Attachments:</span>
|
||||||
<ul>
|
<ul>
|
||||||
{% for att in task.attachments %}
|
{% for att in task.attachments %}
|
||||||
<li><a class="attachment-link" href="{{ att.local_file }}" download>{{ att.file_name or att.local_file }}</a></li>
|
<li><a class="attachment-link" href="{{ att.local_file }}" download>{{ att.file_name or att.local_file }}</a></li>
|
||||||
@ -54,7 +86,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if task.comments %}
|
{% if task.comments %}
|
||||||
<div class="comments">
|
<div class="comments">
|
||||||
<span class="field">Comments:</span>
|
<span class="field-name">Comments:</span>
|
||||||
<ul>
|
<ul>
|
||||||
{% for comment in task.comments %}
|
{% for comment in task.comments %}
|
||||||
<li>{{ comment.content }} <span class="meta">({{ comment.posted_at }})</span></li>
|
<li>{{ comment.content }} <span class="meta">({{ comment.posted_at }})</span></li>
|
||||||
@ -69,11 +101,55 @@
|
|||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
{% for task in project.completed_tasks %}
|
{% for task in project.completed_tasks %}
|
||||||
<div class="task completed">
|
<div class="task completed">
|
||||||
<span class="field">Content:</span> {{ task.content }}<br>
|
<span class="task-name">{{ task.content | markdown | safe }}</span><br>
|
||||||
<span class="meta">ID: {{ task.id }} | Due: {{ task.due }} | Priority: {{ task.priority }}</span><br>
|
{% if task.description %}
|
||||||
|
<div class="taskdesc">{{ task.description | markdown | safe }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<span class="meta">
|
||||||
|
{% set meta_fields = [] %}
|
||||||
|
{% if task.id is not none %}
|
||||||
|
{% set _ = meta_fields.append('ID: ' ~ task.id) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.due and task.due.date %}
|
||||||
|
{% set due_dt = task.due.date %}
|
||||||
|
{% if due_dt.__class__.__name__ == 'datetime' or due_dt.__class__.__name__ == 'date' %}
|
||||||
|
{% set due_fmt = due_dt.strftime('%Y-%m-%d %H:%M') if due_dt.__class__.__name__ == 'datetime' else due_dt.strftime('%Y-%m-%d 00:00') %}
|
||||||
|
{% else %}
|
||||||
|
{% set due_str = due_dt|string %}
|
||||||
|
{% if 'T' in due_str %}
|
||||||
|
{% set due_fmt = due_str[:16].replace('T', ' ') %}
|
||||||
|
{% else %}
|
||||||
|
{% set due_fmt = due_str %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% set _ = meta_fields.append('Due: ' ~ due_fmt) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.due and task.due.is_recurring %}
|
||||||
|
{% if task.due.string %}
|
||||||
|
{% set _ = meta_fields.append('Recurring: ' ~ task.due.string) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.priority is not none %}
|
||||||
|
{% set _ = meta_fields.append('Priority: ' ~ task.priority) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if task.completed_at %}
|
||||||
|
{% if task.completed_at.__class__.__name__ == 'datetime' or task.completed_at.__class__.__name__ == 'date' %}
|
||||||
|
{% set completed_fmt = task.completed_at.strftime('%Y-%m-%d') %}
|
||||||
|
{% else %}
|
||||||
|
{% set completed_str = task.completed_at|string %}
|
||||||
|
{% if 'T' in completed_str %}
|
||||||
|
{% set completed_fmt = completed_str[:10] %}
|
||||||
|
{% else %}
|
||||||
|
{% set completed_fmt = completed_str %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% set _ = meta_fields.append('Completed: ' ~ completed_fmt) %}
|
||||||
|
{% endif %}
|
||||||
|
{{ meta_fields|join(' | ') }}
|
||||||
|
</span><br>
|
||||||
{% if task.attachments %}
|
{% if task.attachments %}
|
||||||
<div class="attachments">
|
<div class="attachments">
|
||||||
<span class="field">Attachments:</span>
|
<span class="field-name">Attachments:</span>
|
||||||
<ul>
|
<ul>
|
||||||
{% for att in task.attachments %}
|
{% for att in task.attachments %}
|
||||||
<li><a class="attachment-link" href="{{ att.local_file }}" download>{{ att.file_name or att.local_file }}</a></li>
|
<li><a class="attachment-link" href="{{ att.local_file }}" download>{{ att.file_name or att.local_file }}</a></li>
|
||||||
|
Reference in New Issue
Block a user