commit d7315ceffeba30bd911e04f5cba02754851e73a6 Author: Felix W. Dekker Date: Sat May 2 23:02:42 2020 +0200 Set up basic template diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fd1294f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true + +end_of_line = lf +insert_final_newline = true + +indent_style = space +indent_size = 4 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1a6bd45 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +package-lock.json binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ee442ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,120 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.pnp.* + + +## Custom +build/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e172412 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Felix W. Dekker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e0901c --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# FWDekker Template +The template used on many pages on fwdekker.com. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8d9f95a Binary files /dev/null and b/package-lock.json differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..779a6e4 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "@fwdekker/template", + "version": "0.0.5", + "description": "The template used on many pages on fwdekker.com.", + "author": "Felix W. Dekker (https://fwdekker.com)", + "license": "MIT", + "homepage": "https://git.fwdekker.com/FWDekker/fwdekker-template", + "repository": { + "type": "git", + "url": "git@git.fwdekker.com:FWDekker/fwdekker-template.git" + }, + "bugs": { + "url": "https://git.fwdekker.com/FWDekker/fwdekker-template/issues" + }, + "main": "src/main/js/Template.js", + "dependencies": { + "hyperscript": "^2.0.2" + } +} diff --git a/src/main/js/Template.js b/src/main/js/Template.js new file mode 100644 index 0000000..df96d75 --- /dev/null +++ b/src/main/js/Template.js @@ -0,0 +1,63 @@ +const h = require("hyperscript"); + + +/** + * Creates a header element with the given title and description. + * + * @param title {string} the title to display + * @param description {string} the description to display + * @returns {HTMLElement} a header element + */ +exports.header = function ({title, description}) { + return h("header.header", + h("section.container", + h("h1", title), + h("p", h("em", description)) + ) + ); +} + +/** + * Creates a footer element with the given data. + * + * @param [author] {string} the author + * @param [authorURL] {string} the URL to link the author's name to + * @param [license] {string} the type of license + * @param [licenseURL] {string} the URL to the license file + * @param [vcs] {string} the type of version control + * @param [vcsURL] {string} the URL to the repository + * @param [version] {string} the page version + * @returns {HTMLElement} a footer element + */ +exports.footer = function ({author, authorURL, license, licenseURL, vcs, vcsURL, version}) { + return h("footer.footer", + h("section.container", + footerLink("Made by ", author, authorURL, ". "), + footerLink("Licensed under the ", license, licenseURL, ". "), + footerLink("Source code available on ", vcs, vcsURL, ". "), + h("div", version || "", {style: {"float": "right"}}) + ) + ); +} + + +/** + * Constructs a link that is used in footers. + * + * @param prefix {string} the text to display before the text if the text is not undefined + * @param text {string|undefined} the text to display, or `undefined` if the returned element should be empty + * @param url {string|undefined} the URL to link the text to, or `undefined` if the text should not be a link + * @param suffix {string} the text to display after the text if the text is not undefined + * @returns {HTMLElement} a footer link element + */ +const footerLink = function (prefix, text, url, suffix) { + if (text === undefined) return h("span"); + + return h("span", + h("span", prefix), + url !== undefined + ? h("a", text, {href: url}) + : h("span", text), + h("span", suffix) + ); +}