From d949093e5332ff4caf0c4e9b92483eb353b5da4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=AB=20=E3=82=A6=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=96?= Date: Fri, 18 Jan 2019 12:15:17 -0600 Subject: [PATCH 1/2] Closes #208 --- app/index.js | 4 ++++ app/modules/redirect-404.js | 48 ------------------------------------- app/views/redirect.js | 4 ++-- 3 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 app/modules/redirect-404.js diff --git a/app/index.js b/app/index.js index 09c7076..24ec78e 100755 --- a/app/index.js +++ b/app/index.js @@ -17,6 +17,7 @@ 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: { @@ -46,6 +47,9 @@ 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 deleted file mode 100644 index c699305..0000000 --- a/app/modules/redirect-404.js +++ /dev/null @@ -1,48 +0,0 @@ -"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 57465cc..0e6289a 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 redirect404 from "../modules/redirect-404"; +import page404 from "./404"; @@ -23,7 +23,7 @@ export default (state, emit) => { // eslint-disable-line const path = `./documents/${partialPath}.md`; if (!fs.existsSync(path)) - return redirect404(state); + return page404(); const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); -- 2.45.2 From 477e0095b51ada4de1bc7f40c76bcbcfc6e98b3e Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 18 Jan 2019 13:29:04 -0500 Subject: [PATCH 2/2] Update contribute.md --- documents/contribute.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.45.2