1
0
Fork 0

appUrl prefix

This commit is contained in:
gluzzati 2024-03-21 16:48:35 +00:00
parent 6d87e20e29
commit 8a5849dedb
12 changed files with 38 additions and 24 deletions

View File

@ -42,7 +42,7 @@ const ConfigurationHeader = ({
</Group> </Group>
</Link> </Link>
<MediaQuery smallerThan="sm" styles={{ display: "none" }}> <MediaQuery smallerThan="sm" styles={{ display: "none" }}>
<Button variant="light" component={Link} href="/admin"> <Button variant="light" component={Link} href={config.get("general.appUrl") + "/admin"}>
<FormattedMessage id="common.button.go-back" /> <FormattedMessage id="common.button.go-back" />
</Button> </Button>
</MediaQuery> </MediaQuery>

View File

@ -13,6 +13,7 @@ import Link from "next/link";
import { Dispatch, SetStateAction } from "react"; import { Dispatch, SetStateAction } from "react";
import { TbAt, TbMail, TbShare, TbSocial, TbSquare } from "react-icons/tb"; import { TbAt, TbMail, TbShare, TbSocial, TbSquare } from "react-icons/tb";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import useConfig from "../../../hooks/config.hook";
const categories = [ const categories = [
{ name: "General", icon: <TbSquare /> }, { name: "General", icon: <TbSquare /> },
@ -46,6 +47,7 @@ const ConfigurationNavBar = ({
setIsMobileNavBarOpened: Dispatch<SetStateAction<boolean>>; setIsMobileNavBarOpened: Dispatch<SetStateAction<boolean>>;
}) => { }) => {
const { classes } = useStyles(); const { classes } = useStyles();
const config = useConfig();
return ( return (
<Navbar <Navbar
p="md" p="md"
@ -69,7 +71,7 @@ const ConfigurationNavBar = ({
: undefined : undefined
} }
key={category.name} key={category.name}
href={`/admin/config/${category.name.toLowerCase()}`} href={`${config.get("general.appUrl")}/admin/config/${category.name.toLowerCase()}`}
> >
<Group> <Group>
<ThemeIcon <ThemeIcon
@ -92,7 +94,7 @@ const ConfigurationNavBar = ({
</Stack> </Stack>
</Navbar.Section> </Navbar.Section>
<MediaQuery largerThan="sm" styles={{ display: "none" }}> <MediaQuery largerThan="sm" styles={{ display: "none" }}>
<Button mt="xl" variant="light" component={Link} href="/admin"> <Button mt="xl" variant="light" component={Link} href={webroot + "/admin"}>
<FormattedMessage id="common.button.go-back" /> <FormattedMessage id="common.button.go-back" />
</Button> </Button>
</MediaQuery> </MediaQuery>

View File

@ -145,7 +145,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
/> />
{config.get("smtp.enabled") && ( {config.get("smtp.enabled") && (
<Group position="right" mt="xs"> <Group position="right" mt="xs">
<Anchor component={Link} href="/auth/resetPassword" size="xs"> <Anchor component={Link} href={config.get("general.appUrl") + "/auth/resetPassword"} size="xs">
<FormattedMessage id="resetPassword.title" /> <FormattedMessage id="resetPassword.title" />
</Anchor> </Anchor>
</Group> </Group>

View File

@ -4,9 +4,11 @@ import { TbDoorExit, TbSettings, TbUser } from "react-icons/tb";
import useUser from "../../hooks/user.hook"; import useUser from "../../hooks/user.hook";
import authService from "../../services/auth.service"; import authService from "../../services/auth.service";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import useConfig from "../../hooks/config.hook";
const ActionAvatar = () => { const ActionAvatar = () => {
const { user } = useUser(); const { user } = useUser();
const config = useConfig();
return ( return (
<Menu position="bottom-start" withinPortal> <Menu position="bottom-start" withinPortal>
@ -16,13 +18,13 @@ const ActionAvatar = () => {
</ActionIcon> </ActionIcon>
</Menu.Target> </Menu.Target>
<Menu.Dropdown> <Menu.Dropdown>
<Menu.Item component={Link} href="/account" icon={<TbUser size={14} />}> <Menu.Item component={Link} href={config.get("general.appUrl") + "/account"} icon={<TbUser size={14} />}>
<FormattedMessage id="navbar.avatar.account" /> <FormattedMessage id="navbar.avatar.account" />
</Menu.Item> </Menu.Item>
{user!.isAdmin && ( {user!.isAdmin && (
<Menu.Item <Menu.Item
component={Link} component={Link}
href="/admin" href={config.get("general.appUrl") + "/admin"}
icon={<TbSettings size={14} />} icon={<TbSettings size={14} />}
> >
<FormattedMessage id="navbar.avatar.admin" /> <FormattedMessage id="navbar.avatar.admin" />

View File

@ -125,7 +125,7 @@ const Header = () => {
const authenticatedLinks: NavLink[] = [ const authenticatedLinks: NavLink[] = [
{ {
link: "/upload", link: config.get("general.appUrl") + "/upload",
label: t("navbar.upload"), label: t("navbar.upload"),
}, },
{ {
@ -138,27 +138,27 @@ const Header = () => {
let unauthenticatedLinks: NavLink[] = [ let unauthenticatedLinks: NavLink[] = [
{ {
link: "/auth/signIn", link: config.get("general.appUrl") + "/auth/signIn",
label: t("navbar.signin"), label: t("navbar.signin"),
}, },
]; ];
if (config.get("share.allowUnauthenticatedShares")) { if (config.get("share.allowUnauthenticatedShares")) {
unauthenticatedLinks.unshift({ unauthenticatedLinks.unshift({
link: "/upload", link: config.get("general.appUrl") + "/upload",
label: t("navbar.upload"), label: t("navbar.upload"),
}); });
} }
if (config.get("general.showHomePage")) if (config.get("general.showHomePage"))
unauthenticatedLinks.unshift({ unauthenticatedLinks.unshift({
link: "/", link: config.get("general.appUrl") + "/",
label: t("navbar.home"), label: t("navbar.home"),
}); });
if (config.get("share.allowRegistration")) if (config.get("share.allowRegistration"))
unauthenticatedLinks.push({ unauthenticatedLinks.push({
link: "/auth/signUp", link: config.get("general.appUrl") + "/auth/signUp",
label: t("navbar.signup"), label: t("navbar.signup"),
}); });
@ -191,7 +191,7 @@ const Header = () => {
return ( return (
<MantineHeader height={HEADER_HEIGHT} mb={40} className={classes.root}> <MantineHeader height={HEADER_HEIGHT} mb={40} className={classes.root}>
<Container className={classes.header}> <Container className={classes.header}>
<Link href="/" passHref> <Link href={config.get("general.appUrl")+"/"} passHref>
<Group> <Group>
<Logo height={35} width={35} /> <Logo height={35} width={35} />
<Text weight={600}>{config.get("general.appName")}</Text> <Text weight={600}>{config.get("general.appName")}</Text>

View File

@ -2,8 +2,10 @@ import { ActionIcon, Menu } from "@mantine/core";
import Link from "next/link"; import Link from "next/link";
import { TbArrowLoopLeft, TbLink } from "react-icons/tb"; import { TbArrowLoopLeft, TbLink } from "react-icons/tb";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import useConfig from "../../hooks/config.hook";
const NavbarShareMneu = () => { const NavbarShareMneu = () => {
const config = useConfig();
return ( return (
<Menu position="bottom-start" withinPortal> <Menu position="bottom-start" withinPortal>
<Menu.Target> <Menu.Target>
@ -12,12 +14,12 @@ const NavbarShareMneu = () => {
</ActionIcon> </ActionIcon>
</Menu.Target> </Menu.Target>
<Menu.Dropdown> <Menu.Dropdown>
<Menu.Item component={Link} href="/account/shares" icon={<TbLink />}> <Menu.Item component={Link} href={config.get("general.appUrl") + "/account/shares"} icon={<TbLink />}>
<FormattedMessage id="navbar.links.shares" /> <FormattedMessage id="navbar.links.shares" />
</Menu.Item> </Menu.Item>
<Menu.Item <Menu.Item
component={Link} component={Link}
href="/account/reverseShares" href={config.get("general.appUrl") + "/account/reverseShares"}
icon={<TbArrowLoopLeft />} icon={<TbArrowLoopLeft />}
> >
<FormattedMessage id="navbar.links.reverse" /> <FormattedMessage id="navbar.links.reverse" />

View File

@ -12,6 +12,7 @@ import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import api from "../../services/api.service"; import api from "../../services/api.service";
import Markdown from "markdown-to-jsx"; import Markdown from "markdown-to-jsx";
import useConfig from "../../hooks/config.hook";
const FilePreviewContext = React.createContext<{ const FilePreviewContext = React.createContext<{
shareId: string; shareId: string;
@ -36,7 +37,7 @@ const FilePreview = ({
}) => { }) => {
const [isNotSupported, setIsNotSupported] = useState(false); const [isNotSupported, setIsNotSupported] = useState(false);
if (isNotSupported) return <UnSupportedFile />; if (isNotSupported) return <UnSupportedFile />;
const config = useConfig();
return ( return (
<Stack> <Stack>
<FilePreviewContext.Provider <FilePreviewContext.Provider
@ -49,7 +50,7 @@ const FilePreview = ({
component={Link} component={Link}
onClick={() => modals.closeAll()} onClick={() => modals.closeAll()}
target="_blank" target="_blank"
href={`/api/shares/${shareId}/files/${fileId}?download=false`} href={`${config.get("general.appUrl")}/api/shares/${shareId}/files/${fileId}?download=false`}
> >
View original file View original file
{/* Add translation? */} {/* Add translation? */}

View File

@ -9,6 +9,7 @@ import {
import Link from "next/link"; import Link from "next/link";
import Meta from "../components/Meta"; import Meta from "../components/Meta";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import useConfig from "../hooks/config.hook";
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
root: { root: {
@ -38,7 +39,7 @@ const useStyles = createStyles((theme) => ({
const ErrorNotFound = () => { const ErrorNotFound = () => {
const { classes } = useStyles(); const { classes } = useStyles();
const config = useConfig();
return ( return (
<> <>
<Meta title="Not found" /> <Meta title="Not found" />
@ -53,7 +54,7 @@ const ErrorNotFound = () => {
className={classes.description} className={classes.description}
></Text> ></Text>
<Group position="center"> <Group position="center">
<Button component={Link} href="/" variant="light"> <Button component={Link} href={config.get("general.appUrl") + "/"} variant="light">
<FormattedMessage id="404.button.home" /> <FormattedMessage id="404.button.home" />
</Button> </Button>
</Group> </Group>

View File

@ -58,7 +58,7 @@ const MyShares = () => {
<FormattedMessage id="account.shares.description.empty" /> <FormattedMessage id="account.shares.description.empty" />
</Text> </Text>
<Space h={5} /> <Space h={5} />
<Button component={Link} href="/upload" variant="light"> <Button component={Link} href={config.get("general.appUrl") + "/upload"} variant="light">
<FormattedMessage id="account.shares.button.create" /> <FormattedMessage id="account.shares.button.create" />
</Button> </Button>
</Stack> </Stack>

View File

@ -10,8 +10,10 @@ import {
import Link from "next/link"; import Link from "next/link";
import Logo from "../../components/Logo"; import Logo from "../../components/Logo";
import Meta from "../../components/Meta"; import Meta from "../../components/Meta";
import useConfig from "../../hooks/config.hook";
const Intro = () => { const Intro = () => {
const config = useConfig();
return ( return (
<> <>
<Meta title="Intro" /> <Meta title="Intro" />
@ -43,10 +45,10 @@ const Intro = () => {
<Text>Enough talked, have fun with Pingvin Share!</Text> <Text>Enough talked, have fun with Pingvin Share!</Text>
<Text mt="lg">How to you want to continue?</Text> <Text mt="lg">How to you want to continue?</Text>
<Stack> <Stack>
<Button href="/admin/config/general" component={Link}> <Button href={config.get("general.appUrl") + "/admin/config/general"} component={Link}>
Customize configuration Customize configuration
</Button> </Button>
<Button href="/" component={Link} variant="light"> <Button href={config.get("general.appUrl") + "/"} component={Link} variant="light">
Explore Pingvin Share Explore Pingvin Share
</Button> </Button>
</Stack> </Stack>

View File

@ -20,6 +20,7 @@ import * as yup from "yup";
import useTranslate from "../../../hooks/useTranslate.hook"; import useTranslate from "../../../hooks/useTranslate.hook";
import authService from "../../../services/auth.service"; import authService from "../../../services/auth.service";
import toast from "../../../utils/toast.util"; import toast from "../../../utils/toast.util";
import useConfig from "../../../hooks/config.hook";
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
title: { title: {
@ -61,6 +62,7 @@ const ResetPassword = () => {
), ),
}); });
const config = useConfig();
return ( return (
<Container size={460} my={30}> <Container size={460} my={30}>
<Title order={2} weight={900} align="center"> <Title order={2} weight={900} align="center">
@ -93,7 +95,7 @@ const ResetPassword = () => {
color="dimmed" color="dimmed"
size="sm" size="sm"
className={classes.control} className={classes.control}
href={"/auth/signIn"} href={config.get("general.appUrl") + "/auth/signIn"}
> >
<Center inline> <Center inline>
<TbArrowLeft size={12} /> <TbArrowLeft size={12} />

View File

@ -16,6 +16,7 @@ import { FormattedMessage } from "react-intl";
import Logo from "../components/Logo"; import Logo from "../components/Logo";
import Meta from "../components/Meta"; import Meta from "../components/Meta";
import useUser from "../hooks/user.hook"; import useUser from "../hooks/user.hook";
import useConfig from "../hooks/config.hook";
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
inner: { inner: {
@ -73,12 +74,13 @@ export default function Home() {
const { classes } = useStyles(); const { classes } = useStyles();
const { refreshUser } = useUser(); const { refreshUser } = useUser();
const router = useRouter(); const router = useRouter();
const config = useConfig();
// If the user is already logged in, redirect to the upload page // If the user is already logged in, redirect to the upload page
useEffect(() => { useEffect(() => {
refreshUser().then((user) => { refreshUser().then((user) => {
if (user) { if (user) {
router.replace("/upload"); router.replace(config.get("general.appUrl") + "/upload");
} }
}); });
}, []); }, []);
@ -142,7 +144,7 @@ export default function Home() {
<Group mt={30}> <Group mt={30}>
<Button <Button
component={Link} component={Link}
href="/auth/signUp" href={config.get("general.appUrl") + "/auth/signUp"}
radius="xl" radius="xl"
size="md" size="md"
className={classes.control} className={classes.control}