From febc95326c410da539937fd4180ef4ad9853b79c Mon Sep 17 00:00:00 2001 From: MrOrz Date: Sun, 29 Sep 2024 21:26:17 +0800 Subject: [PATCH 1/4] fix(article): hide title when article is blocked --- pages/article/[id].js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pages/article/[id].js b/pages/article/[id].js index 5821aa31..3206f00a 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -382,7 +382,10 @@ function ArticlePage() { - {ellipsis(article.text, { wordCount: 100 })} | {t`Cofacts`} + {article.status === 'BLOCKED' + ? t`Cofacts` + : ellipsis(article.text, { wordCount: 100 })}{' '} + | {t`Cofacts`} {/* Don't let search engines index blocked spam */ article.status === 'BLOCKED' && } From fdbff12f68955e095fc90b95f44ab11db146b9db Mon Sep 17 00:00:00 2001 From: MrOrz Date: Sun, 29 Sep 2024 21:26:35 +0800 Subject: [PATCH 2/4] fix(reply): hide contenta and title for blocked replies --- pages/reply/[id].js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/reply/[id].js b/pages/reply/[id].js index 03d975b3..7a4cfd06 100644 --- a/pages/reply/[id].js +++ b/pages/reply/[id].js @@ -206,15 +206,15 @@ function ReplyPage() { return ( - - {ellipsis(reply.text, { wordCount: 100 })} | {t`Cofacts`} - + {t`Cofacts`}
{t`This reply`} - {reply.text} + + {!currentUser ? t`Log in to view content` : reply.text} +
From d5c51779e644db16b647cc841332384640b06bdf Mon Sep 17 00:00:00 2001 From: MrOrz Date: Sun, 29 Sep 2024 22:17:02 +0800 Subject: [PATCH 3/4] fix(article): logic for blocked title --- pages/article/[id].js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/article/[id].js b/pages/article/[id].js index 3206f00a..5445525f 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -384,8 +384,8 @@ function ArticlePage() { {article.status === 'BLOCKED' ? t`Cofacts` - : ellipsis(article.text, { wordCount: 100 })}{' '} - | {t`Cofacts`} + : `${ellipsis(article.text, { wordCount: 100 })} + | ${t`Cofacts`}`} {/* Don't let search engines index blocked spam */ article.status === 'BLOCKED' && } From fd8d6d64d539ce301082bfa8709e93a60baa5148 Mon Sep 17 00:00:00 2001 From: MrOrz Date: Sun, 29 Sep 2024 23:06:17 +0800 Subject: [PATCH 4/4] refactor(article): use logic similar to reply page onto article page to remove everything else for non-logged users visiting blocked article --- pages/article/[id].js | 178 +++++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 82 deletions(-) diff --git a/pages/article/[id].js b/pages/article/[id].js index 5445525f..966d43dd 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -378,14 +378,47 @@ function ArticlePage() { element => element.user && currentUser && element.user.id === currentUser.id ); + const headerElem = ( +
+ + {ngettext( + msgid`${replyRequestCount} person report this message`, + `${replyRequestCount} people report this message`, + replyRequestCount + )} + + + + {timeAgo => t`First reported ${timeAgo}`} + + +
+ ); + + if (article.status === 'BLOCKED' && !currentUser) { + return ( + + + {t`Cofacts`} + + +
+
+ + {headerElem} + {t`Log in to view content`} + +
+
+
+ ); + } + return ( - {article.status === 'BLOCKED' - ? t`Cofacts` - : `${ellipsis(article.text, { wordCount: 100 })} - | ${t`Cofacts`}`} + {ellipsis(article.text, { wordCount: 100 })} | {t`Cofacts`} {/* Don't let search engines index blocked spam */ article.status === 'BLOCKED' && } @@ -393,85 +426,66 @@ function ArticlePage() {
-
- - {ngettext( - msgid`${replyRequestCount} person report this message`, - `${replyRequestCount} people report this message`, - replyRequestCount - )} - - - - {timeAgo => t`First reported ${timeAgo}`} - - -
+ {headerElem} - {article.status === 'BLOCKED' && !currentUser ? ( - t`Log in to view content` - ) : ( - <> - {(() => { - switch (articleType) { - case 'IMAGE': - return !originalAttachmentUrl ? ( - image - ) : ( - - image - - ); - case 'VIDEO': - return !originalAttachmentUrl ? ( - t`Log in to view video content` - ) : ( -