2026-08-21 10:02:50 +02:00
|
|
|
"""Wiki plugin - knowledge articles, categories, versioning."""
|
2026-08-18 11:55:43 +02:00
|
|
|
from __future__ import annotations
|
2026-08-24 13:36:17 +02:00
|
|
|
|
2026-08-20 22:02:16 +02:00
|
|
|
import logging
|
2026-08-24 13:36:17 +02:00
|
|
|
|
2026-08-18 11:55:43 +02:00
|
|
|
from app.plugins.base import BasePlugin
|
2026-08-31 00:10:31 +02:00
|
|
|
from app.plugins.manifest import (
|
|
|
|
|
FrontendMenuItem,
|
|
|
|
|
FrontendPageRoute,
|
|
|
|
|
MiniAppContribution,
|
|
|
|
|
PluginManifest,
|
|
|
|
|
PluginRouteDef,
|
|
|
|
|
)
|
2026-08-18 11:55:43 +02:00
|
|
|
|
2026-08-20 22:02:16 +02:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2026-08-21 10:02:50 +02:00
|
|
|
|
2026-08-18 11:55:43 +02:00
|
|
|
class WikiPlugin(BasePlugin):
|
|
|
|
|
manifest = PluginManifest(
|
|
|
|
|
name="wiki",
|
|
|
|
|
version="1.0.0",
|
|
|
|
|
display_name="Wiki",
|
|
|
|
|
description="Knowledge articles with Markdown, categories, tags, versioning, entity links.",
|
2026-08-23 20:29:09 +02:00
|
|
|
dependencies=["permissions", "unified_search"],
|
2026-08-18 11:55:43 +02:00
|
|
|
routes=[
|
|
|
|
|
PluginRouteDef(path="/api/v1/wiki", module="app.plugins.builtins.wiki.routes", router_attr="router"),
|
|
|
|
|
],
|
2026-08-31 00:10:31 +02:00
|
|
|
miniapps=[
|
|
|
|
|
MiniAppContribution(
|
|
|
|
|
app_id="wiki_recent",
|
|
|
|
|
name="Wiki-Neuigkeiten",
|
|
|
|
|
icon="BookOpen",
|
|
|
|
|
description="Zuletzt aktualisierte Wiki-Artikel.",
|
|
|
|
|
permission="wiki:read",
|
|
|
|
|
settings_schema={
|
|
|
|
|
"fields": [
|
|
|
|
|
{"name": "max_items", "label": "Max. Artikel", "type": "number", "default": 5},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
col_span=2,
|
|
|
|
|
row_span=1,
|
|
|
|
|
hosts=["chat", "dashboard", "window"],
|
|
|
|
|
component="@/components/dashboard/WikiRecentWidget",
|
|
|
|
|
order=80,
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-08-18 11:55:43 +02:00
|
|
|
permissions=["wiki:read", "wiki:write", "wiki:delete", "wiki:admin"],
|
2026-08-23 21:59:22 +02:00
|
|
|
menu_items=[FrontendMenuItem(label_key="wiki.menu.wiki", label="Wiki", path="/wiki", icon="BookOpen", permission="wiki:read")],
|
|
|
|
|
page_routes=[FrontendPageRoute(path="/wiki", component="@/pages/Wiki", permission="wiki:read")],
|
2026-08-18 11:55:43 +02:00
|
|
|
)
|
2026-08-20 22:02:16 +02:00
|
|
|
|
|
|
|
|
async def on_activate(self, db, service_container, event_bus) -> None:
|
|
|
|
|
await super().on_activate(db, service_container, event_bus)
|
|
|
|
|
try:
|
2026-08-22 07:25:48 +02:00
|
|
|
from app.plugins.builtins.contracts import get_contract
|
|
|
|
|
search_contract = get_contract("unified_search")
|
2026-08-23 19:24:12 +02:00
|
|
|
if search_contract and hasattr(search_contract, "get_search_registry"):
|
2026-08-24 13:36:17 +02:00
|
|
|
from app.plugins.builtins.unified_search.providers.wiki_provider import (
|
|
|
|
|
WikiSearchProvider,
|
|
|
|
|
)
|
2026-08-23 19:24:12 +02:00
|
|
|
search_contract.get_search_registry().register(WikiSearchProvider())
|
2026-08-22 07:25:48 +02:00
|
|
|
logger.info("Registered WikiSearchProvider via contract")
|
|
|
|
|
else:
|
|
|
|
|
logger.warning("unified_search contract not available, skipping WikiSearchProvider registration")
|
2026-08-20 22:02:16 +02:00
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to register WikiSearchProvider")
|
2026-08-21 10:02:50 +02:00
|
|
|
|
|
|
|
|
async def on_deactivate(self, db, service_container, event_bus) -> None:
|
2026-08-23 19:24:12 +02:00
|
|
|
from app.core.hooks import get_hook_registry
|
|
|
|
|
get_hook_registry().unregister_all_for_plugin("wiki")
|
|
|
|
|
|
|
|
|
|
# Unregister the search provider registered in on_activate (ARCH-012).
|
|
|
|
|
try:
|
|
|
|
|
from app.plugins.builtins.contracts import get_contract
|
|
|
|
|
search_contract = get_contract("unified_search")
|
|
|
|
|
if search_contract and hasattr(search_contract, "get_search_registry"):
|
|
|
|
|
search_contract.get_search_registry().unregister("wiki_article")
|
|
|
|
|
logger.info("Unregistered WikiSearchProvider via contract")
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to unregister WikiSearchProvider")
|
|
|
|
|
|
2026-08-21 10:02:50 +02:00
|
|
|
await super().on_deactivate(db, service_container, event_bus)
|