aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2021-12-19 14:21:33 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2021-12-19 14:21:33 +0100
commit5d9f7190bd118fe4d44594d7a9584de98b527467 (patch)
treec323938b4626290a227a652380af769d7f4c4518 /src
parent29f687276d9e9ef01ce70ebd210a01386ca581ae (diff)
Port to svelte
Diffstat (limited to 'src')
-rw-r--r--src/app.html16
-rw-r--r--src/global.d.ts1
-rw-r--r--src/lib/components/rules.svelte20
-rw-r--r--src/lib/rule_generator.js32
-rw-r--r--src/lib/rules/business.js74
-rw-r--r--src/lib/rules/curfew.js69
-rw-r--r--src/lib/rules/group.js51
-rw-r--r--src/lib/rules/index.js11
-rw-r--r--src/lib/rules/mask.js51
-rw-r--r--src/lib/stores/rules.js24
-rw-r--r--src/routes/index.svelte10
11 files changed, 359 insertions, 0 deletions
diff --git a/src/app.html b/src/app.html
new file mode 100644
index 0000000..d584386
--- /dev/null
+++ b/src/app.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="author" content="Rubén Beltrán del Río">
+ <meta name="theme-color" content="#db5945">
+
+ <link rel="stylesheet" href="/global.css" />
+ %svelte.head%
+ </head>
+ <body>
+ <div id="svelte">%svelte.body%</div>
+ </body>
+</html>
diff --git a/src/global.d.ts b/src/global.d.ts
new file mode 100644
index 0000000..63908c6
--- /dev/null
+++ b/src/global.d.ts
@@ -0,0 +1 @@
+/// <reference types="@sveltejs/kit" />
diff --git a/src/lib/components/rules.svelte b/src/lib/components/rules.svelte
new file mode 100644
index 0000000..4693579
--- /dev/null
+++ b/src/lib/components/rules.svelte
@@ -0,0 +1,20 @@
+<script>
+ import { getRules } from '$lib/stores/rules';
+
+ $: rules = getRules();
+</script>
+
+<h1>
+ New Corona Regulations Berlin
+</h1>
+<ul>
+ {#each $rules as rule}
+ <li>
+ <h2>Starting {rule.time}</h2>
+ <p>
+ <span class="emoji">{rule.rule.emoji}</span>
+ <span class="text">{rule.rule.text}</span>
+ </p>
+ </li>
+ {/each}
+</ul>
diff --git a/src/lib/rule_generator.js b/src/lib/rule_generator.js
new file mode 100644
index 0000000..6958bec
--- /dev/null
+++ b/src/lib/rule_generator.js
@@ -0,0 +1,32 @@
+import Rules from './rules';
+
+const internals = {
+
+ dates: [
+ 'today',
+ 'tomorrow',
+ 'next friday',
+ 'next wednesday',
+ 'last thursday',
+ 'last tuesday',
+ 'the next day divisible by 7',
+ 'this afternoon',
+ 'next fiscal quarter',
+ ],
+
+ rules: [
+ ...Rules
+ ],
+ currentIndex: 0
+}
+
+export const generate = async function () {
+
+ const rule = internals.rules[internals.currentIndex];
+ const time = internals.dates[Math.floor(Math.random() * internals.dates.length)];
+ internals.currentIndex = (internals.currentIndex + 1) % internals.rules.length
+ return {
+ rule: rule(),
+ time
+ }
+}
diff --git a/src/lib/rules/business.js b/src/lib/rules/business.js
new file mode 100644
index 0000000..d021173
--- /dev/null
+++ b/src/lib/rules/business.js
@@ -0,0 +1,74 @@
+const internals ={
+
+ businesses: [
+ 'butcher shops',
+ 'plant shops',
+ 'balloon factories',
+ 'pet hotels',
+ 'sex shops',
+ 'clothes incineration facilities',
+ 'city dumps',
+ 'glass factories',
+ 'roads',
+ 'windfarm analysis consultancies',
+ 'peanut depots',
+ 'glue factories',
+ 'bürgeramts',
+ 'chiropractors',
+ 'gong bath facilities',
+ 'wrestling rings',
+ 'cat cafés',
+ 'paint your own pottery centers',
+ 'dungeons',
+ 'television sets',
+ 'nasa offices',
+ 'toilet factories',
+ 'condom inspection facilities',
+ 'high school newspapers',
+ 'dog spas',
+ 'mink breeding centers',
+ 'NGOs',
+ 'yoga cults',
+ 'MI6 safehouses',
+ 'döner shops',
+ 'hospitals'
+ ],
+
+ restrictions: [
+ 'are required to work from home',
+ 'require mandatory testing',
+ 'must remain closed',
+ 'must remain open',
+ 'must offer 50% covid discounts',
+ 'must become vaccination centers',
+ 'must pay staff 3x on thursdays',
+ 'can only meet with one other household',
+ 'must share facilities',
+ 'are exempt from mask rules',
+ ],
+
+ join(array) {
+
+ const firstPart = array.slice(0, -1).join(', ')
+ const lastPart = array.slice(-1)
+
+ const conjunction = array.length <= 1 ? '' : ', and '
+
+ return [firstPart, lastPart].join(conjunction)
+ }
+};
+
+export default function () {
+
+ const businesses = internals.businesses
+ .filter(() => true)
+ .sort(() => Math.random() - 0.5)
+ .slice(0, Math.floor(Math.random() * 3) + 1)
+ const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)];
+ const text = `${internals.join(businesses)} ${restriction}`
+
+ return {
+ emoji: '🏢',
+ text: text.charAt(0).toUpperCase() + text.slice(1)
+ };
+}
diff --git a/src/lib/rules/curfew.js b/src/lib/rules/curfew.js
new file mode 100644
index 0000000..379f64b
--- /dev/null
+++ b/src/lib/rules/curfew.js
@@ -0,0 +1,69 @@
+const internals ={
+
+ activities: [
+ 'sex',
+ 'skinny dipping',
+ 'playing chess',
+ 'debating',
+ 'dancing',
+ 'breeding horses',
+ 'laughing',
+ 'sneezing',
+ 'cat wrestling',
+ 'ordering food',
+ 'remote work',
+ 'internet usage',
+ 'sleeping',
+ 'eating',
+ 'vacuuming',
+ 'using a blender',
+ 'having a party',
+ 'theft',
+ 'engaging in economic activity',
+ 'using ketchup',
+ 'tailgating',
+ 'embezzelment',
+ 'taking the U-Bahn',
+ 'cutting your hair',
+ 'using recreational drugs',
+ 'tipping',
+ 'interpretive dancing',
+ 'origami',
+ 'whittling',
+ 'going for a walk',
+ 'working'
+ ],
+
+ restrictions: [
+ 'is not allowed',
+ 'is mandatory',
+ 'is optional',
+ 'requires a mask',
+ 'is only allowed indoors',
+ 'is only allowed outdoors',
+ 'is only allowed in groups larger than seven',
+ 'requires a license',
+ 'is allowed under police supervision',
+ 'is allowed following social distancing rules',
+ 'is only allowed in Neukölln',
+ 'is only allowed in Kreuzberg',
+ 'is only allowed in Charlottenburg',
+ 'is only allowed in Wedding',
+ 'is only allowed in Mitte',
+ 'is only allowed in Prenzlauer Berg',
+ 'is only allowed in Friedrichshain',
+ ]
+};
+
+export default function () {
+
+ const startTime = Math.floor(Math.random() * 23) + 1;
+ const endTtime = Math.floor(Math.random() * 23) + 1;
+ const activity = internals.activities[Math.floor(Math.random() * internals.activities.length)];
+ const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)];
+
+ return {
+ emoji: '🕚',
+ text: `From ${startTime}:00 to ${endTtime}:00 ${activity} ${restriction}`
+ };
+}
diff --git a/src/lib/rules/group.js b/src/lib/rules/group.js
new file mode 100644
index 0000000..60cca55
--- /dev/null
+++ b/src/lib/rules/group.js
@@ -0,0 +1,51 @@
+const internals ={
+
+ groups: [
+ 'teenagers',
+ 'influencers',
+ 'vegans',
+ 'tik-tok users',
+ 'lactose intolerants',
+ 'households',
+ 'ice cream vendors',
+ 'babies',
+ 'police officers',
+ 'drug dealers',
+ 'tech workers',
+ 'cryptocurrency miners',
+ 'mexicans',
+ 'smokers',
+ 'drug users',
+ 'octogenarians',
+ 'public officials',
+ 'atheists',
+ 'god fearing parishioners',
+ 'b-list actors',
+ 'jugglers',
+ 'seagulls',
+ 'lighthouse operators',
+ 'tram drivers',
+ 'psychics',
+ 'magicians',
+ 'classically trained musicians',
+ 'food delivery drivers',
+ 'librarians',
+ 'doctors',
+ 'vaccinated cats',
+ 'balloon artists'
+ ],
+};
+
+export default function () {
+
+ const countA = Math.floor(Math.random() * 8) + 2;
+ const magnitude = Math.random() > 0.5 ? 99 : 5;
+ const countB = Math.floor(Math.random() * magnitude) + 1;
+ const groupA = internals.groups[Math.floor(Math.random() * internals.groups.length)];
+ const groupB = internals.groups[Math.floor(Math.random() * internals.groups.length)];
+
+ return {
+ emoji: '👨',
+ text: `No more than ${countA} ${groupA} + ${countB} ${groupB} are allowed to meet`
+ };
+}
diff --git a/src/lib/rules/index.js b/src/lib/rules/index.js
new file mode 100644
index 0000000..d18d9b6
--- /dev/null
+++ b/src/lib/rules/index.js
@@ -0,0 +1,11 @@
+import Business from './business';
+import Curfew from './curfew';
+import Group from './group';
+import Mask from './mask';
+
+export default [
+ Business,
+ Curfew,
+ Group,
+ Mask
+];
diff --git a/src/lib/rules/mask.js b/src/lib/rules/mask.js
new file mode 100644
index 0000000..a27fe36
--- /dev/null
+++ b/src/lib/rules/mask.js
@@ -0,0 +1,51 @@
+const internals ={
+
+ masks: [
+ 'HTML',
+ 'FFP4',
+ 'Leather',
+ 'Denim',
+ 'Pink',
+ 'RSVP',
+ 'TBD',
+ 'Quantum',
+ 'Medical',
+ 'GMO',
+ 'FFP9',
+ 'FFP2.5',
+ 'KN96',
+ 'France98',
+ 'Mesh',
+ ],
+
+ conditions: [
+ 'when dancing',
+ 'at all times',
+ 'in bed',
+ 'outdoors',
+ 'when running',
+ 'when driving',
+ 'when cycling',
+ 'in restaurants',
+ 'in pools',
+ 'in small groups',
+ 'at 3pm',
+ 'at 5pm',
+ 'when nobody is looking',
+ 'around the police',
+ 'when speaking',
+ 'while chewing gum',
+ 'while eating bread',
+ ]
+};
+
+export default function () {
+
+ const mask = internals.masks[Math.floor(Math.random() * internals.masks.length)];
+ const condition = internals.conditions[Math.floor(Math.random() * internals.conditions.length)];
+
+ return {
+ emoji: '😷',
+ text: `${mask} masks must be worn ${condition}`
+ };
+}
diff --git a/src/lib/stores/rules.js b/src/lib/stores/rules.js
new file mode 100644
index 0000000..8c2755e
--- /dev/null
+++ b/src/lib/stores/rules.js
@@ -0,0 +1,24 @@
+import { readable } from 'svelte/store';
+import { generate } from '$lib/rule_generator';
+
+const internals = {
+ ruleCount: 4
+};
+
+export const getRules = function () {
+
+ return readable([], function (set) {
+
+ (async function() {
+
+ const rules = [];
+ for (let i = 0; i < internals.ruleCount; ++i) {
+ rules.push(await generate());
+ }
+
+ set(rules.sort(() => Math.random() - 0.5));
+ })();
+
+ return function stop() {};
+ });
+};
diff --git a/src/routes/index.svelte b/src/routes/index.svelte
new file mode 100644
index 0000000..12e59b3
--- /dev/null
+++ b/src/routes/index.svelte
@@ -0,0 +1,10 @@
+<script>
+ import Rules from '$lib/components/rules.svelte';
+</script>
+
+<svelte:head>
+ <title>New Corona Regulations for Berlin</title>
+ <meta name="description" content="New corona regulations for Berlin">
+</svelte:head>
+
+<Rules />