Skip to content

Commit ef298ce

Browse files
AtkinsSJKernelDeimos
authored andcommitted
feat: Display app icon and description in embeds
1 parent c8abe23 commit ef298ce

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

packages/backend/src/routers/_default.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ router.all('*', async function(req, res, next) {
265265
// ------------------------
266266
else{
267267
let canonical_url = config.origin + path;
268-
let app_name, app_title, description;
268+
let app_name, app_title, app_description, app_icon;
269269
let launch_options = {
270270
on_initialized: []
271271
};
@@ -283,7 +283,8 @@ router.all('*', async function(req, res, next) {
283283
const app = await get_app({name: app_name});
284284
if(app){
285285
app_title = app.title;
286-
description = app.description;
286+
app_description = app.description;
287+
app_icon = app.icon;
287288
}
288289
// 404 - Not found!
289290
else if(app_name){
@@ -319,10 +320,11 @@ router.all('*', async function(req, res, next) {
319320
const svc_puterHomepage = Context.get('services').get('puter-homepage');
320321
return svc_puterHomepage.send({ req, res }, {
321322
title: app_title,
322-
description: description || config.short_description,
323-
short_description: config.short_description,
323+
description: app_description || config.short_description,
324+
short_description: app_description || config.short_description,
324325
company: 'Puter Technologies Inc.',
325326
canonical_url: canonical_url,
327+
icon: app_icon,
326328
}, launch_options);
327329
}
328330

@@ -417,4 +419,4 @@ router.all('*', async function(req, res, next) {
417419
}
418420
});
419421

420-
module.exports = router
422+
module.exports = router

packages/backend/src/services/PuterHomepageService.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class PuterHomepageService extends BaseService {
122122
short_description,
123123
company,
124124
canonical_url,
125+
icon,
125126
} = meta;
126127

127128
gui_params = {
@@ -141,6 +142,8 @@ class PuterHomepageService extends BaseService {
141142

142143
const bundled = env != 'dev' || use_bundled_gui;
143144

145+
const icon_url = icon || `${asset_dir}/images/screenshot.png`;
146+
144147
const writeScriptTag = path =>
145148
`<script type="${
146149
Array.isArray(path) ? 'text/javascirpt' : 'module'
@@ -158,19 +161,19 @@ class PuterHomepageService extends BaseService {
158161
<link rel="canonical" href="${e(canonical_url)}">
159162
160163
<!-- Meta meta tags -->
161-
<meta property="og:url" content="${app_origin}">
164+
<meta property="og:url" content="${e(canonical_url)}">
162165
<meta property="og:type" content="website">
163166
<meta property="og:title" content="${e(title)}">
164167
<meta property="og:description" content="${e((short_description).replace(/\n/g, " "))}">
165-
<meta property="og:image" content="${asset_dir}/images/screenshot.png">
168+
<meta property="og:image" content="${e(icon_url)}">
166169
167170
<!-- Twitter meta tags -->
168171
<meta name="twitter:card" content="summary_large_image">
169172
<meta property="twitter:domain" content="puter.com">
170-
<meta property="twitter:url" content="${app_origin}">
173+
<meta property="twitter:url" content="${e(canonical_url)}">
171174
<meta name="twitter:title" content="${e(title)}">
172175
<meta name="twitter:description" content="${e((short_description).replace(/\n/g, " "))}">
173-
<meta name="twitter:image" content="${asset_dir}/images/screenshot.png">
176+
<meta name="twitter:image" content="${e(icon_url)}">
174177
175178
<!-- favicons -->
176179
<link rel="apple-touch-icon" sizes="57x57" href="${asset_dir}/favicons/apple-icon-57x57.png">

0 commit comments

Comments
 (0)