Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(examples): update to_gif app (AppAPI 5.0.0) #302

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/as_app/to_gif/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-bookworm
FROM python:3-bookworm

COPY requirements.txt /

Expand Down
76 changes: 54 additions & 22 deletions examples/as_app/to_gif/Makefile
Original file line number Diff line number Diff line change
@@ -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 <target>\` where <target> is one of"
@echo "Welcome to $(APP_NAME). Please use \`make <target>\` where <target> 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
16 changes: 10 additions & 6 deletions examples/as_app/to_gif/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>ToGif</name>
<summary>Nextcloud To Gif Example</summary>
<description>
<![CDATA[Example of the Nextcloud application written in python]]>
<![CDATA[Example of a Nextcloud application written in Python]]>
</description>
<version>1.0.0</version>
<licence>MIT</licence>
Expand All @@ -16,17 +16,21 @@
<bugs>https://github.com/cloud-py-api/nc_py_api/issues</bugs>
<repository type="git">https://github.com/cloud-py-api/nc_py_api</repository>
<dependencies>
<nextcloud min-version="28" max-version="30"/>
<nextcloud min-version="28" max-version="31"/>
</dependencies>
<external-app>
<docker-install>
<registry>ghcr.io</registry>
<image>cloud-py-api/to_gif</image>
<image-tag>latest</image-tag>
</docker-install>
<scopes>
<value>FILES</value>
<value>NOTIFICATIONS</value>
</scopes>
<routes>
<route>
<url>.*</url>
<verb>GET,POST,PUT,DELETE</verb>
<access_level>USER</access_level>
<headers_to_exclude>[]</headers_to_exclude>
</route>
</routes>
</external-app>
</info>
2 changes: 1 addition & 1 deletion examples/as_app/to_gif/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down