Updated dep
This commit is contained in:
parent
b033619612
commit
babf056f7c
13 changed files with 157 additions and 131 deletions
|
@ -8,6 +8,7 @@ initializePlayground();
|
|||
|
||||
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];
|
||||
|
||||
fetchMetadata(1, searchParameter);
|
||||
}
|
||||
|
||||
|
@ -112,6 +113,7 @@ function debounce(func, wait, immediate) {
|
|||
};
|
||||
|
||||
const callNow = immediate && !timeout;
|
||||
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(later, wait);
|
||||
|
@ -126,7 +128,7 @@ function initializePlayground() {
|
|||
document.querySelector(".playground__navigation__example:nth-child(1)").classList.add("active");
|
||||
|
||||
send(JSON.stringify({
|
||||
"message": "landed on playground"
|
||||
message: "landed on playground"
|
||||
}));
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -142,10 +144,10 @@ function fetchMetadata(exampleNumber, data) {
|
|||
switch(exampleNumber) {
|
||||
case 1:
|
||||
send(JSON.stringify({
|
||||
"claim": data,
|
||||
"message": "fetch metadata",
|
||||
"method": "resolve",
|
||||
"example": exampleNumber
|
||||
claim: data,
|
||||
message: "fetch metadata",
|
||||
method: "resolve",
|
||||
example: exampleNumber
|
||||
}));
|
||||
|
||||
document.getElementById("fetch-claim-uri").value = data;
|
||||
|
@ -165,10 +167,10 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
|
|||
|
||||
case 2:
|
||||
send(JSON.stringify({
|
||||
"data": data,
|
||||
"message": "fetch metadata",
|
||||
"method": "publish",
|
||||
"example": exampleNumber
|
||||
data: data,
|
||||
message: "fetch metadata",
|
||||
method: "publish",
|
||||
example: exampleNumber
|
||||
}));
|
||||
|
||||
document.getElementById("playground-results").innerHTML = `
|
||||
|
@ -186,10 +188,10 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
|
|||
|
||||
case 3:
|
||||
send(JSON.stringify({
|
||||
"claim": data,
|
||||
"message": "fetch metadata",
|
||||
"method": "wallet_send",
|
||||
"example": exampleNumber
|
||||
claim: data,
|
||||
message: "fetch metadata",
|
||||
method: "wallet_send",
|
||||
example: exampleNumber
|
||||
}));
|
||||
|
||||
document.getElementById("fetch-claim-uri").value = data;
|
||||
|
@ -269,7 +271,7 @@ const handleExamples = debounce(event => {
|
|||
document.getElementById("playground-results").removeAttribute("style");
|
||||
|
||||
send(JSON.stringify({
|
||||
"message": `request for ${data.action}`
|
||||
message: `request for ${data.action}`
|
||||
}));
|
||||
|
||||
break;
|
||||
|
@ -295,7 +297,7 @@ const handleExamples = debounce(event => {
|
|||
document.getElementById("playground-results").removeAttribute("style");
|
||||
|
||||
send(JSON.stringify({
|
||||
"message": `request for ${data.action}`
|
||||
message: `request for ${data.action}`
|
||||
}));
|
||||
|
||||
break;
|
||||
|
@ -324,7 +326,7 @@ const handleExamples = debounce(event => {
|
|||
document.getElementById("playground-results").removeAttribute("style");
|
||||
|
||||
send(JSON.stringify({
|
||||
"message": `request for ${data.action}`
|
||||
message: `request for ${data.action}`
|
||||
}));
|
||||
|
||||
break;
|
||||
|
|
6
app/dist/scripts/app.js
vendored
6
app/dist/scripts/app.js
vendored
|
@ -60,11 +60,12 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
|
|||
// Newsletter
|
||||
document.querySelector("[data-action='subscribe to newsletter']").onclick = () => {
|
||||
const email = document.getElementById("emailAddress").value;
|
||||
|
||||
if (!validateEmail(email)) return;
|
||||
|
||||
send(JSON.stringify({
|
||||
"email": email,
|
||||
"message": "subscribe"
|
||||
email: email,
|
||||
message: "subscribe"
|
||||
}));
|
||||
};
|
||||
|
||||
|
@ -88,5 +89,6 @@ function scrollToElementOnLoad() {
|
|||
|
||||
function validateEmail(email) {
|
||||
const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i;
|
||||
|
||||
return emailRegex.test(String(email));
|
||||
}
|
||||
|
|
36
app/dist/scripts/plugins/jets.js
vendored
36
app/dist/scripts/plugins/jets.js
vendored
|
@ -21,6 +21,7 @@
|
|||
};
|
||||
|
||||
const self = this;
|
||||
|
||||
self.options = {};
|
||||
|
||||
[
|
||||
|
@ -58,11 +59,11 @@
|
|||
self.search = (search_query, optional_column) => {
|
||||
const new_search_query =
|
||||
self.options.callSearchManually &&
|
||||
typeof search_query !== "undefined"
|
||||
? search_query
|
||||
: self.search_tag
|
||||
? self.search_tag.value
|
||||
: "";
|
||||
typeof search_query !== "undefined" ?
|
||||
search_query :
|
||||
self.search_tag ?
|
||||
self.search_tag.value :
|
||||
"";
|
||||
|
||||
if (last_search_query === (last_search_query = new_search_query)) return;
|
||||
(0, self._applyCSS(last_search_query, optional_column));
|
||||
|
@ -108,9 +109,9 @@
|
|||
.replace(/\s\s+/g, " ")
|
||||
).replace(/\\/g, "\\\\");
|
||||
|
||||
const words = options.searchSelectorMode
|
||||
? search_phrase.split(" ").filter((item, pos, arr) => arr.indexOf(item) === pos)
|
||||
: [search_phrase];
|
||||
const words = options.searchSelectorMode ?
|
||||
search_phrase.split(" ").filter((item, pos, arr) => arr.indexOf(item) === pos) :
|
||||
[search_phrase];
|
||||
|
||||
const is_strict_selector = options.searchSelectorMode === "AND";
|
||||
const selectors = new Array(words.length);
|
||||
|
@ -144,7 +145,9 @@
|
|||
},
|
||||
|
||||
_sanitize: function(text) {
|
||||
return this.replaceDiacritics(text).trim().replace(/\s+/g, " ").toLowerCase();
|
||||
return this.replaceDiacritics(text).trim()
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase();
|
||||
},
|
||||
|
||||
_getContentTags: function(query) {
|
||||
|
@ -155,6 +158,7 @@
|
|||
|
||||
_handleSpecificColumns: function(tag, set) {
|
||||
const self = this;
|
||||
|
||||
if (!self.options.searchInSpecificColumn) return;
|
||||
|
||||
Array.prototype.slice.call(tag.children).map((children, i) => {
|
||||
|
@ -176,12 +180,12 @@
|
|||
for (const tag of tags) {
|
||||
if (tag.hasAttribute("data-jets") && !force) continue;
|
||||
|
||||
text = this.options.manualContentHandling
|
||||
? this.options.manualContentHandling(tag)
|
||||
: self.options.columns &&
|
||||
self.options.columns.length
|
||||
? self.options.columns.map(column => self._getText(tag.children[column])).join(" ")
|
||||
: self._getText(tag);
|
||||
text = this.options.manualContentHandling ?
|
||||
this.options.manualContentHandling(tag) :
|
||||
self.options.columns &&
|
||||
self.options.columns.length ?
|
||||
self.options.columns.map(column => self._getText(tag.children[column])).join(" ") :
|
||||
self._getText(tag);
|
||||
|
||||
tag.setAttribute("data-jets", self._sanitize(text));
|
||||
self._handleSpecificColumns(tag, "set");
|
||||
|
@ -227,10 +231,12 @@
|
|||
proto[method] = function(selectors) {
|
||||
if (/(^|,)\s*:scope/.test(selectors)) {
|
||||
const id = this.getAttribute("id");
|
||||
|
||||
this.id = "ID_" + Date.now();
|
||||
selectors = selectors.replace(/((^|,)\s*):scope/g, "$1#" + this.getAttribute("id"));
|
||||
|
||||
const result = doc[method](selectors);
|
||||
|
||||
this.id = id;
|
||||
|
||||
return result;
|
||||
|
|
|
@ -44,9 +44,9 @@ module.exports = exports = (data, socket) => {
|
|||
let apiRequestMethod = "";
|
||||
|
||||
if (allowedMethods.indexOf(resolveMethod) < 0) return socket.send(JSON.stringify({
|
||||
"details": "Unallowed resolve method for tutorial",
|
||||
"message": "notification",
|
||||
"type": "error"
|
||||
details: "Unallowed resolve method for tutorial",
|
||||
message: "notification",
|
||||
type: "error"
|
||||
}));
|
||||
|
||||
|
||||
|
@ -73,9 +73,9 @@ module.exports = exports = (data, socket) => {
|
|||
return uploadImage(body.file_path).then(uploadResponse => {
|
||||
if (!uploadResponse.status || uploadResponse.status !== "ok") {
|
||||
socket.send(JSON.stringify({
|
||||
"details": "Image upload failed",
|
||||
"message": "notification",
|
||||
"type": "error"
|
||||
details: "Image upload failed",
|
||||
message: "notification",
|
||||
type: "error"
|
||||
}));
|
||||
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
|
@ -94,9 +94,9 @@ module.exports = exports = (data, socket) => {
|
|||
return publishMeme(body).then(publishResponse => {
|
||||
if (publishResponse.error) {
|
||||
socket.send(JSON.stringify({
|
||||
"details": "Meme publish failed",
|
||||
"message": "notification",
|
||||
"type": "error"
|
||||
details: "Meme publish failed",
|
||||
message: "notification",
|
||||
type: "error"
|
||||
}));
|
||||
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
|
@ -126,14 +126,14 @@ module.exports = exports = (data, socket) => {
|
|||
`;
|
||||
|
||||
return socket.send(JSON.stringify({
|
||||
"example": data.example,
|
||||
"html": raw(`
|
||||
example: data.example,
|
||||
html: raw(`
|
||||
<h3>Response</h3>
|
||||
${explorerNotice}
|
||||
<pre><code class="language-json">${renderedCode}</code></pre>
|
||||
`),
|
||||
"message": "show result",
|
||||
"selector": `#example${data.example}-result`
|
||||
message: "show result",
|
||||
selector: `#example${data.example}-result`
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@ -160,13 +160,13 @@ module.exports = exports = (data, socket) => {
|
|||
|
||||
if (!approvedIds.includes(claimAddress)) {
|
||||
return socket.send(JSON.stringify({
|
||||
"example": data.example,
|
||||
"html": raw(`
|
||||
example: data.example,
|
||||
html: raw(`
|
||||
<h3>Response</h3>
|
||||
<pre><code class="language-text">Tipping creators not in the whitelist for this example is not allowed.</code></pre>
|
||||
`),
|
||||
"message": "show result",
|
||||
"selector": `#example${data.example}-result`
|
||||
message: "show result",
|
||||
selector: `#example${data.example}-result`
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -227,14 +227,14 @@ module.exports = exports = (data, socket) => {
|
|||
);
|
||||
|
||||
return socket.send(JSON.stringify({
|
||||
"example": data.example,
|
||||
"html": raw(`
|
||||
example: data.example,
|
||||
html: raw(`
|
||||
<h3>Response</h3>
|
||||
${explorerNotice}
|
||||
<pre><code class="language-json">${renderedCode}</code></pre>
|
||||
`),
|
||||
"message": "show result",
|
||||
"selector": `#example${data.example}-result`
|
||||
message: "show result",
|
||||
selector: `#example${data.example}-result`
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -280,7 +280,10 @@ function generateGitHubFeed(displayGitHubFeed) {
|
|||
|
||||
displayGitHubFeed(`
|
||||
<h3>GitHub</h3>
|
||||
<h5 class="last-updated">Last updated: ${new Date().format("YYYY-MM-DD").replace(/-/g, "·")} 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, "·")} at ${new Date().add(-4, "hours")
|
||||
.format("UTC:H:mm:ss A")
|
||||
.toLowerCase()} EST</h5>
|
||||
|
||||
${renderedEvents.join("")}
|
||||
`);
|
||||
|
@ -336,7 +339,8 @@ function updateGithubFeed() {
|
|||
else callback();
|
||||
});
|
||||
}, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
logSlackError(
|
||||
"\n" +
|
||||
"> *GITHUB FEED ERROR:* ```" + JSON.parse(JSON.stringify(err)) + "```" + "\n" +
|
||||
|
|
|
@ -12,5 +12,6 @@ const crypto = require("crypto");
|
|||
|
||||
module.exports = exports = len => {
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -59,6 +59,7 @@ function superscript(state, silent) {
|
|||
|
||||
if (content.match(regexForIds)) {
|
||||
const theLink = supText.match(regexForIds)[0].replace("(#", "").replace(")", "");
|
||||
|
||||
token.attrPush([ "id", theLink ]);
|
||||
}
|
||||
|
||||
|
@ -66,6 +67,7 @@ function superscript(state, silent) {
|
|||
|
||||
if (content.match(regexForIds)) {
|
||||
const theText = supText.match(regexForTextBeforeLink)[0];
|
||||
|
||||
token.content = theText;
|
||||
} else token.content = supText;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ module.exports = exports = (socket, action) => {
|
|||
case (action.message === "landed on homepage"):
|
||||
generateGitHubFeed(result => {
|
||||
socket.send(JSON.stringify({
|
||||
"html": result,
|
||||
"message": "updated html",
|
||||
"selector": "#github-feed"
|
||||
html: result,
|
||||
message: "updated html",
|
||||
selector: "#github-feed"
|
||||
}));
|
||||
});
|
||||
break;
|
||||
|
@ -39,9 +39,9 @@ module.exports = exports = (socket, action) => {
|
|||
case (action.message === "landed on playground"):
|
||||
generateContent(1, result => {
|
||||
socket.send(JSON.stringify({
|
||||
"html": result,
|
||||
"message": "updated html",
|
||||
"selector": "#playground-loader"
|
||||
html: result,
|
||||
message: "updated html",
|
||||
selector: "#playground-loader"
|
||||
}));
|
||||
});
|
||||
break;
|
||||
|
@ -49,9 +49,9 @@ module.exports = exports = (socket, action) => {
|
|||
case (action.message === "request for playground, example 1"):
|
||||
generateContent(1, result => {
|
||||
socket.send(JSON.stringify({
|
||||
"html": result,
|
||||
"message": "updated html",
|
||||
"selector": "#playground-loader"
|
||||
html: result,
|
||||
message: "updated html",
|
||||
selector: "#playground-loader"
|
||||
}));
|
||||
});
|
||||
break;
|
||||
|
@ -63,9 +63,9 @@ module.exports = exports = (socket, action) => {
|
|||
case (action.message === "request for playground, example 3"):
|
||||
generateContent(3, result => {
|
||||
socket.send(JSON.stringify({
|
||||
"html": result,
|
||||
"message": "updated html",
|
||||
"selector": "#playground-loader"
|
||||
html: result,
|
||||
message: "updated html",
|
||||
selector: "#playground-loader"
|
||||
}));
|
||||
});
|
||||
break;
|
||||
|
@ -291,10 +291,10 @@ function generateMemeCreator(socket) {
|
|||
`;
|
||||
|
||||
return socket.send(JSON.stringify({
|
||||
"example": 2,
|
||||
"html": memeCreator,
|
||||
"message": "updated html",
|
||||
"selector": "#playground-loader"
|
||||
example: 2,
|
||||
html: memeCreator,
|
||||
message: "updated html",
|
||||
selector: "#playground-loader"
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -315,9 +315,9 @@ function newsletterSubscribe(data, socket) {
|
|||
const email = data.email;
|
||||
|
||||
if (!validateEmail(email)) return socket.send(JSON.stringify({
|
||||
"html": "Your email is invalid",
|
||||
"message": "updated html",
|
||||
"selector": "#emailMessage"
|
||||
html: "Your email is invalid",
|
||||
message: "updated html",
|
||||
selector: "#emailMessage"
|
||||
}));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -333,9 +333,9 @@ function newsletterSubscribe(data, socket) {
|
|||
);
|
||||
|
||||
return resolve(socket.send(JSON.stringify({
|
||||
"html": "Something is terribly wrong",
|
||||
"message": "updated html",
|
||||
"selector": "#emailMessage"
|
||||
html: "Something is terribly wrong",
|
||||
message: "updated html",
|
||||
selector: "#emailMessage"
|
||||
})));
|
||||
}
|
||||
|
||||
|
@ -349,18 +349,19 @@ function newsletterSubscribe(data, socket) {
|
|||
);
|
||||
|
||||
return reject(socket.send(JSON.stringify({
|
||||
"html": body.error,
|
||||
"message": "updated html",
|
||||
"selector": "#emailMessage"
|
||||
html: body.error,
|
||||
message: "updated html",
|
||||
selector: "#emailMessage"
|
||||
})));
|
||||
}
|
||||
|
||||
return resolve(socket.send(JSON.stringify({
|
||||
"html": "Thank you! Please confirm subscription in your inbox.",
|
||||
"message": "updated html",
|
||||
"selector": "#emailMessage"
|
||||
html: "Thank you! Please confirm subscription in your inbox.",
|
||||
message: "updated html",
|
||||
selector: "#emailMessage"
|
||||
})));
|
||||
}).catch(welp => {
|
||||
})
|
||||
.catch(welp => {
|
||||
if (welp.statusCode === 409) {
|
||||
logSlackError(
|
||||
"\n" +
|
||||
|
@ -369,9 +370,9 @@ function newsletterSubscribe(data, socket) {
|
|||
);
|
||||
|
||||
return resolve(socket.send(JSON.stringify({
|
||||
"html": "You have already subscribed!",
|
||||
"message": "updated html",
|
||||
"selector": "#emailMessage"
|
||||
html: "You have already subscribed!",
|
||||
message: "updated html",
|
||||
selector: "#emailMessage"
|
||||
})));
|
||||
}
|
||||
});
|
||||
|
@ -380,5 +381,6 @@ function newsletterSubscribe(data, socket) {
|
|||
|
||||
function validateEmail(email) {
|
||||
const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i;
|
||||
|
||||
return emailRegex.test(String(email));
|
||||
}
|
||||
|
|
|
@ -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/api.js"></script>
|
||||
`;
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
const redirectUrl = redirects[state.href];
|
||||
|
||||
return asyncHtml`
|
||||
|
@ -88,6 +89,7 @@ function createApiContent(apiDetails) {
|
|||
|
||||
for (const apiDetail of apiDetails) {
|
||||
let apiDetailsReturns = "";
|
||||
|
||||
if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
|
||||
|
||||
apiContent.push(`
|
||||
|
@ -165,7 +167,8 @@ function parseApiFile(urlSlug) {
|
|||
|
||||
return fetch(apiFileLink).then(() => fetch(apiFileLink, {
|
||||
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) {
|
||||
|
|
|
@ -44,6 +44,7 @@ const md = require("markdown-it")({
|
|||
|
||||
module.exports = exports = (state, emit) => { // eslint-disable-line
|
||||
let path;
|
||||
|
||||
if (state.route === "resources/*") path = `resources/${state.params.wildcard}`;
|
||||
else path = state.params.wildcard;
|
||||
|
||||
|
@ -69,6 +70,7 @@ module.exports = exports = (state, emit) => { // eslint-disable-line
|
|||
}
|
||||
|
||||
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>";
|
||||
|
@ -104,7 +106,9 @@ function partialFinder(markdownBody) {
|
|||
if (!partials) return markdownBody;
|
||||
|
||||
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
|
||||
|
||||
if (!fileExistsTest)
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
"@babel/plugin-syntax-import-meta": "7.0.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"@inc/eslint-config": "^1.0.4",
|
||||
"@inc/eslint-config": "^1.0.5",
|
||||
"eslint": "^5.6.1",
|
||||
"husky": "^1.1.1",
|
||||
"nodemon": "^1.18.4",
|
||||
|
|
Loading…
Reference in a new issue