0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-02-19 01:55:48 -05:00

Merge branch 'development' into main

This commit is contained in:
Elias Schneider 2022-10-17 22:47:22 +02:00
commit f3ec9be63b
7 changed files with 108 additions and 53 deletions

96
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,96 @@
# Contributing
We would ❤️ for you to contribute to Pingvin Share and help make it better! All contributions are welcome, including issues, suggestions, pull requests and more.
## Getting started
You've found a bug, have suggestion or something else, just create an issue on GitHub and we can get in touch 😊.
## Submit a Pull Request
Once you created a issue and you want to create a pull request, follow this guide.
Branch naming convention is as following
`TYPE-ISSUE_ID-DESCRIPTION`
example:
```
feat-69-ability-to-set-share-expiration-to-never
```
When `TYPE` can be:
- **feat** - is a new feature
- **doc** - documentation only changes
- **fix** - a bug fix
- **refactor** - code change that neither fixes a bug nor adds a feature
**All PRs must include a commit message with the changes description!**
For the initial start, fork the project and use the `git clone` command to download the repository to your computer. A standard procedure for working on an issue would be to:
1. `git pull`, before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
```
$ git pull
```
2. Create new branch from `main` like: `feat-69-ability-to-set-share-expiration-to-never`<br/>
```
$ git checkout -b [name_of_your_new_branch]
```
3. Work - commit - repeat
4. Before you push your changes, make sure you run the linter and format the code.
```bash
npm run lint
npm run format
```
5. Push changes to GitHub
```
$ git push origin [name_of_your_new_branch]
```
6. Submit your changes for review
If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button.
7. Start a Pull Request
Now submit the pull request and click on `Create pull request`.
8. Get a code review approval/reject
## Setup project
Pingvin Share consists of a frontend and a backend.
### Backend
The backend is built with [Nest.js](https://nestjs.com) and uses Typescript.
#### Setup
1. Open the `backend` folder
2. Duplicate the `.env.example` file, rename the duplicate to `.env` and change the environment variables if needed
3. Install the dependencies with `npm install`
4. Push the database schema to the database by running `npx prisma db push`
5. Start the backend with `npm run dev`
### Frontend
The frontend is built with [Next.js](https://nextjs.org) and uses Typescript.
#### Setup
1. Start the backend first
2. Open the `frontend` folder
3. Duplicate the `.env.example` file, rename the duplicate to `.env` and change the environment variables if needed
4. Install the dependencies with `npm install`
5. Start the frontend with `npm run dev`
You're all set!
### Testing
At the moment we only have system tests for the backend. To run these tests, run `npm run test:system` in the backend folder.

View file

@ -10,10 +10,11 @@ Demo: https://pingvin-share.dev.eliasschneider.com
## ✨ Features
- Create a simple share with a link
- Create a share with files that you can access with a link
- No file size limit, only your disk will be your limit
- Set a share expiration
- Optionally secure your share with a visitor limit and a password
- Dark mode
- Light & dark mode
## ⌨️ Setup
@ -43,29 +44,4 @@ Just update the docker container by running `docker compose pull && docker compo
## 🖤 Contribute
You're very welcome to contribute to Pingvin Share!
Contact me, create an issue or directly create a pull request.
### Development setup
#### Backend
1. Open the `backend` folder
2. Duplicate the `.env.example` file, rename the duplicate to `.env` and change the environment variables if needed
3. Install the dependencies with `npm install`
4. Push the database schema to the database by running `npx prisma db push`
5. Start the backend with `npm run dev`
#### Frontend
1. Start the backend first
2. Open the `frontend` folder
3. Duplicate the `.env.example` file, rename the duplicate to `.env` and change the environment variables if needed
4. Install the dependencies with `npm install`
5. Start the frontend with `npm run dev`
You're all set!
### Testing
At the moment we only have system tests for the backend. To run these tests, run `npm run test:system` in the backend folder.
You're very welcome to contribute to Pingvin Share! Follow the [contribution guide](/CONTRIBUTING.md) to get started.

View file

@ -1,4 +1,3 @@
SHOW_HOME_PAGE=true
ALLOW_REGISTRATION=true
MAX_FILE_SIZE=1000000000
TWELVE_HOUR_TIME=false

View file

@ -5,8 +5,6 @@ const nextConfig = {
ALLOW_REGISTRATION: process.env.ALLOW_REGISTRATION,
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
BACKEND_URL: process.env.BACKEND_URL,
TWELVE_HOUR_TIME: process.env.TWELVE_HOUR_TIME
}
}

View file

@ -1,8 +1,8 @@
import {
Accordion,
Button,
Col,
Checkbox,
Col,
Grid,
NumberInput,
PasswordInput,
@ -13,13 +13,10 @@ import {
} from "@mantine/core";
import { useForm, yupResolver } from "@mantine/form";
import { useModals } from "@mantine/modals";
import moment from "moment";
import * as yup from "yup";
import shareService from "../../services/share.service";
import { ShareSecurity } from "../../types/share.type";
import moment from "moment";
import getConfig from "next/config";
const { publicRuntimeConfig } = getConfig();
const PreviewExpiration = ({ form }: { form: any }) => {
const value = form.values.never_expires
@ -34,14 +31,7 @@ const PreviewExpiration = ({ form }: { form: any }) => {
)
.toDate();
if (publicRuntimeConfig.TWELVE_HOUR_TIME === "true")
return `This share will expire on ${moment(expirationDate).format(
"MMMM Do YYYY, h:mm a"
)}`;
else
return `This share will expire on ${moment(expirationDate).format(
"MMMM DD YYYY, HH:mm"
)}`;
return `This share will expire on ${moment(expirationDate).format("LLL")}`;
};
const CreateUploadModalBody = ({

View file

@ -62,11 +62,9 @@ const Body = ({ share }: { share: Share }) => {
{/* If our share.expiration is timestamp 0, show a different message */}
{moment(share.expiration).unix() === 0
? "This share will never expire."
: `This share will expire on ${
publicRuntimeConfig.TWELVE_HOUR_TIME === "true"
? moment(share.expiration).format("MMMM Do YYYY, h:mm a")
: moment(share.expiration).format("MMMM DD YYYY, HH:mm")
}`}
: `This share will expire on ${moment(share.expiration).format(
"LLL"
)}`}
</Text>
<Button

View file

@ -14,6 +14,7 @@ import { useClipboard } from "@mantine/hooks";
import { useModals } from "@mantine/modals";
import { NextLink } from "@mantine/next";
import moment from "moment";
import getConfig from "next/config";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { TbLink, TbTrash } from "react-icons/tb";
@ -22,7 +23,6 @@ import useUser from "../../hooks/user.hook";
import shareService from "../../services/share.service";
import { MyShare } from "../../types/share.type";
import toast from "../../utils/toast.util";
import getConfig from "next/config";
const { publicRuntimeConfig } = getConfig();
@ -77,9 +77,7 @@ const MyShares = () => {
<td>
{moment(share.expiration).unix() === 0
? "Never"
: publicRuntimeConfig.TWELVE_HOUR_TIME === "true"
? moment(share.expiration).format("MMMM Do YYYY, h:mm a")
: moment(share.expiration).format("MMMM DD YYYY, HH:mm")}
: moment(share.expiration).format("LLL")}
</td>
<td>
<Group position="right">