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);
} }
@ -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

@ -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

@ -21,6 +21,7 @@
}; };
const self = this; const self = this;
self.options = {}; self.options = {};
[ [
@ -58,11 +59,11 @@
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));
@ -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);
@ -144,7 +145,9 @@
}, },
_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) {
@ -155,6 +158,7 @@
_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) => {
@ -176,12 +180,12 @@
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");
@ -227,10 +231,12 @@
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`
@ -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",