diff --git a/app/index.js b/app/index.js index 24ec78e..09c7076 100755 --- a/app/index.js +++ b/app/index.js @@ -17,7 +17,6 @@ import websockets from "@inc/fastify-ws"; import handleSocketMessages from "./sockets"; import messageSlack from "./helpers/slack"; -import redirects from "./data/redirects.json"; const server = fastify({ logger: { @@ -47,9 +46,6 @@ server app: require("./client") }) .addHook("preHandler", (request, reply, next) => { - if (redirects[request.raw.originalUrl]) - reply.redirect(301, redirects[request.raw.originalUrl]); - if (process.env.NODE_ENV !== "development") { if (request.headers["x-forwarded-proto"] !== "https") reply.redirect(302, `https://${request.raw.hostname}${request.raw.originalUrl}`); diff --git a/app/modules/redirect-404.js b/app/modules/redirect-404.js new file mode 100644 index 0000000..c699305 --- /dev/null +++ b/app/modules/redirect-404.js @@ -0,0 +1,48 @@ +"use strict"; + + + +// I M P O R T + +import html from "choo/html"; + +// U T I L S + +import page404 from "../views/404"; +import redirects from "../data/redirects.json"; + + + +// E X P O R T + +export default state => { + const redirectUrl = redirects[state.href]; + + if (redirectUrl) { + return html` +
+ + +
+
+

Redirecting you to ${redirectUrl}

+
+
+
+ + + `; + } + + return page404(); +}; diff --git a/app/views/redirect.js b/app/views/redirect.js index 0e6289a..57465cc 100644 --- a/app/views/redirect.js +++ b/app/views/redirect.js @@ -12,7 +12,7 @@ import raw from "choo/html/raw"; // U T I L S import markdown from "../components/markdown"; -import page404 from "./404"; +import redirect404 from "../modules/redirect-404"; @@ -23,7 +23,7 @@ export default (state, emit) => { // eslint-disable-line const path = `./documents/${partialPath}.md`; if (!fs.existsSync(path)) - return page404(); + return redirect404(state); const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); diff --git a/documents/contribute.md b/documents/contribute.md index 4d4edab..7767bc3 100644 --- a/documents/contribute.md +++ b/documents/contribute.md @@ -23,8 +23,8 @@ If you want to contribute to LBRY, there's definitely something for you! The fir | [lbrycrd](https://github.com/lbryio/lbrycrd) | C++ | A full node for the LBRY blockchain, including a standalone wallet. Used by miners and some applications. Most consumer applications do not bundle [[lbrycrd]] directly, and instead bundle [[lbry-sdk]]. | [lbry-sdk](https://github.com/lbryio/lbry) | Python (Twisted) | A daemon that can be used directly or to develop other applications. Provides convenience [APIs](/api/sdk), bundles an SPV wallet ([[torba]]), and contains an implementation of the LBRY data network. | | [torba](https://github.com/lbryio/torba) | Python | An [[SPV]] (Simple Payment Verification) wallet. Bundled with [[lbry-sdk]]. | -| [lbryumx](https://github.com/lbryio/lbryumx) | Protobuf, Python | The wallet server used by [[torba]]. -| [lbry-schema](https://github.com/lbryio/lbryschema) | Protobuf, Python | Defines the structure of the metadata stored in the LBRY blockchain. +| [wallet server](https://github.com/lbryio/lbry/tree/master/lbrynet/extras/wallet/server) | Protobuf, Python | The wallet server used by [[torba]]. +| [schema](https://github.com/lbryio/lbry/tree/master/lbrynet/schema) | Protobuf, Python | Defines the structure of the metadata stored in the LBRY blockchain. ### Official Applications | Application | Language (Toolset) | What Is It