From 1cdb8ef6abf2864d9277a833737c9bf096733732 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 4 May 2023 22:37:58 -0500 Subject: [PATCH] Add some `` to pages Part of https://github.com/matrix-org/matrix-public-archive/issues/202 --- server/hydrogen-render/render-page-html.js | 2 ++ server/middleware/timeout-middleware.js | 1 + server/routes/client-side-room-alias-hash-redirect-route.js | 3 ++- server/routes/room-directory-routes.js | 1 + server/routes/room-routes.js | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/hydrogen-render/render-page-html.js b/server/hydrogen-render/render-page-html.js index 4135af2a..95de82ab 100644 --- a/server/hydrogen-render/render-page-html.js +++ b/server/hydrogen-render/render-page-html.js @@ -17,6 +17,7 @@ function renderPageHtml({ assert(vmRenderContext); assert(pageOptions); assert(pageOptions.title); + assert(pageOptions.description); assert(pageOptions.entryPoint); assert(pageOptions.cspNonce); @@ -47,6 +48,7 @@ function renderPageHtml({ ${sanitizeHtml(`${pageOptions.title}`)} + ${sanitizeHtml(``)} ${styles .map( (styleUrl) => diff --git a/server/middleware/timeout-middleware.js b/server/middleware/timeout-middleware.js index ecec9a20..3e0428d3 100644 --- a/server/middleware/timeout-middleware.js +++ b/server/middleware/timeout-middleware.js @@ -83,6 +83,7 @@ async function timeoutMiddleware(req, res, next) { const pageOptions = { title: `Server timeout - Matrix Public Archive`, + description: `Unable to respond in time (${requestTimeoutMs / 1000}s)`, entryPoint: 'client/js/entry-client-timeout.js', locationHref: urlJoin(basePath, req.originalUrl), // We don't have a Matrix room so we don't know whether or not to index. Just choose diff --git a/server/routes/client-side-room-alias-hash-redirect-route.js b/server/routes/client-side-room-alias-hash-redirect-route.js index deff2956..6ab24434 100644 --- a/server/routes/client-side-room-alias-hash-redirect-route.js +++ b/server/routes/client-side-room-alias-hash-redirect-route.js @@ -15,6 +15,7 @@ assert(basePath); function clientSideRoomAliasHashRedirectRoute(req, res) { const pageOptions = { title: `Page not found - Matrix Public Archive`, + description: `This page does not exist but we may be able to redirect you to the right place.`, entryPoint: 'client/js/entry-client-room-alias-hash-redirect.js', locationHref: urlJoin(basePath, req.originalUrl), // We don't have a Matrix room so we don't know whether or not to index. Just choose @@ -30,7 +31,7 @@ function clientSideRoomAliasHashRedirectRoute(req, res) { 404: Page not found. -

If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.

+

If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.

Otherwise, you're simply in a place that does not exist. You can ${sanitizeHtml(`go back to the homepage.`)} diff --git a/server/routes/room-directory-routes.js b/server/routes/room-directory-routes.js index d0180e09..7ae40572 100644 --- a/server/routes/room-directory-routes.js +++ b/server/routes/room-directory-routes.js @@ -75,6 +75,7 @@ router.get( const pageOptions = { title: `Matrix Public Archive`, + description: 'Browse thousands of rooms using Matrix...', entryPoint: 'client/js/entry-client-room-directory.js', locationHref: urlJoin(basePath, req.originalUrl), shouldIndex, diff --git a/server/routes/room-routes.js b/server/routes/room-routes.js index 1a998bfb..ff222954 100644 --- a/server/routes/room-routes.js +++ b/server/routes/room-routes.js @@ -898,6 +898,7 @@ router.get( const pageOptions = { title: `${roomData.name} - Matrix Public Archive`, + description: `View the history of ${roomData.name} in the Matrix Public Archive`, entryPoint: 'client/js/entry-client-hydrogen.js', locationHref: urlJoin(basePath, req.originalUrl), shouldIndex,