From 664b39f1ebb377b2a1c8c658bb690848d203915a Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sun, 25 Jun 2023 02:37:34 -0400 Subject: [PATCH 01/11] chore(a11y): Remove a11y eslint overrides, as there are (almost) no more violations --- .eslintrc.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 42c7b586..81257cb3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,10 +21,6 @@ "@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/no-empty-function": 0, "arrow-body-style": 0, - "jsx-a11y/anchor-is-valid": 1, - "jsx-a11y/aria-role": 1, - "jsx-a11y/click-events-have-key-events": 1, - "jsx-a11y/no-static-element-interactions": 1, "curly": 0, "eol-last": 0, "eqeqeq": 0, From 1c84a6f94953aec7831811f99558db5bde9f0e2f Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sun, 25 Jun 2023 03:04:33 -0400 Subject: [PATCH 02/11] chore: Empty commit to re-trigger Woodpecker From d1cf01061bf74978d2dad6c41ac27968baa74f28 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Sun, 25 Jun 2023 10:43:58 -0400 Subject: [PATCH 03/11] fix error on prod --- src/server/handlers/theme-handler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server/handlers/theme-handler.ts b/src/server/handlers/theme-handler.ts index b107d854..eb0c8ce4 100644 --- a/src/server/handlers/theme-handler.ts +++ b/src/server/handlers/theme-handler.ts @@ -11,8 +11,7 @@ export default async (req: Request, res: Response) => { const theme = req.params.name; if (!theme.endsWith(".css")) { - res.statusCode = 400; - res.send("Theme must be a css file"); + return res.status(400).send("Theme must be a css file"); } const customTheme = path.resolve(extraThemesFolder, theme); From 9938ac6ee454ea539f9a3a5ad3d8a005942daafd Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Sun, 25 Jun 2023 10:47:21 -0400 Subject: [PATCH 04/11] fix lint error --- src/server/handlers/theme-handler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/handlers/theme-handler.ts b/src/server/handlers/theme-handler.ts index eb0c8ce4..456fb3bd 100644 --- a/src/server/handlers/theme-handler.ts +++ b/src/server/handlers/theme-handler.ts @@ -17,15 +17,15 @@ export default async (req: Request, res: Response) => { const customTheme = path.resolve(extraThemesFolder, theme); if (existsSync(customTheme)) { - res.sendFile(customTheme); + return res.sendFile(customTheme); } else { const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`); // If the theme doesn't exist, just send litely if (existsSync(internalTheme)) { - res.sendFile(internalTheme); + return res.sendFile(internalTheme); } else { - res.sendFile(path.resolve("./dist/assets/css/themes/litely.css")); + return res.sendFile(path.resolve("./dist/assets/css/themes/litely.css")); } } }; From 462c7ab74819a64aa2cc1f83622a19278c3a018e Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:01:40 -0400 Subject: [PATCH 05/11] handle embedded iframe content better --- src/shared/components/post/metadata-card.tsx | 31 ++------------------ src/shared/components/post/post-listing.tsx | 17 ++++++++++- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/shared/components/post/metadata-card.tsx b/src/shared/components/post/metadata-card.tsx index 2d770d44..a1ddca7f 100644 --- a/src/shared/components/post/metadata-card.tsx +++ b/src/shared/components/post/metadata-card.tsx @@ -1,8 +1,7 @@ -import { Component, linkEvent } from "inferno"; +import { Component } from "inferno"; import { Post } from "lemmy-js-client"; import * as sanitizeHtml from "sanitize-html"; import { relTags } from "../../config"; -import { I18NextService } from "../../services"; import { Icon } from "../common/icon"; interface MetadataCardProps { @@ -17,10 +16,6 @@ export class MetadataCard extends Component< MetadataCardProps, MetadataCardState > { - state: MetadataCardState = { - expanded: false, - }; - constructor(props: any, context: any) { super(props, context); } @@ -29,7 +24,7 @@ export class MetadataCard extends Component< const post = this.props.post; return ( <> - {!this.state.expanded && post.embed_title && post.url && ( + {post.embed_title && post.url && (
@@ -61,34 +56,12 @@ export class MetadataCard extends Component< }} /> )} - {post.embed_video_url && ( - - )}
)} - {this.state.expanded && post.embed_video_url && ( -
- -
- )} ); } - - handleIframeExpand(i: MetadataCard) { - i.setState({ expanded: !i.state.expanded }); - } } diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index e5694fa7..092e253e 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -262,6 +262,7 @@ export class PostListing extends Component { const { post } = this.postView; const { url } = post; + // if direct video link if (url && isVideo(url)) { return (
@@ -272,6 +273,20 @@ export class PostListing extends Component { ); } + // if embedded video link + if (url && post.embed_video_url) { + return ( +
+ +
+ ); + } + return <>; } @@ -338,7 +353,7 @@ export class PostListing extends Component { ); } else if (url) { - if (!this.props.hideImage && isVideo(url)) { + if ((!this.props.hideImage && isVideo(url)) || post.embed_video_url) { return ( Date: Sun, 25 Jun 2023 12:09:53 -0400 Subject: [PATCH 06/11] Add margin to new comment text --- src/shared/components/post/post-listing.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 092e253e..20be5b23 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -741,7 +741,7 @@ export class PostListing extends Component { {post_view.counts.comments} {this.unreadCount && ( - + ({this.unreadCount} {I18NextService.i18n.t("new")}) )} From 25cab15cfa489da4161d098fb491573efd8ffaf6 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 25 Jun 2023 13:07:18 -0400 Subject: [PATCH 07/11] Fix search request being called twice on search page --- src/shared/components/search.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 473b18c4..b58580e5 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -332,7 +332,9 @@ export class Search extends Component { } async componentDidMount() { - if (!this.state.isIsomorphic) { + if ( + !(this.state.isIsomorphic || this.props.history.location.state?.searched) + ) { const promises = [this.fetchCommunities()]; if (this.state.searchText) { promises.push(this.search()); @@ -1095,7 +1097,9 @@ export class Search extends Component { sort: sort ?? urlSort, }; - this.props.history.push(`/search${getQueryString(queryParams)}`); + this.props.history.push(`/search${getQueryString(queryParams)}`, { + searched: true, + }); await this.search(); } From 6a69d6b06385b932d4f8a0a8b67de6ad3d4bedae Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 25 Jun 2023 13:28:00 -0400 Subject: [PATCH 08/11] Use spae instead of margin --- src/shared/components/post/post-listing.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 20be5b23..e43590e5 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -741,9 +741,12 @@ export class PostListing extends Component { {post_view.counts.comments} {this.unreadCount && ( - - ({this.unreadCount} {I18NextService.i18n.t("new")}) - + <> + {" "} + + ({this.unreadCount} {I18NextService.i18n.t("new")}) + + )} ); From 434502c6785c1651a2e3d631dbde7f7833db8d22 Mon Sep 17 00:00:00 2001 From: Dominic Mazzoni Date: Sun, 25 Jun 2023 12:12:32 -0700 Subject: [PATCH 09/11] CSP should allow data urls for media-src or the audio captcha won't work --- src/server/middleware/set-default-csp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/middleware/set-default-csp.ts b/src/server/middleware/set-default-csp.ts index a3ee5261..fd776ab6 100644 --- a/src/server/middleware/set-default-csp.ts +++ b/src/server/middleware/set-default-csp.ts @@ -3,7 +3,7 @@ import type { NextFunction, Response } from "express"; export default function ({ res, next }: { res: Response; next: NextFunction }) { res.setHeader( "Content-Security-Policy", - `default-src 'self'; manifest-src *; connect-src *; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'; frame-src *; media-src *` + `default-src 'self'; manifest-src *; connect-src *; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'; frame-src *; media-src * data:` ); next(); From 353d4c7e39dd386eb902c6b3cc656f67b27ec793 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 25 Jun 2023 15:13:27 -0400 Subject: [PATCH 10/11] Update post-listing.tsx Removed unnecessary bootstrap class --- src/shared/components/post/post-listing.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index e43590e5..76a3e445 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -743,7 +743,7 @@ export class PostListing extends Component { {this.unreadCount && ( <> {" "} - + ({this.unreadCount} {I18NextService.i18n.t("new")}) From 937dd5f86a897a7f09bf81f04adc5f10a804c1ae Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sun, 25 Jun 2023 17:18:25 -0400 Subject: [PATCH 11/11] feat(UI): Fix some link hover colors --- src/assets/css/main.css | 2 +- src/shared/components/post/post-listing.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index cb4a8b81..b917b3ec 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -84,7 +84,7 @@ margin-top: -6.5px; } -.post-title a:visited { +.post-title a:visited:not(:hover) { color: var(--bs-gray) !important; } diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 76a3e445..ac90b0d8 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -397,7 +397,7 @@ export class PostListing extends Component { const post_view = this.postView; return ( - + {this.creatorIsMod_ && ( {I18NextService.i18n.t("mod")} @@ -444,8 +444,8 @@ export class PostListing extends Component { { { const url = post.url; return ( -

+

{url && !(hostname(url) === getExternalHost()) && (