From eb966b07c34b07fcec2a6636ca297f51d91481fd Mon Sep 17 00:00:00 2001 From: letzfets Date: Fri, 23 Dec 2022 22:16:25 +0100 Subject: [PATCH 1/6] Adds title of tool to feedback commit --- tools/src/lib/github.ts | 8 ++++++-- tools/src/routes/[link]/+page.server.ts | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/src/lib/github.ts b/tools/src/lib/github.ts index 724adf0d..88673d89 100644 --- a/tools/src/lib/github.ts +++ b/tools/src/lib/github.ts @@ -33,6 +33,7 @@ const TEMPLATES = { disclaimer: '## Disclaimer\nThe following feedback was submitted by an user of https://idg.tools. This has not yet been reviewed or approved by the contributors.\n\n---\n', }, + // NOTE: Seems like this template is currently not used anywhere - in case it is used in future, the call to createIssue() also requires a parameter. CONTENT_SUGGESTION: { title: 'App Content Suggestion', labelIds: [LABEL_IDS.NEEDS_REVIEW, LABEL_IDS.CONTENT_SUGGESTION], @@ -45,6 +46,7 @@ type ISSUE_TYPES = keyof typeof TEMPLATES // NOTE: Seems like there's a rate limiting of 5000/requests per hour, so it might be worth to write multiple issues at once in the future to scale up. export async function createIssue({ + name, userContent, type, url, @@ -56,16 +58,18 @@ export async function createIssue({ const { title, labelIds, disclaimer } = TEMPLATES[type] const body = `${disclaimer} + ${userContent} + --- - URL: ${url} - Git commit: \`${GIT_COMMIT}\` --- -${userContent}` +` const newIssue = { repositoryId: REPOSITORY.id, - title: `[${title}]: ${new Date().toISOString()}`, + title: `[${title}]: ${name || new Date().toISOString()}`, body, labelIds, } diff --git a/tools/src/routes/[link]/+page.server.ts b/tools/src/routes/[link]/+page.server.ts index eb8f5184..b1ccef8e 100644 --- a/tools/src/routes/[link]/+page.server.ts +++ b/tools/src/routes/[link]/+page.server.ts @@ -4,16 +4,18 @@ import stripMarkdown from 'strip-markdown' import { content } from '$lib/content-backend' import { getSkill, getTag, getToolByLink } from '$shared/content-utils' -import type { Actions, PageServerLoad } from './$types' +import type { Tool, Actions, PageServerLoad } from './$types' import { createIssue } from '$lib/github' +let tool: Tool + const sanitizer = remark().use(stripMarkdown) const sanitizeInput = (raw: string) => sanitizer.process(raw).then((value) => value.toString()) /** @type {PageServerLoad} */ export async function load({ params: { link } }: { params: Record }) { - const tool = getToolByLink(link, content) + tool = getToolByLink(link, content) if (tool) { // If page was found on a different URL, @@ -51,6 +53,7 @@ export const actions: Actions = { if (!Boolean(data.liked || data.improve)) return { success: false } await createIssue({ + name: tool.name, userContent: `## What do you like?\n> ${data.liked}\n\n## What can be improved?\n> ${data.improve}`, type: 'FEEDBACK', url: url.href, From 5a5c8597c360074cb022cb522756fdc077d14b9a Mon Sep 17 00:00:00 2001 From: Samuel Plumppu <6125097+Greenheart@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:07:26 +0100 Subject: [PATCH 2/6] Update tools/src/lib/github.ts --- tools/src/lib/github.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/src/lib/github.ts b/tools/src/lib/github.ts index 88673d89..9f52f172 100644 --- a/tools/src/lib/github.ts +++ b/tools/src/lib/github.ts @@ -54,6 +54,11 @@ export async function createIssue({ userContent: string type: ISSUE_TYPES url: string +}) { + name: string + userContent: string + type: ISSUE_TYPES + url: string }) { const { title, labelIds, disclaimer } = TEMPLATES[type] From 0042e380e92d264344d6592838914c2a6aa7a455 Mon Sep 17 00:00:00 2001 From: Samuel Plumppu <6125097+Greenheart@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:07:47 +0100 Subject: [PATCH 3/6] Update tools/src/lib/github.ts --- tools/src/lib/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/lib/github.ts b/tools/src/lib/github.ts index 9f52f172..e5d3529b 100644 --- a/tools/src/lib/github.ts +++ b/tools/src/lib/github.ts @@ -74,7 +74,7 @@ export async function createIssue({ const newIssue = { repositoryId: REPOSITORY.id, - title: `[${title}]: ${name || new Date().toISOString()}`, + title: `[${title}]: ${name}`, body, labelIds, } From 0da5a01b170f995f3515ac75bf582cc506ca42ca Mon Sep 17 00:00:00 2001 From: Samuel Plumppu <6125097+Greenheart@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:08:00 +0100 Subject: [PATCH 4/6] Update tools/src/routes/[link]/+page.server.ts --- tools/src/routes/[link]/+page.server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/routes/[link]/+page.server.ts b/tools/src/routes/[link]/+page.server.ts index b1ccef8e..7cc9ebf0 100644 --- a/tools/src/routes/[link]/+page.server.ts +++ b/tools/src/routes/[link]/+page.server.ts @@ -15,7 +15,7 @@ const sanitizeInput = (raw: string) => sanitizer.process(raw).then((value) => va /** @type {PageServerLoad} */ export async function load({ params: { link } }: { params: Record }) { - tool = getToolByLink(link, content) + const tool = getToolByLink(link, content) if (tool) { // If page was found on a different URL, From ed297abae36767719a89e526aeab3e66b0e3f6aa Mon Sep 17 00:00:00 2001 From: Samuel Plumppu <6125097+Greenheart@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:08:25 +0100 Subject: [PATCH 5/6] Update tools/src/routes/[link]/+page.server.ts --- tools/src/routes/[link]/+page.server.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/src/routes/[link]/+page.server.ts b/tools/src/routes/[link]/+page.server.ts index 7cc9ebf0..3e737e55 100644 --- a/tools/src/routes/[link]/+page.server.ts +++ b/tools/src/routes/[link]/+page.server.ts @@ -7,7 +7,6 @@ import { getSkill, getTag, getToolByLink } from '$shared/content-utils' import type { Tool, Actions, PageServerLoad } from './$types' import { createIssue } from '$lib/github' -let tool: Tool const sanitizer = remark().use(stripMarkdown) From 900f95ff609d02d905d00989cbb1a1d0d0c66535 Mon Sep 17 00:00:00 2001 From: Samuel Plumppu <6125097+Greenheart@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:09:47 +0100 Subject: [PATCH 6/6] Update tools/src/routes/[link]/+page.server.ts --- tools/src/routes/[link]/+page.server.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/src/routes/[link]/+page.server.ts b/tools/src/routes/[link]/+page.server.ts index 3e737e55..3bd66609 100644 --- a/tools/src/routes/[link]/+page.server.ts +++ b/tools/src/routes/[link]/+page.server.ts @@ -7,7 +7,6 @@ import { getSkill, getTag, getToolByLink } from '$shared/content-utils' import type { Tool, Actions, PageServerLoad } from './$types' import { createIssue } from '$lib/github' - const sanitizer = remark().use(stripMarkdown) const sanitizeInput = (raw: string) => sanitizer.process(raw).then((value) => value.toString())