Port to astro
This commit is contained in:
parent
a701743635
commit
93ee2a943e
13 changed files with 3869 additions and 180 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
node_modules/
|
||||
dist/
|
||||
.astro/
|
||||
6
astro.config.mjs
Normal file
6
astro.config.mjs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
|
||||
export default defineConfig({
|
||||
build: { format: 'file' },
|
||||
compressHTML: false,
|
||||
});
|
||||
3657
package-lock.json
generated
Normal file
3657
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
13
package.json
Normal file
13
package.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "kik-website",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"astro": "^7.4.2"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 123 KiB |
1
src/components/Prompt.astro
Normal file
1
src/components/Prompt.astro
Normal file
|
|
@ -0,0 +1 @@
|
|||
<p class="prompt"><b>root@khaos-im-kiez</b>:~# <slot /><span class="cursor"></span></p>
|
||||
110
src/components/Terminal.astro
Normal file
110
src/components/Terminal.astro
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
---
|
||||
import Prompt from './Prompt.astro';
|
||||
---
|
||||
<Prompt><span id="term-input"></span></Prompt>
|
||||
|
||||
<script>
|
||||
const term = document.getElementById('term-input');
|
||||
let buf = '';
|
||||
let ws = null;
|
||||
let connected = false;
|
||||
let firstEnter = true;
|
||||
|
||||
function appendOutput(text){
|
||||
if(!text) return;
|
||||
// append to term display (simple)
|
||||
term.textContent += text;
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(e){
|
||||
const t = e.target;
|
||||
if(t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;
|
||||
if(e.ctrlKey || e.altKey || e.metaKey) return;
|
||||
|
||||
if(e.key === 'Backspace'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\b');
|
||||
return;
|
||||
}
|
||||
buf = buf.slice(0, -1);
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Enter'){
|
||||
e.preventDefault();
|
||||
if(firstEnter && !connected){
|
||||
// open ssh over websocket connection with username/password auth
|
||||
// keep connection open; run command after connection
|
||||
const line = buf;
|
||||
buf = '';
|
||||
firstEnter = false;
|
||||
term.textContent = term.textContent + '\n';
|
||||
// try to connect - endpoint can be configured
|
||||
const wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ssh';
|
||||
try {
|
||||
ws = new WebSocket(wsUrl);
|
||||
ws.onopen = function(){
|
||||
connected = true;
|
||||
// send auth info and/or initial command
|
||||
try {
|
||||
ws.send(JSON.stringify({type:'auth', line: line}));
|
||||
} catch(err) {
|
||||
ws.send(line + '\n');
|
||||
}
|
||||
ws.send('\n'); // run command/start shell
|
||||
};
|
||||
ws.onmessage = function(ev){
|
||||
appendOutput(ev.data);
|
||||
};
|
||||
ws.onclose = function(){
|
||||
connected = false;
|
||||
};
|
||||
ws.onerror = function(){
|
||||
connected = false;
|
||||
};
|
||||
} catch(err) {
|
||||
// fallback
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\r');
|
||||
term.textContent = term.textContent + '\n';
|
||||
return;
|
||||
}
|
||||
buf += '\n';
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Escape'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\x1b');
|
||||
return;
|
||||
}
|
||||
buf = '';
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Tab'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\t');
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.key.length === 1){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send(e.key);
|
||||
// don't echo locally if server echoes; but keep simple
|
||||
return;
|
||||
}
|
||||
buf += e.key;
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
37
src/layouts/Layout.astro
Normal file
37
src/layouts/Layout.astro
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
import '../styles/style.css';
|
||||
import Prompt from '../components/Prompt.astro';
|
||||
import Terminal from '../components/Terminal.astro';
|
||||
|
||||
interface Props {
|
||||
lang: 'de' | 'en';
|
||||
title: string;
|
||||
description?: string;
|
||||
command: string;
|
||||
alternate: string;
|
||||
}
|
||||
|
||||
const { lang, title, description, command, alternate } = Astro.props;
|
||||
---
|
||||
<!doctype html>
|
||||
<html lang={lang}>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{title}</title>
|
||||
{description && <meta name="description" content={description}>}
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="alternate" hreflang={lang === 'de' ? 'en' : 'de'} href={alternate}>
|
||||
</head>
|
||||
<body>
|
||||
<main class="term">
|
||||
|
||||
<Prompt>{command}</Prompt>
|
||||
|
||||
<slot />
|
||||
|
||||
<Terminal />
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Code of Conduct - Khaos im Kiez</title>
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="alternate" hreflang="de" href="coc.html">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="term">
|
||||
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ cat CODE_OF_CONDUCT.en<span class="cursor"></span></p>
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
---
|
||||
<Layout
|
||||
lang="en"
|
||||
title="Code of Conduct - Khaos im Kiez"
|
||||
command="cat CODE_OF_CONDUCT.en"
|
||||
alternate="coc.html"
|
||||
>
|
||||
|
||||
<nav aria-label="Navigation">
|
||||
<a href="en.html"><- back</a>
|
||||
|
|
@ -51,6 +46,4 @@
|
|||
<a href="https://berlin.ccc.de/page/impressum/">Legal notice</a>
|
||||
</footer>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</Layout>
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Code of Conduct - Khaos im Kiez</title>
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="alternate" hreflang="en" href="coc-en.html">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="term">
|
||||
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ cat CODE_OF_CONDUCT<span class="cursor"></span></p>
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
---
|
||||
<Layout
|
||||
lang="de"
|
||||
title="Code of Conduct - Khaos im Kiez"
|
||||
command="cat CODE_OF_CONDUCT"
|
||||
alternate="coc-en.html"
|
||||
>
|
||||
|
||||
<nav aria-label="Navigation">
|
||||
<a href="index.html"><- zurück</a>
|
||||
|
|
@ -51,6 +46,4 @@
|
|||
<a href="https://berlin.ccc.de/page/impressum/">Impressum</a>
|
||||
</footer>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</Layout>
|
||||
|
|
@ -1,18 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Khaos im Kiez</title>
|
||||
<meta name="description" content="Khaos im Kiez - a small CCC Berlin event, 28-29 November 2026, Marienstraße 11, Berlin.">
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="alternate" hreflang="de" href="index.html">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="term">
|
||||
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ cat README.en<span class="cursor"></span></p>
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
---
|
||||
<Layout
|
||||
lang="en"
|
||||
title="Khaos im Kiez"
|
||||
description="Khaos im Kiez - a small CCC Berlin event, 28-29 November 2026, Marienstraße 11, Berlin."
|
||||
command="cat README.en"
|
||||
alternate="index.html"
|
||||
>
|
||||
|
||||
<header>
|
||||
<img src="logo.png" alt="KiK logo: red star with keyboard and the letters kik" width="150" height="150">
|
||||
|
|
@ -98,9 +93,6 @@
|
|||
<footer>
|
||||
<a href="https://berlin.ccc.de/page/impressum/">Legal notice</a> ·
|
||||
<a href="https://berlin.ccc.de/">CCC Berlin</a>
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ <span class="cursor"></span></p>
|
||||
</footer>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</Layout>
|
||||
|
|
@ -1,18 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Khaos im Kiez</title>
|
||||
<meta name="description" content="Khaos im Kiez kleine Chaos-Veranstaltung des CCC Berlin, 28.-29. November 2026, Marienstraße 11, Berlin.">
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="alternate" hreflang="en" href="en.html">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="term">
|
||||
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ cat README<span class="cursor"></span></p>
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
---
|
||||
<Layout
|
||||
lang="de"
|
||||
title="Khaos im Kiez"
|
||||
description="Khaos im Kiez - kleine Chaos-Veranstaltung des CCC Berlin, 28.-29. November 2026, Marienstraße 11, Berlin."
|
||||
command="cat README"
|
||||
alternate="en.html"
|
||||
>
|
||||
|
||||
<header>
|
||||
<img src="logo.png" alt="KiK-Logo: roter Stern mit Tastatur und den Buchstaben kik" width="150" height="150">
|
||||
|
|
@ -102,117 +97,6 @@
|
|||
<a href="https://berlin.ccc.de/page/impressum/">Impressum</a> ·
|
||||
<a href="https://berlin.ccc.de/">CCC Berlin</a>
|
||||
</p>
|
||||
<p class="prompt"><b>visitor@khaos-im-kiez</b>:~$ <span id="term-input"></span><span class="cursor"></span></p>
|
||||
</footer>
|
||||
|
||||
</main>
|
||||
<script>
|
||||
(function(){
|
||||
const term = document.getElementById('term-input');
|
||||
if(!term) return;
|
||||
let buf = '';
|
||||
let ws = null;
|
||||
let connected = false;
|
||||
let firstEnter = true;
|
||||
|
||||
function appendOutput(text){
|
||||
if(!text) return;
|
||||
// append to term display (simple)
|
||||
term.textContent += text;
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(e){
|
||||
const t = e.target;
|
||||
if(t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;
|
||||
if(e.ctrlKey || e.altKey || e.metaKey) return;
|
||||
|
||||
if(e.key === 'Backspace'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\b');
|
||||
return;
|
||||
}
|
||||
buf = buf.slice(0, -1);
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Enter'){
|
||||
e.preventDefault();
|
||||
if(firstEnter && !connected){
|
||||
// open ssh over websocket connection with username/password auth
|
||||
// keep connection open; run command after connection
|
||||
const line = buf;
|
||||
buf = '';
|
||||
firstEnter = false;
|
||||
term.textContent = term.textContent + '\n';
|
||||
// try to connect - endpoint can be configured
|
||||
const wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ssh';
|
||||
try {
|
||||
ws = new WebSocket(wsUrl);
|
||||
ws.onopen = function(){
|
||||
connected = true;
|
||||
// send auth info and/or initial command
|
||||
try {
|
||||
ws.send(JSON.stringify({type:'auth', line: line}));
|
||||
} catch(err) {
|
||||
ws.send(line + '\n');
|
||||
}
|
||||
ws.send('\n'); // run command/start shell
|
||||
};
|
||||
ws.onmessage = function(ev){
|
||||
appendOutput(ev.data);
|
||||
};
|
||||
ws.onclose = function(){
|
||||
connected = false;
|
||||
};
|
||||
ws.onerror = function(){
|
||||
connected = false;
|
||||
};
|
||||
} catch(err) {
|
||||
// fallback
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\r');
|
||||
term.textContent = term.textContent + '\n';
|
||||
return;
|
||||
}
|
||||
buf += '\n';
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Escape'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\x1b');
|
||||
return;
|
||||
}
|
||||
buf = '';
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
if(e.key === 'Tab'){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send('\t');
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.key.length === 1){
|
||||
e.preventDefault();
|
||||
if(connected && ws && ws.readyState === WebSocket.OPEN){
|
||||
ws.send(e.key);
|
||||
// don't echo locally if server echoes; but keep simple
|
||||
return;
|
||||
}
|
||||
buf += e.key;
|
||||
term.textContent = buf;
|
||||
return;
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</Layout>
|
||||
Loading…
Reference in a new issue