htmx-router 1.0.0-alpha.5 → 1.0.0-pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/eventdim-react/package.json +67 -0
- package/example/eventdim-react/server.js +90 -0
- package/example/island-react/global.d.ts +8 -0
- package/example/island-react/package.json +38 -0
- package/example/island-react/server.js +58 -0
- package/global.d.ts +7 -0
- package/package.json +10 -8
- package/readme.md +17 -212
- package/bin/cli/config.d.ts +0 -10
- package/bin/cli/config.js +0 -4
- package/bin/cli/index.d.ts +0 -2
- package/bin/cli/index.js +0 -66
- package/bin/client/entry.d.ts +0 -1
- package/bin/client/entry.js +0 -12
- package/bin/client/index.d.ts +0 -7
- package/bin/client/index.js +0 -132
- package/bin/client/mount.d.ts +0 -2
- package/bin/client/mount.js +0 -116
- package/bin/client/watch.d.ts +0 -1
- package/bin/client/watch.js +0 -11
- package/bin/helper.d.ts +0 -2
- package/bin/helper.js +0 -34
- package/bin/index.d.ts +0 -11
- package/bin/index.js +0 -18
- package/bin/request/http.d.ts +0 -10
- package/bin/request/http.js +0 -41
- package/bin/request/index.d.ts +0 -16
- package/bin/request/index.js +0 -6
- package/bin/request/native.d.ts +0 -9
- package/bin/request/native.js +0 -46
- package/bin/response.d.ts +0 -9
- package/bin/response.js +0 -46
- package/bin/router.d.ts +0 -49
- package/bin/router.js +0 -217
- package/bin/types.d.ts +0 -10
- package/bin/types.js +0 -1
- package/bin/util/cookies.d.ts +0 -25
- package/bin/util/cookies.js +0 -60
- package/bin/util/css.d.ts +0 -13
- package/bin/util/css.js +0 -55
- package/bin/util/dynamic.d.ts +0 -8
- package/bin/util/dynamic.js +0 -40
- package/bin/util/endpoint.d.ts +0 -13
- package/bin/util/endpoint.js +0 -32
- package/bin/util/event-source.d.ts +0 -16
- package/bin/util/event-source.js +0 -85
- package/bin/util/hash.d.ts +0 -4
- package/bin/util/hash.js +0 -10
- package/bin/util/index.d.ts +0 -1
- package/bin/util/index.js +0 -7
- package/bin/util/parameters.d.ts +0 -10
- package/bin/util/parameters.js +0 -17
- package/bin/util/path-builder.d.ts +0 -1
- package/bin/util/path-builder.js +0 -43
- package/bin/util/response.d.ts +0 -11
- package/bin/util/response.js +0 -46
- package/bin/util/shell.d.ts +0 -120
- package/bin/util/shell.js +0 -251
package/bin/util/path-builder.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { relative } from "path";
|
|
2
|
-
/*
|
|
3
|
-
// This feature is disabled because vite doesn't compile import.meta.url to the original url when making the SSR build
|
|
4
|
-
// Even though it's used statically in the routes
|
|
5
|
-
|
|
6
|
-
const parameters = {
|
|
7
|
-
userID: Number
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const urlPath = RoutePathBuilder<typeof parameters>(import.meta.url);
|
|
11
|
-
|
|
12
|
-
export function loader({ params }: RouteContext<typeof parameters>) {
|
|
13
|
-
return <div>You are currently at {urlPath({ userID: params.userID.toString() })}</div>
|
|
14
|
-
}
|
|
15
|
-
*/
|
|
16
|
-
// This feature isn't particularly helpful for a router to refer to it's own URL
|
|
17
|
-
// But instead is useful because you could export this function
|
|
18
|
-
// Allowing other routes to use it, and thus if you move the file your imports will auto update by your LSP
|
|
19
|
-
// And thus so would your SSR rendered urls
|
|
20
|
-
function RoutePathBuilder(importUrl) {
|
|
21
|
-
// file runs all imports before actually executing the route.tsx
|
|
22
|
-
// so I have to do this BS instead of pre-compiling
|
|
23
|
-
let compiled = null;
|
|
24
|
-
return (params) => {
|
|
25
|
-
if (!compiled) {
|
|
26
|
-
const root = globalThis.HTMX_ROUTER_ROOT;
|
|
27
|
-
let path = importUrl.slice("file:///".length);
|
|
28
|
-
const raw = relative(root, path).replaceAll("\\", "/");
|
|
29
|
-
const i = raw.lastIndexOf(".");
|
|
30
|
-
compiled = raw.slice(0, i).split("/");
|
|
31
|
-
}
|
|
32
|
-
let path = "";
|
|
33
|
-
for (const frag of compiled) {
|
|
34
|
-
path += "/";
|
|
35
|
-
if (frag[0] != "$") {
|
|
36
|
-
path += frag;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
path += params[frag.slice(1)] || "_";
|
|
40
|
-
}
|
|
41
|
-
return path;
|
|
42
|
-
};
|
|
43
|
-
}
|
package/bin/util/response.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function text(text: string, init?: ResponseInit): Response;
|
|
2
|
-
export declare function json<T>(data: T, init?: ResponseInit): Omit<Response, "json"> & {
|
|
3
|
-
json(): Promise<T>;
|
|
4
|
-
};
|
|
5
|
-
export declare function redirect(url: string, init?: ResponseInit & {
|
|
6
|
-
clientOnly?: boolean;
|
|
7
|
-
}): Response;
|
|
8
|
-
export declare function revalidate(init?: ResponseInit): Response;
|
|
9
|
-
export declare function refresh(init?: ResponseInit & {
|
|
10
|
-
clientOnly?: boolean;
|
|
11
|
-
}): Response;
|
package/bin/util/response.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export function text(text, init) {
|
|
2
|
-
init ||= {};
|
|
3
|
-
init.statusText ||= "ok";
|
|
4
|
-
init.status = 200;
|
|
5
|
-
const res = new Response(text, init);
|
|
6
|
-
res.headers.set("Content-Type", "text/plain");
|
|
7
|
-
res.headers.set("X-Caught", "true");
|
|
8
|
-
return res;
|
|
9
|
-
}
|
|
10
|
-
export function json(data, init) {
|
|
11
|
-
init ||= {};
|
|
12
|
-
init.statusText ||= "ok";
|
|
13
|
-
init.status = 200;
|
|
14
|
-
const res = new Response(JSON.stringify(data), init);
|
|
15
|
-
res.headers.set("Content-Type", "application/json");
|
|
16
|
-
res.headers.set("X-Caught", "true");
|
|
17
|
-
return res;
|
|
18
|
-
}
|
|
19
|
-
export function redirect(url, init) {
|
|
20
|
-
init ||= {};
|
|
21
|
-
init.statusText ||= "Temporary Redirect";
|
|
22
|
-
init.status = 307;
|
|
23
|
-
const res = new Response("", init);
|
|
24
|
-
if (!init?.clientOnly)
|
|
25
|
-
res.headers.set("Location", url);
|
|
26
|
-
res.headers.set("HX-Location", url); // use hx-boost if applicable
|
|
27
|
-
return res;
|
|
28
|
-
}
|
|
29
|
-
export function revalidate(init) {
|
|
30
|
-
init ||= {};
|
|
31
|
-
init.statusText ||= "ok";
|
|
32
|
-
init.status = 200;
|
|
33
|
-
const res = new Response("", init);
|
|
34
|
-
res.headers.set("HX-Location", "");
|
|
35
|
-
return res;
|
|
36
|
-
}
|
|
37
|
-
export function refresh(init) {
|
|
38
|
-
init ||= {};
|
|
39
|
-
init.statusText ||= "ok";
|
|
40
|
-
init.status = 200;
|
|
41
|
-
const res = new Response("", init);
|
|
42
|
-
if (!init?.clientOnly)
|
|
43
|
-
res.headers.set("Refresh", "0"); // fallback
|
|
44
|
-
res.headers.set("HX-Refresh", "true");
|
|
45
|
-
return res;
|
|
46
|
-
}
|
package/bin/util/shell.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
export type ShellOptions<D = {}> = D & MetaDescriptor;
|
|
2
|
-
export declare function ApplyMetaDescriptorDefaults(options: ShellOptions, defaults: Readonly<Partial<ShellOptions>>): void;
|
|
3
|
-
export type InferShellOptions<F> = F extends (jsx: any, options: infer U) => any ? U : never;
|
|
4
|
-
export type MetaDescriptor = {
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
meta?: Record<string, string>;
|
|
8
|
-
og?: OpenGraph<string>;
|
|
9
|
-
jsonLD?: LdJsonObject[];
|
|
10
|
-
};
|
|
11
|
-
export declare function RenderMetaDescriptor<T>(options: ShellOptions<T>): string;
|
|
12
|
-
export type LdJsonObject = {
|
|
13
|
-
[Key in string]?: LdJsonValue | undefined;
|
|
14
|
-
};
|
|
15
|
-
type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
|
|
16
|
-
type LdJsonPrimitive = string | number | boolean | null;
|
|
17
|
-
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
18
|
-
export type OpenGraphType = "website" | "article" | "book" | "profile" | "music.song" | "music.album" | "music.playlist" | "music.radio_station" | "video.movie" | "video.episode" | "video.tv_show" | "video.other" | string;
|
|
19
|
-
export type OpenGraph<T extends OpenGraphType = string> = {
|
|
20
|
-
type?: T;
|
|
21
|
-
title?: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
determiner?: string;
|
|
24
|
-
url?: string;
|
|
25
|
-
secure_url?: string;
|
|
26
|
-
locale?: string | {
|
|
27
|
-
base: string;
|
|
28
|
-
alternative: string[];
|
|
29
|
-
};
|
|
30
|
-
image?: OpenGraphImage[];
|
|
31
|
-
video?: OpenGraphVideo[];
|
|
32
|
-
audio?: OpenGraphAudio[];
|
|
33
|
-
} & (T extends "music.song" ? OpenGraphSong : T extends "music.album" ? OpenGraphAlbum : T extends "music.playlist" ? OpenGraphPlaylist : T extends "music.radio_station" ? OpenGraphRadioStation : T extends "video.movie" ? OpenGraphMovie : T extends "video.episode" ? OpenGraphEpisode : T extends "video.tv_show" ? OpenGraphTvShow : T extends "video.other" ? OpenGraphVideoOther : T extends "article" ? OpenGraphArticle : T extends "book" ? OpenGraphBook : T extends "profile" ? OpenGraphProfile : {});
|
|
34
|
-
export type OpenGraphImage = {
|
|
35
|
-
url: string;
|
|
36
|
-
secure_url?: string;
|
|
37
|
-
type?: string;
|
|
38
|
-
width?: number;
|
|
39
|
-
height?: number;
|
|
40
|
-
alt?: string;
|
|
41
|
-
};
|
|
42
|
-
export type OpenGraphVideo = {
|
|
43
|
-
url: string;
|
|
44
|
-
type?: string;
|
|
45
|
-
secure_url?: string;
|
|
46
|
-
width?: number;
|
|
47
|
-
height?: number;
|
|
48
|
-
alt?: string;
|
|
49
|
-
};
|
|
50
|
-
export type OpenGraphAudio = {
|
|
51
|
-
url: string;
|
|
52
|
-
type?: string;
|
|
53
|
-
secure_url?: string;
|
|
54
|
-
};
|
|
55
|
-
type OpenGraphSong = {
|
|
56
|
-
duration?: number;
|
|
57
|
-
album?: Array<string | {
|
|
58
|
-
url: string;
|
|
59
|
-
disc?: number;
|
|
60
|
-
track?: number;
|
|
61
|
-
}>;
|
|
62
|
-
musician?: string[];
|
|
63
|
-
};
|
|
64
|
-
type OpenGraphAlbum = {
|
|
65
|
-
songs?: Array<string | {
|
|
66
|
-
url: string;
|
|
67
|
-
disc?: number;
|
|
68
|
-
track?: number;
|
|
69
|
-
}>;
|
|
70
|
-
musician?: string[];
|
|
71
|
-
release_date?: Date;
|
|
72
|
-
};
|
|
73
|
-
type OpenGraphPlaylist = {
|
|
74
|
-
songs?: Array<string | {
|
|
75
|
-
url: string;
|
|
76
|
-
disc?: number;
|
|
77
|
-
track?: number;
|
|
78
|
-
}>;
|
|
79
|
-
creator?: string[];
|
|
80
|
-
};
|
|
81
|
-
type OpenGraphRadioStation = {
|
|
82
|
-
creator?: string[];
|
|
83
|
-
};
|
|
84
|
-
type OpenGraphMovie = {
|
|
85
|
-
actors?: Array<string | {
|
|
86
|
-
url: string;
|
|
87
|
-
role: string;
|
|
88
|
-
}>;
|
|
89
|
-
directors?: string[];
|
|
90
|
-
writers?: string[];
|
|
91
|
-
duration?: number;
|
|
92
|
-
release_date?: Date;
|
|
93
|
-
tag: string[];
|
|
94
|
-
};
|
|
95
|
-
type OpenGraphEpisode = OpenGraphMovie & {
|
|
96
|
-
series?: string;
|
|
97
|
-
};
|
|
98
|
-
type OpenGraphTvShow = OpenGraphMovie;
|
|
99
|
-
type OpenGraphVideoOther = OpenGraphMovie;
|
|
100
|
-
type OpenGraphArticle = {
|
|
101
|
-
published_time?: Date;
|
|
102
|
-
modified_time?: Date;
|
|
103
|
-
expiration_time?: Date;
|
|
104
|
-
authors?: string[];
|
|
105
|
-
section?: string;
|
|
106
|
-
tag?: string;
|
|
107
|
-
};
|
|
108
|
-
type OpenGraphBook = {
|
|
109
|
-
authors?: string[];
|
|
110
|
-
isbn?: string;
|
|
111
|
-
release_date?: Date;
|
|
112
|
-
tag?: string;
|
|
113
|
-
};
|
|
114
|
-
type OpenGraphProfile = {
|
|
115
|
-
first_name?: string;
|
|
116
|
-
last_name?: string;
|
|
117
|
-
username?: string;
|
|
118
|
-
gender?: "male" | "female";
|
|
119
|
-
};
|
|
120
|
-
export {};
|
package/bin/util/shell.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
export function ApplyMetaDescriptorDefaults(options, defaults) {
|
|
2
|
-
if (defaults.title && !options.title)
|
|
3
|
-
options.title = defaults.title;
|
|
4
|
-
if (defaults.description && !options.description)
|
|
5
|
-
options.description = defaults.description;
|
|
6
|
-
if (defaults.meta && !options.meta)
|
|
7
|
-
options.meta = defaults.meta;
|
|
8
|
-
if (defaults.og && !options.og)
|
|
9
|
-
options.og = defaults.og;
|
|
10
|
-
if (defaults.jsonLD && !options.jsonLD)
|
|
11
|
-
options.jsonLD = defaults.jsonLD;
|
|
12
|
-
}
|
|
13
|
-
export function RenderMetaDescriptor(options) {
|
|
14
|
-
let out = "";
|
|
15
|
-
if (options.title)
|
|
16
|
-
out += `<title>${EscapeHTML(options.title)}</title>`;
|
|
17
|
-
if (options.description)
|
|
18
|
-
out += `<meta name="description" content="${EscapeHTML(options.description)}">\n`;
|
|
19
|
-
if (options.meta)
|
|
20
|
-
for (const key in options.meta) {
|
|
21
|
-
out += `<meta name="${EscapeHTML(key)}" content="${EscapeHTML(options.meta[key])}">\n`;
|
|
22
|
-
}
|
|
23
|
-
if (options.jsonLD)
|
|
24
|
-
for (const json of options.jsonLD) {
|
|
25
|
-
out += `<script>${EscapeHTML(JSON.stringify(json))}</script>\n`;
|
|
26
|
-
}
|
|
27
|
-
// Auto apply og:title + og:description if not present
|
|
28
|
-
if (options.title && !options.og?.title)
|
|
29
|
-
out += `<meta property="og:title" content="${EscapeHTML(options.title)}">\n`;
|
|
30
|
-
if (options.description && !options.og?.description)
|
|
31
|
-
out += `<meta property="og:description" content="${EscapeHTML(options.description)}">\n`;
|
|
32
|
-
// Apply open graphs
|
|
33
|
-
if (options.og)
|
|
34
|
-
out += RenderOpenGraph(options.og);
|
|
35
|
-
return out;
|
|
36
|
-
}
|
|
37
|
-
function RenderOpenGraph(og) {
|
|
38
|
-
// Manually encoding everything rather than using a loop to ensure they are in the correct order
|
|
39
|
-
// And to ensure extra values can't leak in creating unsafe og tags
|
|
40
|
-
const type = og.type || "website";
|
|
41
|
-
let out = RenderProperty("og:type", type);
|
|
42
|
-
if (og.title)
|
|
43
|
-
out += RenderProperty("og:title", og.title);
|
|
44
|
-
if (og.description)
|
|
45
|
-
out += RenderProperty("og:description", og.description);
|
|
46
|
-
if (og.determiner)
|
|
47
|
-
out += RenderProperty("og:determiner", og.determiner);
|
|
48
|
-
if (og.url)
|
|
49
|
-
out += RenderProperty("og:url", og.url);
|
|
50
|
-
if (og.secure_url)
|
|
51
|
-
out += RenderProperty("og:secure_url", og.secure_url);
|
|
52
|
-
if (og.locale) {
|
|
53
|
-
if (typeof og.locale === "string")
|
|
54
|
-
out += RenderProperty("og:locale", og.locale);
|
|
55
|
-
else {
|
|
56
|
-
out += RenderProperty("og:locale", og.locale.base);
|
|
57
|
-
for (const l of og.locale.alternative)
|
|
58
|
-
out += RenderProperty("og:locale:alternative", l);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (og.image)
|
|
62
|
-
for (const img of og.image) {
|
|
63
|
-
out += RenderProperty("og:image", img.url);
|
|
64
|
-
if (img.secure_url)
|
|
65
|
-
out += RenderProperty("og:image:secure_url", img.secure_url);
|
|
66
|
-
if (img.type)
|
|
67
|
-
out += RenderProperty("og:image:type", img.type);
|
|
68
|
-
if (img.width)
|
|
69
|
-
out += RenderProperty("og:image:width", img.width.toString());
|
|
70
|
-
if (img.height)
|
|
71
|
-
out += RenderProperty("og:image:height", img.height.toString());
|
|
72
|
-
if (img.alt)
|
|
73
|
-
out += RenderProperty("og:image:alt", img.alt);
|
|
74
|
-
}
|
|
75
|
-
if (og.video)
|
|
76
|
-
for (const vid of og.video) {
|
|
77
|
-
out += RenderProperty("og:video", vid.url);
|
|
78
|
-
if (vid.secure_url)
|
|
79
|
-
out += RenderProperty("og:video:secure_url", vid.secure_url);
|
|
80
|
-
if (vid.type)
|
|
81
|
-
out += RenderProperty("og:video:type", vid.type);
|
|
82
|
-
if (vid.width)
|
|
83
|
-
out += RenderProperty("og:video:width", vid.width.toString());
|
|
84
|
-
if (vid.height)
|
|
85
|
-
out += RenderProperty("og:video:height", vid.height.toString());
|
|
86
|
-
if (vid.alt)
|
|
87
|
-
out += RenderProperty("og:video:alt", vid.alt);
|
|
88
|
-
}
|
|
89
|
-
if (og.audio)
|
|
90
|
-
for (const audio of og.audio) {
|
|
91
|
-
out += RenderProperty("og:audio", audio.url);
|
|
92
|
-
if (audio.secure_url)
|
|
93
|
-
out += RenderProperty("og:audio:secure_url", audio.secure_url);
|
|
94
|
-
if (audio.type)
|
|
95
|
-
out += RenderProperty("og:audio:type", audio.type);
|
|
96
|
-
}
|
|
97
|
-
return out + RenderOpenGraphExtras(og);
|
|
98
|
-
}
|
|
99
|
-
function RenderProperty(name, value) {
|
|
100
|
-
return `<meta property="${name}" content="${EscapeHTML(value)}">\n`;
|
|
101
|
-
}
|
|
102
|
-
function RenderOpenGraphExtras(og) {
|
|
103
|
-
let out = "";
|
|
104
|
-
if (og.type === "music.song") {
|
|
105
|
-
const g = og;
|
|
106
|
-
if (g.duration)
|
|
107
|
-
out += RenderProperty("og:music:duration", g.duration.toString());
|
|
108
|
-
if (g.album)
|
|
109
|
-
for (const album of g.album) {
|
|
110
|
-
if (typeof album === "string")
|
|
111
|
-
out += RenderProperty("og:music:album", album);
|
|
112
|
-
else {
|
|
113
|
-
out += RenderProperty("og:music:album", album.url);
|
|
114
|
-
if (album.disc)
|
|
115
|
-
out += RenderProperty("og:music:album:disc", album.disc.toString());
|
|
116
|
-
if (album.track)
|
|
117
|
-
out += RenderProperty("og:music:album:track", album.track.toString());
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (g.musician)
|
|
121
|
-
for (const profile of g.musician)
|
|
122
|
-
out += RenderProperty("og:music:musician", profile);
|
|
123
|
-
return out;
|
|
124
|
-
}
|
|
125
|
-
if (og.type === "music.album") {
|
|
126
|
-
const g = og;
|
|
127
|
-
if (g.songs)
|
|
128
|
-
for (const song of g.songs) {
|
|
129
|
-
if (typeof song === "string")
|
|
130
|
-
out += RenderProperty("og:music:song", song);
|
|
131
|
-
else {
|
|
132
|
-
out += RenderProperty("og:music:song", song.url);
|
|
133
|
-
if (song.disc)
|
|
134
|
-
out += RenderProperty("og:music:song:disc", song.disc.toString());
|
|
135
|
-
if (song.track)
|
|
136
|
-
out += RenderProperty("og:music:song:track", song.track.toString());
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (g.musician)
|
|
140
|
-
for (const profile of g.musician)
|
|
141
|
-
out += RenderProperty("og:music:musician", profile);
|
|
142
|
-
if (g.release_date)
|
|
143
|
-
out += RenderProperty("og:music:release_date", g.release_date.toISOString());
|
|
144
|
-
return out;
|
|
145
|
-
}
|
|
146
|
-
if (og.type === "music.playlist") {
|
|
147
|
-
const g = og;
|
|
148
|
-
if (g.songs)
|
|
149
|
-
for (const song of g.songs) {
|
|
150
|
-
if (typeof song === "string")
|
|
151
|
-
out += RenderProperty("og:music:song", song);
|
|
152
|
-
else {
|
|
153
|
-
out += RenderProperty("og:music:song", song.url);
|
|
154
|
-
if (song.disc)
|
|
155
|
-
out += RenderProperty("og:music:song:disc", song.disc.toString());
|
|
156
|
-
if (song.track)
|
|
157
|
-
out += RenderProperty("og:music:song:track", song.track.toString());
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (g.creator)
|
|
161
|
-
for (const profile of g.creator)
|
|
162
|
-
out += RenderProperty("og:music:creator", profile);
|
|
163
|
-
return out;
|
|
164
|
-
}
|
|
165
|
-
if (og.type === "music.radio_station") {
|
|
166
|
-
const g = og;
|
|
167
|
-
if (g.creator)
|
|
168
|
-
for (const profile of g.creator)
|
|
169
|
-
out += RenderProperty("og:music:creator", profile);
|
|
170
|
-
return out;
|
|
171
|
-
}
|
|
172
|
-
if (og.type === "video.movie" || og.type === "video.episode" || og.type === "video.tv_show" || og.type === "video.other") {
|
|
173
|
-
const g = og;
|
|
174
|
-
if (g.actors)
|
|
175
|
-
for (const actor of g.actors) {
|
|
176
|
-
if (typeof actor === "string")
|
|
177
|
-
out += RenderProperty("og:video:actor", actor);
|
|
178
|
-
else {
|
|
179
|
-
out += RenderProperty("og:video:actor", actor.url);
|
|
180
|
-
out += RenderProperty("og:video:actor:role", actor.role);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
if (g.directors)
|
|
184
|
-
for (const profile of g.directors)
|
|
185
|
-
out += RenderProperty("og:video:director", profile);
|
|
186
|
-
if (g.writers)
|
|
187
|
-
for (const profile of g.writers)
|
|
188
|
-
out += RenderProperty("og:video:writer", profile);
|
|
189
|
-
if (g.duration)
|
|
190
|
-
out += RenderProperty("og:video:duration", g.duration.toString());
|
|
191
|
-
if (g.release_date)
|
|
192
|
-
out += RenderProperty("og:video:release_date", g.release_date.toISOString());
|
|
193
|
-
if (g.tag)
|
|
194
|
-
for (const tag of g.tag)
|
|
195
|
-
out += RenderProperty("og:video:tag", tag);
|
|
196
|
-
if (g.series)
|
|
197
|
-
out += RenderProperty("og:video:series", g.series);
|
|
198
|
-
}
|
|
199
|
-
if (og.type === "article") {
|
|
200
|
-
const g = og;
|
|
201
|
-
if (g.published_time)
|
|
202
|
-
out += RenderProperty("og:article:published_time", g.published_time.toISOString());
|
|
203
|
-
if (g.modified_time)
|
|
204
|
-
out += RenderProperty("og:article:modified_time", g.modified_time.toISOString());
|
|
205
|
-
if (g.expiration_time)
|
|
206
|
-
out += RenderProperty("og:article:expiration_time", g.expiration_time.toISOString());
|
|
207
|
-
if (g.authors)
|
|
208
|
-
for (const profile of g.authors)
|
|
209
|
-
out += RenderProperty("og:article:author", profile);
|
|
210
|
-
if (g.section)
|
|
211
|
-
out += RenderProperty("og:article:section", g.section);
|
|
212
|
-
if (g.tag)
|
|
213
|
-
for (const tag of g.tag)
|
|
214
|
-
out += RenderProperty("og:video:tag", tag);
|
|
215
|
-
}
|
|
216
|
-
if (og.type === "book") {
|
|
217
|
-
const g = og;
|
|
218
|
-
if (g.authors)
|
|
219
|
-
for (const profile of g.authors)
|
|
220
|
-
out += RenderProperty("og:article:author", profile);
|
|
221
|
-
if (g.isbn)
|
|
222
|
-
out += RenderProperty("og:book:isbn", g.isbn);
|
|
223
|
-
if (g.release_date)
|
|
224
|
-
out += RenderProperty("og:book:release_date", g.release_date.toISOString());
|
|
225
|
-
if (g.tag)
|
|
226
|
-
for (const tag of g.tag)
|
|
227
|
-
out += RenderProperty("og:video:tag", tag);
|
|
228
|
-
}
|
|
229
|
-
if (og.type === "profile") {
|
|
230
|
-
const g = og;
|
|
231
|
-
if (g.first_name)
|
|
232
|
-
out += RenderProperty("og:profile:first_name", g.first_name);
|
|
233
|
-
if (g.last_name)
|
|
234
|
-
out += RenderProperty("og:profile:last_name", g.last_name);
|
|
235
|
-
if (g.username)
|
|
236
|
-
out += RenderProperty("og:profile:username", g.username);
|
|
237
|
-
if (g.gender)
|
|
238
|
-
out += RenderProperty("og:profile:gender", g.gender);
|
|
239
|
-
}
|
|
240
|
-
return "";
|
|
241
|
-
}
|
|
242
|
-
const escapeTo = {
|
|
243
|
-
"&": "&",
|
|
244
|
-
"<": "<",
|
|
245
|
-
">": ">",
|
|
246
|
-
"\"": """,
|
|
247
|
-
"'": "'",
|
|
248
|
-
};
|
|
249
|
-
function EscapeHTML(str) {
|
|
250
|
-
return str.replace(/[&<>"']/g, (match) => escapeTo[match] || match);
|
|
251
|
-
}
|