commit d0ae0041e8c78c4b6911a378d7949fb77bc4c587 Author: Flummi Date: Fri Feb 16 14:25:46 2018 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4ea7c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +cfg/config.mjs +package-lock.json \ No newline at end of file diff --git a/db.txt b/db.txt new file mode 100644 index 0000000..a0701c4 --- /dev/null +++ b/db.txt @@ -0,0 +1,10 @@ +pastes: + id + uuid + datetime + language + title + paste + hidden + description + (owner) \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..7599fdc --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "fpaste", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node --experimental-modules src/fpaste.mjs" + }, + "author": "Flummi", + "license": "ISC", + "dependencies": { + "express": "^4.16.2", + "express-handlebars": "^3.0.0", + "highlight": "^0.2.4", + "highlight.js": "^9.12.0" + } +} diff --git a/public/css/Ubuntu-Medium.ttf b/public/css/Ubuntu-Medium.ttf new file mode 100644 index 0000000..c6f048e Binary files /dev/null and b/public/css/Ubuntu-Medium.ttf differ diff --git a/public/css/Ubuntu-Regular.ttf b/public/css/Ubuntu-Regular.ttf new file mode 100644 index 0000000..2001d6e Binary files /dev/null and b/public/css/Ubuntu-Regular.ttf differ diff --git a/public/css/code.css b/public/css/code.css new file mode 100644 index 0000000..0b4fc6f --- /dev/null +++ b/public/css/code.css @@ -0,0 +1,125 @@ +div.formatedCode { + display: table; + margin: 5px 0 15px; + padding: 0; +} + +div.formatedCode div.lineNumbers { + border-right: 1px solid #ccc; + text-align: right; +} +div.formatedCode div.lineNumbers a { + color: #aaa; +} + +div.formatedCode div.lineNumbers, +div.formatedCode div.sourceCode { + display: table-cell; +} + +div.formatedCode pre.plainText, +div.formatedCode div.lineNumbers pre, +div.formatedCode div.sourceCode pre { + padding: 0; + margin: 0 10px 0; + line-height: 12pt; + font-size: 10pt; +} + +/* +github.com style (c) Vasily Polovnyov +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} + +.hljs-comment, +.hljs-quote { + color: #998; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} + +.hljs-string, +.hljs-doctag { + color: #d14; +} + +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} + +.hljs-subst { + font-weight: normal; +} + +.hljs-type, +.hljs-class .hljs-title { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} + +.hljs-regexp, +.hljs-link { + color: #009926; +} + +.hljs-symbol, +.hljs-bullet { + color: #990073; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} \ No newline at end of file diff --git a/public/css/fonts.css b/public/css/fonts.css new file mode 100644 index 0000000..2fcd945 --- /dev/null +++ b/public/css/fonts.css @@ -0,0 +1,17 @@ +@media screen { + @font-face { + font-family: 'Ubuntu'; + font-style: normal; + font-weight: normal; + src: local('Ubuntu'), url('/css/Ubuntu-Regular.ttf') format('ttf'); + } +} + +@media screen { + @font-face { + font-family: 'Ubuntu'; + font-style: normal; + font-weight: 500; + src: local('Ubuntu Medium'), local('Ubuntu-Medium'), url('/css/Ubuntu-Medium.ttf') format('ttf'); + } +} \ No newline at end of file diff --git a/public/css/index.css b/public/css/index.css new file mode 100644 index 0000000..f006b70 --- /dev/null +++ b/public/css/index.css @@ -0,0 +1,59 @@ +section#main .settings { + background-color: #999; + border: 1px solid #666; + width: 650px; + margin: 0; + padding: 5px 1px 5px; + border-radius: 3px; + box-shadow: 3px 3px 10px #666; +} + +section#main ul.settings { + list-style: none; +} + +section#main ul.settings li { + display: inline; + margin-right: 15px; +} + +section#main .settings p { + font-size: 11px; + color: white; + display: inline-block; + margin: 5px; +} + +section#main input#desc, +section#main select#lang { + margin: 1px 0 1px; + font-size: 11px; +} + +section#main input#desc { + min-width: 400px; + margin: 1px 0 1px; +} + +section#main select#lang { + width: 100px; + text-align: left; +} + +section#main input[type=checkbox] { + margin: 0; + position: relative; + top: 2px; +} + +section#main textarea { + display: block; + margin: 5px 0 5px; + padding: 0; + width: 652px; + height: 400px; +} + +section#main input#email { + display: none; +} \ No newline at end of file diff --git a/public/css/main.css b/public/css/main.css new file mode 100644 index 0000000..d82adc7 --- /dev/null +++ b/public/css/main.css @@ -0,0 +1,236 @@ +body { + margin: 0; + padding: 0; + background: #fff; + color: #666; + font-size: 12pt; + font-family: sans-serif; +} + +h1,h2,h3,h4,h5,h6,header,menu { + font-family: 'Ubuntu', sans-serif; +} + +a { + color: #088; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +li { + font-size: 9pt; +} + +input.inputDesc { + color: #999; +} + +section, menu, header, div { + margin: 0; + padding: 0; +} + +pre { + line-height: 12pt; + font-size: 10pt; +} + +form input[type=submit], +form input[type=reset] { + background-color: #777; + color: white; + border: 1px solid #666; + font-family: 'Ubuntu', sans-serif; + font-weight: bold; + padding: 10px; + margin: 5px 0 5px; + border-radius: 3px; + display: block; + box-shadow: 3px 3px 10px #666; + cursor: pointer; +} + +form input[type=submit]:hover { + text-decoration: underline; +} + + +/* {{{ Logo */ + +header +{ + margin: 100px auto 40px; + width: 500px; + font-size: 20pt; +} + + header p#left a#n3 + { + text-decoration: none; + position: relative; + left: 6px; + } + header p#left a#n3 sup + { + font-size: 12pt; + position: relative; + top: -4px; + right: 3px; + } + + header p#left + { + padding: 0; + margin: 0; + display: inline-block; + font-weight: bold; + text-align: right; + width: 210px; + } + + header p#center + { + padding: 0; + margin: 0; + display: inline-block; + text-align: center; + color: #999; + font-size: 22pt; + + width: 68px; /* hmm... to align stuff correctly */ + } + + header p#right + { + padding: 0; + margin: 0; + display: inline-block; + text-align: left; + color: #999; + + width: 210px; + } + + header p#info + { + width: 500px; + text-align: center; + font-size: 12pt; + } + +/* }}} */ + + +/* {{{ Menu */ + +menu +{ + float: left; + margin: 107px 20px auto; + padding: 40px 0 40px; + list-style-type: none; + position: fixed; + top: 100px; + left: 20px; + vertical-align: middle; + background-color: #666; + border-radius: 5px; + box-shadow: 3px 3px 10px #444; +} + menu li + { + padding: 5px; + width: 170px; + background-color: #666; + color: #ccc; + text-align: center; + } + + menu li.highlight:hover, + menu li.active + { + background-color: #777; + } + + menu li p + { + display: inline; + } + + menu li a { + width: 100%; + display: inline-block; + color: #fff; + } + + menu hr + { + margin: 0 auto 0; + width: 60%; + border: 0; + height: 1px; + background-color: #777; + } + + menu ul.submenu + { + border-top: 1px dotted #aaa; + list-style-type: none; + margin: 4px auto 0; + padding: 0; + width: 60%; + } + + menu ul.submenu li { + margin: 4px 2px 2px; + padding: 0; + font-size: 10px; + width: 100%; + background-color: #777; + } + + menu ul.submenu li span.info { + color: #aaa; + } + + menu ul.submenu li a { + color: #ddd; + } + +/* }}} */ + +section#main +{ + margin: 20px 20px 0 270px; + width: 760px; +} + + section#main .error + { + font-weight: bold; + color: #c20; + } + + section#main .warning + { + color: #c20; + } + + section#main .success + { + color: #0a3; + } + + section#main .info + { + font-weight: bold; + font-style: italic; + } + + section#main p.moreless + { + text-align: right; + } \ No newline at end of file diff --git a/public/css/notifications.css b/public/css/notifications.css new file mode 100644 index 0000000..360f954 --- /dev/null +++ b/public/css/notifications.css @@ -0,0 +1,30 @@ +section#notifications { + position: absolute; + top: 0; + text-align: center; + width: 100%; +} + +section#notifications p { + background-color: #999; + border: 1px solid #666; + box-shadow: 3px 3px 10px #666; + border-radius: 3px; + color: white; + font-size: 11px; + width: 50%; + margin-left: auto; + margin-right: auto; + padding: 5px 1px 5px; +} + +section#notifications p a { + background-color: #666; + border-radius: 4px; + color: #ccc; + padding: 2px 5px 2px; + margin-left: 5px; + margin-right: 5px; + cursor: pointer; + display: inline-block; +} \ No newline at end of file diff --git a/public/css/view.css b/public/css/view.css new file mode 100644 index 0000000..4c1bb4f --- /dev/null +++ b/public/css/view.css @@ -0,0 +1,75 @@ +#main form#filter_form p { + display: inline-block; + margin-right: 20px; +} + +#filter_form input[type=submit] { + padding: 4px; + margin-left: 20px; + display: inline-block; +} + +div.pasteInfo { + background-color: #999; + border: 1px solid #666; + width: 650px; + padding: 5px; + margin-top: 16px; + border-radius: 3px; + color: white; + font-size: 11px; + box-shadow: 3px 3px 10px #666; +} + +div.pasteInfo p { + margin: 0; + padding: 4px; +} + +div.pasteInfo p a { + color: #055; +} + +div.pasteInfo p.desc { + font-style: italic; +} + +div.pasteInfo p.timestamp { + float: right; + width: 150px; + text-align: right; +} +div.pasteInfo p.language { + clear: right; + float: right; + width: 150px; + text-align: right; +} + +div.pasteInfo p a { + margin-left: 5px; + margin-right: 5px; + color: #ccc; + background-color: #666; + padding: 2px 5px 2px; + border: 0; + border-radius: 4px; + font-size: 11px; + font-family: sans-serif; + font-weight: normal; + display: inline; + vertical-align: baseline; + cursor: pointer; + font-style: normal; +} + +div.pasteInfo p.language a { + margin: 0; +} + +div.formatedCode pre.plainText, +div.formatedCode div.lineNumbers pre, +div.formatedCode div.sourceCode pre { + max-width: 580px; + overflow-x: auto; +} \ No newline at end of file diff --git a/src/fpaste.mjs b/src/fpaste.mjs new file mode 100644 index 0000000..8c26d36 --- /dev/null +++ b/src/fpaste.mjs @@ -0,0 +1,30 @@ +import cfg from "../cfg/config"; +import express from "express"; +import exphbs from "express-handlebars"; +import router from "./routes"; + +const hbs = exphbs.create({ + defaultLayout: "main", + helpers: { + times: (n, block) => { + let rows = []; + for(var i = 0; i < n; ++i) + rows.push(block.fn(i+1)); + return rows.join("
"); + } + } +}); + +const app = express(); +app + .engine("handlebars", hbs.engine) + .set("view engine", "handlebars") + .use(express.static("public", cfg.websrv.static_options)) + + .use("/", router.index) + .use("/v", router.view) + .use("/a", router.about) + + .listen(cfg.websrv.port, () => { + console.log(`fpaste listening on port ${cfg.websrv.port}`); + }); \ No newline at end of file diff --git a/src/routes/index.mjs b/src/routes/index.mjs new file mode 100644 index 0000000..d2e8e55 --- /dev/null +++ b/src/routes/index.mjs @@ -0,0 +1,10 @@ +import index from "./r/index"; +import view from "./r/view"; +import about from "./r/about"; + + +export default { + index: index, + view: view, + about: about +}; \ No newline at end of file diff --git a/src/routes/r/about.mjs b/src/routes/r/about.mjs new file mode 100644 index 0000000..c4fea08 --- /dev/null +++ b/src/routes/r/about.mjs @@ -0,0 +1,8 @@ +import express from "express"; +const router = express.Router(); + +router.get("/", (req, res) => { + res.render("about"); +}); + +export default router; \ No newline at end of file diff --git a/src/routes/r/index.mjs b/src/routes/r/index.mjs new file mode 100644 index 0000000..72c8ce3 --- /dev/null +++ b/src/routes/r/index.mjs @@ -0,0 +1,8 @@ +import express from "express"; +const router = express.Router(); + +router.get("/", (req, res) => { + res.render("index"); +}); + +export default router; \ No newline at end of file diff --git a/src/routes/r/view.mjs b/src/routes/r/view.mjs new file mode 100644 index 0000000..f7cf078 --- /dev/null +++ b/src/routes/r/view.mjs @@ -0,0 +1,33 @@ +import express from "express"; +const router = express.Router(); + +import highlight from "highlight.js"; +console.log(highlight.highlightAuto("")); + +router.get("/", (req, res) => { + const data = { + pastes: [ + { + title: "title 01", + paste: highlight.highlightAuto("").value, + language: "PHP", + rows: "".split(/\n/).length + }, + { + title: "title 02", + paste: highlight.highlightAuto("blub").value, + language: "Plaintext", + rows: "blub".split(/\n/).length + }, + { + title: "title 03", + paste: highlight.highlightAuto("muh").value, + language: "Plaintext", + rows: "muh".split(/\n/).length + } + ] + }; + res.render("view", data); +}); + +export default router; \ No newline at end of file diff --git a/views/about.handlebars b/views/about.handlebars new file mode 100644 index 0000000..1991675 --- /dev/null +++ b/views/about.handlebars @@ -0,0 +1,5 @@ +

About fpaste.cc

+

fpaste.cc is here in it's 1st version – and it's better than expected! A completly written backend in NodeJS makes it possible to develop new features faster than ever before.

+

With the MariaDB database backend fpaste.cc is even more reliable and the express webserver library offers a powerfull framework.

+

The highlight highlighting engine offers great support for a variety of programming languages.

+

If you're interested in the source code of fpaste.cc, take a look at github.com. If you have any questions/suggestions or would like to contribute to fpaste.cc feel free to contact me.

\ No newline at end of file diff --git a/views/index.handlebars b/views/index.handlebars new file mode 100644 index 0000000..34a2bee --- /dev/null +++ b/views/index.handlebars @@ -0,0 +1,11 @@ +

New paste

+
+

Description:

+ +
    +
  • Language:

  • +
  • Hide from recent pastes:

  • +
+ + +
\ No newline at end of file diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars new file mode 100644 index 0000000..099acd8 --- /dev/null +++ b/views/layouts/main.handlebars @@ -0,0 +1,30 @@ + + + + fpaste + + + + + + + + +
+

3,5paste.cc

::

+

a javascript pastebin

+
+ +
  • New paste
  • +
  • View pastes
  • +

  • +
  • Login
  • +

  • +
  • About
  • +
    +
    +
    + {{{body}}} +
    + + \ No newline at end of file diff --git a/views/partials/pasteview.handlebars b/views/partials/pasteview.handlebars new file mode 100644 index 0000000..3baa58a --- /dev/null +++ b/views/partials/pasteview.handlebars @@ -0,0 +1,17 @@ +{{#each this}} +
    +

    15:13 - Thu 2017.06.15

    +

    {{language}}

    +

    Paste: /nNm/Show related

    +

    {{title}}

    +
    +
    +
    +
    {{#times rows}}{{this}}{{/times}}
    +
    +
    +
    +{{{paste}}}
    +
    +
    +{{/each}} \ No newline at end of file diff --git a/views/view.handlebars b/views/view.handlebars new file mode 100644 index 0000000..2e40e68 --- /dev/null +++ b/views/view.handlebars @@ -0,0 +1,8 @@ +{{!-- pasteview inside views/partials --}} +

    Most recent pastes

    +
    +

    Filter pastes (help):

    +
    +
    + {{> pasteview pastes }} +
    \ No newline at end of file