This is an automated email from the ASF dual-hosted git repository. bdelacretaz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 387949128e32557aac796da4543346e73288f49c Author: Bertrand Delacretaz <[email protected]> AuthorDate: Fri Jul 26 13:46:17 2019 +0200 Markdown renderer action --- serverless-microsling/install | 14 ++++++-- .../rendering-actions/markdown-default.js | 40 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/serverless-microsling/install b/serverless-microsling/install index eccbccc..c4b8e50 100755 --- a/serverless-microsling/install +++ b/serverless-microsling/install @@ -18,7 +18,17 @@ echo Preparing $ZIP ... \ && wsk action update $ACTION $ZIP --web true --kind nodejs:10 --param debug true -a provide-api-key true echo "Installing rendering actions..." -wsk action update somedoc-rendering rendering-actions/somedoc-html.js -a sling:resourceType microsling/somedoc -a sling:extensions html +wsk action update somedoc-html rendering-actions/somedoc-html.js -a sling:resourceType microsling/somedoc -a sling:contentType text/html -a sling:extensions html +wsk action update markdown-default rendering-actions/markdown-default.js -a sling:resourceType '*' -a sling:contentType text/markdown -a sling:extensions md -echo "Microsling is available at at $(wsk -i action get $ACTION --url | grep http)" +export URL=$(wsk -i action get $ACTION --url | grep http) +echo "Microsling is available at at $URL" +echo "Interesting test URLs are:" +for f in demo/index demo/docs/somedoc +do + for x in json txt html md + do + echo "open $URL/$f.$x" + done +done diff --git a/serverless-microsling/rendering-actions/markdown-default.js b/serverless-microsling/rendering-actions/markdown-default.js new file mode 100644 index 0000000..a36c5f1 --- /dev/null +++ b/serverless-microsling/rendering-actions/markdown-default.js @@ -0,0 +1,40 @@ +/* + * Copyright 2019 The Apache Software Foundation. + * + * 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. + */ + + /* eslint-disable no-console */ +function main (params) { + const resource = params.resource || { testing:42, thefunction:'here'}; + let result = ''; + let heading = '==='; + Object.keys(resource).forEach(key => { + result += `${key}\n${heading}\n${resource[key]}\n\n`; + heading = '---'; + }) + return { output: result }; +} + +if (require.main === module) { + const input = { + resource: { + title: 'cmdline title', + body: 'cmdline body', + something: 'else', + } + }; + console.log(JSON.stringify(main(input), 2, null)); +} + +module.exports.main = main \ No newline at end of file
