pandoc and pdfeditor examples.
This commit is contained in:
@@ -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'
|
||||
@@ -0,0 +1,41 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>PDF Editor</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/siimple/dist/siimple.min.css">
|
||||
<head>
|
||||
<body>
|
||||
<div class="siimple-content siimple-content--extra-large">
|
||||
<div class="siimple-grid">
|
||||
<div class="siimple-grid-row">
|
||||
<div class="siimple-grid-col siimple-grid-col--12">
|
||||
<div class="siimple-grid-col siimple-grid-col--6">
|
||||
<div class="siimple-form">
|
||||
<form action="/editor/pdf" method="post" target="result" id="editor">
|
||||
<div class="siimple-form-title">AWYSIWYG PDF Editor</div>
|
||||
<div class="siimple-form-field">
|
||||
<div class="siimple-form-field-label">InputFormat</div>
|
||||
<select name="from">
|
||||
<option value="markdown">Markdown</option>
|
||||
<option value="rst">ReStructuredText</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="siimple-form-field">
|
||||
<div class="siimple-form-field-label">InputFormat</div>
|
||||
<textarea class="siimple-textarea siimple-textarea--fluid" rows="25" name="content">Example text</textarea>
|
||||
</div>
|
||||
<div class="siimple-form-field">
|
||||
<div class="siimple-btn siimple-btn--blue" onclick="document.getElementById('editor').submit();">Preview!</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="siimple-grid-col siimple-grid-col--6">
|
||||
<iframe name="result" src="" style="height: 100%; width: 100%;"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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'
|
||||
@@ -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}
|
||||
Reference in New Issue
Block a user