Add support for webhook embeds

This commit is contained in:
2023-01-22 23:00:03 +01:00
parent 4bc2a7dc6f
commit 269948303e
9 changed files with 804 additions and 42 deletions

@ -236,9 +236,9 @@
type="text"
class="form-control bg-dark border-dark text-muted"
id="custom_message"
value="{% if custom_message %}
{{- custom_message -}}
{% endif %}"/>
{% if custom_message %}
value="{{- custom_message -}}"
{% endif %}/>
</div>
</div>
<!-- Add a hidden feed_url field to the form -->

@ -0,0 +1,301 @@
{% extends "base.html" %}
{% block title %}
| Embed
{% endblock title %}
{% block content %}
<div class="p-2 border border-dark">
<form action="/embed" method="post">
<div class="row pb-2">
<div class="col-sm-12">
<div class="form-text">
<ul class="list-inline">
<br/>
<li>
<code>
{% raw %}
{{feed_author}}
{% endraw %}
</code>{{feed.author}}
</li>
<li>
<code>
{% raw %}
{{feed_added}}
{% endraw %}
</code>{{feed.added}}
</li>
<li>
<code>
{% raw %}
{{feed_last_exception}}
{% endraw %}
</code>{{feed.last_exception}}
</li>
<li>
<code>
{% raw %}
{{feed_last_updated}}
{% endraw %}
</code>{{feed.last_updated}}
</li>
<li>
<code>
{% raw %}
{{feed_link}}
{% endraw %}
</code>{{feed.link}}
</li>
<li>
<code>
{% raw %}
{{feed_subtitle}}
{% endraw %}
</code>{{feed.subtitle}}
</li>
<li>
<code>
{% raw %}
{{feed_title}}
{% endraw %}
</code>{{feed.title}}
</li>
<li>
<code>
{% raw %}
{{feed_updated}}
{% endraw %}
</code>{{feed.updated}}
</li>
<li>
<code>
{% raw %}
{{feed_updates_enabled}}
{% endraw %}
</code>{{feed.updates_enabled}}
</li>
<li>
<code>
{% raw %}
{{feed_url}}
{% endraw %}
</code>{{feed.url}}
</li>
<li>
<code>
{% raw %}
{{feed_user_title}}
{% endraw %}
</code>{{feed.user_title}}
</li>
<li>
<code>
{% raw %}
{{feed_version}}
{% endraw %}
</code>{{feed.version}}
</li>
<br/>
{% if entry %}
<li>
<code>
{% raw %}
{{entry_added}}
{% endraw %}
</code>{{entry.added}}
</li>
<li>
<code>
{% raw %}
{{entry_author}}
{% endraw %}
</code>{{entry.author}}
</li>
<li>
<code>
{% raw %}
{{entry_content}}
{% endraw %}
</code>{{entry.content[0].value|discord_markdown}}
</li>
<li>
<code>
{% raw %}
{{entry_content_raw}}
{% endraw %}
</code>{{entry.content[0].value}}
</li>
<li>
<code>
{% raw %}
{{entry_id}}
{% endraw %}
</code>{{entry.id}}
</li>
<li>
<code>
{% raw %}
{{entry_important}}
{% endraw %}
</code>{{entry.important}}
</li>
<li>
<code>
{% raw %}
{{entry_link}}
{% endraw %}
</code>{{entry.link}}
</li>
<li>
<code>
{% raw %}
{{entry_published}}
{% endraw %}
</code>{{entry.published}}
</li>
<li>
<code>
{% raw %}
{{entry_read}}
{% endraw %}
</code>{{entry.read}}
</li>
<li>
<code>
{% raw %}
{{entry_read_modified}}
{% endraw %}
</code>{{entry.read_modified}}
</li>
<li>
<code>
{% raw %}
{{entry_summary}}
{% endraw %}
</code>{{entry.summary|discord_markdown}}
</li>
<li>
<code>
{% raw %}
{{entry_summary_raw}}
{% endraw %}
</code>{{entry.summary}}
</li>
<li>
<code>
{% raw %}
{{entry_title}}
{% endraw %}
</code>{{entry.title}}
</li>
<li>
<code>
{% raw %}
{{entry_updated}}
{% endraw %}
</code>{{entry.updated}}
</li>
<br/>
<li>
<code>
{% raw %}
{{image_1}}
{% endraw %}
</code>First image in the entry if it exists
</li>
</ul>
{% else %}
Something went wrong, there was no entry found. If this feed has entries and you still see this message, please contact the developer.
{% endif %}
</div>
<label for="title" class="col-sm-6 col-form-label">Title</label>
<input name="title"
type="text"
class="form-control bg-dark border-dark text-muted"
id="title"
{% if title %}
value="{{- title -}}"
{% endif %}/>
<label for="description" class="col-sm-6 col-form-label">Description</label>
<input name="description"
type="text"
class="form-control bg-dark border-dark text-muted"
id="description"
{% if description %}
value="{{- description -}}"
{% endif %}/>
<label for="color" class="col-sm-6 col-form-label">Embed color</label>
<input name="color"
type="color"
class="form-control form-control-color bg-dark border-dark text-muted"
id="color"
{% if color %}
value="{{- color -}}"
{% endif %}/>
<label for="author_name" class="col-sm-6 col-form-label">Author name</label>
<input name="author_name"
type="text"
class="form-control bg-dark border-dark text-muted"
id="author_name"
{% if author_name %}
value="{{- author_name -}}"
{% endif %}/>
<label for="author_url" class="col-sm-6 col-form-label">Author URL</label>
<input name="author_url"
type="text"
class="form-control bg-dark border-dark text-muted"
id="author_url"
{% if author_url %}
value="{{- author_url -}}"
{% endif %}/>
<label for="author_icon_url" class="col-sm-6 col-form-label">Author icon URL</label>
<input name="author_icon_url"
type="text"
class="form-control bg-dark border-dark text-muted"
id="author_icon_url"
{% if author_icon_url %}
value="{{- author_icon_url -}}"
{% endif %}/>
<label for="image_url" class="col-sm-6 col-form-label">Image URL - Add {% raw %}{{image_1}}{% endraw %} for first image</label>
<input name="image_url"
type="text"
class="form-control bg-dark border-dark text-muted"
id="image_url"
{% if image_url %}
value="{{- image_url -}}"
{% endif %}/>
<label for="thumbnail_url" class="col-sm-6 col-form-label">Thumbnail</label>
<input name="thumbnail_url"
type="text"
class="form-control bg-dark border-dark text-muted"
id="thumbnail_url"
{% if thumbnail_url %}
value="{{- thumbnail_url -}}"
{% endif %}/>
<label for="footer_text" class="col-sm-6 col-form-label">Footer text</label>
<input name="footer_text"
type="text"
class="form-control bg-dark border-dark text-muted"
id="footer_text"
{% if footer_text %}
value="{{- footer_text -}}"
{% endif %}/>
<label for="footer_icon_url" class="col-sm-6 col-form-label">Footer icon</label>
<input name="footer_icon_url"
type="text"
class="form-control bg-dark border-dark text-muted"
id="footer_icon_url"
{% if footer_icon_url %}
value="{{- footer_icon_url -}}"
{% endif %}/>
</div>
</div>
<!-- Add a hidden feed_url field to the form -->
<input type="hidden" name="feed_url" value="{{ feed.url }}"/>
<!-- Submit button -->
<div class="d-md-flex">
<button class="btn btn-dark btn-sm">Update embed</button>
</div>
</form>
</div>
{% endblock content %}

@ -31,11 +31,33 @@
<button class="btn btn-danger btn-sm" name="feed_url" value="{{ feed.url }}">Pause</button>
</form>
{% endif %}
{% if should_send_embed == True %}
<form action="/use_text" method="post">
<button class="btn btn-dark btn-sm" name="feed_url" value="{{ feed.url }}">
Send text messages instead of embeds
</button>
</form>
{% else %}
<form action="/use_embed" method="post">
<button class="btn btn-dark btn-sm" name="feed_url" value="{{ feed.url }}">
Send embeds instead of text messages
</button>
</form>
{% endif %}
<a class="text-muted"
href="/whitelist?feed_url={{ feed.url|encode_url }}">Whitelist</a>
<br/>
<a class="text-muted"
href="/blacklist?feed_url={{ feed.url|encode_url }}">Blacklist</a>
<a class="text-muted" href="/custom?feed_url={{ feed.url|encode_url }}">Custom message</a>
<br/>
<a class="text-muted" href="/custom?feed_url={{ feed.url|encode_url }}">Customize message
{% if not should_send_embed %}(Active){% endif %}
</a>
<br/>
<a class="text-muted" href="/embed?feed_url={{ feed.url|encode_url }}">Customize embed
{% if should_send_embed %}(Active){% endif %}
</a>
<br/>
</div>
{# HTML is created in main.create_html_for_feed #}
<pre>