7ed5349e86
Check Cross-Plugin Imports / check (push) Has been cancelled
- 5 Manifest-Beiträge (MiniAppContribution): dms_folders (dms:read), mail_unread (mail:read), wiki_recent (wiki:read), graph_overview (graph:read), automation_status (automation:read) — je settings_schema max_items, order 60-100 - 5 Frontend-Widgets auf bestehenden API-Clients (keine neuen Backend-Endpoints): DmsFoldersWidget, MailUnreadWidget, WikiRecentWidget, GraphOverviewWidget, AutomationStatusWidget - MiniAppHost-Registry +5; tsc clean, build OK - Tests: M5 7/7 (TDD rot->gruen), Backend-Regression 53/53, Vitest 22/22
83 lines
3.5 KiB
Python
83 lines
3.5 KiB
Python
"""Wiki plugin - knowledge articles, categories, versioning."""
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from app.plugins.base import BasePlugin
|
|
from app.plugins.manifest import (
|
|
FrontendMenuItem,
|
|
FrontendPageRoute,
|
|
MiniAppContribution,
|
|
PluginManifest,
|
|
PluginRouteDef,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class WikiPlugin(BasePlugin):
|
|
manifest = PluginManifest(
|
|
name="wiki",
|
|
version="1.0.0",
|
|
display_name="Wiki",
|
|
description="Knowledge articles with Markdown, categories, tags, versioning, entity links.",
|
|
dependencies=["permissions", "unified_search"],
|
|
routes=[
|
|
PluginRouteDef(path="/api/v1/wiki", module="app.plugins.builtins.wiki.routes", router_attr="router"),
|
|
],
|
|
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,
|
|
),
|
|
],
|
|
permissions=["wiki:read", "wiki:write", "wiki:delete", "wiki:admin"],
|
|
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")],
|
|
)
|
|
|
|
async def on_activate(self, db, service_container, event_bus) -> None:
|
|
await super().on_activate(db, service_container, event_bus)
|
|
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"):
|
|
from app.plugins.builtins.unified_search.providers.wiki_provider import (
|
|
WikiSearchProvider,
|
|
)
|
|
search_contract.get_search_registry().register(WikiSearchProvider())
|
|
logger.info("Registered WikiSearchProvider via contract")
|
|
else:
|
|
logger.warning("unified_search contract not available, skipping WikiSearchProvider registration")
|
|
except Exception:
|
|
logger.exception("Failed to register WikiSearchProvider")
|
|
|
|
async def on_deactivate(self, db, service_container, event_bus) -> None:
|
|
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")
|
|
|
|
await super().on_deactivate(db, service_container, event_bus)
|