Update for first iteration
This commit is contained in:
parent
8327073431
commit
0e5c22c68a
137
.gitignore
vendored
Normal file
137
.gitignore
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# ---> Node
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
certs/
|
||||||
|
build/
|
||||||
|
public/js/
|
||||||
|
node-modules/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# 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 variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# 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
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
12
README.md
12
README.md
@ -1,2 +1,12 @@
|
|||||||
# ausreden
|
# Die Ausreden
|
||||||
|
|
||||||
|
The happenest, hippest excuse generator. To compile, just run `npm start`.
|
||||||
|
|
||||||
|
Once built, all that's needed is to copy the build path into your web server.
|
||||||
|
|
||||||
|
Et voilà!
|
||||||
|
|
||||||
|
## Getting the Excuse Downfunnel
|
||||||
|
|
||||||
|
This is simple. Just copy the contents of the text field. This is to allow for
|
||||||
|
insecure connections. Secure connections are required to copy to the clipboard.
|
||||||
|
14
gulpfile.js
Normal file
14
gulpfile.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const replace = require('gulp-replace');
|
||||||
|
const { src, dest } = require('gulp');
|
||||||
|
require('dotenv/config');
|
||||||
|
|
||||||
|
// or replace multiple strings
|
||||||
|
function replaceTemplate() {
|
||||||
|
return src(['./dist/**'])
|
||||||
|
// .pipe(replace(/FONTAWESOME_SCRIPT_URL/g, process.env.FONTAWESOME_SCRIPT_URL))
|
||||||
|
// .pipe(replace(/CONFIG_STORE_URL/g, process.env.CONFIG_STORE_URL))
|
||||||
|
// .pipe(replace(/CONFIG_FETCH_URL/g, process.env.CONFIG_FETCH_URL))
|
||||||
|
.pipe(dest('./dist/'));
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.default = replaceTemplate;
|
BIN
images/favicon.png
Normal file
BIN
images/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
images/logo192.png
Normal file
BIN
images/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
BIN
images/logo512.png
Normal file
BIN
images/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 471 KiB |
7
js/serviceworker.js
Normal file
7
js/serviceworker.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// This code executes in its own worker or thread
|
||||||
|
self.addEventListener("install", event => {
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener("fetch", (e) => {
|
||||||
|
console.log(`[Service Worker] Fetched resource ${e.request.url}`);
|
||||||
|
});
|
6453
package-lock.json
generated
Normal file
6453
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
package.json
Normal file
33
package.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "ausreden",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "npm run build",
|
||||||
|
"build": "npx tsc && cp -R public dist && npx gulp && npx rollup -c",
|
||||||
|
"clean": "rm -rf build && rm -rf dist",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^16.4.5",
|
||||||
|
"lit": "^3.1.2",
|
||||||
|
"typescript": "^5.4.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-babel": "^6.0.4",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
|
"@types/node": "^20.12.5",
|
||||||
|
"@web/rollup-plugin-copy": "^0.4.1",
|
||||||
|
"@web/rollup-plugin-html": "^2.3.0",
|
||||||
|
"@web/rollup-plugin-polyfills-loader": "^2.1.1",
|
||||||
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-replace": "^1.1.4",
|
||||||
|
"rollup": "^2.79.1",
|
||||||
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
||||||
|
"rollup-plugin-summary": "^2.0.0"
|
||||||
|
}
|
||||||
|
}
|
0
public/css/app.css
Normal file
0
public/css/app.css
Normal file
18
public/index.html
Normal file
18
public/index.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="./css/app.css">
|
||||||
|
<link rel="manifest" href="./manifest.json" />
|
||||||
|
<script type="module" src="./js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<excuse-generator></excuse-generator>
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register("./js/serviceworker.js", {scope: '.'});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
25
public/manifest.json
Normal file
25
public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"short_name": "Ausreden",
|
||||||
|
"name": "Ausreden",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "../images/favicon.png",
|
||||||
|
"sizes": "32x32",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "../images/logo192.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "../images/logo512.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
30
rollup.config.mjs
Normal file
30
rollup.config.mjs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Import rollup plugins
|
||||||
|
import { rollupPluginHTML as html } from "@web/rollup-plugin-html";
|
||||||
|
import {copy} from '@web/rollup-plugin-copy';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
// import * as terser from '@rollup/plugin-terser';
|
||||||
|
// import * as minifyHTML from 'rollup-plugin-minify-html-literals';
|
||||||
|
import summary from 'rollup-plugin-summary';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
plugins: [
|
||||||
|
// Entry point for application build; can specify a glob to build multiple
|
||||||
|
// HTML files for non-SPA app
|
||||||
|
html({
|
||||||
|
input: 'dist/**.html',
|
||||||
|
}),
|
||||||
|
// Resolve bare module specifiers to relative paths
|
||||||
|
resolve(),
|
||||||
|
// Print bundle summary
|
||||||
|
summary(),
|
||||||
|
// Optional: copy any static assets to build directory
|
||||||
|
copy({
|
||||||
|
patterns: ['images/**/*', 'manifest.json', 'js/**/*'],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
dir: 'build',
|
||||||
|
},
|
||||||
|
experimentalCodeSplitting: true,
|
||||||
|
preserveEntrySignatures: 'strict',
|
||||||
|
};
|
114
src/index.ts
Normal file
114
src/index.ts
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
import { LitElement, css, html } from 'lit';
|
||||||
|
import { customElement } from 'lit/decorators.js';
|
||||||
|
|
||||||
|
@customElement('excuse-generator')
|
||||||
|
export class ExcuseGenerator extends LitElement {
|
||||||
|
excuse = '';
|
||||||
|
excuses = [
|
||||||
|
// Courtesy of https://github.com/jfsmig/daily
|
||||||
|
"<I've had a sleepless night|My cat puked last night, it kept me up late>. I'm <too tired|sleepless|exhausted>.",
|
||||||
|
"<I've had a sleepless night|My dog puked last night, it kept me up late>. I'm <too tired|sleepless|exhausted>.",
|
||||||
|
"I've been sprayed by a skunk, I cannot focus because of the smell.",
|
||||||
|
'<shingles|a tree> fell on my car.',
|
||||||
|
'My <tongue|toe|thumb> is trapped in the bath tap.',
|
||||||
|
'I used too much body lotion, I slipped and cannot exit my bathtub.',
|
||||||
|
'My trousers split on the way to work.',
|
||||||
|
"I've had a hair <dye|douche bag> disaster.",
|
||||||
|
'My curlers burned my hair and I had to go to the hairdresser.',
|
||||||
|
"I am stuck in my house because the door's broken.",
|
||||||
|
"I forgot to come back to work after lunch.",
|
||||||
|
"My <right arm|brain> went to sleep, and I couldn't wake it up.",
|
||||||
|
'I forgot what day of the week it was.',
|
||||||
|
"My dog has had a big fright and I don't want to leave him.",
|
||||||
|
"I drank too much last night and I don't know where I am.",
|
||||||
|
'I woke up late and missed my train... again.',
|
||||||
|
"I'm in A&E as I got a clothes peg stuck on my tongue.",
|
||||||
|
"I ate some very spicy chicken wings last night -- It's best I stay home.",
|
||||||
|
'I woke up and unexpectedly had to drive my family to another state.',
|
||||||
|
"My bus broke down and was held up by robbers.",
|
||||||
|
'I was arrested as a result of <mistaken identity|extreme blood alcohol|unbearable smell>.',
|
||||||
|
"I totaled my wife's jeep in a collision with <a cow|my mother-in-law>.",
|
||||||
|
'A <IRS agent|hitman|US Marshall|guy in leather> was looking for me.',
|
||||||
|
"I eloped. They are after me, but won't catch me.",
|
||||||
|
"I had to be there for my <mother|partner>'s grand jury trial.",
|
||||||
|
"I had to ship my <mother-in-law's body|grandmother's bones> to her homeland, but she doesn't agree.",
|
||||||
|
'Someone slipped drugs in my drink last night.',
|
||||||
|
'My car handbrake broke and it rolled down the hill into a lamppost.',
|
||||||
|
"I'm using a new contact lens solution and my eyes are watering.",
|
||||||
|
'I tripped over my dog and was knocked unconscious.',
|
||||||
|
'I burned my <foot|hand|tongue> on the toaster.',
|
||||||
|
"I've got a sore <finger|throat>.",
|
||||||
|
'I have a blocked <nose|knee|window|car wheel>.',
|
||||||
|
'I was spit on by a <venomous snake|homeless guy without teeth>. It hurts and stinks.',
|
||||||
|
'my kids are sick< |, as usual onlyk on weekdays> and are puking all around.',
|
||||||
|
'<My laptop|A can of baked beans> landed on my big toe.',
|
||||||
|
"I've <injured|hurt|bit> myself during <sex|pair programming>.",
|
||||||
|
'My <dog|parrot|new girlfriend> bit me i`n a delicate place.',
|
||||||
|
'I swallowed <white spirit|bioethanol|a billiard ball>.',
|
||||||
|
'I am <hallucinating|fainting|seeing dead animals>.',
|
||||||
|
'I was swimming too fast and smacked my head on the poolside.',
|
||||||
|
"I've been bitten by <an insect|a spider> and the larva are starting to get out.",
|
||||||
|
'Someone slipped drugs in my drink last night.',
|
||||||
|
'I identify as on holiday.',
|
||||||
|
];
|
||||||
|
|
||||||
|
randomSubsection(section: string) {
|
||||||
|
let genSubsection = section;
|
||||||
|
const matches = section.match(/\<(?!\<)([^\>]+)\>/g);
|
||||||
|
|
||||||
|
matches?.forEach((match: string) => {
|
||||||
|
const matchedString = match.replace(/^\</, '').replace(/\>$/, '');
|
||||||
|
const subsections = matchedString.split('|');
|
||||||
|
if (subsections) {
|
||||||
|
const subsection = subsections[Math.floor(Math.random() * subsections.length)];
|
||||||
|
const randSubsection = this.randomSubsection(subsection);
|
||||||
|
genSubsection = genSubsection.replace(/\<[^\<]+\>/, randSubsection);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return genSubsection;
|
||||||
|
}
|
||||||
|
|
||||||
|
getExcuse() {
|
||||||
|
const randomPosition = Math.floor(Math.random() * this.excuses.length);
|
||||||
|
const generatedExcuse = this.excuses[randomPosition];
|
||||||
|
this.excuse = this.randomSubsection(generatedExcuse);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateNewExcuse() {
|
||||||
|
this.getExcuse();
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
static override styles = [
|
||||||
|
css`
|
||||||
|
.centerit {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
border: .01em solid black;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
];
|
||||||
|
|
||||||
|
override render() {
|
||||||
|
this.getExcuse();
|
||||||
|
return html`
|
||||||
|
<h1 class="centerit">Die Ausreden</h1>
|
||||||
|
<div style="margin-left: auto; margin-right: auto; width: 30%;">
|
||||||
|
<button @click="${() => this.generateNewExcuse()}">Generate Excuse</button>
|
||||||
|
<br></br>
|
||||||
|
<textarea cols="80" rows="5" readOnly="true">${this.excuse}</textarea>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'excuse-generator': ExcuseGenerator;
|
||||||
|
}
|
||||||
|
}
|
34
tsconfig.json
Normal file
34
tsconfig.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2019",
|
||||||
|
"module": "ES2020",
|
||||||
|
"lib": ["ES2019", "DOM", "DOM.Iterable"],
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"outDir": "./public/js",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"strict": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitOverride": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "ts-lit-plugin",
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"compileOnSave": true
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user