commit
52df602af7
@ -0,0 +1,78 @@
|
|||||||
|
# include the decorator
|
||||||
|
from apprise.decorators import notify
|
||||||
|
|
||||||
|
@notify(on="delete")
|
||||||
|
@notify(on="deletes")
|
||||||
|
@notify(on="get")
|
||||||
|
@notify(on="gets")
|
||||||
|
@notify(on="post")
|
||||||
|
@notify(on="posts")
|
||||||
|
@notify(on="put")
|
||||||
|
@notify(on="puts")
|
||||||
|
def apprise_custom_api_call_wrapper(body, title, notify_type, *args, **kwargs):
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from apprise.utils import parse_url as apprise_parse_url
|
||||||
|
from apprise import URLBase
|
||||||
|
|
||||||
|
url = kwargs['meta'].get('url')
|
||||||
|
|
||||||
|
if url.startswith('post'):
|
||||||
|
r = requests.post
|
||||||
|
elif url.startswith('get'):
|
||||||
|
r = requests.get
|
||||||
|
elif url.startswith('put'):
|
||||||
|
r = requests.put
|
||||||
|
elif url.startswith('delete'):
|
||||||
|
r = requests.delete
|
||||||
|
|
||||||
|
url = url.replace('post://', 'http://')
|
||||||
|
url = url.replace('posts://', 'https://')
|
||||||
|
url = url.replace('put://', 'http://')
|
||||||
|
url = url.replace('puts://', 'https://')
|
||||||
|
url = url.replace('get://', 'http://')
|
||||||
|
url = url.replace('gets://', 'https://')
|
||||||
|
url = url.replace('put://', 'http://')
|
||||||
|
url = url.replace('puts://', 'https://')
|
||||||
|
url = url.replace('delete://', 'http://')
|
||||||
|
url = url.replace('deletes://', 'https://')
|
||||||
|
|
||||||
|
headers = {}
|
||||||
|
params = {}
|
||||||
|
auth = None
|
||||||
|
|
||||||
|
# Convert /foobar?+some-header=hello to proper header dictionary
|
||||||
|
results = apprise_parse_url(url)
|
||||||
|
if results:
|
||||||
|
# Add our headers that the user can potentially over-ride if they wish
|
||||||
|
# to to our returned result set and tidy entries by unquoting them
|
||||||
|
headers = {URLBase.unquote(x): URLBase.unquote(y)
|
||||||
|
for x, y in results['qsd+'].items()}
|
||||||
|
|
||||||
|
# https://github.com/caronc/apprise/wiki/Notify_Custom_JSON#get-parameter-manipulation
|
||||||
|
# In Apprise, it relies on prefixing each request arg with "-", because it uses say &method=update as a flag for apprise
|
||||||
|
# but here we are making straight requests, so we need todo convert this against apprise's logic
|
||||||
|
for k, v in results['qsd'].items():
|
||||||
|
if not k.strip('+-') in results['qsd+'].keys():
|
||||||
|
params[URLBase.unquote(k)] = URLBase.unquote(v)
|
||||||
|
|
||||||
|
# Determine Authentication
|
||||||
|
auth = ''
|
||||||
|
if results.get('user') and results.get('password'):
|
||||||
|
auth = (URLBase.unquote(results.get('user')), URLBase.unquote(results.get('user')))
|
||||||
|
elif results.get('user'):
|
||||||
|
auth = (URLBase.unquote(results.get('user')))
|
||||||
|
|
||||||
|
# Try to auto-guess if it's JSON
|
||||||
|
try:
|
||||||
|
json.loads(body)
|
||||||
|
headers['Content-Type'] = 'application/json; charset=utf-8'
|
||||||
|
except ValueError as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
r(results.get('url'),
|
||||||
|
auth=auth,
|
||||||
|
data=body.encode('utf-8') if type(body) is str else body,
|
||||||
|
headers=headers,
|
||||||
|
params=params
|
||||||
|
)
|
@ -0,0 +1,45 @@
|
|||||||
|
body.preview-text-enabled {
|
||||||
|
#filters-and-triggers > div {
|
||||||
|
display: flex; /* Establishes Flexbox layout */
|
||||||
|
gap: 20px; /* Adds space between the columns */
|
||||||
|
position: relative; /* Ensures the sticky positioning is relative to this parent */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* layout of the page */
|
||||||
|
#edit-text-filter, #text-preview {
|
||||||
|
flex: 1; /* Each column takes an equal amount of available space */
|
||||||
|
align-self: flex-start; /* Aligns the right column to the start, allowing it to maintain its content height */
|
||||||
|
}
|
||||||
|
|
||||||
|
#edit-text-filter {
|
||||||
|
#pro-tips {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#text-preview {
|
||||||
|
position: sticky;
|
||||||
|
top: 25px;
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* actual preview area */
|
||||||
|
#text-preview-inner {
|
||||||
|
background: var(--color-grey-900);
|
||||||
|
border: 1px solid var(--color-grey-600);
|
||||||
|
padding: 1rem;
|
||||||
|
color: #333;
|
||||||
|
font-family: "Courier New", Courier, monospace; /* Sets the font to a monospace type */
|
||||||
|
font-size: 12px;
|
||||||
|
overflow-x: scroll;
|
||||||
|
white-space: pre-wrap; /* Preserves whitespace and line breaks like <pre> */
|
||||||
|
overflow-wrap: break-word; /* Allows long words to break and wrap to the next line */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#activate-text-preview {
|
||||||
|
right: 0;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 0;
|
||||||
|
box-shadow: 1px 1px 4px var(--color-shadow-jump);
|
||||||
|
}
|
Loading…
Reference in new issue