lint fixes, minor copy adjustments, dep updates

This commit is contained in:
Max Leiter 2023-05-18 18:25:08 -07:00
parent d0a73a7cbc
commit 11ac185f86
8 changed files with 900 additions and 792 deletions

View file

@ -23,7 +23,8 @@ GITHUB_CLIENT_SECRET=
# Optional: if you want Keycloak oauth. Currently incompatible with the registration password
KEYCLOAK_ID=
KEYCLOAK_SECRET=
KEYCLOAK_ISSUER= # keycloak path including realm
# keycloak path including realm
KEYCLOAK_ISSUER=
KEYCLOAK_NAME=
# Optional: if you want to support credential auth (username/password, supports registration password)
@ -31,5 +32,5 @@ KEYCLOAK_NAME=
CREDENTIAL_AUTH=true
# Optional:
WELCOME_CONTENT=
WELCOME_TITLE=
WELCOME_CONTENT="## Drift is a self-hostable clone of GitHub Gist. \nIt is a simple way to share code and text snippets. It supportsthe following:\n \n - Render GitHub Extended Markdown (including images)\n - User authentication\n - Private, public, and password protected posts\n - Markdown is rendered and stored on the server\n - Syntax highlighting and automatic language detection\n - Drag-and-drop file uploading\n\n If you want to signup, you can join at [/signup](/signup) as long as you have a passcode provided by the administrator (which you don\'t need for this demo). **This demo is on a memory-only database, so accounts and pastes can be deleted at any time.** \n\nYou can find the source code on [GitHub](https://github.com/MaxLeiter/drift)."
WELCOME_TITLE="Welcome to Drift"

View file

@ -14,72 +14,73 @@
},
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.5",
"@next/eslint-plugin-next": "^13.2.4",
"@prisma/client": "^4.11.0",
"@next/eslint-plugin-next": "13.3.1-canary.6",
"@prisma/client": "^4.12.0",
"@radix-ui/react-dialog": "^1.0.3",
"@radix-ui/react-dropdown-menu": "^2.0.4",
"@radix-ui/react-popover": "^1.0.5",
"@radix-ui/react-tabs": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.5",
"@vercel/og": "^0.4.0",
"@vercel/og": "^0.5.2",
"client-only": "^0.0.1",
"client-zip": "2.3.0",
"client-zip": "2.3.1",
"cmdk": "^0.2.0",
"jest": "^29.5.0",
"lodash.debounce": "^4.0.8",
"next": "^13.2.4",
"next-auth": "^4.20.1",
"next": "13.4.3-canary.2",
"next-auth": "^4.22.0",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-cookie": "^4.1.1",
"react-datepicker": "4.10.0",
"react-cookie": "^4.1.1",
"react-datepicker": "4.11.0",
"react-dom": "18.2.0",
"react-dropzone": "14.2.3",
"react-error-boundary": "^3.1.4",
"react-error-boundary": "^4.0.3",
"react-feather": "^2.0.10",
"react-hot-toast": "2.4.0",
"server-only": "^0.0.1",
"swr": "^2.1.0",
"swr": "^2.1.3",
"textarea-markdown-editor": "1.0.4",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.0",
"ts-morph": "^18.0.0",
"uuid": "^9.0.0",
"zlib": "^1.0.5"
},
"devDependencies": {
"@next/bundle-analyzer": "13.2.4",
"@next/bundle-analyzer": "13.4.3-canary.2",
"@total-typescript/ts-reset": "^0.4.2",
"@types/bcrypt": "^5.0.0",
"@types/git-http-backend": "^1.0.1",
"@types/jest": "^29.4.1",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "18.15.3",
"@types/react": "18.0.28",
"@types/node": "18.15.11",
"@types/react": "18.0.35",
"@types/react-datepicker": "4.10.0",
"@types/react-dom": "18.0.11",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@wcj/markdown-to-html": "^2.2.1",
"clsx": "^1.2.1",
"cross-env": "7.0.3",
"csstype": "^3.1.1",
"csstype": "^3.1.2",
"dotenv": "^16.0.3",
"eslint": "8.36.0",
"eslint-config-next": "13.2.4",
"eslint": "8.38.0",
"eslint-config-next": "13.4.3-canary.2",
"jest-mock-extended": "^3.0.3",
"next-unused": "0.0.6",
"postcss": "^8.4.21",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-hover-media-feature": "^1.0.2",
"postcss-nested": "^6.0.1",
"postcss-preset-env": "^8.0.1",
"prettier": "2.8.4",
"prisma": "^4.11.0",
"typescript": "4.9.5",
"typescript-plugin-css-modules": "4.2.3"
"postcss-preset-env": "^8.3.1",
"prettier": "2.8.7",
"prisma": "^4.12.0",
"typescript": "5.0.4",
"typescript-plugin-css-modules": "5.0.1"
},
"optionalDependencies": {
"sharp": "^0.31.3"
"sharp": "^0.32.0"
},
"next-unused": {
"alias": {

File diff suppressed because it is too large Load diff

View file

@ -32,18 +32,16 @@ function Auth({
const [username, setUsername] = useState("")
const [password, setPassword] = useState("")
const [submitting, setSubmitting] = useState(false)
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
setSubmitting(true)
const res = await signIn("credentials", {
username,
password,
registration_password: serverPassword,
redirect: false,
// callbackUrl: "/signin",
signingIn: signingIn
signingIn
})
if (res?.error) {
setToast({
@ -191,7 +189,7 @@ const getProviderIcon = (provider: string) => {
switch (provider) {
case "github":
return <GitHub />
case "keycloak":
case "keycloak":
return <Key />
default:
return <User />

View file

@ -7,7 +7,7 @@ import { useMemo, useState, useEffect } from "react"
import Badge from "../badge"
const CreatedAgoBadge = ({ createdAt }: { createdAt: string | Date }) => {
const createdDate = new Date(createdAt)
const createdDate = useMemo(() => new Date(createdAt), [createdAt])
const [time, setTimeAgo] = useState(timeAgo(createdDate))
const { setToast } = useToasts()

View file

@ -39,7 +39,7 @@ const ExpirationBadge = ({
if (!expirationDate) {
return null
}
const isExpired = expirationDate < new Date()
return (

View file

@ -1,6 +1,6 @@
"use client"
import { useSelectedLayoutSegment, useSelectedLayoutSegments } from "next/navigation"
import { useSelectedLayoutSegments } from "next/navigation"
import FadeIn from "@components/fade-in"
import { setDriftTheme } from "src/app/lib/set-theme"
import {
@ -46,13 +46,17 @@ export function HeaderButtons({
theme: string
}) {
const { isAdmin, userId } = useSessionSWR()
const { resolvedTheme } = useTheme();
return getButtons({
const { resolvedTheme } = useTheme()
return (
<>
{getButtons({
isAuthenticated,
theme: resolvedTheme ? resolvedTheme : initialTheme,
isAdmin,
userId
})
})}
</>
)
}
function NavButton(tab: Tab) {
@ -111,7 +115,7 @@ export function getButtons({
isAuthenticated: boolean
theme: string
// mutate: KeyedMutator<Session>
isAdmin?: boolean,
isAdmin?: boolean
userId?: string
}) {
return [
@ -152,9 +156,7 @@ export function getButtons({
value="signout"
onClick={() => {
signOut({
callbackUrl: `/signedout${
userId ? "?userId=" + userId : ""
}`
callbackUrl: `/signedout${userId ? "?userId=" + userId : ""}`
})
}}
width={SIGN_IN_WIDTH}

View file

@ -6,7 +6,7 @@ services:
restart: unless-stopped
user: 1000:1000
environment:
- WELCOME_CONTENT="## Drift is a self-hostable clone of GitHub Gist. \nIt is a simple way to share code and text snippets with your friends, with support for the following:\n \n - Render GitHub Extended Markdown (including images)\n - User authentication\n - Private, public, and password protected posts\n - Markdown is rendered and stored on the server\n - Syntax highlighting and automatic language detection\n - Drag-and-drop file uploading\n\n If you want to signup, you can join at [/signup](/signup) as long as you have a passcode provided by the administrator (which you don\'t need for this demo). **This demo is on a memory-only database, so accounts and pastes can be deleted at any time.** \n\nYou can find the source code on [GitHub](https://github.com/MaxLeiter/drift)."
- WELCOME_CONTENT="## Drift is a self-hostable clone of GitHub Gist. \nIt is a simple way to share code and text snippets. It supportsthe following:\n \n - Render GitHub Extended Markdown (including images)\n - User authentication\n - Private, public, and password protected posts\n - Markdown is rendered and stored on the server\n - Syntax highlighting and automatic language detection\n - Drag-and-drop file uploading\n\n If you want to signup, you can join at [/signup](/signup) as long as you have a passcode provided by the administrator (which you don\'t need for this demo). **This demo is on a memory-only database, so accounts and pastes can be deleted at any time.** \n\nYou can find the source code on [GitHub](https://github.com/MaxLeiter/drift)."
- WELCOME_TITLE="Drift"
- REGISTRATION_PASSWORD=""
- NEXTAUTH_URL=http://localhost:3000