fix: stuff
This commit is contained in:
parent
e2fd27cbba
commit
68d346e69d
7 changed files with 32 additions and 5 deletions
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
|
@ -19,8 +19,13 @@ jobs:
|
|||
id: cache-restore
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}
|
||||
path: |
|
||||
node_modules
|
||||
${{ github.workspace }}/.next/cache
|
||||
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cache-restore.outputs.cache-hit != 'true'
|
||||
|
|
|
@ -32,6 +32,8 @@ A ShareX/file upload server that is easy to use, packed with features, and with
|
|||
- Fully customizable Discord webhook notifications
|
||||
- OAuth2 registration (Discord and GitHub)
|
||||
- User invites
|
||||
- File Chunking (for large files)
|
||||
- File deletion once it reaches a certain amount of views
|
||||
- Easy setup instructions on [docs](https://zipl.vercel.app/) (One command install `docker-compose up -d`)
|
||||
|
||||
# Usage
|
||||
|
|
|
@ -5,6 +5,7 @@ import Image from 'next/image';
|
|||
export default function DiscordIcon({ ...props }) {
|
||||
return (
|
||||
<Image
|
||||
alt='discord'
|
||||
src='https://assets-global.website-files.com/6257adef93867e50d84d30e2/62595384f934b806f37f4956_145dc557845548a36a82337912ca3ac5.svg'
|
||||
width={24}
|
||||
height={24}
|
||||
|
|
|
@ -5,6 +5,7 @@ import Image from 'next/image';
|
|||
export default function FlameshotIcon({ ...props }) {
|
||||
return (
|
||||
<Image
|
||||
alt='flameshot'
|
||||
src='https://raw.githubusercontent.com/flameshot-org/flameshot/master/data/img/app/flameshot.svg'
|
||||
width={24}
|
||||
height={24}
|
||||
|
|
|
@ -3,5 +3,7 @@
|
|||
import Image from 'next/image';
|
||||
|
||||
export default function ShareXIcon({ ...props }) {
|
||||
return <Image src='https://getsharex.com/img/ShareX_Logo.svg' width={24} height={24} {...props} />;
|
||||
return (
|
||||
<Image alt='sharex' src='https://getsharex.com/img/ShareX_Logo.svg' width={24} height={24} {...props} />
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Button, Group, PasswordInput, Select, Tabs, Title, Tooltip } from '@mantine/core';
|
||||
import { Button, Group, NumberInput, PasswordInput, Select, Tabs, Title, Tooltip } from '@mantine/core';
|
||||
import { Prism } from '@mantine/prism';
|
||||
import { Language } from 'prism-react-renderer';
|
||||
import { showNotification, updateNotification } from '@mantine/notifications';
|
||||
|
@ -17,6 +17,7 @@ export default function Upload() {
|
|||
const [lang, setLang] = useState('txt');
|
||||
const [password, setPassword] = useState('');
|
||||
const [expires, setExpires] = useState('never');
|
||||
const [maxViews, setMaxViews] = useState<number>(undefined);
|
||||
|
||||
const handleUpload = async () => {
|
||||
const file = new File([value], 'text.' + lang);
|
||||
|
@ -97,6 +98,7 @@ export default function Upload() {
|
|||
|
||||
expires !== 'never' && req.setRequestHeader('Expires-At', 'date=' + expires_at.toISOString());
|
||||
password !== '' && req.setRequestHeader('Password', password);
|
||||
maxViews && maxViews !== 0 && req.setRequestHeader('Max-Views', String(maxViews));
|
||||
|
||||
req.send(body);
|
||||
};
|
||||
|
@ -139,6 +141,9 @@ export default function Upload() {
|
|||
icon={<TypeIcon />}
|
||||
searchable
|
||||
/>
|
||||
<Tooltip label='After the file reaches this amount of views, it will be deleted automatically. Leave blank for no limit.'>
|
||||
<NumberInput placeholder='Max Views' min={0} value={maxViews} onChange={(x) => setMaxViews(x)} />
|
||||
</Tooltip>
|
||||
<Tooltip label='Add a password to your files (optional, leave blank for none)'>
|
||||
<PasswordInput
|
||||
style={{ width: '252px' }}
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
Title,
|
||||
Card,
|
||||
Center,
|
||||
NumberInput,
|
||||
} from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
|
@ -32,6 +33,7 @@ export default function Urls() {
|
|||
initialValues: {
|
||||
url: '',
|
||||
vanity: '',
|
||||
maxViews: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -47,17 +49,25 @@ export default function Urls() {
|
|||
return form.setFieldError('url', 'Invalid URL');
|
||||
}
|
||||
|
||||
const data = {
|
||||
const data: {
|
||||
url: string;
|
||||
vanity?: string;
|
||||
} = {
|
||||
url: cleanURL,
|
||||
vanity: cleanVanity === '' ? null : cleanVanity,
|
||||
};
|
||||
|
||||
const headers = {};
|
||||
|
||||
if (values.maxViews && values.maxViews !== 0) headers['Max-Views'] = values.maxViews;
|
||||
|
||||
setCreateOpen(false);
|
||||
const res = await fetch('/api/shorten', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: user.token,
|
||||
'Content-Type': 'application/json',
|
||||
...headers,
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
@ -92,6 +102,7 @@ export default function Urls() {
|
|||
<form onSubmit={form.onSubmit((v) => onSubmit(v))}>
|
||||
<TextInput id='url' label='URL' {...form.getInputProps('url')} />
|
||||
<TextInput id='vanity' label='Vanity' {...form.getInputProps('vanity')} />
|
||||
<NumberInput id='maxViews' label='Max Views' {...form.getInputProps('maxViews')} />
|
||||
|
||||
<Group position='right' mt='md'>
|
||||
<Button onClick={() => setCreateOpen(false)}>Cancel</Button>
|
||||
|
|
Loading…
Reference in a new issue