Use standard template

This commit is contained in:
Florine W. Dekker 2020-10-01 20:26:11 +02:00
parent 1150cabaea
commit 86ce93d067
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
10 changed files with 528 additions and 249 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
package-lock.json binary

117
.gitignore vendored Normal file
View File

@ -0,0 +1,117 @@
## Node
# 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.*

112
Gruntfile.js Normal file
View File

@ -0,0 +1,112 @@
const path = require("path");
module.exports = grunt => {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
default: ["dist/"],
},
copy: {
html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/"}]
},
},
focus: {
dev: {
include: ["html", "js", "link"],
},
},
replace: {
dev: {
src: ["./dist/*.html", "./dist/*.js"],
replacements: [
{
from: "%%VERSION_NUMBER%%",
to: "<%= pkg.version %>+" + new Date().toISOString().slice(0, 19).replace(/[-:T]/g, "")
}
],
overwrite: true
},
deploy: {
src: ["./dist/*.html", "./dist/*.js"],
replacements: [
{
from: "%%VERSION_NUMBER%%",
to: "<%= pkg.version %>"
}
],
overwrite: true
},
},
watch: {
html: {
files: ["src/main/**/*.html"],
tasks: ["copy:html"],
},
js: {
files: ["src/main/**/*.js"],
tasks: ["webpack:dev", "replace:dev"],
},
link: {
files: ["node_modules/@fwdekker/*/dist/**"],
tasks: ["webpack:dev", "replace:dev"],
},
},
webpack: {
options: {
entry: "./src/main/js/index.js",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".js"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist/"),
},
},
dev: {
mode: "development",
devtool: "inline-source-map",
},
deploy: {
mode: "production",
},
},
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-focus");
grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-webpack");
grunt.registerTask("dev", [
// Pre
"clean",
// Copy files
"copy:html",
// Compile JS
"webpack:dev",
"replace:dev",
]);
grunt.registerTask("dev:server", ["dev", "focus:dev"]);
grunt.registerTask("deploy", [
// Pre
"clean",
// Copy files
"copy:html",
// Compile JS
"webpack:deploy",
"replace:deploy",
]);
grunt.registerTask("default", ["dev"]);
};

View File

@ -1,3 +1,23 @@
# Codsworth name generator
Choose a fitting name for your _Fallout 4_ character that Codsworth can pronounce.
This tool gives you a list of names that look like yours so that you can pretend he's saying the right name.
## Development
### Requirements
* [npm](https://www.npmjs.com/)
### Setting up
```shell script
# Install dependencies (only needed once)
$> npm ci
```
### Building
```shell script
# Build the tool in `dist/` for development
$> npm run dev
# Same as above, but automatically rerun it whenever files are changed
$> npm run dev:server
# Build the tool in `dist/` for deployment
$> npm run deploy
```

File diff suppressed because one or more lines are too long

BIN
package-lock.json generated Normal file

Binary file not shown.

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "codsworth-namegen",
"version": "1.1.0",
"description": "Choose a fitting name for your Fallout 4 character that Codsworth can pronounce",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
"repository": {
"type": "git",
"url": "git@git.fwdekker.com:FWDekker/codsworth-namegen.git"
},
"private": true,
"scripts": {
"clean": "grunt clean",
"dev": "grunt dev",
"dev:server": "grunt dev:server",
"deploy": "grunt deploy"
},
"dependencies": {
"@fwdekker/template": "^0.0.21"
},
"devDependencies": {
"grunt": "^1.2.1",
"grunt-cli": "^1.3.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.2",
"webpack": "^4.44.0",
"webpack-cli": "^3.3.12"
}
}

76
src/main/index.html Normal file
View File

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="Felix W. Dekker" />
<meta name="application-name" content="Codsworth name generator" />
<meta name="description"
content="Choose a fitting name for your Fallout 4 character that Codsworth can pronounce." />
<meta name="theme-color" content="#0033cc" />
<title>Codsworth name generator</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"
crossorigin="anonymous" />
</head>
<body>
<noscript>
<span style="color: red; font-weight: bold;">
This website does not function if JavaScript is disabled.
Please check the <a href="https://www.enable-javascript.com/">
instructions on how to enable JavaScript in your web browser</a>.
</span>
</noscript>
<main style="display: none;">
<div id="nav"></div>
<div id="contents">
<div id="header"></div>
<!-- Generators -->
<section class="container">
<!-- Headers -->
<div class="row">
<div class="column">
<h2>Similar names</h2>
</div>
<div class="column">
<h2>Random names</h2>
</div>
</div>
<!-- Inputs -->
<div class="row">
<div class="column">
<label for="similarInput">Your name</label>
<input id="similarInput" type="text" autofocus />
</div>
<div class="column"></div>
</div>
<!-- Outputs -->
<div class="row">
<div class="column">
<button id="generateSimilar" type="button">Generate similar names</button>
<label for="similarNames">Similar names are...</label>
<textarea id="similarNames" style="height: 10em;" readonly></textarea>
</div>
<div class="column">
<button id="generateRandom" type="button">Generate random name</button>
<label for="randomNames">Your name is...</label>
<textarea id="randomNames" style="height: 10em;" readonly></textarea>
</div>
</div>
</section>
</div>
<div id="footer"></div>
</main>
<!-- Scripts -->
<script src="bundle.js"></script>
</body>
</html>

160
src/main/js/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,15 @@
"use strict";
const jaro_winkler = function (a, b, options) {
const optionDefault = (template, options) => {
for (let prop in options)
if (options.hasOwnProperty(prop))
template[prop] = options[prop];
return template;
};
export const jaro_winkler = function (a, b, options) {
// Load default options
options = optionDefault({"caseSensitive": true}, options);