diff --git a/__init__.py b/__init__.py index 8733998..4c1987d 100644 --- a/__init__.py +++ b/__init__.py @@ -29,7 +29,7 @@ except: print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.") -version = [2, 10, 3] +version = [2, 11] version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '') print(f"### Loading: ComfyUI-Manager ({version_str})") @@ -831,7 +831,6 @@ def nickname_filter(json_obj): return json_obj - @server.PromptServer.instance.routes.get("/customnode/getmappings") async def fetch_customnode_mappings(request): mode = request.rel_url.query["mode"] @@ -2127,6 +2126,26 @@ async def api_get_comfyworkflows_auth(request): return web.Response(status=404) return web.json_response({"comfyworkflows_sharekey" : comfyworkflows_auth}) +args.enable_cors_header = "*" +if hasattr(server.PromptServer.instance, "app"): + app = server.PromptServer.instance.app + cors_middleware = server.create_cors_middleware(args.enable_cors_header) + app.middlewares.append(cors_middleware) + +@server.PromptServer.instance.routes.post("/manager/set_esheep_workflow_and_images") +async def set_esheep_workflow_and_images(request): + json_data = await request.json() + current_workflow = json_data['workflow'] + images = json_data['images'] + with open(os.path.join(comfyui_manager_path, "esheep_share_message.json"), "w", encoding='utf-8') as file: + json.dump(json_data, file, indent=4) + return web.Response(status=200) + +@server.PromptServer.instance.routes.get("/manager/get_esheep_workflow_and_images") +async def get_esheep_workflow_and_images(request): + with open(os.path.join(comfyui_manager_path, "esheep_share_message.json"), 'r', encoding='utf-8') as file: + data = json.load(file) + return web.Response(status=200, text=json.dumps(data)) def set_matrix_auth(json_data): homeserver = json_data['homeserver'] diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index 7cbd8dd..8ae6fff 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -1210,6 +1210,15 @@ class ManagerMenuDialog extends ComfyDialog { modifyButtonStyle(url); }, }, + { + title: "Open 'esheep'", + callback: () => { + const url = "https://www.esheep.com"; + localStorage.setItem("wg_last_visited", url); + window.open(url, url); + modifyButtonStyle(url); + }, + }, { title: "Close", callback: () => { diff --git a/js/comfyui-share-common.js b/js/comfyui-share-common.js index 74ab6af..ca09dd7 100644 --- a/js/comfyui-share-common.js +++ b/js/comfyui-share-common.js @@ -164,6 +164,29 @@ export function parseURLPath(urlPath) { } +export const shareToEsheep= () => { + app.graphToPrompt() + .then(prompt => { + const nodes = app.graph._nodes + const { potential_outputs, potential_output_nodes } = getPotentialOutputsAndOutputNodes(nodes); + const workflow = prompt['workflow'] + api.fetchApi(`/manager/set_esheep_workflow_and_images`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + workflow: workflow, + images: potential_outputs + }) + }).then(response => { + var domain = window.location.hostname; + var port = window.location.port; + port = port || (window.location.protocol === 'http:' ? '80' : window.location.protocol === 'https:' ? '443' : ''); + var full_domin = domain + ':' + port + window.open('https://www.esheep.com/app/workflow_upload?from_local='+ full_domin, '_blank'); + }); + }) +} + export const showOpenArtShareDialog = () => { if (!OpenArtShareDialog.instance) { OpenArtShareDialog.instance = new OpenArtShareDialog(); @@ -283,6 +306,16 @@ export class ShareDialogChooser extends ComfyDialog { }) } }, + { + key: "esheep", + textContent: "eSheep", + website: "https://www.esheep.com", + description: "Share & download thousands of ComfyUI workflows on esheep.com", + onclick: () => { + shareToEsheep(); + this.close(); + } + }, ]; function createShareButtonsWithDescriptions() {