From 7269d73b757c12e0700d9bc047fee70f066ac6b3 Mon Sep 17 00:00:00 2001 From: moklick Date: Fri, 5 Jan 2018 18:13:15 +0100 Subject: [PATCH] feat(docs): add generator --- .gitignore | 1 + docs/generate.js | 54 ++++++++ docs/index.tpl.html | 21 +++ docs/index_docs.html | 300 +++++++++++++++++++++++++++++++++++++++++++ docs/style.css | 26 ++++ package-lock.json | 50 ++++---- package.json | 2 +- 7 files changed, 428 insertions(+), 26 deletions(-) create mode 100644 docs/generate.js create mode 100644 docs/index.tpl.html create mode 100644 docs/index_docs.html create mode 100644 docs/style.css diff --git a/.gitignore b/.gitignore index 74fc986..667a66c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ yarn.lock config.json npm-debug.log *.sublime-* +.DS_Store \ No newline at end of file diff --git a/docs/generate.js b/docs/generate.js new file mode 100644 index 0000000..c418390 --- /dev/null +++ b/docs/generate.js @@ -0,0 +1,54 @@ +const fs = require('fs'); +const path = require('path'); +const marked = require('marked'); + +const renderer = new marked.Renderer(); +renderer.heading = headingParser; + +const toc = []; + +const docsMarkdown = readFile('docs.md'); +const docsAsHtml = marked(docsMarkdown, { renderer }); +const navAsHtml = generateNavigation(toc); + +const indexTemplate = readFile('index.tpl.html'); +const index = indexTemplate + .replace('{{content}}', docsAsHtml) + .replace('{{navigation}}', navAsHtml); + + +fs.writeFile(path.resolve(__dirname, 'index_docs.html'), index, () => {}); + + +function generateNavigation(toc) { + return toc + .filter(item => item.level === 1 || item.level === 2) + .map(item => ` + + ${item.text} + + `) + .join('\n'); +} + +// helper +function readFile(fileName) { + return fs.readFileSync(path.resolve(__dirname, fileName)).toString(); +} + +function headingParser(text, level) { + const slug = text.toLowerCase().replace(/[^\w]+/g, '-'); + + toc.push({ level, slug, text }); + + return ` + + + ${text} + + + `; +} \ No newline at end of file diff --git a/docs/index.tpl.html b/docs/index.tpl.html new file mode 100644 index 0000000..79b64d1 --- /dev/null +++ b/docs/index.tpl.html @@ -0,0 +1,21 @@ + + + schnack - simple self-hosted comment system for static websites + + + +
+ +
+
+

schnack!

+

An easy to use and open source commenting system

+
+ {{content}} +
+
+ + diff --git a/docs/index_docs.html b/docs/index_docs.html new file mode 100644 index 0000000..537912b --- /dev/null +++ b/docs/index_docs.html @@ -0,0 +1,300 @@ + + + schnack - simple self-hosted comment system for static websites + + + +
+ +
+
+

schnack!

+

An easy to use and open source commenting system

+
+ +

+ + Quickstart + +

+

This is the fastest way to setup schnack.

+

Requirements:

+
    +
  • Node.js (>= v6)
  • +
  • npm (>= v5)
  • +
+

Clone or download schnack:

+
git clone https://github.com/gka/schnack
+

Go to the schnack directory:

+
cd schnack
+

Install dependencies:

+
npm install
+

Copy and edit the config file according to Configuration:

+
cp config.tpl.json config.json
+

Run the server:

+
npm start
+
    +
  • Embed in your HTML page:
    <div class="comments-go-here"></div>
    +<script src="https://comments.yoursite.com/embed.js"
    +  data-schnack-slug="post-slug"
    +  data-schnack-target=".comments-go-here">
    +</script>
    +
    +
  • +
+ +

+ + Configuration + +

+ +

+ + General + +

+ +

+ + Authentication + +

+
    +
  • secret
  • +
+ +

+ + Twitter + +

+ +

+ + GitHub + +

+ +

+ + Google + +

+ +

+ + Facebook + +

+ +

+ + Notifications + +

+ +

+ + web-push + +

+ +

+ + slack + +

+ +

+ + PushOver + +

+ +

+ + Trust your friends + +

+ +

+ + Administration + +

+ +

+ + Moderation + +

+ +

+ + Backups + +

+ +

+ + Import comments + +

+ +

+ + WordPress + +

+ +

+ + Disqus + +

+ +

+ + Docker + +

+ +

+ + How it works ? + +

+ +

+ + Development + +

+ +
+
+ + diff --git a/docs/style.css b/docs/style.css new file mode 100644 index 0000000..38a5132 --- /dev/null +++ b/docs/style.css @@ -0,0 +1,26 @@ +* { + box-sizing: border-box; +} + +html, body { + margin: 0; +} + +.main{ + max-width: 1000px; + margin: 0 auto; + display: flex; +} + +aside { + width: 25%; + max-width: 300px; +} + +aside img { + width: 100px; +} + +aside .nav__item { + display: block +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e30e092..6516353 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1187,14 +1187,6 @@ "uglify-js": "3.1.3" } }, - "http_ece": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/http_ece/-/http_ece-0.5.2.tgz", - "integrity": "sha1-VlTX7J2Za3Sc4AonbhjVS22PkF8=", - "requires": { - "urlsafe-base64": "1.0.0" - } - }, "http-errors": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", @@ -1249,6 +1241,14 @@ "sshpk": "1.13.1" } }, + "http_ece": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/http_ece/-/http_ece-0.5.2.tgz", + "integrity": "sha1-VlTX7J2Za3Sc4AonbhjVS22PkF8=", + "requires": { + "urlsafe-base64": "1.0.0" + } + }, "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", @@ -3431,14 +3431,6 @@ } } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -3449,6 +3441,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", @@ -3590,15 +3590,6 @@ "duplexer": "0.1.1" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -3609,6 +3600,15 @@ "strip-ansi": "4.0.0" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/package.json b/package.json index 7f73b5c..6eee450 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "scripts": { "start": "node index.js", - "docs": "echo 'building docs (TODO)'", + "docs": "node docs/generate.js", "build": "rollup -cw", "test-server": "http-server test -o 'http://localhost:8080/' -P 'http://localhost:3000/'", "server": "NODE_ENV=development nodemon index.js",