diff --git a/README.md b/README.md index c725e157..77bceb5e 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,10 @@ Drift is a self-hostable Gist clone. It's also a major work-in-progress, but is You can try a demo at https://drift.maxleiter.com. The demo is built on master but has no database, so files and accounts can be wiped at any time. -If you want to contribute, need support, or want to stay updated, you can join the IRC channel at #drift on irc.libera.chat or [reach me on twitter](https://twitter.com/Max_Leiter). If you don't have an IRC client yet, you can use a webclient [here](https://demo.thelounge.chat/#/connect?join=%23drift&nick=drift-user&realname=Drift%20User). - +If you want to contribute, need support, or want to stay updated, you can join the IRC channel at #drift on irc.libera.chat or [reach me on twitter](https://twitter.com/Max_Leiter). If you don't have an IRC client yet, you can use a webclient [here](https://demo.thelounge.chat/#/connect?join=%23drift&nick=drift-user&realname=Drift%20User).
**Contents:** - - [Setup](#setup) - [Development](#development) - [Production](#production) @@ -29,7 +27,7 @@ To migrate the sqlite database in development, you can use `yarn migrate` to see ### Production -`yarn build` in both `client/` and `server/` will produce production code for the client and server respectively. +`yarn build` in both `client/` and `server/` will produce production code for the client and server respectively. If you're deploying the front-end to something like Vercel, you'll need to set the root folder to `client/`. @@ -52,6 +50,8 @@ You can change these to your liking. - `MEMORY_DB`: if `true`, a sqlite database will not be created and changes will only exist in memory. Mainly for the demo. - `REGISTRATION_PASSWORD`: if `true`, the user will be required to provide this password to sign-up, in addition to their username and account password. If it's not set, no additional password will be required. - `SECRET_KEY`: the same secret key as the client +- `WELCOME_CONTENT`: a markdown string that's rendered on the home page +- `WELCOME_TITLE`: the file title for the post on the homepage. - `ENABLE_ADMIN`: the first account created is an administrator account - `DRIFT_HOME`: defaults to ~/.drift, the directory for storing the database and eventually images diff --git a/client/components/admin/action-dropdown/index.tsx b/client/components/admin/action-dropdown/index.tsx index 41516896..48c57335 100644 --- a/client/components/admin/action-dropdown/index.tsx +++ b/client/components/admin/action-dropdown/index.tsx @@ -2,37 +2,42 @@ import { Popover, Button } from "@geist-ui/core" import { MoreVertical } from "@geist-ui/icons" type Action = { - title: string - onClick: () => void + title: string + onClick: () => void } const ActionDropdown = ({ - title = "Actions", - actions, - showTitle = false + title = "Actions", + actions, + showTitle = false, }: { - title?: string - showTitle?: boolean - actions: Action[] + title?: string, + showTitle?: boolean, + actions: Action[] }) => { - return ( - - {showTitle && {title}} - {actions.map((action) => ( - - {action.title} - - ))} - - } - hideArrow - > - - - ) + return ( + + {showTitle && + {title} + } + {actions.map(action => ( + + {action.title} + + ))} + + } + hideArrow + > + + + ) } -export default ActionDropdown +export default ActionDropdown \ No newline at end of file diff --git a/client/components/admin/index.tsx b/client/components/admin/index.tsx index bb09b59d..338babe9 100644 --- a/client/components/admin/index.tsx +++ b/client/components/admin/index.tsx @@ -2,7 +2,6 @@ import { Text, Spacer } from "@geist-ui/core" import Cookies from "js-cookie" import styles from "./admin.module.css" import PostTable from "./post-table" -import ServerInfo from "./server-info" import UserTable from "./user-table" export const adminFetcher = async ( @@ -25,8 +24,6 @@ const Admin = () => { return (
Administration - - diff --git a/client/components/admin/post-table.tsx b/client/components/admin/post-table.tsx index a7f5c4a6..c66f99ea 100644 --- a/client/components/admin/post-table.tsx +++ b/client/components/admin/post-table.tsx @@ -9,7 +9,7 @@ import ActionDropdown from "./action-dropdown" const PostTable = () => { const [posts, setPosts] = useState() - // const { setToast } = useToasts() + const { setToast } = useToasts() useEffect(() => { const fetchPosts = async () => { @@ -35,8 +35,8 @@ const PostTable = () => { visibility: post.visibility, size: post.files ? byteToMB( - post.files.reduce((acc, file) => acc + file.html.length, 0) - ) + post.files.reduce((acc, file) => acc + file.html.length, 0) + ) : 0, actions: "" } @@ -109,14 +109,14 @@ const PostTable = () => { dataIndex: "", key: "actions", width: 50, - render() { + render(post: Post) { return ( deletePost() + onClick: () => deletePost(post.id) } ]} /> @@ -128,11 +128,7 @@ const PostTable = () => { return ( {!posts && Loading...} - {posts && ( - -
{posts.length} posts
-
- )} + {posts &&
{posts.length} posts
} {posts && } ) diff --git a/client/components/admin/server-info.tsx b/client/components/admin/server-info.tsx deleted file mode 100644 index 2b7bf96b..00000000 --- a/client/components/admin/server-info.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import SettingsGroup from "@components/settings-group" -import { Button, Input, Spacer, Textarea, useToasts } from "@geist-ui/core" -import { useEffect, useState } from "react" -import { adminFetcher } from "." - -const Homepage = () => { - const [description, setDescription] = useState("") - const [title, setTitle] = useState("") - const { setToast } = useToasts() - useEffect(() => { - const fetchServerInfo = async () => { - const res = await adminFetcher("/server-info") - const data = await res.json() - setDescription(data.welcomeMessage) - setTitle(data.welcomeTitle) - } - fetchServerInfo() - }, []) - - const onSubmit = async (e: React.FormEvent) => { - e.preventDefault() - - const res = await adminFetcher("/server-info", { - method: "PUT", - body: { - description, - title - } - }) - - if (res.status === 200) { - setToast({ - type: "success", - text: "Server info updated" - }) - setDescription(description) - setTitle(title) - } else { - setToast({ - text: "Something went wrong", - type: "error" - }) - } - } - - return ( - -
-
- - setTitle(e.target.value)} - /> -
- -
- -