-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New plugin discovery logic (without tests)
- Loading branch information
Showing
13 changed files
with
83 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# Plugin guide | ||
# Plugin guide | ||
|
||
Misago implements a plugin system that enables developers to customize and extend the core functionality of the software. This plugin system itself extends existing Django applications mechanism. | ||
|
||
> plugins vs. forking note | ||
|
||
## Plugin installation | ||
|
||
|
||
## Writing custom plugin | ||
|
||
- django applications mechanism | ||
- plugin structure | ||
- plugins vs. forking | ||
|
||
|
||
## Hooks | ||
|
||
- how to hooks | ||
- hook reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .discover import discover_plugins | ||
from .manifest import MisagoPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
from pathlib import Path | ||
from typing import List | ||
|
||
|
||
def discover_plugins(plugins_path: str | None) -> List[str]: | ||
if not plugins_path: | ||
return [] | ||
|
||
plugins_path_obj = Path(plugins_path) | ||
if not plugins_path_obj.is_dir(): | ||
return [] | ||
|
||
return discover_plugins_in_directory(plugins_path_obj) | ||
|
||
|
||
def discover_plugins_in_directory(plugins_path: Path) -> List[str]: | ||
plugins_apps: List[str] = [] | ||
|
||
for plugin_path in plugins_path.glob("*/*/misago_plugin.py"): | ||
plugin_package = plugin_path.parent | ||
|
||
# Add plugin to Python path so its importable | ||
plugin_dir = str(plugin_package.parent) | ||
if plugin_dir not in sys.path: | ||
sys.path.append(plugin_dir) | ||
|
||
# Add plugin to apps to make Django include it | ||
plugins_apps.append(plugin_package.name) | ||
|
||
return plugins_apps |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
@dataclass(frozen=True) | ||
class MisagoPlugin: | ||
name: str | ||
description: Optional[str] = None | ||
license: Optional[str] = None | ||
icon: Optional[str] = None | ||
color: Optional[str] = None | ||
version: Optional[str] = None | ||
author: Optional[str] = None | ||
homepage: Optional[str] = None | ||
repo: Optional[str] = None |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from misago import MisagoPlugin | ||
|
||
|
||
manifest = MisagoPlugin( | ||
name="My example plugin", | ||
) |