Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "easydb-pdf-creator-plugin"]
path = easydb-pdf-creator-plugin
url = git@github.com:programmfabrik/easydb-pdf-creator-plugin.git
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ 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
cd html2pdf; CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o ../build/server-pdf/html2pdf-windows-arm64.exe
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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 9 additions & 0 deletions apitest/manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions apitest/setup/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
18 changes: 18 additions & 0 deletions apitest/setup/plugin_enable.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
31 changes: 31 additions & 0 deletions apitest/setup/plugin_init.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
27 changes: 27 additions & 0 deletions apitest/setup/plugin_put_zip.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
26 changes: 26 additions & 0 deletions apitest/setup/plugin_wait_for_zip_done.json
Original file line number Diff line number Diff line change
@@ -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
}
]
1 change: 1 addition & 0 deletions easydb-pdf-creator-plugin
20 changes: 20 additions & 0 deletions manifest.master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down