feat!: release v2 (#6545)

Co-authored-by: Artur <145776561+arturict@users.noreply.github.com>
Co-authored-by: arturict <arturict@users.noreply.github.com>
Co-authored-by: Thomas <thomas@ajnart.fr>
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
Co-authored-by: Danura30082 <danura30082+github@gmail.com>
Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com>
Co-authored-by: ajnart <thomas@ajnart.fr>
Co-authored-by: ajnart <thomas@ajnart.dev>
Co-authored-by: chenjun <chenjun@foxmail.com>
Co-authored-by: Wikibear <wikibear@users.noreply.github.com>
Co-authored-by: Bergasha <bergasha@gmail.com>
Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com>
Co-authored-by: Lucas Araujo <lucas.lra@gmail.com>
Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com>
Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social>
Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com>
Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com>
Co-authored-by: thrawnx <tight.bulb9384@fastmail.com>
Co-authored-by: Chris <58918656+nordada@users.noreply.github.com>
Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com>
Co-authored-by: Yanis <naamaneyanis@gmail.com>
Co-authored-by: Wikibear <me@sej.de>
Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386 -139176

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>New Comment on Homarr Workshop</title>
</head>
<body style="margin: 0; padding: 0; background-color: #f4f4f4; font-family: Helvetica, Arial, sans-serif">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f4f4">
<tr>
<td align="center" style="padding: 50px 20px">
<table
role="presentation"
width="600"
cellpadding="0"
cellspacing="0"
style="width: 600px; max-width: 100%; background-color: #ffffff; border: 1px solid #000000"
>
<!-- Header -->
<tr>
<td align="center" style="background-color: #000000; padding: 36px 20px">
<a href="https://homarr.dev" target="_blank" style="text-decoration: none">
<img
src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/homarr-wordmark-light.png"
alt="Homarr"
width="170"
style="display: block; width: 170px; height: auto; border: 0; margin: 0 auto"
/>
</a>
</td>
</tr>
<!-- Body -->
<tr>
<td style="padding: 45px 40px; color: #000000; font-size: 15px; line-height: 1.7">
<p style="margin: 0 0 18px 0">Hi there,</p>
<p style="margin: 0 0 18px 0">
<strong>{{commenterName}}</strong> left a comment on your submission
<strong>{{submissionTitle}}</strong>:
</p>
<blockquote
style="
margin: 0 0 24px 0;
padding: 16px 20px;
border-left: 3px solid #000000;
background-color: #f9f9f9;
color: #555555;
"
>
{{commentExcerpt}}
</blockquote>
<!-- CTA button -->
<table role="presentation" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="background-color: #000000">
<a
href="{{submissionUrl}}"
target="_blank"
style="
display: inline-block;
padding: 12px 28px;
color: #ffffff;
font-size: 14px;
font-weight: bold;
text-decoration: none;
letter-spacing: 0.5px;
"
>
VIEW THE COMMENT
</a>
</td>
</tr>
</table>
</td>
</tr>
<!-- Divider -->
<tr>
<td style="border-top: 1px solid #000000"></td>
</tr>
<!-- Footer -->
<tr>
<td align="center" style="padding: 24px 20px; color: #000000; font-size: 12px">
<a href="https://homarr.dev" target="_blank" style="color: #000000; text-decoration: underline"
>homarr.dev</a
>
&nbsp;&middot;&nbsp; Homarr &mdash; 2026
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
+64
View File
@@ -0,0 +1,64 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Workshop report</title>
</head>
<body style="margin: 0; padding: 0; background: #f4f4f4; font-family: Helvetica, Arial, sans-serif">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background: #f4f4f4">
<tr>
<td align="center" style="padding: 50px 20px">
<table
role="presentation"
width="600"
cellpadding="0"
cellspacing="0"
style="width: 600px; max-width: 100%; background: #ffffff; border: 1px solid #dc2626"
>
<tr>
<td style="background: #991b1b; padding: 28px 36px; color: #ffffff">
<div style="font-size: 12px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase">
Moderation alert
</div>
<div style="margin-top: 8px; font-size: 22px; font-weight: bold">
A Workshop submission was reported
</div>
</td>
</tr>
<tr>
<td style="padding: 36px; color: #18181b; font-size: 15px; line-height: 1.65">
<p style="margin: 0 0 18px">
<strong>{{reporterName}}</strong> reported <a href="{{submissionUrl}}">{{submissionTitle}}</a>.
</p>
<p
style="margin: 0 0 8px; font-size: 12px; font-weight: bold; text-transform: uppercase; color: #991b1b"
>
{{category}}
</p>
<blockquote
style="margin: 0 0 26px; padding: 16px 18px; border-left: 3px solid #dc2626; background: #fef2f2"
>
{{explanation}}
</blockquote>
<a
href="{{adminUrl}}"
style="
display: inline-block;
padding: 12px 20px;
background: #991b1b;
color: #ffffff;
font-weight: bold;
text-decoration: none;
"
>
REVIEW REPORT
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Workshop submission removed</title>
</head>
<body style="margin: 0; padding: 0; background: #f4f4f4; font-family: Helvetica, Arial, sans-serif">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background: #f4f4f4">
<tr>
<td align="center" style="padding: 50px 20px">
<table
role="presentation"
width="600"
cellpadding="0"
cellspacing="0"
style="width: 600px; max-width: 100%; background: #ffffff; border: 1px solid #27272a"
>
<tr>
<td style="background: #18181b; padding: 28px 36px; color: #ffffff">
<div style="font-size: 12px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase">
Homarr Workshop
</div>
<div style="margin-top: 8px; font-size: 22px; font-weight: bold">Your submission was removed</div>
</td>
</tr>
<tr>
<td style="padding: 36px; color: #18181b; font-size: 15px; line-height: 1.65">
<p style="margin: 0 0 18px">A Workshop moderator removed your submission:</p>
<div style="margin: 0 0 24px; padding: 16px 18px; border-left: 3px solid #dc2626; background: #fef2f2">
<strong>{{submissionTitle}}</strong>
</div>
<p style="margin: 0">
The submission is no longer available in Workshop. Widgets or CSS already installed by users are not
removed from their Homarr instances.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
+68
View File
@@ -0,0 +1,68 @@
const rejectRequest = (message) => {
throw new BadRequestError(message);
};
const escapeHtml = (value) =>
String(value)
.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll('"', "&quot;")
.replaceAll("'", "&#039;");
const renderWorkshopSocialHtml = (html, metadata) => {
const title = escapeHtml(metadata.title);
const description = escapeHtml(metadata.description);
const url = escapeHtml(metadata.url);
const image = escapeHtml(metadata.image);
const imageAlt = escapeHtml(`${metadata.submissionTitle} preview`);
const section = escapeHtml(metadata.section);
const tags = [
`<title>${title}</title>`,
`<meta name="description" content="${description}">`,
`<link rel="canonical" href="${url}">`,
`<meta property="og:type" content="article">`,
`<meta property="og:site_name" content="Homarr Workshop">`,
`<meta property="og:title" content="${title}">`,
`<meta property="og:description" content="${description}">`,
`<meta property="og:url" content="${url}">`,
`<meta property="article:section" content="${section}">`,
`<meta name="twitter:card" content="summary_large_image">`,
`<meta name="twitter:title" content="${title}">`,
`<meta name="twitter:description" content="${description}">`,
`<meta property="og:image" content="${image}">`,
`<meta property="og:image:alt" content="${imageAlt}">`,
`<meta name="twitter:image" content="${image}">`,
`<meta name="twitter:image:alt" content="${imageAlt}">`,
].join("\n");
const replaceableTags =
/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*(?:name|property)=["'](?:robots|description|og:(?:title|description|url|image|image:alt|type|site_name)|twitter:(?:card|title|description|image|image:alt)|article:section)["'][^>]*>|<link\b[^>]*rel=["']canonical["'][^>]*>/gi;
return html.replace(replaceableTags, "").replace("<head>", `<head>\n${tags}`);
};
const emailTemplate = (filename) => {
const hooksPath = $os.getenv("WORKSHOP_PB_HOOKS_DIR") || __hooks;
return $os.readFile($filepath.join(hooksPath, filename));
};
const sendEmail = (app, recipientEmail, subject, text, html) => {
const sender = app.settings().meta;
app.newMailClient().send(
new MailerMessage({
from: { address: sender.senderAddress, name: sender.senderName },
to: [{ address: recipientEmail }],
subject,
text,
html,
}),
);
};
module.exports = {
emailTemplate,
escapeHtml,
rejectRequest,
renderWorkshopSocialHtml,
sendEmail,
};
+263
View File
@@ -0,0 +1,263 @@
/// <reference path="../pb_data/types.d.ts" />
onBootstrap((event) => {
const clientId = String($os.getenv("GITHUB_CLIENT_ID") || "").trim();
const clientSecret = String($os.getenv("GITHUB_CLIENT_SECRET") || "").trim();
if (Boolean(clientId) !== Boolean(clientSecret)) {
console.log(JSON.stringify({ event: "workshop_oauth_configuration_rejected", reason: "partial_credentials" }));
throw new Error("GitHub OAuth requires both GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET");
}
const configured = Boolean(clientId && clientSecret);
event.next();
const users = event.app.findCollectionByNameOrId("users");
users.oauth2.enabled = configured;
users.oauth2.mappedFields = { id: "", name: "", username: "name", avatarURL: "" };
users.oauth2.providers = configured ? [{ name: "github", clientId, clientSecret }] : [];
event.app.save(users);
console.log(JSON.stringify({ event: "workshop_oauth_synchronized", enabled: configured }));
});
const workshopDetailPage = (event) => {
const id = event.request.pathValue("id");
if (id === "admin") return event.fileFS($os.dirFS("/pb_public"), "workshop/admin/index.html");
const indexHtml = toString($os.readFile("/pb_public/404.html"));
const remoteApiUrl = String($os.getenv("WORKSHOP_REMOTE_API_URL") || "")
.replace(/\/$/, "")
.replace(/\/api$/, "");
try {
const { renderWorkshopSocialHtml } = require(`${__hooks}/workshop-utils.js`);
let submission;
if (remoteApiUrl) {
const response = $http.send({
url: `${remoteApiUrl}/api/collections/workshop_listings/records/${encodeURIComponent(id)}`,
timeout: 5,
});
if (response.statusCode === 404) return event.html(404, indexHtml);
if (response.statusCode !== 200) return event.html(503, indexHtml);
submission = response.json;
} else {
const record = event.app.findRecordById("submissions", id);
submission = {
id: record.id,
type: record.getString("type"),
title: record.getString("title"),
description: record.getString("description"),
screenshots: record.getStringSlice("screenshots"),
};
}
const type = submission.type;
const section = type === "customCss" ? "Custom CSS" : "Custom widget";
const submissionTitle = submission.title;
const title = `${submissionTitle} · Homarr Workshop`;
const description = `${section} for Homarr. ${submission.description}`.trim();
const workshopUrl = $os.getenv("WORKSHOP_WEB_URL").replace(/\/$/, "");
const apiUrl = remoteApiUrl || $os.getenv("WORKSHOP_API_URL").replace(/\/$/, "");
const websiteUrl = $os.getenv("HOMARR_WEBSITE_URL").replace(/\/$/, "");
const screenshot = submission.screenshots[0];
const image = screenshot
? `${apiUrl}/api/files/submissions/${submission.id}/${encodeURIComponent(screenshot)}`
: `${websiteUrl}/img/logo.png`;
return event.html(
200,
renderWorkshopSocialHtml(indexHtml, {
title,
description,
url: `${workshopUrl}/${submission.id}`,
image,
section,
submissionTitle,
}),
);
} catch {
return event.html(remoteApiUrl ? 503 : 404, indexHtml);
}
};
routerAdd("GET", "/workshop/{id}", workshopDetailPage);
routerAdd("GET", "/workshop/{id}/{$}", workshopDetailPage);
onRecordCreateRequest((event) => {
event.record.set("revision", 1);
event.record.set("expectedRevision", 0);
event.record.set("changelog", "");
event.record.set("outdated", false);
event.next();
}, "submissions");
onRecordUpdateRequest((event) => {
const { rejectRequest } = require(`${__hooks}/workshop-utils.js`);
const original = event.record.original();
const currentRevision = original.getInt("revision");
const expectedRevision = event.record.getInt("expectedRevision");
if (!Number.isSafeInteger(expectedRevision) || expectedRevision < 1) {
rejectRequest("Submission changed since it was read");
}
event.record.set("expectedRevision", expectedRevision);
event.record.set("revision", currentRevision + 1);
event.next();
}, "submissions");
onRecordCreateRequest((event) => {
const auth = event.requestInfo().auth;
const reporter = event.record.getString("reporter");
const submission = event.record.getString("submission");
if (auth && auth.id === reporter) {
const dismissed = event.app.findRecordsByFilter(
"reports",
"reporter = {:reporter} && submission = {:submission} && status = 'dismissed'",
"",
1,
0,
{ reporter, submission },
);
if (dismissed.length > 0) {
event.app.delete(dismissed[0]);
console.log(
JSON.stringify({
event: "workshop_report_reopened",
reporterId: reporter,
submissionId: submission,
}),
);
}
}
event.record.set("status", "open");
event.next();
}, "reports");
onRecordAfterCreateSuccess((event) => {
try {
const votes = event.app.findCollectionByNameOrId("votes");
const vote = new Record(votes);
vote.set("submission", event.record.id);
vote.set("user", event.record.get("author"));
vote.set("value", 1);
event.app.save(vote);
} catch (error) {
console.log(`Workshop initial upvote failed for ${event.record.id}: ${error}`);
}
event.next();
}, "submissions");
onRecordAfterCreateSuccess((event) => {
try {
const { emailTemplate, escapeHtml, sendEmail } = require(`${__hooks}/workshop-utils.js`);
const submission = event.app.findRecordById("submissions", event.record.get("submission"));
const recipient = event.app.findRecordById("users", submission.get("author"));
const commenter = event.app.findRecordById("users", event.record.get("author"));
const recipientEmail = recipient.email();
const publicOrigin = $os.getenv("WORKSHOP_PUBLIC_ORIGIN").replace(/\/$/, "");
const publicWorkshopUrl = ($os.getenv("WORKSHOP_WEB_URL") || `${publicOrigin}/workshop`).replace(/\/$/, "");
if (!recipientEmail || recipient.id === commenter.id || !publicOrigin) {
event.next();
return;
}
const commenterName = commenter.getString("name") || "A community member";
const submissionTitle = submission.getString("title");
const rawExcerpt = event.record.getString("content").slice(0, 280);
const submissionUrl = `${publicWorkshopUrl}/${submission.id}/`;
const template = emailTemplate("comment-email.html")
.replaceAll("{{commenterName}}", escapeHtml(commenterName))
.replaceAll("{{submissionTitle}}", escapeHtml(submissionTitle))
.replaceAll("{{commentExcerpt}}", escapeHtml(rawExcerpt))
.replaceAll("{{submissionUrl}}", escapeHtml(submissionUrl));
sendEmail(
event.app,
recipientEmail,
`${commenterName} commented on ${submissionTitle}`,
`${commenterName} commented on “${submissionTitle}”:\n\n${rawExcerpt}\n\n${submissionUrl}`,
template,
);
} catch (error) {
console.log(`Workshop comment email failed for ${event.record.id}: ${error}`);
}
event.next();
}, "comments");
onRecordAfterCreateSuccess((event) => {
try {
const { emailTemplate, escapeHtml, sendEmail } = require(`${__hooks}/workshop-utils.js`);
const submission = event.app.findRecordById("submissions", event.record.get("submission"));
const reporter = event.app.findRecordById("users", event.record.get("reporter"));
const publicOrigin = $os.getenv("WORKSHOP_PUBLIC_ORIGIN").replace(/\/$/, "");
const publicWorkshopUrl = ($os.getenv("WORKSHOP_WEB_URL") || `${publicOrigin}/workshop`).replace(/\/$/, "");
const admins = event.app.findRecordsByFilter("users", "isAdmin = true && email != ''", "", 100, 0);
if (!publicOrigin || admins.length === 0) {
event.next();
return;
}
const reporterName = reporter.getString("name") || "A community member";
const submissionTitle = submission.getString("title");
const category = event.record.getString("category");
const explanation = event.record.getString("explanation");
const adminUrl = `${publicWorkshopUrl}/admin`;
const submissionUrl = `${publicWorkshopUrl}/${submission.id}/`;
const template = emailTemplate("report-email.html")
.replaceAll("{{reporterName}}", escapeHtml(reporterName))
.replaceAll("{{submissionTitle}}", escapeHtml(submissionTitle))
.replaceAll("{{category}}", escapeHtml(category))
.replaceAll("{{explanation}}", escapeHtml(explanation))
.replaceAll("{{adminUrl}}", escapeHtml(adminUrl))
.replaceAll("{{submissionUrl}}", escapeHtml(submissionUrl));
for (const admin of admins) {
try {
sendEmail(
event.app,
admin.email(),
`Workshop report: ${submissionTitle}`,
`${reporterName} reported “${submissionTitle}” for ${category}.\n\n${explanation}\n\nReview: ${adminUrl}`,
template,
);
} catch (error) {
console.log(`Workshop report email failed for admin ${admin.id}: ${error}`);
}
}
} catch (error) {
console.log(`Workshop report email failed for ${event.record.id}: ${error}`);
}
event.next();
}, "reports");
onRecordDeleteRequest((event) => {
const { emailTemplate, escapeHtml, sendEmail } = require(`${__hooks}/workshop-utils.js`);
const submissionId = event.record.id;
const submissionTitle = event.record.getString("title");
const authorId = event.record.get("author");
const actor = event.requestInfo().auth;
const notifyAuthor = actor && actor.getBool("isAdmin") && actor.id !== authorId;
event.next();
if (!notifyAuthor) return;
try {
const author = event.app.findRecordById("users", authorId);
const recipientEmail = author.email();
if (!recipientEmail) return;
const publicOrigin = $os.getenv("WORKSHOP_PUBLIC_ORIGIN").replace(/\/$/, "");
const workshopUrl = ($os.getenv("WORKSHOP_WEB_URL") || (publicOrigin ? `${publicOrigin}/workshop` : "")).replace(
/\/?$/,
"/",
);
const template = emailTemplate("submission-deleted-email.html").replaceAll(
"{{submissionTitle}}",
escapeHtml(submissionTitle),
);
const text = `A Workshop moderator removed your submission “${submissionTitle}”.${
workshopUrl ? `\n\nReturn to Workshop: ${workshopUrl}` : ""
}`;
sendEmail(event.app, recipientEmail, `Your Workshop submission was removed`, text, template);
} catch (error) {
console.log(`Workshop deletion email failed for ${submissionId}: ${error}`);
}
}, "submissions");