mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 17:05:40 +02:00
feat(rices): refactor rice metadata retrieval and enhance HTML response
This commit is contained in:
parent
aa45364f4d
commit
d5f39678c4
2 changed files with 19 additions and 7 deletions
|
@ -60,22 +60,27 @@ export class RicesController {
|
||||||
})
|
})
|
||||||
@Get(':slug')
|
@Get(':slug')
|
||||||
async getRice(@Param('slug') slug: string, @Res() res: Response) {
|
async getRice(@Param('slug') slug: string, @Res() res: Response) {
|
||||||
const riceMetadata = await this.ricesService.findOne(slug);
|
const riceMetadata = await this.ricesService.getRiceMetadata(slug);
|
||||||
|
|
||||||
const htmlContent = `<!DOCTYPE html>
|
const htmlContent = `<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="robots" content="noindex">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<script>
|
<meta name="zen-content-verified" content="unverified">
|
||||||
const zenrice = ${riceMetadata};
|
<meta name="zen-rice-data" data-author="${riceMetadata.author}" data-name="${riceMetadata.name}" data-id="${riceMetadata.id}">
|
||||||
</script>
|
<title>Zen Rice - ${riceMetadata.name}</title>
|
||||||
<title>ZenRice download ${slug}</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script defer>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
window.location.href = 'https://zen-browser.app/download';
|
/* Set time out so the meta tag is set after the next DOM repaint */
|
||||||
|
setTimeout(() => {
|
||||||
|
if (document.querySelector('meta[name="zen-content-verified"]')?.content !== 'verified') {
|
||||||
|
window.location.replace('https://zen-browser.app/download');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<!-- Body content is intentionally left blank -->
|
<!-- Body content is intentionally left blank -->
|
||||||
|
|
|
@ -170,6 +170,13 @@ export class RicesService {
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getRiceMetadata(slug: string) {
|
||||||
|
const rice = await this.supabaseService.getRiceBySlug(slug);
|
||||||
|
if (!rice) throw new NotFoundException('Rice not found');
|
||||||
|
|
||||||
|
return rice;
|
||||||
|
}
|
||||||
|
|
||||||
async update(
|
async update(
|
||||||
slug: string,
|
slug: string,
|
||||||
token: string,
|
token: string,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue