-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Serveradmin apps to extend the Servershell (Javascript) (#348)
Include JavaScript files from Serveradmin apps Automatically include JavaScript files from Serveradmin apps following a naming convention. This allows Serveradmin apps to extend or plugin into the Serverhshell and for example add custom commands.
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 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
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,22 @@ | ||
from django.apps import apps | ||
from django.contrib.staticfiles import finders | ||
|
||
|
||
def servershell_plugins(): | ||
"""Find $app.servershell.plugin.js files from Serveradmin apps | ||
Scans all apps beginning with serveradmin_ for files that follow the pattern | ||
$app.servershell.plugin.js and return them. This allows Serveradmin apps to | ||
extend the Servershell for example with custom commands. | ||
@return: | ||
""" | ||
js_files = list() | ||
app_names = [app.name for app in apps.get_app_configs() if app.name.startswith("serveradmin_")] | ||
for app_name in app_names: | ||
path = f"js/{app_name}.servershell.plugin.js" | ||
js_file = finders.find(path) | ||
if js_file: | ||
js_files.append(path) | ||
|
||
return js_files |
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