diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 76916e60..ee3d7a54 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @dessalines @SleeplessOne1917 @alectrocute +* @dessalines @SleeplessOne1917 @alectrocute @jsit diff --git a/package.json b/package.json index 1055d853..9e7a0f1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lemmy-ui", - "version": "0.18.0-rc.5", + "version": "0.18.0-rc.6", "description": "An isomorphic UI for lemmy", "repository": "https://github.com/LemmyNet/lemmy-ui", "license": "AGPL-3.0", diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index b9ff13bf..f22b8a17 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -1,12 +1,13 @@ import { initializeSite, isAuthPath } from "@utils/app"; +import { getHttpBaseInternal } from "@utils/env"; import { ErrorPageData } from "@utils/types"; +import fetch from "cross-fetch"; import type { Request, Response } from "express"; import { StaticRouter, matchPath } from "inferno-router"; import { renderToString } from "inferno-server"; import IsomorphicCookie from "isomorphic-cookie"; import { GetSite, GetSiteResponse, LemmyHttp } from "lemmy-js-client"; import { App } from "../../shared/components/app/app"; -import { getHttpBaseInternal } from "../../shared/env"; import { InitialFetchRequest, IsoDataOptionalSite, diff --git a/src/server/handlers/manifest-handler.ts b/src/server/handlers/manifest-handler.ts index 6858cffd..c1756f75 100644 --- a/src/server/handlers/manifest-handler.ts +++ b/src/server/handlers/manifest-handler.ts @@ -1,6 +1,7 @@ +import { getHttpBaseExternal, getHttpBaseInternal } from "@utils/env"; +import fetch from "cross-fetch"; import type { Request, Response } from "express"; import { LemmyHttp } from "lemmy-js-client"; -import { getHttpBaseExternal, getHttpBaseInternal } from "../../shared/env"; import { wrapClient } from "../../shared/services/HttpService"; import generateManifestJson from "../utils/generate-manifest-json"; import { setForwardedHeaders } from "../utils/set-forwarded-headers"; diff --git a/src/server/utils/build-themes-list.ts b/src/server/utils/build-themes-list.ts index 73dc53bc..74b910c7 100644 --- a/src/server/utils/build-themes-list.ts +++ b/src/server/utils/build-themes-list.ts @@ -4,15 +4,20 @@ import { readdir } from "fs/promises"; const extraThemesFolder = process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes"; -const themes = ["darkly", "darkly-red", "litely", "litely-red"]; +const themes: ReadonlyArray = [ + "darkly", + "darkly-red", + "litely", + "litely-red", +]; -export async function buildThemeList(): Promise { +export async function buildThemeList(): Promise> { if (existsSync(extraThemesFolder)) { const dirThemes = await readdir(extraThemesFolder); const cssThemes = dirThemes .filter(d => d.endsWith(".css")) .map(d => d.replace(".css", "")); - themes.push(...cssThemes); + return themes.concat(cssThemes); } return themes; } diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx index ae766b3a..13775981 100644 --- a/src/server/utils/create-ssr-html.tsx +++ b/src/server/utils/create-ssr-html.tsx @@ -4,6 +4,7 @@ import serialize from "serialize-javascript"; import sharp from "sharp"; import { favIconPngUrl, favIconUrl } from "../../shared/config"; import { ILemmyConfig, IsoDataOptionalSite } from "../../shared/interfaces"; +import { buildThemeList } from "./build-themes-list"; import { fetchIconPng } from "./fetch-icon-png"; const customHtmlHeader = process.env["LEMMY_UI_CUSTOM_HTML_HEADER"] || ""; @@ -16,6 +17,10 @@ export async function createSsrHtml( ) { const site = isoData.site_res; + const fallbackTheme = ``; + if (!appleTouchIcon) { appleTouchIcon = site?.site_view.site.icon ? `data:image/png;base64,${sharp( @@ -68,7 +73,7 @@ export async function createSsrHtml( - + - ${helmet.link.toString()} + ${helmet.link.toString() || fallbackTheme} diff --git a/src/server/utils/fetch-icon-png.ts b/src/server/utils/fetch-icon-png.ts index 12b09e70..75497a21 100644 --- a/src/server/utils/fetch-icon-png.ts +++ b/src/server/utils/fetch-icon-png.ts @@ -1,3 +1,5 @@ +import fetch from "cross-fetch"; + export async function fetchIconPng(iconUrl: string) { return await fetch(iconUrl) .then(res => res.blob()) diff --git a/src/server/utils/generate-manifest-json.ts b/src/server/utils/generate-manifest-json.ts index b03fd87b..2f9d8b80 100644 --- a/src/server/utils/generate-manifest-json.ts +++ b/src/server/utils/generate-manifest-json.ts @@ -1,8 +1,8 @@ +import { getHttpBaseExternal } from "@utils/env"; import { readFile } from "fs/promises"; import { GetSiteResponse } from "lemmy-js-client"; import path from "path"; import sharp from "sharp"; -import { getHttpBaseExternal } from "../../shared/env"; import { fetchIconPng } from "./fetch-icon-png"; const iconSizes = [72, 96, 128, 144, 152, 192, 384, 512]; diff --git a/src/shared/components/common/html-tags.tsx b/src/shared/components/common/html-tags.tsx index 3a8b270a..5d532589 100644 --- a/src/shared/components/common/html-tags.tsx +++ b/src/shared/components/common/html-tags.tsx @@ -1,7 +1,7 @@ +import { httpExternalPath } from "@utils/env"; import { htmlToText } from "html-to-text"; import { Component } from "inferno"; import { Helmet } from "inferno-helmet"; -import { httpExternalPath } from "../../env"; import { md } from "../../markdown"; import { I18NextService } from "../../services"; diff --git a/src/shared/components/common/pictrs-image.tsx b/src/shared/components/common/pictrs-image.tsx index 74437490..31fb1229 100644 --- a/src/shared/components/common/pictrs-image.tsx +++ b/src/shared/components/common/pictrs-image.tsx @@ -22,7 +22,7 @@ export class PictrsImage extends Component { render() { return ( - + @@ -31,7 +31,7 @@ export class PictrsImage extends Component { alt={this.alt()} title={this.alt()} loading="lazy" - className={classNames({ + className={classNames("overflow-hidden pictrs-image", { "img-fluid": !this.props.icon && !this.props.iconOverlay, banner: this.props.banner, "thumbnail rounded": diff --git a/src/shared/components/common/sort-select.tsx b/src/shared/components/common/sort-select.tsx index 90515d56..4d03ab5d 100644 --- a/src/shared/components/common/sort-select.tsx +++ b/src/shared/components/common/sort-select.tsx @@ -67,6 +67,13 @@ export class SortSelect extends Component { + + +