From 65c5023ae4df342ea77ddb7069ba4a4c9b00cccb Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Thu, 19 Sep 2024 21:37:51 +0100 Subject: [PATCH] Added toggle for 'repointing' as well as (slightly) better documentation and homepage --- README.md | 14 +++++++++++++- src/app/[...file]/page.tsx | 14 +++++++++----- src/app/globals.css.ts | 9 +++++++++ src/app/page.css.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/app/page.tsx | 19 ++++++++++++++++--- 5 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 src/app/page.css.ts diff --git a/README.md b/README.md index c7293a4..d5bbb3e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # Motto -Static file beautifier +Motto presents files from a static file server in a more friendly way + +## Documentation + +### Configuration + +- `ROOT_URL=(url)` - the static file server instance to get files from +- `ENABLE_REPOINTING=(true|default:false)` - enable [repointing](#Repointing) + +### Repointing + +If enabled, repointing allows a url to be specified in the `root` query parameter that will override +the default url of the static file server diff --git a/src/app/[...file]/page.tsx b/src/app/[...file]/page.tsx index 48c955f..52e6c43 100644 --- a/src/app/[...file]/page.tsx +++ b/src/app/[...file]/page.tsx @@ -18,23 +18,24 @@ function get_path(file: string[]) { return file.join("/"); } -function get_root(search_params: SearchParams) { - return search_params['root'] ?? 'raw.monodon.me'; +function get_root(enable_repointing: boolean, search_params: SearchParams) { + return `https://${search_params['root'] ?? 'raw.monodon.me'}/`; } export async function generateMetadata( { params, searchParams }: Props, ): Promise { return { - title: `${get_path(params.file)} | ${get_root(searchParams)}`, + title: `${get_path(params.file)} | ${get_root(true, searchParams)}`, }; } export default async function Page({ params, searchParams }: Props) { + const enable_repointing = process.env.ENABLE_REPOINTING == 'true'; const path = get_path(params.file); - const root = `https://${get_root(searchParams)}/`; + const root = get_root(enable_repointing, searchParams); const full = `${root}${path}`; const download_ttys = [ @@ -68,7 +69,10 @@ export default async function Page({
{download_ttys.map((text, index) => {text})}
- + {(!enable_repointing && searchParams['root'] != undefined) ? +

Error: this instance of Motto does not have repointing enabled

: + + } ); diff --git a/src/app/globals.css.ts b/src/app/globals.css.ts index 5cb74ab..8a970e8 100644 --- a/src/app/globals.css.ts +++ b/src/app/globals.css.ts @@ -10,3 +10,12 @@ globalStyle('html, body', { color: colors.foreground, fontFamily: 'sans-serif', }); + +globalStyle('a:link, a:visited', { + color: colors.accent, + textDecoration: 'none', +}); + +globalStyle('a:hover', { + textDecorationLine: 'underline', +}); diff --git a/src/app/page.css.ts b/src/app/page.css.ts new file mode 100644 index 0000000..9b9c7ff --- /dev/null +++ b/src/app/page.css.ts @@ -0,0 +1,38 @@ +import { style } from '@vanilla-extract/css'; + +import * as colors from './colors.css' + +export const center = style({ + display: 'flex', + justifyContent: 'center', + width: '100%', + height: '100%', +}); + +export const version = style({ + float: 'right', + color: colors.foreground2, +}); + +export const content = style({ + margin: '1em', + height: 'max-content', + maxWidth: '50em', + '@media': { + 'screen and (min-width: 768px)': { + marginTop: '5em', + }, + }, +}); + +export const title = style({ + width: '100%', + borderBottom: `1px solid ${colors.background2}`, + paddingBottom: '0.15em', +}); + +export const description = style({ + +}); + + diff --git a/src/app/page.tsx b/src/app/page.tsx index 938ac50..0d40e07 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,8 +1,21 @@ +import * as style from './page.css'; + export default function App() { + const supports_repointing = process.env.ENABLE_REPOINTING == 'true'; + console.log(supports_repointing); return ( -
-

Dev - Motto

-

Motto is a WIP

+
+
+

Mottov0.0.1-dev

+

+ Motto is a static file server beautifier. Click here for more information. +

+

This instance is currently pointed to {process.env.ROOT_URL} { + supports_repointing ? + <>but supports repointing. : + <>and does not support repointing. + }

+
); }