Closes #98 and other minor fixes
This commit is contained in:
parent
d6c7202f31
commit
c4ebf418ce
7 changed files with 56 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// P A C K A G E S
|
// V A R I A B L E S
|
||||||
|
|
||||||
const regexForIds = /\(#.*\)/g;
|
const regexForIds = /\(#.*\)/g;
|
||||||
const regexForTextBeforeLink = /^.*(?=\()/g;
|
const regexForTextBeforeLink = /^.*(?=\()/g;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
scrollToElementOnLoad();
|
scrollToElementOnLoad();
|
||||||
|
|
||||||
$("a[href^=http]").each(function () { // Automatically open external links in new tabs
|
$("a[href^=http]").each(function () { // Automatically open external links in new tabs
|
||||||
|
@ -11,7 +10,6 @@ $(function () {
|
||||||
$(this).attr("target", "_blank");
|
$(this).attr("target", "_blank");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,11 +77,6 @@ fastify.ready(err => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
fastify.ws.on("connection", socket => {
|
fastify.ws.on("connection", socket => {
|
||||||
socket.send(JSON.stringify({ // TODO: Remove this
|
|
||||||
"message": "notification",
|
|
||||||
"details": "Welcome"
|
|
||||||
}));
|
|
||||||
|
|
||||||
socket.on("message", data => {
|
socket.on("message", data => {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
|
||||||
|
@ -147,6 +142,7 @@ function fetchMetadata(data, socket) {
|
||||||
|
|
||||||
const allowedClaims = [
|
const allowedClaims = [
|
||||||
"fortnite-top-stream-moments-nickatnyte",
|
"fortnite-top-stream-moments-nickatnyte",
|
||||||
|
"hellolbry",
|
||||||
"itsadisaster",
|
"itsadisaster",
|
||||||
"six",
|
"six",
|
||||||
"unbubbled1-1"
|
"unbubbled1-1"
|
||||||
|
@ -203,7 +199,7 @@ function fetchMetadata(data, socket) {
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
body = JSON.parse(body);
|
body = JSON.parse(body);
|
||||||
console.log(body);
|
// console.log(body);
|
||||||
resolve(body);
|
resolve(body);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
// https://github.com/lbryio/lbry/blob/master/docs/api.json
|
||||||
// https://www.npmjs.com/package/make-fetch-happen
|
// https://www.npmjs.com/package/make-fetch-happen
|
||||||
|
|
|
@ -73,6 +73,8 @@ module.exports = exports = () => async state => {
|
||||||
const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8");
|
const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8");
|
||||||
const markdownFileDetails = fm(markdownFile);
|
const markdownFileDetails = fm(markdownFile);
|
||||||
const renderedMarkdown = md.render(partialFinder(markdownFileDetails.body));
|
const renderedMarkdown = md.render(partialFinder(markdownFileDetails.body));
|
||||||
|
let newMetadata = "";
|
||||||
|
if (markdownFileDetails.attributes.meta) newMetadata = markdownFileDetails.attributes.meta;
|
||||||
|
|
||||||
let pageScript = "";
|
let pageScript = "";
|
||||||
if (path === "overview") pageScript = "<script>" + fs.readFileSync("./views/partials/ecosystem-scripts.js", "utf-8") + "</script>";
|
if (path === "overview") pageScript = "<script>" + fs.readFileSync("./views/partials/ecosystem-scripts.js", "utf-8") + "</script>";
|
||||||
|
@ -92,6 +94,7 @@ module.exports = exports = () => async state => {
|
||||||
<div class="inner-wrap">
|
<div class="inner-wrap">
|
||||||
${raw(renderedMarkdown)}
|
${raw(renderedMarkdown)}
|
||||||
${raw(pageScript)}
|
${raw(pageScript)}
|
||||||
|
${newMetadata.length ? raw(updateMetadata(newMetadata)) : ""}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
|
@ -100,7 +103,28 @@ module.exports = exports = () => async state => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// H E L P E R
|
// H E L P E R S
|
||||||
|
|
||||||
|
function createMetaTags(metaObject) {
|
||||||
|
/**
|
||||||
|
NOTE:
|
||||||
|
For Markdown files, the custom yaml should look like this:
|
||||||
|
|
||||||
|
meta:
|
||||||
|
- description: Description goes here
|
||||||
|
|
||||||
|
This does not currently work with parameters like "og:image"
|
||||||
|
// https://github.com/lbryio/lbry.tech/issues/30
|
||||||
|
*/
|
||||||
|
|
||||||
|
let html = "";
|
||||||
|
|
||||||
|
for (const metaProperty in metaObject) {
|
||||||
|
html += `document.getElementsByTagName("meta")["${metaProperty}"].content = "${metaObject[metaProperty]}";\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
function partialFinder(markdownBody) {
|
function partialFinder(markdownBody) {
|
||||||
const regexToFindPartials = /<\w+\/>/g;
|
const regexToFindPartials = /<\w+\/>/g;
|
||||||
|
@ -126,3 +150,17 @@ function partialFinder(markdownBody) {
|
||||||
|
|
||||||
return dedent(markdownBody); // partials get rendered as code snippets w/o `dedent`
|
return dedent(markdownBody); // partials get rendered as code snippets w/o `dedent`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateMetadata(metadataDetails) {
|
||||||
|
const generatedMetadata = [];
|
||||||
|
|
||||||
|
for (const metadataDetail of metadataDetails) {
|
||||||
|
generatedMetadata.push(createMetaTags(metadataDetail));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dedent`
|
||||||
|
<script>
|
||||||
|
${generatedMetadata.join("")}
|
||||||
|
</script>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ module.exports = exports = class Ecosystem extends Component {
|
||||||
|
|
||||||
<p>The LBRY blockchain is a public, proof-of-work of work blockchain consensus. It is the foundation of the protocol stack.</p>
|
<p>The LBRY blockchain is a public, proof-of-work of work blockchain consensus. It is the foundation of the protocol stack.</p>
|
||||||
|
|
||||||
<p>The most salient feature of the LBRY blockchain is the association of a normalized character string with up to 8KB of metadata. This string of characters forms a LBRY URL, e.g. <a class="__plain" href="/tour?url=lbry://hellolbry"><code>lbry://hellolbry</code></a></p>
|
<p>The most salient feature of the LBRY blockchain is the association of a normalized character string with up to 8KB of metadata. This string of characters forms a LBRY URL, e.g. <a class="__plain" href="/tour?url=hellolbry"><code>lbry://hellolbry</code></a></p>
|
||||||
|
|
||||||
<p>The LBRY blockchain contains two parallel [[Merkle Tree]]s, one for transactions (ala Bitcoin) and one for storing LBRY URLs and metadata. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain.</p>
|
<p>The LBRY blockchain contains two parallel [[Merkle Tree]]s, one for transactions (ala Bitcoin) and one for storing LBRY URLs and metadata. This allows LBRY URLs to be trustfully resolved even without a full copy of the blockchain.</p>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,13 @@ initializeTour();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (window.location.href.search && window.location.href.split("?url=")[1]) { // pre-fill Tour if search parameter exists
|
||||||
|
const searchParameter = window.location.href.split("?url=")[1];
|
||||||
|
fetchMetadata(1, searchParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("body").on("click", "[data-action]", event => {
|
$("body").on("click", "[data-action]", event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const data = event.currentTarget.dataset;
|
const data = event.currentTarget.dataset;
|
||||||
|
|
Loading…
Add table
Reference in a new issue