mirror of
https://github.com/caronc/apprise-api.git
synced 2025-08-09 22:57:33 +02:00
Config Generator and CSS/Doc Improvements (#151)
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
from .utils import gen_unique_config_id
|
||||
from .utils import ConfigCache
|
||||
from django.conf import settings
|
||||
import apprise
|
||||
@ -46,3 +47,17 @@ def apprise_version(request):
|
||||
Returns the current version of apprise loaded under the hood
|
||||
"""
|
||||
return {'APPRISE_VERSION': apprise.__version__}
|
||||
|
||||
|
||||
def default_config_id(request):
|
||||
"""
|
||||
Returns a unique config identifier
|
||||
"""
|
||||
return {'DEFAULT_CONFIG_ID': settings.APPRISE_DEFAULT_CONFIG_ID}
|
||||
|
||||
|
||||
def unique_config_id(request):
|
||||
"""
|
||||
Returns a unique config identifier
|
||||
"""
|
||||
return {'UNIQUE_CONFIG_ID': gen_unique_config_id()}
|
||||
|
@ -36,7 +36,7 @@
|
||||
<h1>{% trans "Apprise API" %}</h1>
|
||||
<ul>
|
||||
<li>APPRISE v{{APPRISE_VERSION}}</li>
|
||||
<li class="theme"><a href="{{ request.path }}?theme={{request.next_theme}}"><span class="tiny material-icons">invert_colors</span></a></li>
|
||||
<li class="theme"><a href="{{ request.path }}?theme={{request.next_theme}}"><i class="material-icons">invert_colors</i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -46,8 +46,10 @@
|
||||
<div class="col s3" style="width:20em">
|
||||
{% if STATEFUL_MODE != 'disabled' %}
|
||||
<ul class="collection z-depth-1">
|
||||
<a class="collection-item" href="{% url 'config' 'apprise' %}"><i class="material-icons">settings</i>
|
||||
<a class="collection-item" href="{% url 'config' DEFAULT_CONFIG_ID %}"><i class="material-icons">settings</i>
|
||||
{% trans "Configuration Manager" %}</a>
|
||||
<a class="collection-item" href="{% url 'config' UNIQUE_CONFIG_ID %}"><i class="material-icons">refresh</i>
|
||||
{% trans "New Configuration" %}</a>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<ul class="collection z-depth-1">
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% load i18n %}
|
||||
{% block body %}
|
||||
{% if STATEFUL_MODE != 'disabled' %}
|
||||
<h4>{% trans "Management for:" %} <em>{{ key }}</em></h4>
|
||||
<h4>{% trans "Management for Config ID:" %} <em>{{ key }}</em></h4>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<ul class="tabs config-overview">
|
||||
@ -75,12 +75,11 @@
|
||||
<div class="has-config">
|
||||
<div class="section">
|
||||
<h5>{% trans "Working Remotely With Your Configuration" %}</h5>
|
||||
<h6>{% trans "Using The Apprise CLI" %}</h6>
|
||||
<p>
|
||||
{% blocktrans %}The following command would cause apprise to directly notify all of your services:{% endblocktrans %}
|
||||
<br />
|
||||
<pre><code class="bash">apprise --body="Test Message" \<br/>
|
||||
apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all</code></pre>
|
||||
<br />
|
||||
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
|
||||
<pre><code class="bash">apprise --body="Test Message" \<br/>
|
||||
apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all \<br/>
|
||||
@ -95,8 +94,28 @@
|
||||
<br />
|
||||
<pre><code class="bash">apprise --body="Test Message" --tag=all \<br/>
|
||||
--config={{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
|
||||
{% blocktrans %}You may also create an <a href="https://github.com/caronc/apprise/wiki/config#cli" target="_blank">Apprise configuration file</a> that contains this line somewhere in it:{% endblocktrans %}
|
||||
<pre><code class="bash">include {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
|
||||
{% blocktrans %}By leveraging the <em>include</em> directive, it will automatically be referenced for future calls to the <code>apprise</code> tool. All future calls using Apprise now simplify to:{% endblocktrans %}
|
||||
<pre><code class="bash">apprise --body="Test Message" --tag=all</em></code></pre>
|
||||
</p>
|
||||
|
||||
{% endif %}
|
||||
<h6>{% trans "Using CURL" %}</h6>
|
||||
<p>
|
||||
{% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %}
|
||||
<pre><code class="bash">curl -X POST \<br/>
|
||||
-F "body=Test Message" \<br/>
|
||||
-F "tags=all" \<br/>
|
||||
http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
|
||||
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
|
||||
<pre><code class="bash">curl -X POST \<br/>
|
||||
-F "tags=all" \<br/>
|
||||
-F "body=Test Message" \<br/>
|
||||
-F attach1=@Screenshot-1.png \<br/>
|
||||
-F attach2=@/my/path/to/Apprise.doc \<br/>
|
||||
http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h5>{% trans "Loaded Configuration" %}</h5>
|
||||
|
@ -35,6 +35,7 @@ import base64
|
||||
import requests
|
||||
from json import dumps
|
||||
from django.conf import settings
|
||||
from datetime import datetime
|
||||
|
||||
# import the logging library
|
||||
import logging
|
||||
@ -588,6 +589,17 @@ def apply_global_filters():
|
||||
' ignoring.', name)
|
||||
|
||||
|
||||
def gen_unique_config_id():
|
||||
"""
|
||||
Generates a unique configuration ID
|
||||
"""
|
||||
# our key to use
|
||||
h = hashlib.sha256()
|
||||
h.update(datetime.now().strftime('%Y%m%d%H%M%S%f').encode('utf-8'))
|
||||
h.update(settings.SECRET_KEY.encode('utf-8'))
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def send_webhook(payload):
|
||||
"""
|
||||
POST our webhook results
|
||||
|
Reference in New Issue
Block a user