From aa912035a78741259d534f23a0ff6c3e99803d08 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Sun, 30 Sep 2018 15:56:48 -0400 Subject: [PATCH] crappy redirects, 404 tweak, markdown img --- app/data/redirects.json | 5 +++++ app/modules/redirect.js | 4 ++++ app/sass/init/_markdown.scss | 7 +++++++ app/views/404.js | 26 ++++++++++++++++++++++++++ app/views/redirect.js | 26 +++++++++----------------- 5 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 app/data/redirects.json create mode 100644 app/modules/redirect.js diff --git a/app/data/redirects.json b/app/data/redirects.json new file mode 100644 index 0000000..d524784 --- /dev/null +++ b/app/data/redirects.json @@ -0,0 +1,5 @@ +{ + "/tour" : "/playground", + "/play" : "/playground", + "/whitepaper": "https://whitepaper.lbry.tech" +} diff --git a/app/modules/redirect.js b/app/modules/redirect.js new file mode 100644 index 0000000..cc02f28 --- /dev/null +++ b/app/modules/redirect.js @@ -0,0 +1,4 @@ +export default (url, code = 301) => { + console.log(code + ": " + url); + throw "fix this please, needs to redirect to:" + url; +} diff --git a/app/sass/init/_markdown.scss b/app/sass/init/_markdown.scss index 9b12971..6db7178 100644 --- a/app/sass/init/_markdown.scss +++ b/app/sass/init/_markdown.scss @@ -162,6 +162,13 @@ padding-left: 1.25rem; } + img { + display: block; + margin-left: auto; + margin-right: auto; + margin-bottom: 1rem; + } + p { img { float: right; diff --git a/app/views/404.js b/app/views/404.js index e69de29..448e415 100644 --- a/app/views/404.js +++ b/app/views/404.js @@ -0,0 +1,26 @@ +"use strict"; + +import html from "choo/html"; + +export default () => { + return html` +
+ + +
+
+

The requested page could not be found. Here is the image located at lbry://404 to console you.

+ +

Think something should be here? Let us know by raising an issue.

+
+
+
+ `; +}; + diff --git a/app/views/redirect.js b/app/views/redirect.js index e4b936d..a8ce8d4 100644 --- a/app/views/redirect.js +++ b/app/views/redirect.js @@ -11,6 +11,9 @@ import fs from "graceful-fs"; import html from "choo/html"; import path from "path"; import { require as local } from "app-root-path"; +import redirects from '../data/redirects.json'; +import redirect from "../modules/redirect"; +import Page404 from "./404.js"; import raw from "choo/html/raw"; // V A R I A B L E S @@ -46,23 +49,12 @@ module.exports = exports = (state, emit) => { // eslint-disable-line else path = state.params.wildcard; if (!fs.existsSync(`./documents/${path}.md`)) { - return html` -
- - -
-
-

The page you are looking for does not exist.

-
-
-
- `; + const redirectUrl = redirects[path] || redirects["/" + path] + if (redirectUrl) { + redirect(redirectUrl) + } else { + return Page404(); + } } const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8");