Skip to content

Commit

Permalink
fix: hide content of password-protected pages in searching and rss
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamotn committed Feb 6, 2025
1 parent 142a08a commit b773ac2
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions quartz/i18n/locales/ar-SA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default {
wrongPassword: "خاطئة. يرجى إعادة إدخال كلمة المرور لفتح القفل:",
noPayload: "حمولة مشفرة.",
decrypting: "جاري فك التشفير...",
defaultDescription: "هذه صفحة مشفرة",

Check failure on line 97 in quartz/i18n/locales/ar-SA.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/ca-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
wrongPassword: "Contrasenya incorrecta. Introduïu de nou la contrasenya per desbloquejar:",
noPayload: "No hi ha càrrega útil xifrada.",
decrypting: "Desxifrant...",
defaultDescription: "Aquesta és una pàgina xifrada",

Check failure on line 93 in quartz/i18n/locales/ca-ES.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/cs-CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Nesprávné heslo. Zadejte heslo znovu pro odemknutí:",
noPayload: "Není žádné šifrované užitečné zatížení.",
decrypting: "Dekódování...",
defaultDescription: "Toto je šifrovaná stránka",

Check failure on line 92 in quartz/i18n/locales/cs-CZ.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/de-DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
"Falsches Passwort. Bitte geben Sie das Passwort erneut ein, um zu entsperren:",
noPayload: "Keine verschlüsselte Nutzlast.",
decrypting: "Entschlüsseln...",
defaultDescription: "Dies ist eine verschlüsselte Seite",

Check failure on line 94 in quartz/i18n/locales/de-DE.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/en-GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Wrong password. Please re-enter passsword to unlock:",
noPayload: "No encrypted payload.",
decrypting: "Decrypting...",
defaultDescription: "This is encrypted page",

Check failure on line 92 in quartz/i18n/locales/en-GB.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Wrong password. Please re-enter passsword to unlock:",
noPayload: "No encrypted payload.",
decrypting: "Decrypting...",
defaultDescription: "This is encrypted page",

Check failure on line 92 in quartz/i18n/locales/en-US.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
wrongPassword: "Contraseña incorrecta. Vuelva a introducir la contraseña para desbloquear:",
noPayload: "No hay ninguna carga útil cifrada.",
decrypting: "Descifrando...",
defaultDescription: "Esta es una página encriptada",

Check failure on line 93 in quartz/i18n/locales/es-ES.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/fa-IR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
wrongPassword: "رمز عبور اشتباه است. لطفا رمز عبور را دوباره وارد کنید تا قفل باز شود:",
noPayload: "هیچ محموله رمزگذاری شده ای وجود ندارد.",
decrypting: "در حال رمزگشایی...",
defaultDescription: "این صفحه رمزگذاری شده است",

Check failure on line 93 in quartz/i18n/locales/fa-IR.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
"Mot de passe incorrect. Veuillez saisir à nouveau le mot de passe pour déverrouiller :",
noPayload: "Aucune charge utile cryptée.",
decrypting: "Décryptage en cours...",
defaultDescription: "Ceci est une page cryptée",

Check failure on line 94 in quartz/i18n/locales/fr-FR.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/hu-HU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default {
wrongPassword: "Helytelen jelszó. Kérjük, adja meg újra a jelszót a feloldáshoz:",
noPayload: "Nincs titkosított hasznos teher.",
decrypting: "Dekódolás...",
defaultDescription: "Ez egy titkosított oldal",

Check failure on line 91 in quartz/i18n/locales/hu-HU.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Object literal may only specify known properties, and 'defaultDescription' does not exist in type '{ loading: string; password: string; submit: string; enterPassword: string; modernBrowser: string; wrongPassword: string; noPayload: string; decrypting: string; }'.
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/it-IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
wrongPassword: "Password errato. Si prega di reinserire la password per sbloccare:",
noPayload: "Nessun payload crittografato.",
decrypting: "Decifrazione in corso...",
defaultDescription: "Questa è una pagina crittografata",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/ja-JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
"パスワードが間違っています。ロックを解除するにはパスワードを再度入力してください:",
noPayload: "暗号化されたペイロードはありません。",
decrypting: "解読中...",
defaultDescription: "これは暗号化されたページです",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
wrongPassword: "비밀번호가 잘못되었습니다. 잠금을 해제하려면 암호를 다시 입력하십시오:",
noPayload: "암호화된 페이로드가 없습니다.",
decrypting: "해독 중...",
defaultDescription: "이 페이지는 암호화된 페이지입니다",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/nl-NL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default {
"Verkeerd wachtwoord. Voer alstublieft uw wachtwoord opnieuw in om te ontgrendelen:",
noPayload: "Geen versleutelde payload.",
decrypting: "Ontsleutelen..",
defaultDescription: "Dit is een gecodeerde pagina",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/pl-PL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Senha incorreta. Digite a senha novamente para desbloquear:",
noPayload: "Nie ma zaszyfrowanego ładunku.",
decrypting: "Deszyfrowanie...",
defaultDescription: "To jest zaszyfrowana strona",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Parolă greșită. Vă rugăm să reintroduceți parola pentru a debloca:",
noPayload: "Não há nenhuma carga útil criptografada.",
decrypting: "Descifrando...",
defaultDescription: "Esta é uma página criptografada",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/ro-RO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
wrongPassword: "Неправильний пароль. Будь ласка, введіть пароль ще раз, щоб розблокувати:",
noPayload: "Nu există nicio sarcină utilă criptată.",
decrypting: "Decriptare...",
defaultDescription: "Aceasta este o pagină criptată",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default {
wrongPassword: "Неверный пароль. Пожалуйста, введите пароль еще раз для разблокировки:",
noPayload: "Нет зашифрованной полезной нагрузки.",
decrypting: "Расшифровка...",
defaultDescription: "Это зашифрованная страница",
},
},
} as const satisfies Translation
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/uk-UA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Неправильний пароль. Будь ласка, введіть пароль ще раз, щоб розблокувати:",
noPayload: "Немає зашифрованого корисного навантаження.",
decrypting: "Розшифровка...",
defaultDescription: "Це зашифрована сторінка",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/vi-VN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default {
wrongPassword: "Sai mật khẩu. Vui lòng điền lại mật khẩu để mở khóa:",
noPayload: "Không có nội dung được mã hóa.",
decrypting: "Đang giải mã...",
defaultDescription: "Trang này đã được mã hóa",
},
},
} as const satisfies Translation
1 change: 1 addition & 0 deletions quartz/i18n/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
wrongPassword: "密码错误。请重新输入密码解锁:",
noPayload: "没有加密的有效负载。",
decrypting: "解密中...",
defaultDescription: "这是加密页面",
},
},
} as const satisfies Translation
9 changes: 5 additions & 4 deletions quartz/plugins/emitters/contentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
title: file.data.frontmatter?.title!,
links: file.data.links ?? [],
tags: file.data.frontmatter?.tags ?? [],
content: file.data.text ?? "",
richContent: opts?.rssFullHtml
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
: undefined,
content: file.data.text && !file.data.frontmatter?.password ? file.data.text : "",
richContent:
opts?.rssFullHtml && !file.data.frontmatter?.password
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
: undefined,
date: date,
description: file.data.description ?? "",
})
Expand Down
8 changes: 6 additions & 2 deletions quartz/plugins/transformers/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Root as HTMLRoot } from "hast"
import { toString } from "hast-util-to-string"
import { QuartzTransformerPlugin } from "../types"
import { escapeHTML } from "../../util/escape"
import { i18n } from "../../i18n"

export interface Options {
descriptionLength: number
Expand All @@ -22,7 +23,7 @@ export const Description: QuartzTransformerPlugin<Partial<Options>> = (userOpts)
const opts = { ...defaultOptions, ...userOpts }
return {
name: "Description",
htmlPlugins() {
htmlPlugins(ctx) {
return [
() => {
return async (tree: HTMLRoot, file) => {
Expand All @@ -37,7 +38,10 @@ export const Description: QuartzTransformerPlugin<Partial<Options>> = (userOpts)
text = text.replace(urlRegex, "$<domain>" + "$<path>")
}

const desc = frontMatterDescription ?? text
const desc =
(frontMatterDescription ?? file.data.frontmatter?.password)
? i18n(ctx.cfg.configuration.locale).pages.encryptedContent.defaultDescription
: text
const sentences = desc.replace(/\s+/g, " ").split(/\.\s/)
const finalDesc: string[] = []
const len = opts.descriptionLength
Expand Down

0 comments on commit b773ac2

Please sign in to comment.