yieldray-notebook.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import ServeRouter from "https://esm.sh/serve-router@latest";
import { notems } from "https://esm.town/v/yieldray/notems";
import htm from "npm:htm";
import { micromark } from "npm:micromark";
import { gfm, gfmHtml } from "npm:micromark-extension-gfm";
import vhtml from "npm:vhtml";
const html = htm.bind(vhtml);
const markdown = (md) =>
micromark(md, {
extensions: [gfm()],
htmlExtensions: [gfmHtml()],
});
// components
const layout_html = ({ head, body }) =>
`<!DOCTYPE html>`
+ html`<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
${head}
</head>
<body class="markdown-body">
${body}
</body>
</html>`;
const layout_home = (msg = "") =>
layout_html({
head: html`<link rel="stylesheet" href="//unpkg.com/landsoul@latest" />
<style>
html {
padding: 1rem;
}
body {
max-width: 640px;
margin: auto;
}
@media screen and (max-width: 640px) {
body {
margin: 0 0.5rem;
}
}
label {
display: block;
padding: 0.5rem;
}
textarea {
display: block;
width: 100%;
min-height: 5rem;
box-sizing: border-box;
}
</style>`,
body: html`<header style="padding:1rem 0">
<h1>NoteBook</h1>
</header>
${msg}
<form action="/" method="post">
<label>
<span>ID:</span>
<input type="text" name="id" />
</label>
<label>
<span>Type:</span>
<select name="type">
<option value="text">Text</option>
<option value="markdown">Markdown</option>
<option value="html">HTML</option>
<option value="url">URL</option>
</select>
</label>
<label>
<span>Data:</span>
<textarea name="data"></textarea>
</label>
<input type="submit" value="Submit" />
</form>`,
});
const layout_markdown = (md = "") =>
layout_html({
head: html`<link rel="stylesheet" href="//unpkg.com/github-markdown-css@latest/github-markdown.min.css" />
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v5
October 24, 2023