From 503855c53ba943fc2c39d1f07fb496e7f5c134d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Abdelkader=20Mart=C3=ADnez=20P=C3=A9rez?= Date: Mon, 29 Apr 2019 15:29:12 +0200 Subject: [PATCH] pandoc and pdfeditor examples. --- .../{helloworld.pow => pandoc/pandoc.pow} | 14 +++---- poc/examples/pdfeditor/pdfeditor.html | 41 +++++++++++++++++++ poc/examples/pdfeditor/pdfeditor.pow | 20 +++++++++ poc/examples/{ => pdfeditor}/topdf | 10 ++--- 4 files changed, 71 insertions(+), 14 deletions(-) rename poc/examples/{helloworld.pow => pandoc/pandoc.pow} (74%) create mode 100644 poc/examples/pdfeditor/pdfeditor.html create mode 100644 poc/examples/pdfeditor/pdfeditor.pow rename poc/examples/{ => pdfeditor}/topdf (74%) diff --git a/poc/examples/helloworld.pow b/poc/examples/pandoc/pandoc.pow similarity index 74% rename from poc/examples/helloworld.pow rename to poc/examples/pandoc/pandoc.pow index 5bb64e0..4bd2bbf 100755 --- a/poc/examples/helloworld.pow +++ b/poc/examples/pandoc/pandoc.pow @@ -16,15 +16,11 @@ # limitations under the License. # -kroute add -X POST --entrypoint ./topdf '/convert/{from}/pdf' - - kroute add -X POST --entrypoint '/bin/zsh -c' '/convert/{from}/{to}' - <<-'EOF' - pandoc --from=$(request /match/from) --to=$(request /match/to) --output=>(response /body) =(request /body) + pandoc --from=$(request /match/from) \ + --to=$(request /match/to) \ + --output=>(response /body) \ + =(request /body) EOF - -kroute add -X GET '/formats/input' - <<-'EOF' - pandoc --list-input-formats | response /body -EOF - +kroute add -X GET '/formats/input' -c 'pandoc --list-input-formats | response /body' kroute add -X GET '/formats/output' -c 'pandoc --list-output-formats | grep -v pdf | response /body' diff --git a/poc/examples/pdfeditor/pdfeditor.html b/poc/examples/pdfeditor/pdfeditor.html new file mode 100644 index 0000000..378898b --- /dev/null +++ b/poc/examples/pdfeditor/pdfeditor.html @@ -0,0 +1,41 @@ + + + PDF Editor + + + +
+
+
+
+
+
+
+
AWYSIWYG PDF Editor
+
+
InputFormat
+ +
+
+
InputFormat
+ +
+
+
Preview!
+
+
+
+
+
+ +
+
+
+
+
+ + + diff --git a/poc/examples/pdfeditor/pdfeditor.pow b/poc/examples/pdfeditor/pdfeditor.pow new file mode 100644 index 0000000..7b26f7e --- /dev/null +++ b/poc/examples/pdfeditor/pdfeditor.pow @@ -0,0 +1,20 @@ +#!/bin/bash + +# +# Copyright 2019 Banco Bilbao Vizcaya Argentaria, S.A. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +kroute add -X POST --entrypoint ./topdf '/editor/pdf' +kroute add / -c 'response /header/Content-Type text/html && response /body < pdfeditor.html' diff --git a/poc/examples/topdf b/poc/examples/pdfeditor/topdf similarity index 74% rename from poc/examples/topdf rename to poc/examples/pdfeditor/topdf index fb47fa8..722cd20 100755 --- a/poc/examples/topdf +++ b/poc/examples/pdfeditor/topdf @@ -17,12 +17,12 @@ # tmpfile=$(mktemp --suffix=.pdf) -pandoc --from=$(request /match/from) --to=pdf --output=${tmpfile} -t latex =(request /body) +pandoc --from=$(request /form/from) --to=pdf --output=${tmpfile} -t latex =(request /form/content) if [ $? -eq 0 ]; then - cat ${tmpfile} | response /body - echo "application/pdf" | response /header/Content-Type - echo 200 | response /status + response /header/Content-Type application/pdf + response /body < ${tmpfile} + response /status 200 else - echo 500 | response /status + response /status 500 fi rm -f ${tmpfile}