mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-29 08:46:45 +00:00
Adding organisational UI tags
This commit is contained in:
@@ -300,6 +300,11 @@ class TextJsonDiffPlugin:
|
||||
def get_processor_version(self):
|
||||
from changedetectionio import __version__
|
||||
return __version__
|
||||
|
||||
@hookimpl
|
||||
def get_processor_ui_tag(self):
|
||||
from .text_json_diff.processor import UI_tag
|
||||
return UI_tag
|
||||
|
||||
@hookimpl
|
||||
def perform_site_check(self, datastore, watch_uuid):
|
||||
@@ -337,6 +342,11 @@ class RestockDiffPlugin:
|
||||
def get_processor_version(self):
|
||||
from changedetectionio import __version__
|
||||
return __version__
|
||||
|
||||
@hookimpl
|
||||
def get_processor_ui_tag(self):
|
||||
from .restock_diff.processor import UI_tag
|
||||
return UI_tag
|
||||
|
||||
@hookimpl
|
||||
def perform_site_check(self, datastore, watch_uuid):
|
||||
|
||||
@@ -7,6 +7,7 @@ PLUGIN_NAMESPACE = "changedetectionio_processors"
|
||||
hookspec = pluggy.HookspecMarker(PLUGIN_NAMESPACE)
|
||||
hookimpl = pluggy.HookimplMarker(PLUGIN_NAMESPACE)
|
||||
|
||||
UI_tags = {}
|
||||
|
||||
class ProcessorSpec:
|
||||
"""Hook specifications for difference detection processors."""
|
||||
@@ -26,6 +27,11 @@ class ProcessorSpec:
|
||||
"""Return the processor plugin version."""
|
||||
pass
|
||||
|
||||
@hookspec
|
||||
def get_processor_ui_tag():
|
||||
"""Return the UI tag for the processor (used for categorization in UI)."""
|
||||
pass
|
||||
|
||||
@hookspec
|
||||
def perform_site_check(datastore, watch_uuid):
|
||||
"""Return the processor handler class or None if not applicable.
|
||||
@@ -61,9 +67,19 @@ plugin_manager = pluggy.PluginManager(PLUGIN_NAMESPACE)
|
||||
# Register hookspecs
|
||||
plugin_manager.add_hookspecs(ProcessorSpec)
|
||||
|
||||
# Initialize by loading plugins and building UI_tags dictionary
|
||||
try:
|
||||
# Discover installed plugins from external packages (if any)
|
||||
plugin_manager.load_setuptools_entrypoints(PLUGIN_NAMESPACE)
|
||||
logger.info(f"Loaded plugins: {plugin_manager.get_plugins()}")
|
||||
|
||||
# Build UI_tags dictionary from all plugins
|
||||
for plugin in plugin_manager.get_plugins():
|
||||
if hasattr(plugin, "get_processor_name") and hasattr(plugin, "get_processor_ui_tag"):
|
||||
plugin_name = plugin.get_processor_name()
|
||||
ui_tag = plugin.get_processor_ui_tag()
|
||||
if plugin_name and ui_tag:
|
||||
UI_tags[plugin_name] = ui_tag
|
||||
logger.info(f"Found UI tag for plugin {plugin_name}: {ui_tag}")
|
||||
except Exception as e:
|
||||
logger.critical(f"Error loading plugins: {str(e)}")
|
||||
@@ -9,6 +9,7 @@ import time
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
name = 'Re-stock & Price detection for single product pages'
|
||||
description = 'Detects if the product goes back to in-stock'
|
||||
UI_tag = "Restock"
|
||||
|
||||
class UnableToExtractRestockData(Exception):
|
||||
def __init__(self, status_code):
|
||||
|
||||
@@ -17,6 +17,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
name = 'Webpage Text/HTML, JSON and PDF changes'
|
||||
description = 'Detects all text changes where possible'
|
||||
UI_tag = "Text Diff"
|
||||
|
||||
json_filter_prefixes = ['json:', 'jq:', 'jqraw:']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user