1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

404 page allows you to visit that user

Closes #43
This commit is contained in:
Cadence Ember 2020-03-22 17:10:50 +13:00
parent a903647eb1
commit 49ad9ee434
No known key found for this signature in database
GPG Key ID: 81015DF9AA8607E1
6 changed files with 32 additions and 25 deletions

37
package-lock.json generated
View File

@ -1618,9 +1618,9 @@
"dev": true
},
"in-publish": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.0.tgz",
"integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E="
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.1.tgz",
"integrity": "sha512-oDM0kUSNFC31ShNxHKUyfZKy8ZeXZBWMjMdZHKLOk13uvT27VTL/QzRGfRUcevJhpkZAvlhPYuXkF7eNWrtyxQ=="
},
"indent-string": {
"version": "2.1.0",
@ -2287,9 +2287,9 @@
}
},
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"minipass": {
"version": "3.1.1",
@ -2328,18 +2328,11 @@
"integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA=="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
"integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
"minimist": "^1.2.5"
}
},
"ms": {
@ -2940,8 +2933,8 @@
}
},
"pinski": {
"version": "github:cloudrac3r/pinski#1193025936cac58ac329b30e0749884bba6abb11",
"from": "github:cloudrac3r/pinski#1193025936cac58ac329b30e0749884bba6abb11",
"version": "github:cloudrac3r/pinski#4baee0a52b809ff9ac9767dbccc5addebc6c842a",
"from": "github:cloudrac3r/pinski#4baee0a52b809ff9ac9767dbccc5addebc6c842a",
"requires": {
"mime": "^2.4.4",
"node-sass": "^4.13.1",
@ -5241,9 +5234,9 @@
}
},
"ws": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz",
"integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A=="
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ=="
},
"xml-js": {
"version": "1.6.11",

View File

@ -17,7 +17,7 @@
"mixin-deep": "^2.0.1",
"node-dir": "^0.1.17",
"node-fetch": "^2.6.0",
"pinski": "github:cloudrac3r/pinski#1193025936cac58ac329b30e0749884bba6abb11",
"pinski": "github:cloudrac3r/pinski#4baee0a52b809ff9ac9767dbccc5addebc6c842a",
"pug": "^2.0.4",
"semver": "^7.1.2",
"sharp": "^0.24.0",

View File

@ -29,7 +29,8 @@ function request(url, options = {}, settings = {}) {
headers: {
"User-Agent": userAgent
},
followRedirect: false
followRedirect: false,
throwHttpErrors: false
}, options))
} else {
throw new Error("Invalid value for setting `request_backend`.")

10
src/site/api/404.js Normal file
View File

@ -0,0 +1,10 @@
const {render} = require("pinski/plugins")
const constants = require("../../lib/constants")
module.exports = [
{route: "/404", methods: ["GET", "POST", "PATCH", "DELETE"], code: async ({url}) => {
const path = url.searchParams.get("pathname")
const couldBeUsername = path.match(`^/${constants.external.username_regex}$`)
return render(404, "pug/404.pug", {path, couldBeUsername})
}}
]

View File

@ -1,3 +1,5 @@
//- Needs path, couldBeUsername
include includes/error
doctype html
@ -8,3 +10,5 @@ html
body.error-page
+error(404, "Page not found.")
if couldBeUsername
| Trying to access a user? #[a(href=`/u${path}`) Visit @#{path.slice(1)}]

View File

@ -19,7 +19,6 @@ subdirs("pug", async (err, dirs) => {
// need to check for and run db upgrades before anything starts using it
await require("../lib/utils/upgradedb")()
pinski.addRoute("/404", "pug/404.pug", "pug")
pinski.setNotFoundTarget("/404")
pinski.addRoute("/static/css/main.css", "sass/main.sass", "sass")
pinski.addPugDir("pug", dirs)