diff --git a/frontend/src/network/models.ts b/frontend/src/network/models.ts index f6582c8..3b95634 100644 --- a/frontend/src/network/models.ts +++ b/frontend/src/network/models.ts @@ -162,6 +162,7 @@ export interface ServerConfig { allow_normal_user_upload: boolean; max_normal_user_upload_size_in_mb: number; upload_prompt: string; + pinned_resources: number[]; } export enum RSort { diff --git a/frontend/src/network/network.ts b/frontend/src/network/network.ts index 693ceca..d275a5d 100644 --- a/frontend/src/network/network.ts +++ b/frontend/src/network/network.ts @@ -415,6 +415,10 @@ class Network { ); } + async getPinnedResources(): Promise> { + return this._callApi(() => axios.get(`${this.apiBaseUrl}/resource/pinned`)); + } + async createS3Storage( name: string, endPoint: string, diff --git a/frontend/src/pages/activities_page.tsx b/frontend/src/pages/activities_page.tsx index 37346bb..623416f 100644 --- a/frontend/src/pages/activities_page.tsx +++ b/frontend/src/pages/activities_page.tsx @@ -95,7 +95,9 @@ function ActivityCard({ activity }: { activity: Activity }) { ) { content = (
-
{activity.resource?.title}
+
+ {activity.resource?.title} +
{activity.resource?.image && (
-

{activity.file!.filename}

+

+ {activity.file!.filename} +

{activity.file!.description.replaceAll("\n", " \n")} @@ -170,8 +174,12 @@ function ActivityCard({ activity }: { activity: Activity }) { src={network.getUserAvatar(activity.user!)} />
- {activity.user?.username} - + + {activity.user?.username} + + {messages[activity.type]}
diff --git a/frontend/src/pages/collection_page.tsx b/frontend/src/pages/collection_page.tsx index fcf9dfa..e36c1f8 100644 --- a/frontend/src/pages/collection_page.tsx +++ b/frontend/src/pages/collection_page.tsx @@ -164,7 +164,8 @@ export default function CollectionPage() { {!collection.isPublic && ( - {t("Private")} + {" "} + {t("Private")} )}
diff --git a/frontend/src/pages/home_page.tsx b/frontend/src/pages/home_page.tsx index 4226bce..a245619 100644 --- a/frontend/src/pages/home_page.tsx +++ b/frontend/src/pages/home_page.tsx @@ -2,10 +2,11 @@ import { useEffect, useState } from "react"; import ResourcesView from "../components/resources_view.tsx"; import { network } from "../network/network.ts"; import { app } from "../app.ts"; -import { RSort } from "../network/models.ts"; +import { Resource, RSort } from "../network/models.ts"; import { useTranslation } from "../utils/i18n"; import { useAppContext } from "../components/AppContext.tsx"; import Select from "../components/select.tsx"; +import { useNavigate } from "react-router"; export default function HomePage() { useEffect(() => { @@ -31,6 +32,7 @@ export default function HomePage() { return ( <> +
{ + setPinnedResources(e.target.value); + }} + > +

{resource.links && resource.links.map((l) => { @@ -237,7 +238,6 @@ export default function ResourcePage() { ); })} -

{!collection.isPublic && ( - - {t("Private")} - - )} + + {t("Private")} + + )}
); diff --git a/server/middleware/frontend_middleware.go b/server/middleware/frontend_middleware.go index c25daf9..48eeb56 100644 --- a/server/middleware/frontend_middleware.go +++ b/server/middleware/frontend_middleware.go @@ -155,6 +155,14 @@ func serveIndexHtml(c fiber.Ctx) error { preFetchData = url.PathEscape(string(preFetchDataJson)) } } + } else if path == "/" || path == "" { + pinned, err := service.GetPinnedResources() + if err == nil { + preFetchDataJson, _ := json.Marshal(map[string]interface{}{ + "pinned": pinned, + }) + preFetchData = url.PathEscape(string(preFetchDataJson)) + } } content = strings.ReplaceAll(content, "{{SiteName}}", siteName)