Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10360245
html.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
html.ts
View Options
import
{
FlatTemplatable
,
Templatable
,
tempstream
}
from
"tempstream"
;
import
{
Readable
}
from
"stream"
;
import
{
BaseContext
}
from
"koa"
;
import
{
default
as
default_navbar
}
from
"./routes/common/navbar.js"
;
import
{
toKebabCase
}
from
"js-convert-case"
;
export
const
defaultHead
=
(
ctx
:
BaseContext
,
title
:
string
)
=>
/* HTML */
`<title>
${
title
}
·
${
ctx
.
$app
.
manifest
.
name
}
</title>
<meta name="viewport" content="width=device-width" />
<script async src="/dist/bundle.js"></script>
<link href="/dist/main.css" rel="stylesheet" type="text/css" />`
;
export
type
HTMLOptions
=
{
preserveScroll
?:
boolean
;
morphing
?:
boolean
;
navbar
?:
(
ctx
:
BaseContext
)
=>
FlatTemplatable
;
autoRefreshCSS
?:
boolean
;
};
export
default
function
html
(
ctx
:
BaseContext
,
title
:
string
,
body
:
Templatable
,
{
preserveScroll
,
morphing
,
navbar
,
autoRefreshCSS
}
:
HTMLOptions
=
{},
makeHead
:
(
ctx
:
BaseContext
,
title
:
string
)
=>
Templatable
=
defaultHead
)
:
Readable
{
ctx
.
set
(
"content-type"
,
"text/html;charset=utf-8"
);
return
tempstream
/* HTML */
` <!DOCTYPE html>
<html lang="pl" class="title--
${
toKebabCase
(
title
)
}
">
<head>
${
makeHead
(
ctx
,
title
)
}
${
morphing
?
`<meta name="turbo-refresh-method" content="morph" />`
:
""
}
${
preserveScroll
?
`<meta name="turbo-refresh-scroll" content="preserve">`
:
""
}
</head>
<body>
${
(
navbar
||
default_navbar
)(
ctx
)
}
${
body
}
${
autoRefreshCSS
?
/* HTML */
`<script>
function refresh_css() {
Array.from(document.querySelectorAll("link"))
.filter(
(e) =>
new URL(e.href).pathname == "/dist/main.css"
)
.forEach((e) => {
const url = new URL(e.href);
url.search =
"?" + Math.random() + "" + Math.random();
e.href = url.toString();
});
}
const socket = new WebSocket("ws://localhost:60808");
socket.onmessage = refresh_css;
</script>`
:
""
}
</body>
</html>`
;
}
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Nov 8, 05:48 (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034071
Default Alt Text
html.ts (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline
Log In to Comment