aboutsummaryrefslogtreecommitdiff
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
parenttree and view classes (diff)
Raw button implementation
-rw-r--r--app.js15
-rw-r--r--public/css/style.css37
2 files changed, 50 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));
});
});
diff --git a/public/css/style.css b/public/css/style.css
index e70a940..4717cd6 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -110,4 +110,41 @@ kbd {
text-shadow: 0 1px 0 #fff;
color: #5e551f;
}
+.view {
+ position: relative;
+}
+.raw_button {
+ position: absolute;
+ top:10px;
+ right:0;
+
+ margin : 0;
+ padding : 0;
+ border : 0;
+ background : transparent;
+ font-family : inherit;
+ font-size : 1em;
+ cursor : pointer;
+}
+.raw_button > div {
+ width : 40px;
+ height : 24px;
+ background : rgb(192,192,192) url('image.png') no-repeat center center;
+ line-height : 24px;
+ border : 1px solid rgba(27, 31, 35, 0.2);
+ border-radius : 3px;
+ font-size: 12px;
+
+ color: #24292e;
+ background-color: #eff3f6;
+ background-image: linear-gradient(-180deg, #fafbfc 0%, #eff3f6 90%);
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
+}
+.raw_button > div > div {
+ font-weight: bold;
+}
+
+.no-style {
+ text-decoration: none;
+}