feat: Initial custom plugins

This commit is contained in:
2024-02-02 21:40:02 +11:00
parent 69e4d7f496
commit 5bb4e1bc4c
21 changed files with 546 additions and 17 deletions

View File

@@ -178,4 +178,86 @@ def wallets(wallets):
html = ''
for wallet in wallets:
html += f'<option value="{wallet}">{wallet}</option>'
return html
return html
def plugins(plugins):
html = ''
for plugin in plugins:
name = plugin['name']
link = plugin['link']
html += f'<li class="list-group-item"><a class="btn btn-primary" style="width:100%;height:100%;margin:0px;font-size: x-large;" role="button" href="/plugin/{link}">{name}</a></li>'
return html
def plugin_functions(functions, pluginName):
html = ''
for function in functions:
name = functions[function]['name']
description = functions[function]['description']
params = functions[function]['params']
returns = functions[function]['returns']
html += f'<div class="card" style="margin-top: 50px;">'
html += f'<div class="card-body">'
html += f'<h4 class="card-title">{name}</h4>'
html += f'<h6 class="text-muted card-subtitle mb-2">{description}</h6>'
# Form
html += f'<form method="post" style="padding: 20px;" action="/plugin/{pluginName}/{function}">'
for param in params:
html += f'<div style="margin-bottom: 20px;">'
paramName = params[param]["name"]
paramType = params[param]["type"]
if paramType == "text":
html += f'<label for="{param}">{paramName}</label>'
html += f'<input class="form-control" type="text" name="{param}" />'
elif paramType == "longText":
html += f'<label for="{param}">{paramName}</label>'
html += f'<textarea class="form-control" name="{param}" rows="4" cols="50"></textarea>'
elif paramType == "number":
html += f'<label for="{param}">{paramName}</label>'
html += f'<input class="form-control" type="number" name="{param}" />'
elif paramType == "checkbox":
html += f'<div class="form-check"><input id="{param}" class="form-check-input" type="checkbox" name="{param}" /><label class="form-check-label" for="{param}">{paramName}</label></div>'
html += f'</div>'
html += f'<button type="submit" class="btn btn-primary">Submit</button>'
html += f'</form>'
# For debugging
html += f'<p class="card-text">Returns: {returns}</p>'
html += f'</div>'
html += f'</div>'
return html
def plugin_output(outputs, returns):
html = ''
for returnOutput in returns:
print(returns)
html += f'<div class="card" style="margin-top: 50px; margin-bottom: 50px;">'
html += f'<div class="card-body">'
html += f'<h4 class="card-title">{returns[returnOutput]["name"]}</h4>'
# Get the output
output = outputs[returnOutput]
if returns[returnOutput]["type"] == "list":
html += f'<ul>'
for item in output:
html += f'<li>{item}</li>'
html += f'</ul>'
elif returns[returnOutput]["type"] == "text":
html += f'<p>{output}</p>'
html += f'</div>'
html += f'</div>'
return html