More work on plugins

This commit is contained in:
dgtlmoon
2025-03-19 15:52:31 +01:00
parent 9a073fc9aa
commit 673ec24fa3
4 changed files with 54 additions and 4 deletions
@@ -26,6 +26,7 @@
<li class="tab"><a href="#api">API</a></li>
<li class="tab"><a href="#timedate">Time &amp Date</a></li>
<li class="tab"><a href="#proxies">CAPTCHA &amp; Proxies</a></li>
<li class="tab"><a href="#plugins">Plugins</a></li>
</ul>
</div>
<div class="box-wrap inner">
@@ -297,6 +298,32 @@ nav
{{ render_field(form.requests.form.extra_browsers) }}
</div>
</div>
<div class="tab-pane-inner" id="plugins">
<div class="pure-control-group">
<h4>Registered Plugins</h4>
<p>The following plugins are currently registered in the system - <a href="https://changedetection.io/plugins">Get more plugins here</a></p>
<table class="pure-table pure-table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{% for plugin in plugins_info %}
<tr>
<td>{{ plugin.name }}</td>
<td>{{ plugin.description }}</td>
<td>{{ plugin.version }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div id="actions">
<div class="pure-control-group">
{{ render_button(form.save_button) }}
+4 -2
View File
@@ -330,7 +330,8 @@ class TextJsonDiffPlugin:
@hookimpl
def get_processor_version(self):
return "1.0.0"
from changedetectionio import __version__
return __version__
@hookimpl
def perform_site_check(self, datastore, watch_uuid):
@@ -366,7 +367,8 @@ class RestockDiffPlugin:
@hookimpl
def get_processor_version(self):
return "1.0.0"
from changedetectionio import __version__
return __version__
@hookimpl
def perform_site_check(self, datastore, watch_uuid):
@@ -1,14 +1,20 @@
"""
Example plugin to demonstrate how to create a new processor plugin
"""
from .pluggy_interface import hookimpl
import importlib
class ExampleProcessorPlugin:
"""
Example processor plugin that extends the text_json_diff processor
"""
def random_string(self, length=50):
import random
import string
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
@hookimpl
def get_processor_name(self):
return "example_processor"
+15
View File
@@ -0,0 +1,15 @@
from flask import url_for
from changedetectionio.tests.util import live_server_setup
def test_checkplugins_registered(live_server, client):
live_server_setup(live_server)
res = client.get(
url_for("settings.settings_page")
)
assert res.status_code == 200
# Should be registered in the info table
assert b'<td>Webpage Text/HTML, JSON and PDF changes' in res.data
assert b'<td>text_json_diff' in res.data