From f88bbc6d72d88905d2eff8e186a947688a103e74 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman <kauffj@gmail.com> Date: Mon, 8 Oct 2018 10:36:09 -0400 Subject: [PATCH 1/5] convert markdown logic to re-usable component --- app/components/ecosystem/module-lbrycrd.js | 20 +--- app/components/markdown.js | 82 +++++++++++++++++ app/sass/init/_markdown.scss | 2 +- app/views/redirect.js | 101 +++------------------ documents/partials/lbrycrd.md | 16 ++++ 5 files changed, 114 insertions(+), 107 deletions(-) create mode 100644 app/components/markdown.js create mode 100644 documents/partials/lbrycrd.md diff --git a/app/components/ecosystem/module-lbrycrd.js b/app/components/ecosystem/module-lbrycrd.js index 331cf19..744620a 100644 --- a/app/components/ecosystem/module-lbrycrd.js +++ b/app/components/ecosystem/module-lbrycrd.js @@ -1,6 +1,6 @@ "use strict"; - +import markdown from "../markdown"; // E X P O R T @@ -20,23 +20,7 @@ module.exports = exports = () => ` </h2> <div class="ecosystem__module__details"> - <p><em>This section assumes "blockchain" already means something to you. If you're totally new, the key problem solved by blockhain is the ability for distributed, disparate entities to all agree on a rivalrous state of affairs. For a more comprehensive introduction to blockchain, try starting [here]</em></p> - - <p>LBRY uses a public, proof-of-work blockchain that is very similar to Bitcoin. The blockchain is the foundation of the protocol stack.</p> - - <p>The most salient feature of the LBRY blockchain is the association of a string of characters (a "name") with a structured set of metadata. This name can be accessed as a LBRY URL, e.g. <a class="__plain" href="/playground?url=hellolbry"><code>lbry://hellolbry</code></a></p> - - <p>The LBRY blockchain stores names and metadata in a Merkle tree. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain.</p> - - <p>The metadata contains information about the content, such as the title, creator, price (if any), and a unique signature allowing the actual content to be fetched from the data network, the next level in the LBRY stack.</p> - - <h3>Additional Resources</h3> - <ul> - <li>See the <a href="/whitepaper" title="Whitepaper">Whitepaper</a> for a more comprehensive introduction to the LBRY blockchain.</li> - <li>See the <a href="/resources" title="">Resources</a> for documentation about the LBRY blockchain, including its API.</li> - <li>See [[Naming]] for learning more about LBRY URLs and how they work.</li> - <li>See [[Identities]] for learning how the LBRY blockchain handles publisher identities.</li> - </ul> + ${markdown("./documents/partials/lbrycrd.md")} </div> </div> `; diff --git a/app/components/markdown.js b/app/components/markdown.js new file mode 100644 index 0000000..9004433 --- /dev/null +++ b/app/components/markdown.js @@ -0,0 +1,82 @@ +"use strict"; + +import decamelize from "decamelize"; +import exists from "fs-exists-sync"; +import fs from "graceful-fs"; +import fm from "front-matter"; +import html from "choo/html"; +import path from "path"; +import raw from "choo/html/raw"; +import { require as local } from "app-root-path"; + +const numberRegex = /^[0-9]/g; +const md = require("markdown-it")({ + html: true, + typographer: true +}).use(local("app/modules/markdown-it-sup")) + .use(require("markdown-it-anchor"), { + slugify: stringToSlugify => { + let finalString = stringToSlugify + .toLowerCase() + .replace(/\s\/\s/g, "-") + .replace(/\s/g, "-") + .replace(/%/g, "") + .replace(/\(/g, "") + .replace(/\)/g, "") + .replace(/,/g, ""); + + if (finalString.match(numberRegex)) finalString = `_${finalString}`; + return finalString; + } + }); + + + +export default path => { + + const markdownFile = fs.readFileSync(path, "utf-8"); + const markdownFileDetails = fm(markdownFile); + const renderedMarkdown = md.render(markdownFileDetails.body); + const updatedMarkdown = wikiFinder(partialFinder(renderedMarkdown)); + + return html` + <div class="page__markup">${raw(updatedMarkdown)}</div> + `; +}; + +function partialFinder(markdownBody) { + const regexToFindPartials = /<\w+ ?\/>/g; + const partials = markdownBody.match(regexToFindPartials); + + if (!partials) return markdownBody; + + for (const partial of partials) { + const filename = decamelize(partial, "-").replace("<", "") + .replace("/>", "") + .trim(); + const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist + + if (!fileExistsTest) + markdownBody = markdownBody.replace(partial, ""); + + else { + const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`)); + + if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction); + else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`); + } + } + + return markdownBody; +} + +function wikiFinder(markdownBody) { + return markdownBody.replace(/\[\[([\w\s/-]+)\]\]/g, (match, p1) => { + const label = p1.trim(); + const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-")); + + return label ? + `<a href="${url}" class="link--glossary">${label}</a>` : + match.input; + }); +} diff --git a/app/sass/init/_markdown.scss b/app/sass/init/_markdown.scss index 5e86f52..33a6664 100644 --- a/app/sass/init/_markdown.scss +++ b/app/sass/init/_markdown.scss @@ -184,7 +184,7 @@ } } - a:not(.__button-black):not(.button):not(.header-anchor):not(.newsletter-standalone__submit):not(.__plain) { + a:not(.__button-black):not(.button) { @include underline($teal, $white); color: $teal; diff --git a/app/views/redirect.js b/app/views/redirect.js index 149fd4a..a35efd4 100644 --- a/app/views/redirect.js +++ b/app/views/redirect.js @@ -1,60 +1,24 @@ "use strict"; - - -// P A C K A G E S - -import decamelize from "decamelize"; -import exists from "fs-exists-sync"; -import fm from "front-matter"; import fs from "graceful-fs"; import html from "choo/html"; -import path from "path"; +import fm from "front-matter"; import { require as local } from "app-root-path"; +import markdown from "../components/markdown"; import raw from "choo/html/raw"; -// V A R I A B L E S - -const numberRegex = /^[0-9]/g; const redirect404 = local("app/modules/redirect-404"); -const md = require("markdown-it")({ - html: true, - typographer: true -}).use(local("app/modules/markdown-it-sup")) - .use(require("markdown-it-anchor"), { - slugify: stringToSlugify => { - let finalString = stringToSlugify - .toLowerCase() - .replace(/\s\/\s/g, "-") - .replace(/\s/g, "-") - .replace(/%/g, "") - .replace(/\(/g, "") - .replace(/\)/g, "") - .replace(/,/g, ""); - - if (finalString.match(numberRegex)) finalString = `_${finalString}`; - return finalString; - } - }); - - - -// E X P O R T - module.exports = exports = (state, emit) => { // eslint-disable-line - let path; + const partialPath = state.route === "resources/*" ? `resources/${state.params.wildcard}` : state.params.wildcard; + const path = `./documents/${partialPath}.md`; - if (state.route === "resources/*") path = `resources/${state.params.wildcard}`; - else path = state.params.wildcard; - - if (!fs.existsSync(`./documents/${path}.md`)) + if (!fs.existsSync(path)) { return redirect404(state); + } - const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8"); + const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); - const renderedMarkdown = md.render(markdownFileDetails.body); - const updatedMarkdown = wikiFinder(partialFinder(renderedMarkdown)); if (markdownFileDetails.attributes.meta) { const customMetadata = {}; @@ -66,14 +30,16 @@ module.exports = exports = (state, emit) => { // eslint-disable-line } } + // below seems evil state.lbry = customMetadata; } + // below should be refactored into components let pageScript = ""; - if (path === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; - if (path === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>"; - if (path === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>"; + if (partialPath === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; + if (partialPath === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>"; + if (partialPath === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>"; return html` <article class="page" itemtype="http://schema.org/BlogPosting"> @@ -87,51 +53,10 @@ module.exports = exports = (state, emit) => { // eslint-disable-line <section class="page__content" itemprop="articleBody"> <div class="inner-wrap"> - <div class="page__markup">${raw(updatedMarkdown)}</div> + ${markdown(path)} ${raw(pageScript)} </div> </section> </article> `; }; - - - -// H E L P E R S - -function partialFinder(markdownBody) { - const regexToFindPartials = /<\w+ ?\/>/g; - const partials = markdownBody.match(regexToFindPartials); - - if (!partials) return markdownBody; - - for (const partial of partials) { - const filename = decamelize(partial, "-").replace("<", "") - .replace("/>", "") - .trim(); - const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist - - if (!fileExistsTest) - markdownBody = markdownBody.replace(partial, ""); - - else { - const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`)); - - if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction); - else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`); - } - } - - return markdownBody; -} - -function wikiFinder(markdownBody) { - return markdownBody.replace(/\[\[([\w\s/-]+)\]\]/g, (match, p1) => { - const label = p1.trim(); - const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-")); - - return label ? - `<a href="${url}" class="link--glossary">${label}</a>` : - match.input; - }); -} diff --git a/documents/partials/lbrycrd.md b/documents/partials/lbrycrd.md new file mode 100644 index 0000000..683ffa1 --- /dev/null +++ b/documents/partials/lbrycrd.md @@ -0,0 +1,16 @@ +_This section assumes "blockchain" already means something to you. If you're totally new, the key problem solved by blockhain is the ability for distributed, disparate entities to all agree on a rivalrous state of affairs. For a more comprehensive introduction to blockchain, try starting [here](https://lopp.net/bitcoin.html)_ + +LBRY uses a public, proof-of-work blockchain that is very similar to Bitcoin. The blockchain is the foundation of the protocol stack. + +The most salient feature of the LBRY blockchain is the association of a normalized string of characters (a "name") with a structured set of metadata. This coupling is called a [[claim]]. The content referenced by a claim can be accessed as a LBRY URL, e.g. [lbry://hellolbry](/playground?url=hellolbry). + +The LBRY blockchain stores names and metadata in a parallel [[Merkle tree]], separate from the tree used to store transaction data. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain. + +The metadata contains information about the content, such as the title, creator, price (if any), and a unique signature allowing the actual content to be fetched from the data network, the next level in the LBRY stack. + +### Additional Resources + +* See the [Whitepaper](/whitepaper "Whitepaper") for a more comprehensive introduction to the LBRY blockchain. +* See the [Resources](/resources) for documentation about the LBRY blockchain, including its API. +* See [[Naming]] for learning more about LBRY URLs and how they work. +* See [[Identities]] for learning how the LBRY blockchain handles publisher identities. From 78cca6bc3eeb54af1ce85964ac9ebfa2904e64c7 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman <kauffj@gmail.com> Date: Mon, 8 Oct 2018 10:38:11 -0400 Subject: [PATCH 2/5] remove unnecessary class --- app/components/mission-statement.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/mission-statement.js b/app/components/mission-statement.js index b0f2a07..3a0fecb 100644 --- a/app/components/mission-statement.js +++ b/app/components/mission-statement.js @@ -13,11 +13,11 @@ import html from "choo/html"; export default () => html` <div class="component--mission-statement"> <strong class="component--mission-statement__title">Mission Statement</strong> - To create a market for accessing and publishing information<sup><a class="__plain" href="#footnote-1" title="First footnote of our mission statement">1</a></sup> - that is global<sup><a class="__plain" href="#footnote-2" title="Second footnote of our mission statement">2</a></sup>, - decentralized<sup><a class="__plain" href="#footnote-3" title="Third footnote of our mission statement">3</a></sup>, - robust<sup><a class="__plain" href="#footnote-4" title="Fourth footnote of our mission statement">4</a></sup>, - optimal<sup><a class="__plain" href="#footnote-5" title="Fifth footnote of our mission statement">5</a></sup> - and complete<sup><a class="__plain" href="#footnote-6" title="Sixth footnote of our mission statement">6</a></sup>. + To create a market for accessing and publishing information<sup><a href="#footnote-1" title="First footnote of our mission statement">1</a></sup> + that is global<sup><a href="#footnote-2" title="Second footnote of our mission statement">2</a></sup>, + decentralized<sup><a href="#footnote-3" title="Third footnote of our mission statement">3</a></sup>, + robust<sup><a href="#footnote-4" title="Fourth footnote of our mission statement">4</a></sup>, + optimal<sup><a href="#footnote-5" title="Fifth footnote of our mission statement">5</a></sup> + and complete<sup><a href="#footnote-6" title="Sixth footnote of our mission statement">6</a></sup>. </div> `; From 723966778492df68193e6b950bd325a653d501ac Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman <kauffj@gmail.com> Date: Mon, 8 Oct 2018 10:36:09 -0400 Subject: [PATCH 3/5] convert markdown logic to re-usable component --- app/components/ecosystem/module-lbrycrd.js | 20 +---- app/components/markdown.js | 82 +++++++++++++++++++ app/sass/init/_markdown.scss | 2 +- app/views/redirect.js | 95 +++------------------- documents/partials/lbrycrd.md | 16 ++++ 5 files changed, 114 insertions(+), 101 deletions(-) create mode 100644 app/components/markdown.js create mode 100644 documents/partials/lbrycrd.md diff --git a/app/components/ecosystem/module-lbrycrd.js b/app/components/ecosystem/module-lbrycrd.js index 331cf19..744620a 100644 --- a/app/components/ecosystem/module-lbrycrd.js +++ b/app/components/ecosystem/module-lbrycrd.js @@ -1,6 +1,6 @@ "use strict"; - +import markdown from "../markdown"; // E X P O R T @@ -20,23 +20,7 @@ module.exports = exports = () => ` </h2> <div class="ecosystem__module__details"> - <p><em>This section assumes "blockchain" already means something to you. If you're totally new, the key problem solved by blockhain is the ability for distributed, disparate entities to all agree on a rivalrous state of affairs. For a more comprehensive introduction to blockchain, try starting [here]</em></p> - - <p>LBRY uses a public, proof-of-work blockchain that is very similar to Bitcoin. The blockchain is the foundation of the protocol stack.</p> - - <p>The most salient feature of the LBRY blockchain is the association of a string of characters (a "name") with a structured set of metadata. This name can be accessed as a LBRY URL, e.g. <a class="__plain" href="/playground?url=hellolbry"><code>lbry://hellolbry</code></a></p> - - <p>The LBRY blockchain stores names and metadata in a Merkle tree. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain.</p> - - <p>The metadata contains information about the content, such as the title, creator, price (if any), and a unique signature allowing the actual content to be fetched from the data network, the next level in the LBRY stack.</p> - - <h3>Additional Resources</h3> - <ul> - <li>See the <a href="/whitepaper" title="Whitepaper">Whitepaper</a> for a more comprehensive introduction to the LBRY blockchain.</li> - <li>See the <a href="/resources" title="">Resources</a> for documentation about the LBRY blockchain, including its API.</li> - <li>See [[Naming]] for learning more about LBRY URLs and how they work.</li> - <li>See [[Identities]] for learning how the LBRY blockchain handles publisher identities.</li> - </ul> + ${markdown("./documents/partials/lbrycrd.md")} </div> </div> `; diff --git a/app/components/markdown.js b/app/components/markdown.js new file mode 100644 index 0000000..9004433 --- /dev/null +++ b/app/components/markdown.js @@ -0,0 +1,82 @@ +"use strict"; + +import decamelize from "decamelize"; +import exists from "fs-exists-sync"; +import fs from "graceful-fs"; +import fm from "front-matter"; +import html from "choo/html"; +import path from "path"; +import raw from "choo/html/raw"; +import { require as local } from "app-root-path"; + +const numberRegex = /^[0-9]/g; +const md = require("markdown-it")({ + html: true, + typographer: true +}).use(local("app/modules/markdown-it-sup")) + .use(require("markdown-it-anchor"), { + slugify: stringToSlugify => { + let finalString = stringToSlugify + .toLowerCase() + .replace(/\s\/\s/g, "-") + .replace(/\s/g, "-") + .replace(/%/g, "") + .replace(/\(/g, "") + .replace(/\)/g, "") + .replace(/,/g, ""); + + if (finalString.match(numberRegex)) finalString = `_${finalString}`; + return finalString; + } + }); + + + +export default path => { + + const markdownFile = fs.readFileSync(path, "utf-8"); + const markdownFileDetails = fm(markdownFile); + const renderedMarkdown = md.render(markdownFileDetails.body); + const updatedMarkdown = wikiFinder(partialFinder(renderedMarkdown)); + + return html` + <div class="page__markup">${raw(updatedMarkdown)}</div> + `; +}; + +function partialFinder(markdownBody) { + const regexToFindPartials = /<\w+ ?\/>/g; + const partials = markdownBody.match(regexToFindPartials); + + if (!partials) return markdownBody; + + for (const partial of partials) { + const filename = decamelize(partial, "-").replace("<", "") + .replace("/>", "") + .trim(); + const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist + + if (!fileExistsTest) + markdownBody = markdownBody.replace(partial, ""); + + else { + const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`)); + + if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction); + else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`); + } + } + + return markdownBody; +} + +function wikiFinder(markdownBody) { + return markdownBody.replace(/\[\[([\w\s/-]+)\]\]/g, (match, p1) => { + const label = p1.trim(); + const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-")); + + return label ? + `<a href="${url}" class="link--glossary">${label}</a>` : + match.input; + }); +} diff --git a/app/sass/init/_markdown.scss b/app/sass/init/_markdown.scss index 901b467..c07dc61 100644 --- a/app/sass/init/_markdown.scss +++ b/app/sass/init/_markdown.scss @@ -184,7 +184,7 @@ } } - a:not(.__button-black):not(.button):not(.header-anchor):not(.newsletter-standalone__submit):not(.__plain) { + a:not(.__button-black):not(.button) { @include underline($teal, $white); color: $teal; diff --git a/app/views/redirect.js b/app/views/redirect.js index 16efdf6..708a3c0 100644 --- a/app/views/redirect.js +++ b/app/views/redirect.js @@ -4,60 +4,31 @@ // P A C K A G E S -import decamelize from "decamelize"; -import exists from "fs-exists-sync"; -import fm from "front-matter"; import fs from "graceful-fs"; import html from "choo/html"; -import path from "path"; +import fm from "front-matter"; import { require as local } from "app-root-path"; import raw from "choo/html/raw"; -// V A R I A B L E - -const numberRegex = /^[0-9]/g; - // U T I L S -const redirect404 = local("app/modules/redirect-404"); - -const md = require("markdown-it")({ - html: true, - typographer: true -}).use(local("app/modules/markdown-it-sup")) - .use(require("markdown-it-anchor"), { - slugify: stringToSlugify => { - let finalString = stringToSlugify - .toLowerCase() - .replace(/\s\/\s/g, "-") - .replace(/\s/g, "-") - .replace(/%/g, "") - .replace(/\(/g, "") - .replace(/\)/g, "") - .replace(/,/g, ""); - - if (finalString.match(numberRegex)) finalString = `_${finalString}`; - return finalString; - } - }); +const markdown = local("/app/components/markdown"); +const redirect404 = local("/app/modules/redirect-404"); // E X P O R T module.exports = exports = (state, emit) => { // eslint-disable-line - let path; + const partialPath = state.route === "resources/*" ? `resources/${state.params.wildcard}` : state.params.wildcard; + const path = `./documents/${partialPath}.md`; - if (state.route === "resources/*") path = `resources/${state.params.wildcard}`; - else path = state.params.wildcard; - - if (!fs.existsSync(`./documents/${path}.md`)) + if (!fs.existsSync(path)) { return redirect404(state); + } - const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8"); + const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); - const renderedMarkdown = md.render(markdownFileDetails.body); - const updatedMarkdown = wikiFinder(partialFinder(renderedMarkdown)); if (markdownFileDetails.attributes.meta) { const customMetadata = {}; @@ -72,11 +43,12 @@ module.exports = exports = (state, emit) => { // eslint-disable-line state.lbry = customMetadata; } + // below should be refactored into components let pageScript = ""; - if (path === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; - if (path === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>"; - if (path === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>"; + if (partialPath === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; + if (partialPath === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>"; + if (partialPath === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>"; return html` <article class="page" itemtype="http://schema.org/BlogPosting"> @@ -90,51 +62,10 @@ module.exports = exports = (state, emit) => { // eslint-disable-line <section class="page__content" itemprop="articleBody"> <div class="inner-wrap"> - <div class="page__markup">${raw(updatedMarkdown)}</div> + ${markdown(path)} ${raw(pageScript)} </div> </section> </article> `; }; - - - -// H E L P E R S - -function partialFinder(markdownBody) { - const regexToFindPartials = /<\w+ ?\/>/g; - const partials = markdownBody.match(regexToFindPartials); - - if (!partials) return markdownBody; - - for (const partial of partials) { - const filename = decamelize(partial, "-").replace("<", "") - .replace("/>", "") - .trim(); - const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist - - if (!fileExistsTest) - markdownBody = markdownBody.replace(partial, ""); - - else { - const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`)); - - if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction); - else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`); - } - } - - return markdownBody; -} - -function wikiFinder(markdownBody) { - return markdownBody.replace(/\[\[([\w\s/-]+)\]\]/g, (match, p1) => { - const label = p1.trim(); - const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-")); - - return label ? - `<a href="${url}" class="link--glossary">${label}</a>` : - match.input; - }); -} diff --git a/documents/partials/lbrycrd.md b/documents/partials/lbrycrd.md new file mode 100644 index 0000000..683ffa1 --- /dev/null +++ b/documents/partials/lbrycrd.md @@ -0,0 +1,16 @@ +_This section assumes "blockchain" already means something to you. If you're totally new, the key problem solved by blockhain is the ability for distributed, disparate entities to all agree on a rivalrous state of affairs. For a more comprehensive introduction to blockchain, try starting [here](https://lopp.net/bitcoin.html)_ + +LBRY uses a public, proof-of-work blockchain that is very similar to Bitcoin. The blockchain is the foundation of the protocol stack. + +The most salient feature of the LBRY blockchain is the association of a normalized string of characters (a "name") with a structured set of metadata. This coupling is called a [[claim]]. The content referenced by a claim can be accessed as a LBRY URL, e.g. [lbry://hellolbry](/playground?url=hellolbry). + +The LBRY blockchain stores names and metadata in a parallel [[Merkle tree]], separate from the tree used to store transaction data. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain. + +The metadata contains information about the content, such as the title, creator, price (if any), and a unique signature allowing the actual content to be fetched from the data network, the next level in the LBRY stack. + +### Additional Resources + +* See the [Whitepaper](/whitepaper "Whitepaper") for a more comprehensive introduction to the LBRY blockchain. +* See the [Resources](/resources) for documentation about the LBRY blockchain, including its API. +* See [[Naming]] for learning more about LBRY URLs and how they work. +* See [[Identities]] for learning how the LBRY blockchain handles publisher identities. From 8a20651804d2cb8a22d7e61cf4919b9569c65b2d Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman <kauffj@gmail.com> Date: Mon, 8 Oct 2018 10:38:11 -0400 Subject: [PATCH 4/5] remove unnecessary class --- app/components/mission-statement.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/mission-statement.js b/app/components/mission-statement.js index b0f2a07..3a0fecb 100644 --- a/app/components/mission-statement.js +++ b/app/components/mission-statement.js @@ -13,11 +13,11 @@ import html from "choo/html"; export default () => html` <div class="component--mission-statement"> <strong class="component--mission-statement__title">Mission Statement</strong> - To create a market for accessing and publishing information<sup><a class="__plain" href="#footnote-1" title="First footnote of our mission statement">1</a></sup> - that is global<sup><a class="__plain" href="#footnote-2" title="Second footnote of our mission statement">2</a></sup>, - decentralized<sup><a class="__plain" href="#footnote-3" title="Third footnote of our mission statement">3</a></sup>, - robust<sup><a class="__plain" href="#footnote-4" title="Fourth footnote of our mission statement">4</a></sup>, - optimal<sup><a class="__plain" href="#footnote-5" title="Fifth footnote of our mission statement">5</a></sup> - and complete<sup><a class="__plain" href="#footnote-6" title="Sixth footnote of our mission statement">6</a></sup>. + To create a market for accessing and publishing information<sup><a href="#footnote-1" title="First footnote of our mission statement">1</a></sup> + that is global<sup><a href="#footnote-2" title="Second footnote of our mission statement">2</a></sup>, + decentralized<sup><a href="#footnote-3" title="Third footnote of our mission statement">3</a></sup>, + robust<sup><a href="#footnote-4" title="Fourth footnote of our mission statement">4</a></sup>, + optimal<sup><a href="#footnote-5" title="Fifth footnote of our mission statement">5</a></sup> + and complete<sup><a href="#footnote-6" title="Sixth footnote of our mission statement">6</a></sup>. </div> `; From dbd3da4680ffb97ba45f62f748415f338f08b98d 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?= <netopwibby@thenetwork.email> Date: Thu, 11 Oct 2018 17:10:32 -0500 Subject: [PATCH 5/5] Some fixes --- app/components/ecosystem/module-lbrycrd.js | 12 +++++++++++- app/components/markdown.js | 22 ++++++++++++++++++---- app/modules/redirect-404.js | 4 ++-- app/views/redirect.js | 7 +++---- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/components/ecosystem/module-lbrycrd.js b/app/components/ecosystem/module-lbrycrd.js index 744620a..21524ab 100644 --- a/app/components/ecosystem/module-lbrycrd.js +++ b/app/components/ecosystem/module-lbrycrd.js @@ -1,6 +1,16 @@ "use strict"; -import markdown from "../markdown"; + + +// P A C K A G E + +import { require as local } from "app-root-path"; + +// U T I L + +const markdown = local("/app/components/markdown").default; + + // E X P O R T diff --git a/app/components/markdown.js b/app/components/markdown.js index 9004433..3939fd5 100644 --- a/app/components/markdown.js +++ b/app/components/markdown.js @@ -1,19 +1,28 @@ "use strict"; + + +// P A C K A G E S + import decamelize from "decamelize"; import exists from "fs-exists-sync"; -import fs from "graceful-fs"; import fm from "front-matter"; +import fs from "graceful-fs"; import html from "choo/html"; import path from "path"; import raw from "choo/html/raw"; import { require as local } from "app-root-path"; +// V A R I A B L E + const numberRegex = /^[0-9]/g; + +// U T I L + const md = require("markdown-it")({ html: true, typographer: true -}).use(local("app/modules/markdown-it-sup")) +}).use(local("/app/modules/markdown-it-sup")) .use(require("markdown-it-anchor"), { slugify: stringToSlugify => { let finalString = stringToSlugify @@ -32,8 +41,9 @@ const md = require("markdown-it")({ -export default path => { +// E X P O R T +export default path => { const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); const renderedMarkdown = md.render(markdownFileDetails.body); @@ -44,6 +54,10 @@ export default path => { `; }; + + +// H E L P E R + function partialFinder(markdownBody) { const regexToFindPartials = /<\w+ ?\/>/g; const partials = markdownBody.match(regexToFindPartials); @@ -76,7 +90,7 @@ function wikiFinder(markdownBody) { const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-")); return label ? - `<a href="${url}" class="link--glossary">${label}</a>` : + `<a class="link--glossary" href="${url}">${label}</a>` : match.input; }); } diff --git a/app/modules/redirect-404.js b/app/modules/redirect-404.js index 891e529..52efad7 100644 --- a/app/modules/redirect-404.js +++ b/app/modules/redirect-404.js @@ -9,8 +9,8 @@ import { require as local } from "app-root-path"; // U T I L S -const page404 = local("app/views/404.js"); -const redirects = local("app/data/redirects.json"); +const page404 = local("/app/views/404.js"); +const redirects = local("/app/data/redirects.json"); diff --git a/app/views/redirect.js b/app/views/redirect.js index 708a3c0..b71a211 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 -const markdown = local("/app/components/markdown"); +const markdown = local("/app/components/markdown").default; const redirect404 = local("/app/modules/redirect-404"); @@ -23,9 +23,8 @@ module.exports = exports = (state, emit) => { // eslint-disable-line const partialPath = state.route === "resources/*" ? `resources/${state.params.wildcard}` : state.params.wildcard; const path = `./documents/${partialPath}.md`; - if (!fs.existsSync(path)) { + if (!fs.existsSync(path)) return redirect404(state); - } const markdownFile = fs.readFileSync(path, "utf-8"); const markdownFileDetails = fm(markdownFile); @@ -49,7 +48,7 @@ module.exports = exports = (state, emit) => { // eslint-disable-line if (partialPath === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; if (partialPath === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>"; if (partialPath === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>"; - + // console.log(markdown(path)); return html` <article class="page" itemtype="http://schema.org/BlogPosting"> <header class="page__header">