From bbf300781488178cce400e329c35ecefe043b76b Mon Sep 17 00:00:00 2001 From: Edward Ly Date: Sun, 29 Sep 2024 02:41:25 -0700 Subject: [PATCH] chore(examples): update `to_gif` app (AppAPI 5.0.0) (#302) Signed-off-by: Edward Ly Co-authored-by: Alexander Piskun <13381981+bigcat88@users.noreply.github.com> --- examples/as_app/to_gif/Dockerfile | 2 +- examples/as_app/to_gif/Makefile | 76 ++++++++++++++++++------- examples/as_app/to_gif/appinfo/info.xml | 16 ++++-- examples/as_app/to_gif/lib/main.py | 2 +- 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/examples/as_app/to_gif/Dockerfile b/examples/as_app/to_gif/Dockerfile index 8d3764fe..5663e18a 100644 --- a/examples/as_app/to_gif/Dockerfile +++ b/examples/as_app/to_gif/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-bookworm +FROM python:3-bookworm COPY requirements.txt / diff --git a/examples/as_app/to_gif/Makefile b/examples/as_app/to_gif/Makefile index 99db0b79..8ce10a9c 100644 --- a/examples/as_app/to_gif/Makefile +++ b/examples/as_app/to_gif/Makefile @@ -1,50 +1,82 @@ .DEFAULT_GOAL := help +GITHUB_USERNAME := cloud-py-api + +APP_ID := to_gif +APP_NAME := ToGif +APP_VERSION := 1.0.0 +APP_SECRET := 12345 +APP_PORT := 9031 + +JSON_INFO := "{\"id\":\"$(APP_ID)\",\"name\":\"$(APP_NAME)\",\"daemon_config_name\":\"manual_install\",\"version\":\"$(APP_VERSION)\",\"secret\":\"$(APP_SECRET)\",\"port\":$(APP_PORT),\"routes\":[{\"url\":\".*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}]}" + .PHONY: help help: - @echo "Welcome to ToGif example. Please use \`make \` where is one of" + @echo "Welcome to $(APP_NAME). Please use \`make \` where is one of" @echo " " @echo " Next commands are only for dev environment with nextcloud-docker-dev!" @echo " They should run from the host you are developing on(with activated venv) and not in the container with Nextcloud!" @echo " " @echo " build-push build image and upload to ghcr.io" @echo " " - @echo " run28 install ToGif for Nextcloud 28" - @echo " run install ToGif for Nextcloud Last" + @echo " run28 install $(APP_NAME) for Nextcloud 28" + @echo " run29 install $(APP_NAME) for Nextcloud 29" + @echo " run30 install $(APP_NAME) for Nextcloud 30" + @echo " run install $(APP_NAME) for Nextcloud Latest" @echo " " - @echo " For development of this example use PyCharm run configurations. Development is always set for last Nextcloud." - @echo " First run 'ToGif' and then 'make registerXX', after that you can use/debug/develop it and easy test." + @echo " For development of this example use PyCharm run configurations. Development is always set to the latest version of Nextcloud." + @echo " First run '$(APP_NAME)' and then 'make registerXX', after that you can use/debug/develop it and easy test." @echo " " - @echo " register28 perform registration of running 'to_gif' into the 'manual_install' deploy daemon." - @echo " register perform registration of running 'to_gif' into the 'manual_install' deploy daemon." + @echo " register28 perform registration of running '$(APP_ID)' into the 'manual_install' deploy daemon." + @echo " register29 perform registration of running '$(APP_ID)' into the 'manual_install' deploy daemon." + @echo " register30 perform registration of running '$(APP_ID)' into the 'manual_install' deploy daemon." + @echo " register perform registration of running '$(APP_ID)' into the 'manual_install' deploy daemon." .PHONY: build-push build-push: docker login ghcr.io - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/to_gif:latest . + docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/$(GITHUB_USERNAME)/$(APP_ID):latest . .PHONY: run28 run28: - docker exec master-stable28-1 sudo -u www-data php occ app_api:app:unregister to_gif --silent --force || true - docker exec master-stable28-1 sudo -u www-data php occ app_api:app:register to_gif --force-scopes \ - --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/to_gif/appinfo/info.xml + docker exec master-stable28-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable28-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --force-scopes \ + --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/$(APP_ID)/appinfo/info.xml + +.PHONY: run29 +run29: + docker exec master-stable29-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable29-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --force-scopes \ + --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/$(APP_ID)/appinfo/info.xml + +.PHONY: run30 +run30: + docker exec master-stable30-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable30-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --force-scopes \ + --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/$(APP_ID)/appinfo/info.xml .PHONY: run run: - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister to_gif --silent --force || true - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register to_gif --force-scopes \ - --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/to_gif/appinfo/info.xml + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --force-scopes \ + --info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/$(APP_ID)/appinfo/info.xml .PHONY: register28 register28: - docker exec master-stable28-1 sudo -u www-data php occ app_api:app:unregister to_gif --silent --force || true - docker exec master-stable28-1 sudo -u www-data php occ app_api:app:register to_gif manual_install --json-info \ - "{\"id\":\"to_gif\",\"name\":\"to_gif\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9031,\"scopes\":[\"FILES\", \"NOTIFICATIONS\"]}" \ - --force-scopes --wait-finish + docker exec master-stable28-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable28-1 sudo -u www-data php occ app_api:app:register $(APP_ID) manual_install --json-info $(JSON_INFO) --force-scopes --wait-finish + +.PHONY: register29 +register29: + docker exec master-stable29-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable29-1 sudo -u www-data php occ app_api:app:register $(APP_ID) manual_install --json-info $(JSON_INFO) --force-scopes --wait-finish + +.PHONY: register30 +register30: + docker exec master-stable30-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-stable30-1 sudo -u www-data php occ app_api:app:register $(APP_ID) manual_install --json-info $(JSON_INFO) --force-scopes --wait-finish .PHONY: register register: - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister to_gif --silent --force || true - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register to_gif manual_install --json-info \ - "{\"id\":\"to_gif\",\"name\":\"to_gif\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9031,\"scopes\":[\"FILES\", \"NOTIFICATIONS\"]}" \ - --force-scopes --wait-finish + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister $(APP_ID) --silent --force || true + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register $(APP_ID) manual_install --json-info $(JSON_INFO) --force-scopes --wait-finish diff --git a/examples/as_app/to_gif/appinfo/info.xml b/examples/as_app/to_gif/appinfo/info.xml index 9364acc4..a9fe3160 100644 --- a/examples/as_app/to_gif/appinfo/info.xml +++ b/examples/as_app/to_gif/appinfo/info.xml @@ -4,7 +4,7 @@ ToGif Nextcloud To Gif Example - + 1.0.0 MIT @@ -16,7 +16,7 @@ https://github.com/cloud-py-api/nc_py_api/issues https://github.com/cloud-py-api/nc_py_api - + @@ -24,9 +24,13 @@ cloud-py-api/to_gif latest - - FILES - NOTIFICATIONS - + + + .* + GET,POST,PUT,DELETE + USER + [] + + diff --git a/examples/as_app/to_gif/lib/main.py b/examples/as_app/to_gif/lib/main.py index 30283353..23bd32e7 100644 --- a/examples/as_app/to_gif/lib/main.py +++ b/examples/as_app/to_gif/lib/main.py @@ -85,7 +85,7 @@ def enabled_handler(enabled: bool, nc: NextcloudApp) -> str: if enabled: nc.ui.files_dropdown_menu.register_ex( "to_gif", - "TO GIF", + "To GIF", "/video_to_gif", mime="video", icon="img/icon.svg",