From 46dfa57ee0996cb71b32d2dfd6c49fb0cd4a65fd Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 16 Nov 2022 13:30:40 +0530 Subject: [PATCH 01/14] Allow the core project to ship UI plugins --- ...t UI plugins here (developer team only).txt | 3 +++ ui/server.py | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 ui/plugins/ui/Put UI plugins here (developer team only).txt diff --git a/ui/plugins/ui/Put UI plugins here (developer team only).txt b/ui/plugins/ui/Put UI plugins here (developer team only).txt new file mode 100644 index 00000000..028157f5 --- /dev/null +++ b/ui/plugins/ui/Put UI plugins here (developer team only).txt @@ -0,0 +1,3 @@ +Custom plugins in this folder will be shipped to all the users by default. + +This allows UI features to be built as plugins (testing our Plugins API, and keeping our core lean and modular). \ No newline at end of file diff --git a/ui/server.py b/ui/server.py index 852dbdf6..8b54f847 100644 --- a/ui/server.py +++ b/ui/server.py @@ -16,7 +16,10 @@ sys.path.append(os.path.dirname(SD_UI_DIR)) CONFIG_DIR = os.path.abspath(os.path.join(SD_UI_DIR, '..', 'scripts')) MODELS_DIR = os.path.abspath(os.path.join(SD_DIR, '..', 'models')) -UI_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, '..', 'plugins', 'ui')) + +USER_UI_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, '..', 'plugins', 'ui')) +CORE_UI_PLUGINS_DIR = os.path.abspath(os.path.join(SD_UI_DIR, 'plugins', 'ui')) +UI_PLUGINS_SOURCES = ((CORE_UI_PLUGINS_DIR, 'core'), (USER_UI_PLUGINS_DIR, 'user')) OUTPUT_DIRNAME = "Stable Diffusion UI" # in the user's home folder TASK_TTL = 15 * 60 # Discard last session's task timeout @@ -49,7 +52,7 @@ app = FastAPI() modifiers_cache = None outpath = os.path.join(os.path.expanduser("~"), OUTPUT_DIRNAME) -os.makedirs(UI_PLUGINS_DIR, exist_ok=True) +os.makedirs(USER_UI_PLUGINS_DIR, exist_ok=True) # don't show access log entries for URLs that start with the given prefix ACCESS_LOG_SUPPRESS_PATH_PREFIXES = ['/ping', '/image', '/modifier-thumbnails'] @@ -57,7 +60,9 @@ ACCESS_LOG_SUPPRESS_PATH_PREFIXES = ['/ping', '/image', '/modifier-thumbnails'] NOCACHE_HEADERS={"Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0"} app.mount('/media', StaticFiles(directory=os.path.join(SD_UI_DIR, 'media')), name="media") -app.mount('/plugins', StaticFiles(directory=UI_PLUGINS_DIR), name="plugins") + +for plugins_dir, dir_prefix in UI_PLUGINS_SOURCES: + app.mount(f'/plugins/{dir_prefix}', StaticFiles(directory=plugins_dir), name=f"plugins-{dir_prefix}") def getConfig(default_val=APP_CONFIG_DEFAULTS): try: @@ -223,9 +228,10 @@ def getModels(): def getUIPlugins(): plugins = [] - for file in os.listdir(UI_PLUGINS_DIR): - if file.endswith('.plugin.js'): - plugins.append(f'/plugins/{file}') + for plugins_dir, dir_prefix in UI_PLUGINS_SOURCES: + for file in os.listdir(plugins_dir): + if file.endswith('.plugin.js'): + plugins.append(f'/plugins/{dir_prefix}/{file}') return plugins From 4c5f66185debd1f2fd7d9dec4c6aa9e6b1ee7692 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Wed, 16 Nov 2022 10:44:56 +0100 Subject: [PATCH 02/14] Add Change history --- CHANGES.md | 8 ++++++++ CONTRIBUTING.md | 1 + 2 files changed, 9 insertions(+) create mode 100644 CHANGES.md diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 00000000..33209896 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,8 @@ +# Change history + +Please add all changes that have a noticeable impact on users (including plugin +developers) to this change list + +# 2.4.5 +* Add checkbox for "Open browser on startup" +* Add a directory for core plugins that ship with Stable Diffusion UI by default diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3872fb27..229df851 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,6 +40,7 @@ or for Windows `mklink /J \projects\stable-diffusion-ui-archive\ui \projects\stable-diffusion-ui-repo\ui` (link name first, source repo dir second) 9) Run the project again (like in step 2) and ensure you can still use the UI. 10) Congrats, now any changes you make in your repo `ui` folder are linked to this running archive of the app and can be previewed in the browser. +11) Please update CHANGES.md in your pull requests. Check the `ui/frontend/build/README.md` for instructions on running and building the React code. From 18d9d2602ade6cb3f46fd3faaaa2b2e8c0c62aac Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 16 Nov 2022 16:54:28 +0530 Subject: [PATCH 03/14] Add a 'What's New?' tab as a core plugin, which fetches the contents of CHANGES.md from the app's release branch --- CHANGES.md | 6 ++-- ui/index.html | 3 +- ui/media/js/main.js | 6 ++-- ui/media/js/marked.min.js | 6 ++++ ui/plugins/ui/release-notes.plugin.js | 47 +++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 ui/media/js/marked.min.js create mode 100644 ui/plugins/ui/release-notes.plugin.js diff --git a/CHANGES.md b/CHANGES.md index 33209896..799179fd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,6 @@ -# Change history - -Please add all changes that have a noticeable impact on users (including plugin -developers) to this change list +# What's new? # 2.4.5 * Add checkbox for "Open browser on startup" * Add a directory for core plugins that ship with Stable Diffusion UI by default +* Add a "What's New?" tab as a core plugin, which fetches the contents of CHANGES.md from the app's release branch \ No newline at end of file diff --git a/ui/index.html b/ui/index.html index 2e817256..36f72d21 100644 --- a/ui/index.html +++ b/ui/index.html @@ -14,6 +14,7 @@ +
@@ -333,7 +334,7 @@ - + - + + - +