From 8ddb1daabdce934486a043e00d2aee49a9e69c54 Mon Sep 17 00:00:00 2001 From: Philipp Hempel Date: Mon, 26 May 2025 16:14:55 +0200 Subject: [PATCH] WIP: include frontend part from easydb-pdf-creator-plugin: - include easydb-pdf-creator-plugin submodule - merged necessary parts of Makefile and manifest.yml - copy build files from submodule into own build folder - needs more work in frontend part of easydb-pdf-creator-plugin to work with fylr see #74582 --- .gitmodules | 3 ++ Makefile | 12 +++++++- README.md | 2 +- apitest/manifest.json | 9 ++++++ apitest/setup/all.json | 5 ++++ apitest/setup/plugin_enable.json | 18 ++++++++++++ apitest/setup/plugin_init.json | 31 +++++++++++++++++++++ apitest/setup/plugin_put_zip.json | 27 ++++++++++++++++++ apitest/setup/plugin_wait_for_zip_done.json | 26 +++++++++++++++++ easydb-pdf-creator-plugin | 1 + manifest.master.yml | 20 +++++++++++++ 11 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 100644 apitest/setup/plugin_enable.json create mode 100644 apitest/setup/plugin_init.json create mode 100644 apitest/setup/plugin_put_zip.json create mode 100644 apitest/setup/plugin_wait_for_zip_done.json create mode 160000 easydb-pdf-creator-plugin diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e830807 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "easydb-pdf-creator-plugin"] + path = easydb-pdf-creator-plugin + url = git@github.com:programmfabrik/easydb-pdf-creator-plugin.git diff --git a/Makefile b/Makefile index c570759..39e33ca 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,12 @@ help: all: build ## build all +google-csv: ## download l10n csv from google + make -C easydb-pdf-creator-plugin google_csv + build: ## build files in build folder + mkdir -p build/server-pdf/webfrontend + mkdir -p build/server-pdf/l10n cd html2pdf; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ../build/server-pdf/html2pdf-linux-amd64.exe cd html2pdf; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ../build/server-pdf/html2pdf-linux-arm64.exe cd html2pdf; CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ../build/server-pdf/html2pdf-windows-amd64.exe @@ -13,9 +18,14 @@ build: ## build files in build folder cd html2pdf; CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ../build/server-pdf/html2pdf-darwin-amd64.exe cd html2pdf; CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ../build/server-pdf/html2pdf-darwin-arm64.exe cp -r manifest.master.yml build/server-pdf/manifest.yml + make -C easydb-pdf-creator-plugin build + cp easydb-pdf-creator-plugin/build-info.json build/server-pdf + cp -r easydb-pdf-creator-plugin/build/webfrontend/pdf-creator* build/server-pdf/webfrontend + cp easydb-pdf-creator-plugin/l10n/pdf-creator.csv build/server-pdf/l10n clean: ## clean - rm -rf build + rm -rf build || true + rm -rf easydb-pdf-creator-plugin/build || true test: cat apitest/payload.json | SERVER_PDF_CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" build/server-pdf/html2pdf-darwin-arm64.exe > test.pdf diff --git a/README.md b/README.md index 1caa51a..a21080f 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,4 @@ Plugin to provide HTML to PDF functionality for fylr. * By default the server-pdf plugin expect the binary `chromium` in the exec server. If you prefer to use "Chrome" or want to provide an absolute path to the binary, use environment. * Install this Plugin into fylr (URL, ZIP or disk mode) -* The [easydb-pdf-creator-plugin](https://github.com/programmfabrik/easydb-pdf-creator-plugin) will auto recognize this plugin and call the fylr server pdf creator automatically. +* The [easydb-pdf-creator-plugin](https://github.com/programmfabrik/easydb-pdf-creator-plugin) is included as a submodule and provides the frontend functionality. diff --git a/apitest/manifest.json b/apitest/manifest.json index 084c895..e9ef302 100644 --- a/apitest/manifest.json +++ b/apitest/manifest.json @@ -1,3 +1,12 @@ +////////////////////////////////////////////////////// +// // +// This apitest only works if plugin zip exists at // +// ../../build/server-pdf.zip // +// // +// Run `make zip` before running apitest // +// // +////////////////////////////////////////////////////// + { "name": "fylr html2pdf", "header_from_store": { diff --git a/apitest/setup/all.json b/apitest/setup/all.json index db0a1f0..ba0ad5f 100644 --- a/apitest/setup/all.json +++ b/apitest/setup/all.json @@ -5,4 +5,9 @@ // get settings again, after purge we have a new db instance id ,"@get_settings.json" ,"@root_session.json" + // upload and enable the plugin as a zip plugin + ,"@plugin_put_zip.json" + ,"@plugin_wait_for_zip_done.json" + ,"@plugin_init.json" + ,"@plugin_enable.json" ] diff --git a/apitest/setup/plugin_enable.json b/apitest/setup/plugin_enable.json new file mode 100644 index 0000000..c27e3a9 --- /dev/null +++ b/apitest/setup/plugin_enable.json @@ -0,0 +1,18 @@ +[ + { + "name": "enable server-pdf plugin", + "request": { + "endpoint": "plugin/manage/{{ datastore `plugin_id` }}", + "method": "POST", + "body": { + "id": {{ datastore `plugin_id` }}, + "enabled": true + } + }, + "response": { + "body": { + "enabled": true + } + } + } +] \ No newline at end of file diff --git a/apitest/setup/plugin_init.json b/apitest/setup/plugin_init.json new file mode 100644 index 0000000..e1487f6 --- /dev/null +++ b/apitest/setup/plugin_init.json @@ -0,0 +1,31 @@ +[ + { + "name": "PUT /api/v1/plugin/manage", + "request": { + "body": { + "type": "zip", + "url": "", + "zip_file": { + "_id": {{ datastore `plugin_zip_id` }}, + "preferred": true + } + }, + "endpoint": "plugin/manage", + "method": "PUT" + }, + "response": { + "body": { + "id:control": { + "is_number": true + }, + "zip_file": { + "_id": {{ datastore `plugin_zip_id` }} + } + }, + "statuscode": 200 + }, + "store_response_gjson": { + "plugin_id": "body.id" + } + } +] \ No newline at end of file diff --git a/apitest/setup/plugin_put_zip.json b/apitest/setup/plugin_put_zip.json new file mode 100644 index 0000000..27a9e86 --- /dev/null +++ b/apitest/setup/plugin_put_zip.json @@ -0,0 +1,27 @@ +[ + { + "name": "post build/server-pdf.zip to eas/put", + "request": { + "body": { + "file": "@../../build/server-pdf.zip" + }, + "body_type": "multipart", + "endpoint": "eas/put", + "method": "POST", + "query_params": { + "produce_versions": "[false]" + } + }, + "response": { + "statuscode": 200, + "body": [ + { + "extension": "zip" + } + ] + }, + "store_response_gjson": { + "plugin_zip_id": "body.0._id" + } + } +] \ No newline at end of file diff --git a/apitest/setup/plugin_wait_for_zip_done.json b/apitest/setup/plugin_wait_for_zip_done.json new file mode 100644 index 0000000..503a22e --- /dev/null +++ b/apitest/setup/plugin_wait_for_zip_done.json @@ -0,0 +1,26 @@ +[ + { + "name": "GET /api/v1/eas", + "request": { + "endpoint": "eas", + "method": "GET", + "query_params": { + "format": "standard", + "ids": "[{{ datastore `plugin_zip_id` }}]" + } + }, + "response": { + "statuscode": 200, + "body": { + "{{ datastore `plugin_zip_id` }}": { + "_id": {{ datastore `plugin_zip_id` }}, + "status": "done", + "extension": "zip", + "is_original": true + } + } + }, + "timeout_ms": 60000, + "delay_ms": 1000 + } +] \ No newline at end of file diff --git a/easydb-pdf-creator-plugin b/easydb-pdf-creator-plugin new file mode 160000 index 0000000..7293d31 --- /dev/null +++ b/easydb-pdf-creator-plugin @@ -0,0 +1 @@ +Subproject commit 7293d31b9e2fbc1763a86eacfc51742cd888e3ae diff --git a/manifest.master.yml b/manifest.master.yml index 4179541..fb8a024 100644 --- a/manifest.master.yml +++ b/manifest.master.yml @@ -4,6 +4,26 @@ plugin: displayname: de-DE: "PDF Server" en-US: "PDF Server" + webfrontend: + url: pdf-creator.js + css: pdf-creator.css + print_css: pdf-creator-print.css + l10n: l10n/pdf-creator.csv + +base_url_prefix: "webfrontend" + +base_config: + - name: pdf_creator + group: css + parameters: + fylr_url: + regex: "^https?://[^/]+?/(fylr/|)pdf$" + type: text + position: 0 + custom_css_url: + regex: "^https?://[^/]+?([a-z0-9]|/.*)$" + type: text + position: 1 extensions: html2pdf: