mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
set jinja var to determine use plugin
This commit is contained in:
parent
d479e944cc
commit
270b8fa65b
12 changed files with 68 additions and 13 deletions
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_ANTIBOT'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<!-- info-->
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-6 2xl:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_BAD_BEHAVIOR'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<!-- info-->
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-6 2xl:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_BLACKLIST'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<!-- info-->
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_BUNKERNET'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<!-- status -->
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_CORS'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<!-- info-->
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-6 2xl:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_DNSBL'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
<!-- info-->
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-4 2xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_GREYLIST'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
|
||||
<!-- info-->
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if is_used %}
|
||||
<!-- info-->
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-4 2xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
|
@ -86,5 +87,45 @@
|
|||
},
|
||||
});
|
||||
</script>
|
||||
{% else %}
|
||||
<div
|
||||
class="h-fit transition hover:scale-102 col-span-12 md:col-span-6 2xl:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
>
|
||||
<div class="flex justify-between">
|
||||
<h5 class="mb-2 font-bold dark:text-white/90">Deactived</h5>
|
||||
<!-- icon -->
|
||||
<div
|
||||
role="img"
|
||||
class="dark:brightness-90 inline-block w-12 h-12 text-center rounded-circle bg-yellow-500"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="scale-75 leading-none text-lg relative fill-yellow-500 stroke-white"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<!-- end icon -->
|
||||
</div>
|
||||
|
||||
<div class="mx-1 flex justify-start items-center my-2">
|
||||
<p
|
||||
data-info
|
||||
class="transition duration-300 ease-in-out mb-0 font-sans text-sm leading-normal dark:text-gray-500 dark:opacity-80"
|
||||
>
|
||||
This plugin need to be activated to get metrics.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end info -->
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_REDIS'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
|
||||
<!-- status -->
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_REVERSE_SCAN'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
|
||||
<!-- info-->
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
{% if plugin['settings']['USE_WHITELIST'].get('value') == "yes" %}
|
||||
{% if is_used %}
|
||||
|
||||
<!-- info-->
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -1259,6 +1259,7 @@ def upload_plugin():
|
|||
@app.route("/plugins/<plugin>", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def custom_plugin(plugin: str):
|
||||
# Get current plugin.json
|
||||
plugins = app.config["CONFIG"].get_plugins()
|
||||
|
||||
curr_plugin = {}
|
||||
|
|
@ -1267,6 +1268,20 @@ def custom_plugin(plugin: str):
|
|||
curr_plugin = plug
|
||||
break
|
||||
|
||||
# Get USE_<NAME> and check if the plugin is used by one service
|
||||
services = app.config["CONFIG"].get_services(with_drafts=True)
|
||||
use_key = False
|
||||
is_used = False
|
||||
for key, value in curr_plugin["settings"].items():
|
||||
if key.upper().startswith("USE_"):
|
||||
use_key = key
|
||||
|
||||
if use_key:
|
||||
for service in services:
|
||||
if service[use_key] == "yes":
|
||||
is_used = True
|
||||
break
|
||||
|
||||
message = ""
|
||||
if not plugin_id_rx.match(plugin):
|
||||
message = f'Invalid plugin id, "{plugin}" (must be between 1 and 64 characters, only letters, numbers, underscores and hyphens)'
|
||||
|
|
@ -1285,6 +1300,7 @@ def custom_plugin(plugin: str):
|
|||
username=current_user.get_id(),
|
||||
current_endpoint=plugin,
|
||||
plugin=curr_plugin,
|
||||
is_used=is_used,
|
||||
**app.jinja_env.globals,
|
||||
)
|
||||
|
||||
|
|
@ -1461,9 +1477,7 @@ def logs_linux():
|
|||
|
||||
log_lower = log.lower()
|
||||
error_type = (
|
||||
"error"
|
||||
if "[error]" in log_lower or "[crit]" in log_lower or "[alert]" in log_lower or "❌" in log_lower
|
||||
else ("warn" if "[warn]" in log_lower or "⚠️" in log_lower else ("info" if "[info]" in log_lower or "ℹ️" in log_lower else "message"))
|
||||
"error" if "[error]" in log_lower or "[crit]" in log_lower or "[alert]" in log_lower or "❌" in log_lower else ("warn" if "[warn]" in log_lower or "⚠️" in log_lower else ("info" if "[info]" in log_lower or "ℹ️" in log_lower else "message"))
|
||||
)
|
||||
|
||||
logs.append(
|
||||
|
|
|
|||
Loading…
Reference in a new issue