1 package gmitohtml
2
3 var fs = make(inMemoryFS)
4
5 const pageHeader = `
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta name="viewport" content="width=device-width,initial-scale=1">
10 <link rel="stylesheet" href="/assets/style.css">
11 </head>
12 <body>`
13
14 const navHeader = `
15 <div>
16 <form method="post" action="/" novalidate>
17 <input type="url" name="address" id="navigationaddress" placeholder="Address" size="40" value="~GEMINICURRENTURL~" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" ~GEMINIAUTOFOCUS~>
18 </form>
19 <div id="navigationbar">
20 <a href="/bookmarks" class="navlink">View bookmarks</a> - <a href="/bookmarks?add=~GEMINICURRENTURL~" class="navlink">Add bookmark</a>
21 </div>
22 </div>
23 `
24
25 const contentHeader = `
26 <div id="content">
27 `
28
29 const inputPrompt = `
30 <form method="post" action="~GEMINIINPUTFORM~">
31 <div style="padding-top: 25px;">
32 <span style="font-size: 1.5em;">~GEMINIINPUTPROMPT~</span><br><br>
33 <div>
34 <input type="~GEMINIINPUTTYPE~" name="input" placeholder="Input" size="40" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus>
35 </div>
36 </div>
37 </form>
38 `
39
40 const pageFooter = `
41 </div>
42 </body>
43 </html>
44 `
45
46
47 const StyleCSS = `
48 /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
49
50 /* Document
51 ========================================================================== */
52
53 /**
54 * 1. Correct the line height in all browsers.
55 * 2. Prevent adjustments of font size after orientation changes in iOS.
56 */
57
58 html {
59 line-height: 1.15; /* 1 */
60 -webkit-text-size-adjust: 100%; /* 2 */
61 }
62
63 /* Sections
64 ========================================================================== */
65
66 /**
67 * Remove the margin in all browsers.
68 */
69
70 body {
71 margin: 0;
72 width: 100%;
73 }
74
75 #content {
76 margin: 0.67em;
77 }
78
79 #navigationaddress {
80 box-sizing: border-box;
81 width: 100%
82 }
83
84 #navigationbar {
85 padding: 4px 21px 7px 21px;
86 }
87
88 /**
89 * Render the main element consistently in IE.
90 */
91
92 main {
93 display: block;
94 }
95
96 /**
97 * Correct the font size and margin on h1 elements within section and
98 * article contexts in Chrome, Firefox, and Safari.
99 */
100
101 h1 {
102 font-size: 2em;
103 }
104
105 h1, h2, h3, h4, h5, h6, h7 {
106 margin: 0.25em 0;
107 }
108
109 /* Grouping content
110 ========================================================================== */
111
112 /**
113 * 1. Add the correct box sizing in Firefox.
114 * 2. Show the overflow in Edge and IE.
115 */
116
117 hr {
118 box-sizing: content-box; /* 1 */
119 height: 0; /* 1 */
120 overflow: visible; /* 2 */
121 }
122
123 /**
124 * 1. Correct the inheritance and scaling of font size in all browsers.
125 * 2. Correct the odd em font sizing in all browsers.
126 */
127
128 pre {
129 font-family: monospace, monospace; /* 1 */
130 font-size: 1em; /* 2 */
131 margin: 0;
132 }
133
134 /* Text-level semantics
135 ========================================================================== */
136
137 /**
138 * Remove the gray background on active links in IE 10.
139 */
140
141 a {
142 background-color: transparent;
143 }
144
145 a {
146 color: #0000EE;
147 text-decoration: none;
148 }
149 a:hover,
150 a:focus,
151 a:active {
152 color: #FF0000;
153 text-decoration: underline;
154 }
155 a:visited {
156 color: #551A8B;
157 }
158
159 a.navlink {
160 color: #0000EE;
161 text-decoration: none;
162 }
163 a.navlink:hover,
164 a.navlink:focus,
165 a.navlink:active {
166 color: #FF0000;
167 text-decoration: underline;
168 }
169 a.navlink:visited {
170 color: #0000EE;
171 }
172
173 /**
174 * 1. Remove the bottom border in Chrome 57-
175 * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
176 */
177
178 abbr[title] {
179 border-bottom: none; /* 1 */
180 text-decoration: underline; /* 2 */
181 text-decoration: underline dotted; /* 2 */
182 }
183
184 /**
185 * Add the correct font weight in Chrome, Edge, and Safari.
186 */
187
188 b,
189 strong {
190 font-weight: bolder;
191 }
192
193 /**
194 * 1. Correct the inheritance and scaling of font size in all browsers.
195 * 2. Correct the odd em font sizing in all browsers.
196 */
197
198 code,
199 kbd,
200 samp {
201 font-family: monospace, monospace; /* 1 */
202 font-size: 1em; /* 2 */
203 }
204
205 /**
206 * Add the correct font size in all browsers.
207 */
208
209 small {
210 font-size: 80%;
211 }
212
213 /**
214 * Prevent sub and sup elements from affecting the line height in
215 * all browsers.
216 */
217
218 sub,
219 sup {
220 font-size: 75%;
221 line-height: 0;
222 position: relative;
223 vertical-align: baseline;
224 }
225
226 sub {
227 bottom: -0.25em;
228 }
229
230 sup {
231 top: -0.5em;
232 }
233
234 /* Embedded content
235 ========================================================================== */
236
237 /**
238 * Remove the border on images inside links in IE 10.
239 */
240
241 img {
242 border-style: none;
243 }
244
245 /* Forms
246 ========================================================================== */
247
248 /**
249 * 1. Change the font styles in all browsers.
250 * 2. Remove the margin in Firefox and Safari.
251 */
252
253 button,
254 input,
255 optgroup,
256 select,
257 textarea {
258 font-family: inherit; /* 1 */
259 font-size: 100%; /* 1 */
260 line-height: 1.15; /* 1 */
261 margin: 0; /* 2 */
262 }
263
264 /**
265 * Show the overflow in IE.
266 * 1. Show the overflow in Edge.
267 */
268
269 button,
270 input { /* 1 */
271 overflow: visible;
272 }
273
274 /**
275 * Remove the inheritance of text transform in Edge, Firefox, and IE.
276 * 1. Remove the inheritance of text transform in Firefox.
277 */
278
279 button,
280 select { /* 1 */
281 text-transform: none;
282 }
283
284 /**
285 * Correct the inability to style clickable types in iOS and Safari.
286 */
287
288 button,
289 [type="button"],
290 [type="reset"],
291 [type="submit"] {
292 -webkit-appearance: button;
293 }
294
295 /**
296 * Remove the inner border and padding in Firefox.
297 */
298
299 button::-moz-focus-inner,
300 [type="button"]::-moz-focus-inner,
301 [type="reset"]::-moz-focus-inner,
302 [type="submit"]::-moz-focus-inner {
303 border-style: none;
304 padding: 0;
305 }
306
307 /**
308 * Restore the focus styles unset by the previous rule.
309 */
310
311 button:-moz-focusring,
312 [type="button"]:-moz-focusring,
313 [type="reset"]:-moz-focusring,
314 [type="submit"]:-moz-focusring {
315 outline: 1px dotted ButtonText;
316 }
317
318 /**
319 * Correct the padding in Firefox.
320 */
321
322 fieldset {
323 padding: 0.35em 0.75em 0.625em;
324 }
325
326 /**
327 * 1. Correct the text wrapping in Edge and IE.
328 * 2. Correct the color inheritance from fieldset elements in IE.
329 * 3. Remove the padding so developers are not caught out when they zero out
330 * fieldset elements in all browsers.
331 */
332
333 legend {
334 box-sizing: border-box; /* 1 */
335 color: inherit; /* 2 */
336 display: table; /* 1 */
337 max-width: 100%; /* 1 */
338 padding: 0; /* 3 */
339 white-space: normal; /* 1 */
340 }
341
342 /**
343 * Add the correct vertical alignment in Chrome, Firefox, and Opera.
344 */
345
346 progress {
347 vertical-align: baseline;
348 }
349
350 /**
351 * Remove the default vertical scrollbar in IE 10+.
352 */
353
354 textarea {
355 overflow: auto;
356 }
357
358 /**
359 * 1. Add the correct box sizing in IE 10.
360 * 2. Remove the padding in IE 10.
361 */
362
363 [type="checkbox"],
364 [type="radio"] {
365 box-sizing: border-box; /* 1 */
366 padding: 0; /* 2 */
367 }
368
369 /**
370 * Correct the cursor style of increment and decrement buttons in Chrome.
371 */
372
373 [type="number"]::-webkit-inner-spin-button,
374 [type="number"]::-webkit-outer-spin-button {
375 height: auto;
376 }
377
378 /**
379 * 1. Correct the odd appearance in Chrome and Safari.
380 * 2. Correct the outline style in Safari.
381 */
382
383 [type="search"] {
384 -webkit-appearance: textfield; /* 1 */
385 outline-offset: -2px; /* 2 */
386 }
387
388 /**
389 * Remove the inner padding in Chrome and Safari on macOS.
390 */
391
392 [type="search"]::-webkit-search-decoration {
393 -webkit-appearance: none;
394 }
395
396 /**
397 * 1. Correct the inability to style clickable types in iOS and Safari.
398 * 2. Change font properties to inherit in Safari.
399 */
400
401 ::-webkit-file-upload-button {
402 -webkit-appearance: button; /* 1 */
403 font: inherit; /* 2 */
404 }
405
406 /* Interactive
407 ========================================================================== */
408
409 /*
410 * Add the correct display in Edge, IE 10+, and Firefox.
411 */
412
413 details {
414 display: block;
415 }
416
417 /*
418 * Add the correct display in all browsers.
419 */
420
421 summary {
422 display: list-item;
423 }
424
425 /* Misc
426 ========================================================================== */
427
428 /**
429 * Add the correct display in IE 10+.
430 */
431
432 template {
433 display: none;
434 }
435
436 /**
437 * Add the correct display in IE 10.
438 */
439
440 [hidden] {
441 display: none;
442 }
443
444 @media (prefers-color-scheme: dark) {
445 body {
446 color: white;
447 background-color: black;
448 }
449
450 h1, h2, h3, h4, h5, h6 {
451 color: white;
452 }
453
454 a {
455 color: rgb(26, 168, 245);
456 text-decoration: none;
457 }
458 a:hover,
459 a:focus,
460 a:active {
461 color: rgb(24, 151, 219);
462 text-decoration: underline;
463 }
464 a:visited {
465 color: rgb(200, 118, 255);
466 }
467
468 a.navlink {
469 color: rgb(26, 168, 245);
470 text-decoration: none;
471 }
472 a.navlink:hover,
473 a.navlink:focus,
474 a.navlink:active {
475 color: rgb(24, 151, 219);
476 text-decoration: underline;
477 }
478 a.navlink:visited {
479 color: rgb(26, 168, 245);
480 }
481
482 input {
483 background-color: black;
484 color: white;
485 border-color: gray;
486 border-width: 0.3em;
487 border-style: solid;
488 padding: 0.5em;
489 }
490 }
491 `
492
493 func loadAssets() {
494 fs["/assets/style.css"] = loadFile("style.css", StyleCSS, fs)
495 }
496
View as plain text