From ac73f4fe09ed81436c208cf4b9e5d88278f6a40c Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 6 Jun 2022 08:28:03 +0430 Subject: [PATCH] Added 404 page + Improvements. --- api/pages/404.html | 15 +++++++++++++++ api/server.js | 13 +++++++++++-- src/componets/AddItem.js | 8 ++++---- src/componets/EditItem.js | 4 ++-- src/modules/send.js | 3 +++ src/styles/{AddItem.css => SendItem.css} | 10 +++++----- 6 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 api/pages/404.html rename src/styles/{AddItem.css => SendItem.css} (94%) diff --git a/api/pages/404.html b/api/pages/404.html new file mode 100644 index 0000000..7cd5206 --- /dev/null +++ b/api/pages/404.html @@ -0,0 +1,15 @@ + + + + + + + Document + + +

404: NOT FOUND

+

If you are trying to access a recently added Screenshot/PDF, just wait a bit more for it to be uploaded.

+

If the problem persists, looks like the file wasn't created...

+

¯\_(ツ)_/¯

+ + \ No newline at end of file diff --git a/api/server.js b/api/server.js index 553025d..0de7171 100644 --- a/api/server.js +++ b/api/server.js @@ -6,6 +6,7 @@ const config = require('../src/config.js'); const getData = require('./modules/getData.js'); const fs = require('fs'); const fetch = require('cross-fetch'); +const { dirname } = require('path'); const port = config.API.PORT; @@ -27,11 +28,19 @@ app.get('/api', async (req, res) => { }); app.get('/screenshots/:id', async (req, res) => { - res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/screenshot\'s/' + req.params.id); + res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/screenshot\'s/' + req.params.id, (err) => { + if (err) { + res.sendFile(__dirname +'/pages/404.html'); + } + }); }); app.get('/pdfs/:id', async (req, res) => { - res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/pdf\'s/' + req.params.id); + res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/pdf\'s/' + req.params.id, (err) => { + if (err) { + res.sendFile(__dirname +'/pages/404.html'); + } + }); }); app.post('/api', async (req, res) => { diff --git a/src/componets/AddItem.js b/src/componets/AddItem.js index 6f878be..7e576f7 100644 --- a/src/componets/AddItem.js +++ b/src/componets/AddItem.js @@ -1,5 +1,5 @@ import { useState } from 'react'; -import '../styles/AddItem.css'; +import '../styles/SendItem.css'; import TagSelection from './TagSelection'; import addItem from '../modules/send'; @@ -38,13 +38,13 @@ const AddItem = ({onExit, reFetch, tags, SetLoader}) => {
New bookmark
+

* Link:

+

Name:

-

Link:

-

Tags:

- +
diff --git a/src/componets/EditItem.js b/src/componets/EditItem.js index df39c4c..7a33c82 100644 --- a/src/componets/EditItem.js +++ b/src/componets/EditItem.js @@ -1,6 +1,6 @@ import { useState } from 'react'; import deleteEntity from '../modules/deleteEntity'; -import '../styles/AddItem.css'; +import '../styles/SendItem.css'; import TagSelection from './TagSelection'; import editItem from '../modules/send'; @@ -49,7 +49,7 @@ const EditItem = ({tags, item, onExit, SetLoader, reFetch}) => {

Tags:

- + diff --git a/src/modules/send.js b/src/modules/send.js index a21ab01..54ec0d7 100644 --- a/src/modules/send.js +++ b/src/modules/send.js @@ -34,6 +34,9 @@ const addItem = async (name, link, tag, reFetch, onExit, SetLoader, method, id=n .then(() => {SetLoader(false)}); onExit(); + } else if(name === '' && link === '') { + onExit() + SetLoader(false) } else { SetLoader(false) alert('Please make sure the link is valid.\n\n(i.e. starts with "http"/"https")'); diff --git a/src/styles/AddItem.css b/src/styles/SendItem.css similarity index 94% rename from src/styles/AddItem.css rename to src/styles/SendItem.css index 4982585..94aa190 100644 --- a/src/styles/AddItem.css +++ b/src/styles/SendItem.css @@ -51,10 +51,10 @@ box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; } -.upload-btn { +.send-btn { font-family: 'Font Awesome 5 Free'; - font-size: 1.1rem; - padding: 5px; + font-size: 1.2rem; + padding: 10px; cursor: pointer; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; color: #ffffffb6; @@ -67,11 +67,11 @@ transition: background-color 0.1s; } -.upload-btn:hover { +.send-btn:hover { background-color: rgb(76, 117, 170); } -.upload-btn:active { +.send-btn:active { box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; }