From cf6302904d61ead65e6294e7f1be406eb68ef5f9 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 3 Jul 2017 00:26:08 -0500 Subject: ✨📝🔧 Add generator bin and files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes config for eslint, and jsdoc, plus the executable Squashed commit of the following: commit 7726a2743994800f5c0afbc23e5b529107b79450 Author: Ben Beltran Date: Mon Jul 3 00:25:43 2017 -0500 Update changelog commit 78ad8ab788020c09848a852e48827781aa17341a Author: Ben Beltran Date: Mon Jul 3 00:25:38 2017 -0500 Remove unused image commit 1cd659307a39669cf0fc8d0f676b25625fd16ba2 Author: Ben Beltran Date: Mon Jul 3 00:23:53 2017 -0500 Remove trailing slash on index commit 944160fcbc364e4a829be91e6ad32521b4f94987 Author: Ben Beltran Date: Mon Jul 3 00:21:50 2017 -0500 Add example blog post commit 70645d0214d5d363accfedc3e2583e97232c930e Author: Ben Beltran Date: Mon Jul 3 00:20:44 2017 -0500 ✨ Add binary / generator to lib commit bb8f8bb6e12c89bc4b9b3766fd2ef8e924422005 Author: Ben Beltran Date: Mon Jul 3 00:20:29 2017 -0500 🔧 Add package.json commit 7e9b6f52c1c91bf963319ddeb1696bfac4130b95 Author: Ben Beltran Date: Mon Jul 3 00:19:57 2017 -0500 🔧 Add eslint config commit 26ee06bbf1c2f20620c81fa94c4a9b40460bd401 Author: Ben Beltran Date: Mon Jul 3 00:19:31 2017 -0500 Move static files to template / static commit db84351cbb8e8c4729123650d1cb3a6150da0502 Author: Ben Beltran Date: Sun Jul 2 21:39:20 2017 -0500 Use a hidden name for posts directory --- bin/blog.js | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 bin/blog.js (limited to 'bin') diff --git a/bin/blog.js b/bin/blog.js new file mode 100755 index 0000000..c88a8aa --- /dev/null +++ b/bin/blog.js @@ -0,0 +1,92 @@ +#!/usr/bin/env node +'use strict'; + +const Config = require('../config/config'); +const Blog = require('..'); +const Minimist = require('minimist'); + +const internals = { + blog: new Blog(Config), + expectedKeys: ['add', 'update', 'publish'], + + // Application entry point. Reads arguments and calls the + // corresponding method from the blog lib + + async main() { + + try { + const parsedArguments = this._parseArguments(); + + for (const argument in parsedArguments) { + if (parsedArguments.hasOwnProperty(argument)) { + + const value = parsedArguments[argument]; + + if (argument === 'add') { + await internals.blog.add(value); + return; + } + + if (argument === 'update') { + await internals.blog.update(value); + return; + } + + if (argument === 'publish') { + await internals.blog.update(value); + return; + } + } + } + console.log('Not yet implemented'); + } + catch (err) { + console.error(err.message || err); + this._printUsage(); + process.exit(1); + } + }, + + // Parses arguments and returns them if valid. otherwise Throws + + _parseArguments() { + + const parsedArguments = Minimist(process.argv.slice(2)); + + if (!this._areArgumentsValid(parsedArguments)) { + throw new Error(internals.strings.invalidArguments); + } + + return parsedArguments; + }, + + // Checks if the arguments are valid, returns a boolean value. + + _areArgumentsValid(parsedArguments) { + + const argumentKeys = Object.keys(parsedArguments); + + return argumentKeys.some((key) => internals.expectedKeys.indexOf(key) >= 0); + }, + + // Prints the usage to stderr + + _printUsage() { + + console.error('\nUsage:\n'); + console.error('blog --add path/to/blog_post\t\t(creates new blog post)'); + console.error('blog --update path/to/blog_post\t(updates latest blog post)'); + console.error('blog --publish \t\t\t(publishes the blog)'); + } +}; + +// Add the strings, added after declaration so they can consume the +// internals object. + +internals.strings = { + invalidArguments: `Invalid Arguments, expecting one of: ${internals.expectedKeys.join(', ')}` +}; + + + +internals.main(); -- cgit From 397444675d7156acd6495223a3b15175d6853589 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 3 Jul 2017 00:52:43 -0500 Subject: 🐛✨📝 Add quick access, favicons and fix publish cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit 294b1de9d8d64f8356227b634091c3fd7982346b Author: Ben Beltran Date: Mon Jul 3 00:52:16 2017 -0500 ✨ Add quick access in frontend commit 70acd1f292c6bbfb6596a21bf0106837c85bf2f0 Author: Ben Beltran Date: Mon Jul 3 00:46:51 2017 -0500 Add pizza favicons commit b72471650a7632a1cead64ca9dab2210add13699 Author: Ben Beltran Date: Mon Jul 3 00:39:45 2017 -0500 📝 Correct missing entries in changelog commit 03b9fa8f7ae47a318dbde8bd245988b64cefe66f Author: Ben Beltran Date: Mon Jul 3 00:39:20 2017 -0500 📝 Add docs about publishing with surge commit 710cd3b3bf4a4f913d99addad69efc751a74611f Author: Ben Beltran Date: Mon Jul 3 00:38:06 2017 -0500 🐛 Fix publish command --- CHANGELOG.md | 2 ++ README.md | 8 ++++++++ bin/blog.js | 2 +- static/favicon.ico | Bin 0 -> 5430 bytes static/favicon.png | Bin 0 -> 3807 bytes static/js/blog.js | 28 ++++++++++++++++++++++++++++ templates/index.html | 2 ++ 7 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 static/favicon.ico create mode 100644 static/favicon.png create mode 100644 static/js/blog.js (limited to 'bin') diff --git a/CHANGELOG.md b/CHANGELOG.md index 728047b..f5d320d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- JSDoc config +- Eslint config - Binary to add and update blog posts - Template for index - Static Files diff --git a/README.md b/README.md index 7f7903a..4713730 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,11 @@ shifting the existing entries. `blog --publish` Will publish the blog. + +## How to publish + +At the moment, the app does not include any publishers. [surge][surge] is an easy +way to do it, just point it to your static directory. + + +[surge]: https://surge.sh diff --git a/bin/blog.js b/bin/blog.js index c88a8aa..5d27d4a 100755 --- a/bin/blog.js +++ b/bin/blog.js @@ -33,7 +33,7 @@ const internals = { } if (argument === 'publish') { - await internals.blog.update(value); + await internals.blog.publish(value); return; } } diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..81582e2 Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..b77a959 Binary files /dev/null and b/static/favicon.png differ diff --git a/static/js/blog.js b/static/js/blog.js new file mode 100644 index 0000000..a49a72f --- /dev/null +++ b/static/js/blog.js @@ -0,0 +1,28 @@ +'use strict'; + +/* globals window */ + +((window) => { + + const internals = { + kEntryPoint: '.event-details', + + // Application entry point, for now just band to keyboard + + main() { + + window.document.addEventListener('keydown', internals._onKeyDown); + }, + + // Handles key events to point to the correct blog post. + + _onKeyDown(event) { + + if (['1','2','3'].indexOf(event.key) > -1) { + window.location.hash = event.key; + } + } + }; + + window.addEventListener('load', internals.main); +})(window); diff --git a/templates/index.html b/templates/index.html index 858396b..e741c68 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,6 +6,8 @@ blog 🍕 + + -- cgit