aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-01-02 14:48:41 +0100
committerache <ache@ache.one>2018-01-02 14:50:06 +0100
commit6974a8c306c2d9e2453a3db35f5053066cbb27ae (patch)
treece3b3ed70a25de0235b24f8bea1c4df85844b292 /app.js
parenttree and view classes (diff)
Raw button implementation
Diffstat (limited to 'app.js')
-rw-r--r--app.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/app.js b/app.js
index 1657afd..5182330 100644
--- a/app.js
+++ b/app.js
@@ -36,15 +36,25 @@ const remark = require('remark-parse');
const inspect = require('unist-util-inspect');
const useLandScript = " <script> mermaid.contentLoaded(); </script>"
+const userSide_Button = '<button class="raw_button" ><div><div>Raw</div></div></button></form>'
app.use(express.static('public'));
app.get('/' + path + '/*', function(req, res) {
- var url = decodeURI(req.url);
+ var url = req._parsedUrl.pathname;
+ var query = req.query;
+
console.log("[" + new Date() + "] > " + "200 - " + url);
fs.readFile(url.substr(1), 'utf8', function(err, data) {
if (err)
return console.log(err);
+
+ if( query && query['raw'] == 'true' ) {
+ console.log("PLEASE");
+ res.send( data )
+ return;
+ }
+
// remark()
/* Debbug comment
const a = unified()
@@ -75,7 +85,8 @@ app.get('/' + path + '/*', function(req, res) {
.use(rehypeStringify)
.process(data, function (err, file) {
- res.send(String(file) + useLandScript);
+ res.send(String(file) + useLandScript +
+ '<a href="' + url + '?raw=true" class="no-style">' + userSide_Button + '</a>');
console.error(report(err || file));
});
});