Updated dep

This commit is contained in:
ポール ウェッブ 2018-10-06 15:53:01 -05:00
parent b033619612
commit babf056f7c
13 changed files with 157 additions and 131 deletions

View file

@ -8,6 +8,7 @@ initializePlayground();
if (window.location.href.search && window.location.href.split("?url=")[1]) { // pre-fill example one if search parameter exists if (window.location.href.search && window.location.href.split("?url=")[1]) { // pre-fill example one if search parameter exists
const searchParameter = window.location.href.split("?url=")[1]; const searchParameter = window.location.href.split("?url=")[1];
fetchMetadata(1, searchParameter); fetchMetadata(1, searchParameter);
} }
@ -102,7 +103,7 @@ function detectLanguageAndUpdate() { // eslint-disable-line
function debounce(func, wait, immediate) { function debounce(func, wait, immediate) {
let timeout; let timeout;
return function () { return function() {
const context = this; const context = this;
const args = arguments; const args = arguments;
@ -112,6 +113,7 @@ function debounce(func, wait, immediate) {
}; };
const callNow = immediate && !timeout; const callNow = immediate && !timeout;
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(later, wait); timeout = setTimeout(later, wait);
@ -126,7 +128,7 @@ function initializePlayground() {
document.querySelector(".playground__navigation__example:nth-child(1)").classList.add("active"); document.querySelector(".playground__navigation__example:nth-child(1)").classList.add("active");
send(JSON.stringify({ send(JSON.stringify({
"message": "landed on playground" message: "landed on playground"
})); }));
setTimeout(() => { setTimeout(() => {
@ -142,10 +144,10 @@ function fetchMetadata(exampleNumber, data) {
switch(exampleNumber) { switch(exampleNumber) {
case 1: case 1:
send(JSON.stringify({ send(JSON.stringify({
"claim": data, claim: data,
"message": "fetch metadata", message: "fetch metadata",
"method": "resolve", method: "resolve",
"example": exampleNumber example: exampleNumber
})); }));
document.getElementById("fetch-claim-uri").value = data; document.getElementById("fetch-claim-uri").value = data;
@ -165,10 +167,10 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
case 2: case 2:
send(JSON.stringify({ send(JSON.stringify({
"data": data, data: data,
"message": "fetch metadata", message: "fetch metadata",
"method": "publish", method: "publish",
"example": exampleNumber example: exampleNumber
})); }));
document.getElementById("playground-results").innerHTML = ` document.getElementById("playground-results").innerHTML = `
@ -186,10 +188,10 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
case 3: case 3:
send(JSON.stringify({ send(JSON.stringify({
"claim": data, claim: data,
"message": "fetch metadata", message: "fetch metadata",
"method": "wallet_send", method: "wallet_send",
"example": exampleNumber example: exampleNumber
})); }));
document.getElementById("fetch-claim-uri").value = data; document.getElementById("fetch-claim-uri").value = data;
@ -269,7 +271,7 @@ const handleExamples = debounce(event => {
document.getElementById("playground-results").removeAttribute("style"); document.getElementById("playground-results").removeAttribute("style");
send(JSON.stringify({ send(JSON.stringify({
"message": `request for ${data.action}` message: `request for ${data.action}`
})); }));
break; break;
@ -295,7 +297,7 @@ const handleExamples = debounce(event => {
document.getElementById("playground-results").removeAttribute("style"); document.getElementById("playground-results").removeAttribute("style");
send(JSON.stringify({ send(JSON.stringify({
"message": `request for ${data.action}` message: `request for ${data.action}`
})); }));
break; break;
@ -324,7 +326,7 @@ const handleExamples = debounce(event => {
document.getElementById("playground-results").removeAttribute("style"); document.getElementById("playground-results").removeAttribute("style");
send(JSON.stringify({ send(JSON.stringify({
"message": `request for ${data.action}` message: `request for ${data.action}`
})); }));
break; break;

View file

@ -77,6 +77,6 @@ export default (state, emit) => {
// H E L P E R // H E L P E R
String.prototype.capitalize = function () { String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1); return this.charAt(0).toUpperCase() + this.slice(1);
}; };

View file

@ -29,7 +29,7 @@ if ( // Toggle beta message
localStorage.getItem("hide lbry alert") === "true" // cannot set Booleans for some reason localStorage.getItem("hide lbry alert") === "true" // cannot set Booleans for some reason
) document.querySelector("#alert-beta").style.display = "none"; ) document.querySelector("#alert-beta").style.display = "none";
document.querySelector("#close-alert").onclick = function () { document.querySelector("#close-alert").onclick = function() {
localStorage.setItem("hide lbry alert", true); localStorage.setItem("hide lbry alert", true);
document.querySelector("#alert-beta").style.display = "none"; document.querySelector("#alert-beta").style.display = "none";
}; };
@ -60,11 +60,12 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
// Newsletter // Newsletter
document.querySelector("[data-action='subscribe to newsletter']").onclick = () => { document.querySelector("[data-action='subscribe to newsletter']").onclick = () => {
const email = document.getElementById("emailAddress").value; const email = document.getElementById("emailAddress").value;
if (!validateEmail(email)) return; if (!validateEmail(email)) return;
send(JSON.stringify({ send(JSON.stringify({
"email": email, email: email,
"message": "subscribe" message: "subscribe"
})); }));
}; };
@ -88,5 +89,6 @@ function scrollToElementOnLoad() {
function validateEmail(email) { function validateEmail(email) {
const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i; const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i;
return emailRegex.test(String(email)); return emailRegex.test(String(email));
} }

View file

@ -1,14 +1,14 @@
/* global define */ /* global define */
/*! Jets.js - v0.14.1 - 2018-06-22 /* ! Jets.js - v0.14.1 - 2018-06-22
* http://NeXTs.github.com/Jets.js/ * http://NeXTs.github.com/Jets.js/
* Copyright (c) 2015 Denis Lukov; Refactored 2018 Paul Anthony Webb; Licensed MIT */ * Copyright (c) 2015 Denis Lukov; Refactored 2018 Paul Anthony Webb; Licensed MIT */
(function (root, definition) { (function(root, definition) {
if (typeof module !== "undefined") module.exports = definition(); if (typeof module !== "undefined") module.exports = definition();
else if (typeof define === "function" && typeof define.amd === "object") define(definition); else if (typeof define === "function" && typeof define.amd === "object") define(definition);
else root["Jets"] = definition(); else root["Jets"] = definition();
}(this, function () { }(this, function() {
"use strict"; "use strict";
function Jets(opts) { function Jets(opts) {
@ -21,6 +21,7 @@
}; };
const self = this; const self = this;
self.options = {}; self.options = {};
[ [
@ -58,23 +59,23 @@
self.search = (search_query, optional_column) => { self.search = (search_query, optional_column) => {
const new_search_query = const new_search_query =
self.options.callSearchManually && self.options.callSearchManually &&
typeof search_query !== "undefined" typeof search_query !== "undefined" ?
? search_query search_query :
: self.search_tag self.search_tag ?
? self.search_tag.value self.search_tag.value :
: ""; "";
if (last_search_query === (last_search_query = new_search_query)) return; if (last_search_query === (last_search_query = new_search_query)) return;
(0, self._applyCSS(last_search_query, optional_column)); (0, self._applyCSS(last_search_query, optional_column));
self.options.didSearch && self.options.didSearch(last_search_query); self.options.didSearch && self.options.didSearch(last_search_query);
}; };
self._onSearch = function (event) { self._onSearch = function(event) {
if (event.type === "keydown") return setTimeout(self.search, 0); if (event.type === "keydown") return setTimeout(self.search, 0);
self.search(); self.search();
}; };
self.destroy = function () { self.destroy = function() {
if (!self.options.callSearchManually) self._processEventListeners("remove"); if (!self.options.callSearchManually) self._processEventListeners("remove");
self._destroy(); self._destroy();
}; };
@ -88,17 +89,17 @@
Jets.prototype = { Jets.prototype = {
constructor: Jets, constructor: Jets,
_processEventListeners: function (action) { _processEventListeners: function(action) {
[ [
"change", "change",
"input", "input",
"keydown" "keydown"
].forEach(function (event_type) { ].forEach(function(event_type) {
this.search_tag[action + "EventListener"](event_type, this._onSearch); this.search_tag[action + "EventListener"](event_type, this._onSearch);
}.bind(this)); }.bind(this));
}, },
_applyCSS: function (search_query, optional_column) { _applyCSS: function(search_query, optional_column) {
const options = this.options; const options = this.options;
const search_phrase = this.replaceDiacritics( const search_phrase = this.replaceDiacritics(
@ -108,9 +109,9 @@
.replace(/\s\s+/g, " ") .replace(/\s\s+/g, " ")
).replace(/\\/g, "\\\\"); ).replace(/\\/g, "\\\\");
const words = options.searchSelectorMode const words = options.searchSelectorMode ?
? search_phrase.split(" ").filter((item, pos, arr) => arr.indexOf(item) === pos) search_phrase.split(" ").filter((item, pos, arr) => arr.indexOf(item) === pos) :
: [search_phrase]; [search_phrase];
const is_strict_selector = options.searchSelectorMode === "AND"; const is_strict_selector = options.searchSelectorMode === "AND";
const selectors = new Array(words.length); const selectors = new Array(words.length);
@ -134,27 +135,30 @@
this.styleTag.innerHTML = search_phrase.length ? css_rule : ""; this.styleTag.innerHTML = search_phrase.length ? css_rule : "";
}, },
_addStyleTag: function () { _addStyleTag: function() {
this.styleTag = document.createElement("style"); this.styleTag = document.createElement("style");
document.head.appendChild(this.styleTag); document.head.appendChild(this.styleTag);
}, },
_getText: function (tag) { _getText: function(tag) {
return tag && (tag.textContent || tag.innerText) || ""; return tag && (tag.textContent || tag.innerText) || "";
}, },
_sanitize: function (text) { _sanitize: function(text) {
return this.replaceDiacritics(text).trim().replace(/\s+/g, " ").toLowerCase(); return this.replaceDiacritics(text).trim()
.replace(/\s+/g, " ")
.toLowerCase();
}, },
_getContentTags: function (query) { _getContentTags: function(query) {
return Array.prototype.slice.call(this.content_tag).reduce((all, elem) => { return Array.prototype.slice.call(this.content_tag).reduce((all, elem) => {
return all.concat(Array.prototype.slice.call(elem.querySelectorAll(query || ":scope > *"))); return all.concat(Array.prototype.slice.call(elem.querySelectorAll(query || ":scope > *")));
}, []); }, []);
}, },
_handleSpecificColumns: function (tag, set) { _handleSpecificColumns: function(tag, set) {
const self = this; const self = this;
if (!self.options.searchInSpecificColumn) return; if (!self.options.searchInSpecificColumn) return;
Array.prototype.slice.call(tag.children).map((children, i) => { Array.prototype.slice.call(tag.children).map((children, i) => {
@ -168,7 +172,7 @@
}); });
}, },
_setJets: function (query, force) { _setJets: function(query, force) {
const self = this; const self = this;
const tags = self._getContentTags(force ? "" : query); const tags = self._getContentTags(force ? "" : query);
let text; let text;
@ -176,19 +180,19 @@
for (const tag of tags) { for (const tag of tags) {
if (tag.hasAttribute("data-jets") && !force) continue; if (tag.hasAttribute("data-jets") && !force) continue;
text = this.options.manualContentHandling text = this.options.manualContentHandling ?
? this.options.manualContentHandling(tag) this.options.manualContentHandling(tag) :
: self.options.columns && self.options.columns &&
self.options.columns.length self.options.columns.length ?
? self.options.columns.map(column => self._getText(tag.children[column])).join(" ") self.options.columns.map(column => self._getText(tag.children[column])).join(" ") :
: self._getText(tag); self._getText(tag);
tag.setAttribute("data-jets", self._sanitize(text)); tag.setAttribute("data-jets", self._sanitize(text));
self._handleSpecificColumns(tag, "set"); self._handleSpecificColumns(tag, "set");
} }
}, },
replaceDiacritics: function (text) { replaceDiacritics: function(text) {
const diacritics = this.options.diacriticsMap; const diacritics = this.options.diacriticsMap;
for (const letter in diacritics) if (diacritics.hasOwnProperty(letter)) { for (const letter in diacritics) if (diacritics.hasOwnProperty(letter)) {
@ -200,11 +204,11 @@
return text; return text;
}, },
update: function (force) { update: function(force) {
this._setJets(":scope > :not([data-jets])", force); this._setJets(":scope > :not([data-jets])", force);
}, },
_destroy: function () { _destroy: function() {
this.styleTag.parentNode && document.head.removeChild(this.styleTag); this.styleTag.parentNode && document.head.removeChild(this.styleTag);
const tags = this._getContentTags(); const tags = this._getContentTags();
@ -217,20 +221,22 @@
// :scope polyfill // :scope polyfill
// https://stackoverflow.com/a/17989803/1221082 // https://stackoverflow.com/a/17989803/1221082
;(function (doc, proto) { ;(function(doc, proto) {
try { try {
doc.querySelector(":scope body"); doc.querySelector(":scope body");
} catch (err) { } catch (err) {
["querySelector", "querySelectorAll"].forEach(method => { ["querySelector", "querySelectorAll"].forEach(method => {
const nativ = proto[method]; const nativ = proto[method];
proto[method] = function (selectors) { proto[method] = function(selectors) {
if (/(^|,)\s*:scope/.test(selectors)) { if (/(^|,)\s*:scope/.test(selectors)) {
const id = this.getAttribute("id"); const id = this.getAttribute("id");
this.id = "ID_" + Date.now(); this.id = "ID_" + Date.now();
selectors = selectors.replace(/((^|,)\s*):scope/g, "$1#" + this.getAttribute("id")); selectors = selectors.replace(/((^|,)\s*):scope/g, "$1#" + this.getAttribute("id"));
const result = doc[method](selectors); const result = doc[method](selectors);
this.id = id; this.id = id;
return result; return result;

View file

@ -44,9 +44,9 @@ module.exports = exports = (data, socket) => {
let apiRequestMethod = ""; let apiRequestMethod = "";
if (allowedMethods.indexOf(resolveMethod) < 0) return socket.send(JSON.stringify({ if (allowedMethods.indexOf(resolveMethod) < 0) return socket.send(JSON.stringify({
"details": "Unallowed resolve method for tutorial", details: "Unallowed resolve method for tutorial",
"message": "notification", message: "notification",
"type": "error" type: "error"
})); }));
@ -73,9 +73,9 @@ module.exports = exports = (data, socket) => {
return uploadImage(body.file_path).then(uploadResponse => { return uploadImage(body.file_path).then(uploadResponse => {
if (!uploadResponse.status || uploadResponse.status !== "ok") { if (!uploadResponse.status || uploadResponse.status !== "ok") {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"details": "Image upload failed", details: "Image upload failed",
"message": "notification", message: "notification",
"type": "error" type: "error"
})); }));
if (process.env.NODE_ENV !== "development") { if (process.env.NODE_ENV !== "development") {
@ -94,9 +94,9 @@ module.exports = exports = (data, socket) => {
return publishMeme(body).then(publishResponse => { return publishMeme(body).then(publishResponse => {
if (publishResponse.error) { if (publishResponse.error) {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"details": "Meme publish failed", details: "Meme publish failed",
"message": "notification", message: "notification",
"type": "error" type: "error"
})); }));
if (process.env.NODE_ENV !== "development") { if (process.env.NODE_ENV !== "development") {
@ -126,14 +126,14 @@ module.exports = exports = (data, socket) => {
`; `;
return socket.send(JSON.stringify({ return socket.send(JSON.stringify({
"example": data.example, example: data.example,
"html": raw(` html: raw(`
<h3>Response</h3> <h3>Response</h3>
${explorerNotice} ${explorerNotice}
<pre><code class="language-json">${renderedCode}</code></pre> <pre><code class="language-json">${renderedCode}</code></pre>
`), `),
"message": "show result", message: "show result",
"selector": `#example${data.example}-result` selector: `#example${data.example}-result`
})); }));
}); });
}); });
@ -160,13 +160,13 @@ module.exports = exports = (data, socket) => {
if (!approvedIds.includes(claimAddress)) { if (!approvedIds.includes(claimAddress)) {
return socket.send(JSON.stringify({ return socket.send(JSON.stringify({
"example": data.example, example: data.example,
"html": raw(` html: raw(`
<h3>Response</h3> <h3>Response</h3>
<pre><code class="language-text">Tipping creators not in the whitelist for this example is not allowed.</code></pre> <pre><code class="language-text">Tipping creators not in the whitelist for this example is not allowed.</code></pre>
`), `),
"message": "show result", message: "show result",
"selector": `#example${data.example}-result` selector: `#example${data.example}-result`
})); }));
} }
@ -227,14 +227,14 @@ module.exports = exports = (data, socket) => {
); );
return socket.send(JSON.stringify({ return socket.send(JSON.stringify({
"example": data.example, example: data.example,
"html": raw(` html: raw(`
<h3>Response</h3> <h3>Response</h3>
${explorerNotice} ${explorerNotice}
<pre><code class="language-json">${renderedCode}</code></pre> <pre><code class="language-json">${renderedCode}</code></pre>
`), `),
"message": "show result", message: "show result",
"selector": `#example${data.example}-result` selector: `#example${data.example}-result`
})); }));
} }

View file

@ -280,7 +280,10 @@ function generateGitHubFeed(displayGitHubFeed) {
displayGitHubFeed(` displayGitHubFeed(`
<h3>GitHub</h3> <h3>GitHub</h3>
<h5 class="last-updated">Last updated: ${new Date().format("YYYY-MM-DD").replace(/-/g, "&middot;")} at ${new Date().add(-4, "hours").format("UTC:H:mm:ss A").toLowerCase()} EST</h5> <h5 class="last-updated">Last updated: ${new Date().format("YYYY-MM-DD")
.replace(/-/g, "&middot;")} at ${new Date().add(-4, "hours")
.format("UTC:H:mm:ss A")
.toLowerCase()} EST</h5>
${renderedEvents.join("")} ${renderedEvents.join("")}
`); `);
@ -336,7 +339,8 @@ function updateGithubFeed() {
else callback(); else callback();
}); });
}, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events }, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events
}).catch(err => { })
.catch(err => {
logSlackError( logSlackError(
"\n" + "\n" +
"> *GITHUB FEED ERROR:* ```" + JSON.parse(JSON.stringify(err)) + "```" + "\n" + "> *GITHUB FEED ERROR:* ```" + JSON.parse(JSON.stringify(err)) + "```" + "\n" +

View file

@ -12,5 +12,6 @@ const crypto = require("crypto");
module.exports = exports = len => { module.exports = exports = len => {
if (!Number.isFinite(len)) throw new TypeError("Expected a finite number"); if (!Number.isFinite(len)) throw new TypeError("Expected a finite number");
return crypto.randomBytes(Math.ceil(len / 2)).toString("hex").slice(0, len); return crypto.randomBytes(Math.ceil(len / 2)).toString("hex")
.slice(0, len);
}; };

View file

@ -59,6 +59,7 @@ function superscript(state, silent) {
if (content.match(regexForIds)) { if (content.match(regexForIds)) {
const theLink = supText.match(regexForIds)[0].replace("(#", "").replace(")", ""); const theLink = supText.match(regexForIds)[0].replace("(#", "").replace(")", "");
token.attrPush([ "id", theLink ]); token.attrPush([ "id", theLink ]);
} }
@ -66,6 +67,7 @@ function superscript(state, silent) {
if (content.match(regexForIds)) { if (content.match(regexForIds)) {
const theText = supText.match(regexForTextBeforeLink)[0]; const theText = supText.match(regexForTextBeforeLink)[0];
token.content = theText; token.content = theText;
} else token.content = supText; } else token.content = supText;

View file

@ -29,9 +29,9 @@ module.exports = exports = (socket, action) => {
case (action.message === "landed on homepage"): case (action.message === "landed on homepage"):
generateGitHubFeed(result => { generateGitHubFeed(result => {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"html": result, html: result,
"message": "updated html", message: "updated html",
"selector": "#github-feed" selector: "#github-feed"
})); }));
}); });
break; break;
@ -39,9 +39,9 @@ module.exports = exports = (socket, action) => {
case (action.message === "landed on playground"): case (action.message === "landed on playground"):
generateContent(1, result => { generateContent(1, result => {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"html": result, html: result,
"message": "updated html", message: "updated html",
"selector": "#playground-loader" selector: "#playground-loader"
})); }));
}); });
break; break;
@ -49,9 +49,9 @@ module.exports = exports = (socket, action) => {
case (action.message === "request for playground, example 1"): case (action.message === "request for playground, example 1"):
generateContent(1, result => { generateContent(1, result => {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"html": result, html: result,
"message": "updated html", message: "updated html",
"selector": "#playground-loader" selector: "#playground-loader"
})); }));
}); });
break; break;
@ -63,9 +63,9 @@ module.exports = exports = (socket, action) => {
case (action.message === "request for playground, example 3"): case (action.message === "request for playground, example 3"):
generateContent(3, result => { generateContent(3, result => {
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"html": result, html: result,
"message": "updated html", message: "updated html",
"selector": "#playground-loader" selector: "#playground-loader"
})); }));
}); });
break; break;
@ -291,10 +291,10 @@ function generateMemeCreator(socket) {
`; `;
return socket.send(JSON.stringify({ return socket.send(JSON.stringify({
"example": 2, example: 2,
"html": memeCreator, html: memeCreator,
"message": "updated html", message: "updated html",
"selector": "#playground-loader" selector: "#playground-loader"
})); }));
} }
@ -315,9 +315,9 @@ function newsletterSubscribe(data, socket) {
const email = data.email; const email = data.email;
if (!validateEmail(email)) return socket.send(JSON.stringify({ if (!validateEmail(email)) return socket.send(JSON.stringify({
"html": "Your email is invalid", html: "Your email is invalid",
"message": "updated html", message: "updated html",
"selector": "#emailMessage" selector: "#emailMessage"
})); }));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -333,9 +333,9 @@ function newsletterSubscribe(data, socket) {
); );
return resolve(socket.send(JSON.stringify({ return resolve(socket.send(JSON.stringify({
"html": "Something is terribly wrong", html: "Something is terribly wrong",
"message": "updated html", message: "updated html",
"selector": "#emailMessage" selector: "#emailMessage"
}))); })));
} }
@ -349,18 +349,19 @@ function newsletterSubscribe(data, socket) {
); );
return reject(socket.send(JSON.stringify({ return reject(socket.send(JSON.stringify({
"html": body.error, html: body.error,
"message": "updated html", message: "updated html",
"selector": "#emailMessage" selector: "#emailMessage"
}))); })));
} }
return resolve(socket.send(JSON.stringify({ return resolve(socket.send(JSON.stringify({
"html": "Thank you! Please confirm subscription in your inbox.", html: "Thank you! Please confirm subscription in your inbox.",
"message": "updated html", message: "updated html",
"selector": "#emailMessage" selector: "#emailMessage"
}))); })));
}).catch(welp => { })
.catch(welp => {
if (welp.statusCode === 409) { if (welp.statusCode === 409) {
logSlackError( logSlackError(
"\n" + "\n" +
@ -369,9 +370,9 @@ function newsletterSubscribe(data, socket) {
); );
return resolve(socket.send(JSON.stringify({ return resolve(socket.send(JSON.stringify({
"html": "You have already subscribed!", html: "You have already subscribed!",
"message": "updated html", message: "updated html",
"selector": "#emailMessage" selector: "#emailMessage"
}))); })));
} }
}); });
@ -380,5 +381,6 @@ function newsletterSubscribe(data, socket) {
function validateEmail(email) { function validateEmail(email) {
const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i; const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i;
return emailRegex.test(String(email)); return emailRegex.test(String(email));
} }

View file

@ -51,7 +51,8 @@ module.exports = exports = state => parseApiFile(state.params.wildcard).then(res
<script src="/assets/scripts/plugins/jets.js"></script> <script src="/assets/scripts/plugins/jets.js"></script>
<script src="/assets/scripts/api.js"></script> <script src="/assets/scripts/api.js"></script>
`; `;
}).catch(() => { })
.catch(() => {
const redirectUrl = redirects[state.href]; const redirectUrl = redirects[state.href];
return asyncHtml` return asyncHtml`
@ -77,7 +78,7 @@ module.exports = exports = state => parseApiFile(state.params.wildcard).then(res
}, 2000); }, 2000);
</script> </script>
`; `;
}); });
@ -88,6 +89,7 @@ function createApiContent(apiDetails) {
for (const apiDetail of apiDetails) { for (const apiDetail of apiDetails) {
let apiDetailsReturns = ""; let apiDetailsReturns = "";
if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns)); if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
apiContent.push(` apiContent.push(`
@ -165,7 +167,8 @@ function parseApiFile(urlSlug) {
return fetch(apiFileLink).then(() => fetch(apiFileLink, { return fetch(apiFileLink).then(() => fetch(apiFileLink, {
cache: "no-cache" // forces a conditional request cache: "no-cache" // forces a conditional request
})).then(res => res.json().then(body => body)); // res.status 304 = cache validated }))
.then(res => res.json().then(body => body)); // res.status 304 = cache validated
} }
function renderArguments(args) { function renderArguments(args) {

View file

@ -44,6 +44,7 @@ const md = require("markdown-it")({
module.exports = exports = (state, emit) => { // eslint-disable-line module.exports = exports = (state, emit) => { // eslint-disable-line
let path; let path;
if (state.route === "resources/*") path = `resources/${state.params.wildcard}`; if (state.route === "resources/*") path = `resources/${state.params.wildcard}`;
else path = state.params.wildcard; else path = state.params.wildcard;
@ -69,6 +70,7 @@ module.exports = exports = (state, emit) => { // eslint-disable-line
} }
let pageScript = ""; let pageScript = "";
if (path === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>"; 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 === "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 (path === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>";
@ -104,7 +106,9 @@ function partialFinder(markdownBody) {
if (!partials) return markdownBody; if (!partials) return markdownBody;
for (const partial of partials) { for (const partial of partials) {
const filename = decamelize(partial, "-").replace("<", "").replace("/>", "").trim(); const filename = decamelize(partial, "-").replace("<", "")
.replace("/>", "")
.trim();
const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist
if (!fileExistsTest) if (!fileExistsTest)

View file

@ -56,7 +56,7 @@
"@babel/plugin-syntax-import-meta": "7.0.0", "@babel/plugin-syntax-import-meta": "7.0.0",
"@babel/preset-env": "^7.1.0", "@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0", "@babel/register": "^7.0.0",
"@inc/eslint-config": "^1.0.4", "@inc/eslint-config": "^1.0.5",
"eslint": "^5.6.1", "eslint": "^5.6.1",
"husky": "^1.1.1", "husky": "^1.1.1",
"nodemon": "^1.18.4", "nodemon": "^1.18.4",

View file

@ -59,7 +59,7 @@ fastify.ready(err => {
// B E G I N // B E G I N
const start = async () => { const start = async() => {
try { try {
await fastify.listen(process.env.PORT || 8080, process.env.IP || "0.0.0.0"); await fastify.listen(process.env.PORT || 8080, process.env.IP || "0.0.0.0");
} catch (err) { } catch (err) {