improved oEmbed response generation

pull/19/head
tycrek 3 years ago
parent 8071bffe95
commit 0227ce1e8c
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -102,7 +102,7 @@ If you primarily share media on Discord, you can add these additional (optional)
| **`X-Ass-OG-Description`** | Small text shown below the title but above the media (does not show up on videos yet) |
| **`X-Ass-OG-Author`** | Small text shown above the title |
| **`X-Ass-OG-Author-Url`** | URL to open when the Author is clicked |
| **`X-Ass-OG-Provider`** | Similar to Author. Used to describe the site serving the resource |
| **`X-Ass-OG-Provider`** | Smaller text shown above the author |
| **`X-Ass-OG-Provider-Url`** | URL to open when the Provider is clicked |
| **`X-Ass-OG-Color`** | Colour shown on the left side of the embed. Must be either a hex colour value (for example: `#fe3c29`) or `&random` |

@ -189,16 +189,16 @@ function startup() {
// If the ID is invalid, return 404
if (!resourceId || !data[resourceId]) return res.sendStatus(404);
// Build the oEmbed object
// Build the oEmbed object & send the response
let { opengraph, mimetype } = data[resourceId];
let oembed = { version: '1.0', type: mimetype.includes('video') ? 'video' : 'photo' };
opengraph.author && (oembed.author_name = opengraph.author);
opengraph.authorUrl && (oembed.author_url = opengraph.authorUrl);
opengraph.provider && (oembed.provider_name = opengraph.provider);
opengraph.providerUrl && (oembed.provider_url = opengraph.providerUrl);
// Send the oEmbed resonse
res.type('json').send(oembed);
res.type('json').send({
version: '1.0',
type: mimetype.includes('video') ? 'video' : 'photo',
author_name: opengraph.author,
author_url: opengraph.authorUrl,
provider_name: opengraph.provider,
provider_url: opengraph.providerUrl
});
});
// Delete file

@ -63,14 +63,16 @@ const html = `
<html>
<head>
<title>ass</title>
<!-- Open Graph (https://ogp.me/) -->
<meta property="og:type" content="{{{ogtype}}}">
<meta property="og:{{{type}}}" content="{{{http}}}{{{domain}}}/{{{resourceId}}}{{{ext}}}">
<link rel="alternate" type="application/json+oembed" href="{{{http}}}{{{domain}}}/{{{resourceId}}}/oembed.json" title="oEmbed">
{{{title}}}
{{{description}}}
{{{site}}}
{{{color}}}
{{{card}}}
<!-- oEmbed (https://oembed.com/) -->
<link rel="alternate" type="application/json+oembed" href="{{{http}}}{{{domain}}}/{{{resourceId}}}/oembed.json" title="oEmbed">
</head>
<body>
Open Graph response for <a href="{{{github}}}" target="_blank">ass</a>.

Loading…
Cancel
Save