Compare commits
45
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eeaf4c2b5 | ||
|
|
362c14c83c | ||
|
|
053aad7833 | ||
|
|
026bb01b81 | ||
|
|
e020eb3c13 | ||
|
|
1be0995bbf | ||
|
|
d8b37ed0e6 | ||
|
|
1b56526711 | ||
|
|
707f616224 | ||
|
|
5277050c37 | ||
|
|
698222cf32 | ||
|
|
1c0888e0cf | ||
|
|
39ea483f08 | ||
|
|
6ae0984edf | ||
|
|
d5932ce67c | ||
|
|
777d9f0f83 | ||
|
|
b3ae6ca0d6 | ||
|
|
ebbcb02c87 | ||
|
|
cc965191f2 | ||
|
|
48190d18be | ||
|
|
201f8a4a09 | ||
|
|
ed6cfb239a | ||
|
|
7beeffd008 | ||
|
|
8bfeafa137 | ||
|
|
85226a20d0 | ||
|
|
ee65417441 | ||
|
|
94136dbb69 | ||
|
|
5bc4650ad1 | ||
|
|
741a672538 | ||
|
|
5949bcb16e | ||
|
|
f66349d613 | ||
|
|
753deb4723 | ||
|
|
3e2e6afbc7 | ||
|
|
79f81d4267 | ||
|
|
3e061dbf4b | ||
|
|
8b9ca4302b | ||
|
|
4045de7c2c | ||
|
|
39bf3b56bc | ||
|
|
a6b7340e9d | ||
|
|
4b14cc1a73 | ||
|
|
e260ae0e28 | ||
|
|
0c496b33ae | ||
|
|
fda1e3d800 | ||
|
|
05af3d76a0 | ||
|
|
d673bd6395 |
No files matched your search
@@ -10,9 +10,9 @@ import html from "choo/html";
|
||||
|
||||
// E X P O R T
|
||||
|
||||
export default () => html`
|
||||
export default version => html`
|
||||
<div class="api-content__body">
|
||||
<h2>lbrycrd APIs</h2>
|
||||
<h2>lbrycrd ${version}</h2>
|
||||
<p>Methods and signatures provided by the <a href="/glossary#lbrycrd">lbrycrd</a> blockchain daemon are documented below. To build, download, or run lbrycrd, see the project <a href="https://github.com/lbryio/lbrycrd/blob/master/README.md">README</a>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ import html from "choo/html";
|
||||
|
||||
// E X P O R T
|
||||
|
||||
export default () => html`
|
||||
export default version => html`
|
||||
<div class="api-content__body">
|
||||
<h2>lbry-sdk APIs</h2>
|
||||
<p>Methods and signatures provided by the <a href="/glossary#lbry-sdk">lbry-sdk</a> daemon are documented below. To build, download, or run the daemon, see the project <a href="https://github.com/lbryio/lbry/blob/master/README.md">README</a>.</p>
|
||||
<h2>lbry-sdk ${version}</h2>
|
||||
<p>Methods and signatures provided by the <a href="/glossary#lbry-sdk">lbry-sdk</a> daemon are documented below. To build, download, or run the daemon, see the project <a href="https://github.com/lbryio/lbry-sdk/blob/master/README.md">README</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="api-content__intro">
|
||||
<p>You can find the repo for this API on GitHub:</p>
|
||||
<pre><code>https://github.com/lbryio/lbry</code></pre>
|
||||
<pre><code>https://github.com/lbryio/lbry-sdk</code></pre>
|
||||
</div>
|
||||
`;
|
||||
@@ -24,7 +24,7 @@ if (window.location.search.includes("?code=")) {
|
||||
<p>To receive your LBC, you'll need a wallet address. While graphical wallets are available, the recommended path for engineers is to:</p>
|
||||
|
||||
<ol>
|
||||
<li>Download <a href="https://github.com/lbryio/lbry/releases">the LBRY SDK</a>.</li>
|
||||
<li>Download <a href="https://github.com/lbryio/lbry-sdk/releases">the LBRY SDK</a>.</li>
|
||||
<li>Launch the command-line utility (<code>./lbrynet start</code>).</li>
|
||||
<li>Run <code>./lbrynet address unused</code> and copy the <code>id</code> field.</li>
|
||||
</ol>
|
||||
@@ -56,33 +56,41 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
|
||||
const address = data.address;
|
||||
const code = data.code;
|
||||
|
||||
if (code === null)
|
||||
if (code === null) {
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
"<p><strong>There was an issue with accessing GitHub's API. Please try again later.</strong></p>";
|
||||
}
|
||||
|
||||
fetch(`https://api.lbry.com/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`)
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
switch(true) {
|
||||
case result.error === "this reward is limited to 1 per person":
|
||||
case result.error === "This reward is limited to 1 per person":
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
|
||||
break;
|
||||
return;
|
||||
|
||||
case Boolean(result.error):
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
`<p>${result.error}</p>`;
|
||||
return;
|
||||
|
||||
case result.success:
|
||||
result = result.data;
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
`<p><strong>Success!</strong> Your wallet has been credited with ${result.reward_amount} LBC.</p><p>We have a great reference for the <a href="/api/sdk">LBRY SDK here</a> to help you get started.</p><p>You can see proof of this transaction on <a href="https://explorer.lbry.com/tx/${result.transaction_id}">our Blockchain Explorer</a>.</p>`;
|
||||
break;
|
||||
return;
|
||||
|
||||
default:
|
||||
console.log(data); // eslint-disable-line no-console
|
||||
console.info(data); // eslint-disable-line no-console
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
"<p><strong>The LBRY API might be down. Please try again later.</strong></p>";
|
||||
break;
|
||||
"<p><strong>No success or error was received so the LBRY API might be down.<br/>Please try again later.</strong></p>";
|
||||
return;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
|
||||
// Idk what the error would be (probably a 500) so let's just have this message
|
||||
document.querySelector("developer-program").innerHTML =
|
||||
"<p><strong>LBRY API is down. Please try again later.</strong></p>";
|
||||
|
||||
@@ -249,15 +249,15 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
|
||||
}
|
||||
|
||||
const handleExamples = debounce(event => {
|
||||
let exampleNumber;
|
||||
const exampleNumber = parseInt(document.querySelector(".playground-navigation__example.active").dataset.example || 0);
|
||||
const data = event.dataset;
|
||||
|
||||
if (!parseInt(document.querySelector(".playground-navigation__example.active").dataset.example)) return;
|
||||
exampleNumber = parseInt(document.querySelector(".playground-navigation__example.active").dataset.example);
|
||||
if (!exampleNumber || exampleNumber === 0)
|
||||
return;
|
||||
|
||||
switch(data.action) {
|
||||
case "choose claim":
|
||||
fetchMetadata(exampleNumber, data.claimId);
|
||||
fetchMetadata(exampleNumber, `${data.name}#${data.claimId}`);
|
||||
|
||||
if (document.querySelector(".playground-navigation__example:nth-child(3)").classList.contains("active"))
|
||||
document.getElementById("fetch-claim-uri").value = event.dataset.name + "#" + event.dataset.claimId;
|
||||
@@ -398,9 +398,9 @@ function updateCanvas(imageSource) {
|
||||
if (imageSource) {
|
||||
ctx.drawImage(imageSource, 0, 0, canvasWidth, canvasHeight);
|
||||
img.src = imageSource.src;
|
||||
} else {
|
||||
} else
|
||||
ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
|
||||
}
|
||||
|
||||
|
||||
positionCanvasText(ctx, canvasHeight, canvasWidth);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export default () => `
|
||||
</span>
|
||||
|
||||
<div>
|
||||
<span><a href="https://github.com/lbryio/lbry">lbrysdk</a></span>
|
||||
<span><a href="https://github.com/lbryio/lbry-sdk">lbrysdk</a></span>
|
||||
<span><a href="https://github.com/lbryio/types">lbryschema</a></span>
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
@@ -27,11 +27,11 @@ export default pagePath => {
|
||||
break;
|
||||
|
||||
case "/api/blockchain":
|
||||
githubUrl = "https://github.com/lbryio/lbrycrd/blob/add_api_docs_scripts/contrib/devtools/generated/api_v1.json";
|
||||
githubUrl = "https://github.com/lbryio/lbrycrd/blob/master/contrib/devtools/generated/api_v1.json";
|
||||
break;
|
||||
|
||||
case "/api/sdk":
|
||||
githubUrl = "https://github.com/lbryio/lbry/blob/master/docs/api.json";
|
||||
githubUrl = "https://github.com/lbryio/lbry-sdk/blob/master/lbry/docs/api.json";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -68,11 +68,3 @@ export default (state, emit) => {
|
||||
<script src="/assets/scripts/sockets.js"></script>
|
||||
`;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// H E L P E R
|
||||
|
||||
String.prototype.capitalize = function() {
|
||||
return this.charAt(0).toUpperCase() + this.slice(1);
|
||||
};
|
||||
@@ -9,11 +9,11 @@
|
||||
"/resources/schema": "/spec#metadata",
|
||||
"/resources/signing-claim": "/resources/claim-signing",
|
||||
"/resources/uri": "/spec#urls",
|
||||
"/resources/video-lbrysdk": "https://spee.ch/967f99344308f1e90f0620d91b6c93e4dfb240e0/lbrynet-dev-setup",
|
||||
"/resources/video-lbryandroid": "https://spee.ch/e781060bc708247f07afebc02d5f75cfba8e2c4b/video-2018-10-15053403",
|
||||
"/resources/video-lbrycrd": "https://spee.ch/5803b66dca7707584b36fe6b644f278fc39d1adf/intro-to-LBRYcrd",
|
||||
"/resources/video-lbrydesktop": "https://spee.ch/7da73fc508ffc4ff8b2711e3c3950110430b0c5f/LBRYAppDesign",
|
||||
"/resources/video-lbryandroid": "https://spee.ch/e781060bc708247f07afebc02d5f75cfba8e2c4b/video-2018-10-15053403",
|
||||
"/tour": "/playground",
|
||||
"/resources/video-lbrysdk": "https://spee.ch/967f99344308f1e90f0620d91b6c93e4dfb240e0/lbrynet-dev-setup",
|
||||
"/specification": "/spec",
|
||||
"/tour": "/playground",
|
||||
"/whitepaper": "/spec"
|
||||
}
|
||||
Vendored
+74
-47
@@ -1,65 +1,39 @@
|
||||
"use strict"; /* global document, Jets, window */
|
||||
"use strict"; /* global document, Jets, send, window */
|
||||
|
||||
|
||||
|
||||
// NOTE:
|
||||
// We declare `contentTag` and `jets` with `var` here so
|
||||
// when a visitor toggles the API page version, they are
|
||||
// not incorrectly declared multiple times via `let || const`
|
||||
|
||||
// Initiate search functionality
|
||||
const contentTag = window.location.pathname.split("/").pop() === "sdk" ?
|
||||
if (!contentTag)
|
||||
var contentTag;
|
||||
|
||||
contentTag = window.location.pathname.split("/").pop() === "sdk" ?
|
||||
".api-toc__section" :
|
||||
"#toc";
|
||||
|
||||
let jets = new Jets({
|
||||
if (!jets)
|
||||
var jets;
|
||||
|
||||
jets = new Jets({
|
||||
contentTag,
|
||||
searchTag: "#input-search"
|
||||
});
|
||||
|
||||
// Reset search on page load
|
||||
document.getElementById("input-search").value = "";
|
||||
|
||||
// Activate search
|
||||
document.getElementById("input-search").addEventListener("keyup", () => {
|
||||
if (document.getElementById("input-search").value)
|
||||
document.querySelector(".api-toc__search-clear").classList.add("active");
|
||||
else
|
||||
document.querySelector(".api-toc__search-clear").classList.remove("active");
|
||||
});
|
||||
|
||||
// Cancel search
|
||||
document.querySelector(".api-toc__search-clear").addEventListener("click", () => {
|
||||
document.getElementById("input-search").value = "";
|
||||
document.querySelector(".api-toc__search-clear").classList.remove("active");
|
||||
|
||||
jets.destroy();
|
||||
reinitJets();
|
||||
});
|
||||
|
||||
// Handle menu toggle for mobile
|
||||
if (document.getElementById("toggle-menu")) {
|
||||
document.getElementById("toggle-menu").addEventListener("click", () => {
|
||||
document.querySelector("body").classList.toggle("disable-scrolling");
|
||||
document.querySelector(".api-toc").classList.toggle("active");
|
||||
});
|
||||
|
||||
// Handle menu toggle when clicking on commands
|
||||
document.querySelectorAll(".api-toc__command a").forEach(command => {
|
||||
command.addEventListener("click", () => {
|
||||
document.querySelector("body").classList.remove("disable-scrolling");
|
||||
document.querySelector(".api-toc").classList.remove("active");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Code toggles
|
||||
handleApiLanguageToggles("cli");
|
||||
handleApiLanguageToggles("curl");
|
||||
handleApiLanguageToggles("lbrynet");
|
||||
handleApiLanguageToggles("python");
|
||||
|
||||
|
||||
|
||||
// H E L P E R S
|
||||
|
||||
function changeDocumentationVersion(desiredVersion) { // eslint-disable-line no-unused-vars
|
||||
send({
|
||||
message: "view different documentation version",
|
||||
version: desiredVersion
|
||||
});
|
||||
}
|
||||
|
||||
function handleApiLanguageToggles(language) {
|
||||
if (!document.getElementById(`toggle-${language}`))
|
||||
return;
|
||||
@@ -77,6 +51,59 @@ function handleApiLanguageToggles(language) {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeApiFunctionality() { // eslint-disable-line no-unused-vars
|
||||
// Reset search on page load
|
||||
document.getElementById("input-search").value = "";
|
||||
|
||||
// Activate search
|
||||
document.getElementById("input-search").addEventListener("keyup", () => {
|
||||
if (document.getElementById("input-search").value)
|
||||
document.querySelector(".api-toc__search-clear").classList.add("active");
|
||||
else
|
||||
document.querySelector(".api-toc__search-clear").classList.remove("active");
|
||||
});
|
||||
|
||||
// Cancel search
|
||||
document.querySelector(".api-toc__search-clear").addEventListener("click", () => {
|
||||
document.getElementById("input-search").value = "";
|
||||
document.querySelector(".api-toc__search-clear").classList.remove("active");
|
||||
|
||||
jets.destroy();
|
||||
reinitJets();
|
||||
});
|
||||
|
||||
// Handle menu toggle for mobile
|
||||
if (document.getElementById("toggle-menu")) {
|
||||
document.getElementById("toggle-menu").addEventListener("click", () => {
|
||||
document.querySelector("body").classList.toggle("disable-scrolling");
|
||||
document.querySelector(".api-toc").classList.toggle("active");
|
||||
});
|
||||
|
||||
// Handle menu toggle when clicking on commands
|
||||
document.querySelectorAll(".api-toc__command a").forEach(command => {
|
||||
command.addEventListener("click", () => {
|
||||
document.querySelector("body").classList.remove("disable-scrolling");
|
||||
document.querySelector(".api-toc").classList.remove("active");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Code toggles
|
||||
handleApiLanguageToggles("cli");
|
||||
handleApiLanguageToggles("curl");
|
||||
handleApiLanguageToggles("lbrynet");
|
||||
handleApiLanguageToggles("python");
|
||||
|
||||
// Ensure version selector shows correct version, even on page reloads
|
||||
const currentValue = document.querySelector(".api-content__body h2").textContent.split(/\s/g).pop();
|
||||
const { children } = document.querySelector(".api-toc__select");
|
||||
|
||||
for (const child of children) {
|
||||
if (currentValue === child.text)
|
||||
document.querySelector(".api-toc__select").selectedIndex = child.index;
|
||||
}
|
||||
}
|
||||
|
||||
function reinitJets() {
|
||||
jets = new Jets({
|
||||
contentTag,
|
||||
|
||||
Vendored
+32
-15
@@ -4,6 +4,7 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
scrollToElementOnLoad();
|
||||
initializeSmoothScroll();
|
||||
|
||||
// Automatically open external links in new tabs
|
||||
document.querySelectorAll("a[href^=http]").forEach(anchor => {
|
||||
@@ -39,25 +40,27 @@ if (
|
||||
|
||||
|
||||
|
||||
// Smooth scroll
|
||||
document.querySelectorAll("a[href^='#']").forEach(anchor => {
|
||||
if (anchor.classList.contains("no-smooth")) // Ignore smooth scroll functionality
|
||||
return;
|
||||
function initializeSmoothScroll() {
|
||||
// Smooth scroll
|
||||
document.querySelectorAll("a[href^='#']").forEach(anchor => {
|
||||
if (anchor.classList.contains("no-smooth")) // Ignore smooth scroll functionality
|
||||
return;
|
||||
|
||||
anchor.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
anchor.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
|
||||
const element = event.target.href.split("#").pop()
|
||||
.toLowerCase();
|
||||
let elementOffset;
|
||||
const element = event.target.href.split("#").pop()
|
||||
.toLowerCase();
|
||||
let elementOffset;
|
||||
|
||||
if (document.getElementById(element)) {
|
||||
elementOffset = document.getElementById(element).offsetTop - 150;
|
||||
window.scroll({ top: elementOffset, behavior: "smooth" });
|
||||
history.pushState({}, "", `#${element}`); // Add hash to URL bar
|
||||
}
|
||||
if (document.getElementById(element)) {
|
||||
elementOffset = document.getElementById(element).offsetTop - 150;
|
||||
window.scroll({ top: elementOffset, behavior: "smooth" });
|
||||
history.pushState({}, "", `#${element}`); // Add hash to URL bar
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Newsletter
|
||||
document.getElementById("emailAddress").addEventListener("keyup", event => {
|
||||
@@ -88,6 +91,20 @@ document.querySelector("[data-action='subscribe to newsletter']").onclick = () =
|
||||
|
||||
// H E L P E R S
|
||||
|
||||
function runScriptsInDynamicallyInsertedHTML(element, elementHTML) { // eslint-disable-line no-unused-vars
|
||||
element.innerHTML = elementHTML;
|
||||
|
||||
Array.from(element.querySelectorAll("script")).forEach(oldScript => {
|
||||
const newScript = document.createElement("script");
|
||||
|
||||
Array.from(oldScript.attributes)
|
||||
.forEach(attr => newScript.setAttribute(attr.name, attr.value));
|
||||
|
||||
newScript.appendChild(document.createTextNode(oldScript.innerHTML));
|
||||
oldScript.parentNode.replaceChild(newScript, oldScript);
|
||||
});
|
||||
}
|
||||
|
||||
function scrollToElementOnLoad() {
|
||||
if (window.location.href.includes("#")) {
|
||||
setTimeout(() => { // give page time to breathe
|
||||
|
||||
Vendored
+21
-1
@@ -1,4 +1,4 @@
|
||||
"use strict"; /* global document, location, WebSocket, window */
|
||||
"use strict"; /* global document, initializeSmoothScroll, location, runScriptsInDynamicallyInsertedHTML, WebSocket, window */
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,26 @@ function initializeWebSocketConnection() {
|
||||
window.location.href = data.url;
|
||||
break;
|
||||
|
||||
case data.message === "replace html":
|
||||
// create placeholder
|
||||
var placeholder = document.createElement("div");
|
||||
placeholder.setAttribute("id", "__placeholder"); // eslint-disable-line padding-line-between-statements
|
||||
document.querySelector(data.selector).insertAdjacentElement("afterend", placeholder);
|
||||
|
||||
// remove original element
|
||||
document.querySelector(data.selector).remove();
|
||||
|
||||
// add new element and remove placeholder
|
||||
document.getElementById("__placeholder").insertAdjacentHTML("afterend", data.html);
|
||||
document.getElementById("__placeholder").remove();
|
||||
|
||||
// make our scripts work
|
||||
runScriptsInDynamicallyInsertedHTML(document.querySelector(data.selector), document.querySelector(data.selector).innerHTML);
|
||||
|
||||
// make smooth scroll work on our new content
|
||||
initializeSmoothScroll();
|
||||
break;
|
||||
|
||||
case data.message === "show result":
|
||||
if (!data.example)
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,8 @@ import stringifyObject from "stringify-object";
|
||||
|
||||
import messageSlack from "./slack";
|
||||
import publishMeme from "./publish-meme";
|
||||
import lbrytvAPI from "~helper/lbrytv-sdk";
|
||||
|
||||
import randomString from "./random-string";
|
||||
import { send } from "~socket";
|
||||
import uploadImage from "./upload-image";
|
||||
@@ -55,10 +57,10 @@ export default async(data, socket) => {
|
||||
let dataDetails = "";
|
||||
let explorerNotice = "";
|
||||
|
||||
if (data.example === 1 && !data.claim || !data.method) return;
|
||||
if (data.example === 1 && (!data.claim || !data.method)) return;
|
||||
if (data.example === 2 && !data.data) return;
|
||||
if (data.example === 2) dataDetails = data.data; // file upload
|
||||
if (data.example === 3 && !data.claim || !data.method) return;
|
||||
if (data.example === 3 && (!data.claim || !data.method)) return;
|
||||
|
||||
const claimAddress = data.claim;
|
||||
const resolveMethod = data.method;
|
||||
@@ -76,10 +78,10 @@ export default async(data, socket) => {
|
||||
|
||||
|
||||
|
||||
switch(true) {
|
||||
switch(resolveMethod) {
|
||||
// T I P
|
||||
// E X A M P L E
|
||||
case resolveMethod === "support_create":
|
||||
case "support_create":
|
||||
if (!approvedContentIdsForTipping.includes(claimAddress)) {
|
||||
return send(socket, {
|
||||
example: data.example,
|
||||
@@ -103,7 +105,7 @@ export default async(data, socket) => {
|
||||
|
||||
// P U B L I S H
|
||||
// E X A M P L E
|
||||
case resolveMethod === "publish":
|
||||
case "publish":
|
||||
apiRequestMethod = "PUT";
|
||||
|
||||
// Required for publishing
|
||||
@@ -155,9 +157,7 @@ export default async(data, socket) => {
|
||||
message: "show result",
|
||||
selector: `#example${data.example}-result`
|
||||
});
|
||||
}
|
||||
|
||||
catch(memePublishError) {
|
||||
} catch(memePublishError) {
|
||||
send(socket, {
|
||||
details: "Meme publish failed",
|
||||
message: "notification",
|
||||
@@ -174,9 +174,7 @@ export default async(data, socket) => {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch(imageUploadError) {
|
||||
} catch(imageUploadError) {
|
||||
send(socket, {
|
||||
details: "Image upload failed",
|
||||
message: "notification",
|
||||
@@ -198,10 +196,36 @@ export default async(data, socket) => {
|
||||
|
||||
// R E S O L V E
|
||||
// E X A M P L E
|
||||
case resolveMethod === "resolve":
|
||||
case "resolve":
|
||||
apiRequestMethod = "GET";
|
||||
body.uri = claimAddress;
|
||||
try {
|
||||
let resolveResponse = await lbrytvAPI.resolve([claimAddress]);
|
||||
|
||||
if (socket) {
|
||||
const renderedCode = prism.highlight(
|
||||
stringifyObject(resolveResponse, { indent: " ", singleQuotes: false }),
|
||||
prism.languages.json,
|
||||
"json"
|
||||
);
|
||||
|
||||
return send(socket, {
|
||||
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`
|
||||
});
|
||||
}
|
||||
} catch(error) {
|
||||
messageSlack({
|
||||
message: "```" + error + "```",
|
||||
title: "DAEMON ERROR: resolve"
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -258,10 +282,13 @@ export default async(data, socket) => {
|
||||
});
|
||||
}
|
||||
|
||||
return response.body.result[Object.keys(response.body.result)[0]].claim;
|
||||
}
|
||||
// console.log("——");
|
||||
// console.log(response.body.result[Object.keys(response.body.result)[0]]);
|
||||
// console.log("——");
|
||||
|
||||
catch(error) {
|
||||
return response.body.result[Object.keys(response.body.result)[0]];
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
messageSlack({
|
||||
message: "```" + error + "```",
|
||||
pretext: "_Someone is going through the Playground and the daemon is not running_",
|
||||
|
||||
+18
-15
@@ -16,16 +16,6 @@ import relativeDate from "~module/relative-date";
|
||||
|
||||
let octokit;
|
||||
|
||||
String.prototype.escape = function() {
|
||||
const tagsToReplace = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">"
|
||||
};
|
||||
|
||||
return this.replace(/[&<>]/g, tag => tagsToReplace[tag] || tag);
|
||||
};
|
||||
|
||||
// R E D I S
|
||||
|
||||
let client;
|
||||
@@ -142,7 +132,7 @@ function generateEvent(event) {
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="View this comment on GitHub"
|
||||
>${event.payload.issue.title.escape()}</a></em> in
|
||||
>${escapeSpecialCharacters(event.payload.issue.title)}</a></em> in
|
||||
`;
|
||||
} else {
|
||||
return `
|
||||
@@ -153,7 +143,7 @@ function generateEvent(event) {
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="View this comment on GitHub"
|
||||
>${event.payload.issue.title.escape()}</a></em> in
|
||||
>${escapeSpecialCharacters(event.payload.issue.title)}</a></em> in
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -171,7 +161,7 @@ function generateEvent(event) {
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="View this issue on GitHub"
|
||||
>${event.payload.issue.title.escape()}</a></em> in
|
||||
>${escapeSpecialCharacters(event.payload.issue.title)}</a></em> in
|
||||
`;
|
||||
|
||||
case "PullRequestEvent":
|
||||
@@ -188,7 +178,7 @@ function generateEvent(event) {
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="View this pull request on GitHub"
|
||||
>${event.payload.pull_request.title.escape()}</a></em> in
|
||||
>${escapeSpecialCharacters(event.payload.pull_request.title)}</a></em> in
|
||||
`;
|
||||
|
||||
case "PullRequestReviewCommentEvent":
|
||||
@@ -205,7 +195,7 @@ function generateEvent(event) {
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="View this comment on GitHub"
|
||||
>${event.payload.pull_request.title.escape()}</a></em> in
|
||||
>${escapeSpecialCharacters(event.payload.pull_request.title)}</a></em> in
|
||||
`;
|
||||
|
||||
case "PushEvent":
|
||||
@@ -346,6 +336,9 @@ function updateGithubFeed() {
|
||||
const eventString = JSON.stringify(item);
|
||||
|
||||
client.zrank("events", eventString, (err, reply) => {
|
||||
if (err)
|
||||
return;
|
||||
|
||||
if (reply === null)
|
||||
client.zadd("events", item.id, eventString, callback);
|
||||
else
|
||||
@@ -366,6 +359,16 @@ function updateGithubFeed() {
|
||||
|
||||
// H E L P E R
|
||||
|
||||
function escapeSpecialCharacters(contentToEscape) {
|
||||
const tagsToReplace = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">"
|
||||
};
|
||||
|
||||
return contentToEscape.replace(/[&<>]/g, tag => tagsToReplace[tag] || tag);
|
||||
}
|
||||
|
||||
function refToBranch(ref) {
|
||||
if (ref)
|
||||
return ref.replace("refs/heads/", "");
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
const request = require("request");
|
||||
|
||||
import messageSlack from "./slack";
|
||||
|
||||
|
||||
let addSupport = function() {
|
||||
return;
|
||||
};
|
||||
|
||||
let publish = function() {
|
||||
return;
|
||||
};
|
||||
|
||||
let resolve = function(urls) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let options = {
|
||||
method: "POST",
|
||||
url: "https://api.lbry.tv/api/proxy",
|
||||
headers:
|
||||
{
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: {
|
||||
method: "resolve",
|
||||
params: { urls: urls }
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
request(options, function(error, response, daemonResponse) {
|
||||
if (error) {
|
||||
messageSlack({
|
||||
message: "```" + error + "```",
|
||||
title: "DAEMON ERROR: resolve"
|
||||
});
|
||||
return reject("DAEMON ERROR: resolve");
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(daemonResponse, "error")) {
|
||||
messageSlack({
|
||||
message: "```" + daemonResponse.error + "```",
|
||||
title: "DAEMON ERROR: resolve"
|
||||
});
|
||||
return reject("DAEMON ERROR: resolve");
|
||||
} else
|
||||
return resolve(daemonResponse.result);
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
let getTrending = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let options = {
|
||||
method: "POST",
|
||||
url: "https://api.lbry.tv/api/proxy",
|
||||
headers:
|
||||
{
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body:
|
||||
{
|
||||
method: "claim_search",
|
||||
params:
|
||||
{
|
||||
page_size: 20,
|
||||
page: 1,
|
||||
no_totals: true,
|
||||
any_tags:
|
||||
["art",
|
||||
"automotive",
|
||||
"blockchain",
|
||||
"comedy",
|
||||
"economics",
|
||||
"education",
|
||||
"gaming",
|
||||
"music",
|
||||
"news",
|
||||
"science",
|
||||
"sports",
|
||||
"technology"],
|
||||
channel_ids: [],
|
||||
not_channel_ids: [],
|
||||
not_tags: ["porn", "nsfw", "mature", "xxx"],
|
||||
order_by: ["trending_global", "trending_mixed"]
|
||||
}
|
||||
},
|
||||
json: true
|
||||
};
|
||||
|
||||
request(options, function(error, response, daemonResponse) {
|
||||
if (error) {
|
||||
messageSlack({
|
||||
message: "```" + error + "```",
|
||||
title: "DAEMON ERROR: trending"
|
||||
});
|
||||
return reject("DAEMON ERROR: trending");
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(daemonResponse, "error")) {
|
||||
messageSlack({
|
||||
message: "```" + daemonResponse.error + "```",
|
||||
title: "DAEMON ERROR: trending"
|
||||
});
|
||||
return reject("DAEMON ERROR: trending");
|
||||
} else
|
||||
return resolve(daemonResponse.result.items);
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
addSupport,
|
||||
publish,
|
||||
resolve,
|
||||
getTrending
|
||||
};
|
||||
+15
-2
@@ -4,7 +4,7 @@
|
||||
|
||||
// P A C K A G E S
|
||||
|
||||
import color from "colorette";
|
||||
import * as color from "colorette";
|
||||
import compress from "fastify-compress";
|
||||
import cors from "cors";
|
||||
import fastify from "fastify";
|
||||
@@ -22,7 +22,20 @@ import redirects from "~data/redirects.json";
|
||||
const server = fastify({
|
||||
logger: {
|
||||
level: "warn",
|
||||
prettyPrint: process.env.NODE_ENV === "development" ? true : false
|
||||
prettyPrint: process.env.NODE_ENV === "development",
|
||||
redact: ["req.headers.authorization"],
|
||||
serializers: {
|
||||
req(req) {
|
||||
return {
|
||||
headers: req.headers,
|
||||
hostname: req.hostname,
|
||||
method: req.method,
|
||||
remoteAddress: req.ip,
|
||||
remotePort: req.connection.remotePort,
|
||||
url: req.url
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -16,16 +16,20 @@ function superscript(state, silent) {
|
||||
const max = state.posMax;
|
||||
const start = state.pos;
|
||||
let found;
|
||||
let content;
|
||||
let token;
|
||||
|
||||
if (state.src.charCodeAt(start) !== 0x5E/* ^ */) return false;
|
||||
if (silent) return false; // do not run pairs in validation mode
|
||||
if (start + 2 >= max) return false;
|
||||
if (state.src.charCodeAt(start) !== 0x5E/* ^ */)
|
||||
return false;
|
||||
|
||||
if (silent)
|
||||
return false; // do not run pairs in validation mode
|
||||
|
||||
if (start + 2 >= max)
|
||||
return false;
|
||||
|
||||
state.pos = start + 1;
|
||||
|
||||
while (state.pos < max) {
|
||||
while(state.pos < max) {
|
||||
if (state.src.charCodeAt(state.pos) === 0x5E/* ^ */) {
|
||||
found = true;
|
||||
break;
|
||||
@@ -39,7 +43,7 @@ function superscript(state, silent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
content = state.src.slice(start + 1, state.pos);
|
||||
const content = state.src.slice(start + 1, state.pos);
|
||||
|
||||
// do not allow unescaped spaces/newlines inside
|
||||
if (content.match(/(^|[^\\])(\\\\)*\s/)) {
|
||||
@@ -59,16 +63,14 @@ function superscript(state, silent) {
|
||||
|
||||
if (content.match(regexForIds)) {
|
||||
const theLink = supText.match(regexForIds)[0].replace("(#", "").replace(")", "");
|
||||
|
||||
token.attrPush([ "id", theLink ]);
|
||||
token.attrPush(["id", theLink]); // eslint-disable-line padding-line-between-statements
|
||||
}
|
||||
|
||||
token = state.push("text", "", 0);
|
||||
|
||||
if (content.match(regexForIds)) {
|
||||
const theText = supText.match(regexForTextBeforeLink)[0];
|
||||
|
||||
token.content = theText;
|
||||
token.content = theText; // eslint-disable-line padding-line-between-statements
|
||||
} else token.content = supText;
|
||||
|
||||
token = state.push("sup_close", "sup", -1);
|
||||
@@ -84,6 +86,6 @@ function superscript(state, silent) {
|
||||
|
||||
// E X P O R T
|
||||
|
||||
module.exports = exports = function sup_plugin(md) {
|
||||
module.exports = exports = function sup_plugin(md) { // eslint-disable-line camelcase
|
||||
md.inline.ruler.after("emphasis", "sup", superscript);
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// P R O G R A M
|
||||
|
||||
const relativeDate = (undefined => {
|
||||
const relativeDate = (() => {
|
||||
const SECOND = 1000;
|
||||
const MINUTE = 60 * SECOND;
|
||||
const HOUR = 60 * MINUTE;
|
||||
@@ -14,23 +14,23 @@ const relativeDate = (undefined => {
|
||||
const MONTH = YEAR / 12;
|
||||
|
||||
const formats = [
|
||||
[ 0.7 * MINUTE, "just now" ],
|
||||
[ 1.5 * MINUTE, "a minute ago" ],
|
||||
[ 60 * MINUTE, "minutes ago", MINUTE ],
|
||||
[ 1.5 * HOUR, "an hour ago" ],
|
||||
[ DAY, "hours ago", HOUR ],
|
||||
[ 2 * DAY, "yesterday" ],
|
||||
[ 7 * DAY, "days ago", DAY ],
|
||||
[ 1.5 * WEEK, "a week ago" ],
|
||||
[ MONTH, "weeks ago", WEEK ],
|
||||
[ 1.5 * MONTH, "a month ago" ],
|
||||
[ YEAR, "months ago", MONTH ],
|
||||
[ 1.5 * YEAR, "a year ago" ],
|
||||
[ Number.MAX_VALUE, "years ago", YEAR ]
|
||||
[0.7 * MINUTE, "just now"],
|
||||
[1.5 * MINUTE, "a minute ago"],
|
||||
[60 * MINUTE, "minutes ago", MINUTE],
|
||||
[1.5 * HOUR, "an hour ago"],
|
||||
[DAY, "hours ago", HOUR],
|
||||
[2 * DAY, "yesterday"],
|
||||
[7 * DAY, "days ago", DAY],
|
||||
[1.5 * WEEK, "a week ago"],
|
||||
[MONTH, "weeks ago", WEEK],
|
||||
[1.5 * MONTH, "a month ago"],
|
||||
[YEAR, "months ago", MONTH],
|
||||
[1.5 * YEAR, "a year ago"],
|
||||
[Number.MAX_VALUE, "years ago", YEAR]
|
||||
];
|
||||
|
||||
function relativeDate(input, reference) {
|
||||
!reference && (reference = (new Date).getTime());
|
||||
!reference && (reference = (new Date()).getTime());
|
||||
reference instanceof Date && (reference = reference.getTime());
|
||||
input instanceof Date && (input = input.getTime());
|
||||
|
||||
@@ -40,9 +40,8 @@ const relativeDate = (undefined => {
|
||||
for (let i = -1; ++i < len;) {
|
||||
const format = formats[i];
|
||||
|
||||
if (delta < format[0]) {
|
||||
if (delta < format[0])
|
||||
return format[2] === undefined ? format[1] : Math.round(delta / format[2]) + " " + format[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +52,5 @@ const relativeDate = (undefined => {
|
||||
|
||||
// E X P O R T
|
||||
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
if (typeof module !== "undefined" && module.exports)
|
||||
module.exports = exports = relativeDate;
|
||||
}
|
||||
@@ -55,15 +55,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
.api-toc__select,
|
||||
.api-toc__search-field {
|
||||
width: 100%;
|
||||
|
||||
border-top: none;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid $lbry-gray-1;
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
.api-toc__select {
|
||||
background-position-x: 95%;
|
||||
}
|
||||
|
||||
.api-toc__search {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.api-toc__search-field {
|
||||
width: 100%;
|
||||
padding: 0.25rem calc(2rem + 4px) 0.25rem 0.75rem;
|
||||
|
||||
border-bottom: 1px solid $lbry-gray-1;
|
||||
border-radius: 0; // TODO: Put this rule in components on inputs
|
||||
font-size: 0.8rem;
|
||||
line-height: 2rem;
|
||||
|
||||
@@ -3,6 +3,21 @@ developer-program {
|
||||
|
||||
input-submit {
|
||||
padding-top: 0.5rem;
|
||||
|
||||
button {
|
||||
color: $lbry-white;
|
||||
padding-right: 1.5rem;
|
||||
padding-left: 1.5rem;
|
||||
transition: background-color 0.2s;
|
||||
|
||||
&:not(:hover) {
|
||||
background-color: $lbry-black;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: $lbry-teal-4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button {
|
||||
|
||||
@@ -265,6 +265,7 @@
|
||||
}
|
||||
|
||||
.playground-content__urlbar {
|
||||
height: 2.5rem;
|
||||
border: 1px solid $lbry-gray-1;
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
@@ -289,6 +290,7 @@
|
||||
|
||||
input {
|
||||
width: calc(100% - 9.5rem);
|
||||
border: none;
|
||||
font-size: 1rem;
|
||||
|
||||
&::placeholder {
|
||||
@@ -299,12 +301,12 @@
|
||||
|
||||
span {
|
||||
@include no-user-select;
|
||||
width: 3.5rem;
|
||||
width: 3.5rem; height: 2.5rem;
|
||||
|
||||
color: $lbry-gray-4;
|
||||
cursor: default;
|
||||
font-size: 1rem;
|
||||
line-height: 2rem;
|
||||
line-height: 2.4;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
+104
-96
@@ -9,9 +9,12 @@ import html from "choo/html";
|
||||
|
||||
// U T I L S
|
||||
|
||||
import apiPage from "~view/api";
|
||||
import fetchMetadata from "~helper/fetch-metadata";
|
||||
import lbrytvAPI from "~helper/lbrytv-sdk";
|
||||
import { generateGitHubFeed } from "~helper/github";
|
||||
import messageSlack from "~helper/slack";
|
||||
import { URL } from "url";
|
||||
|
||||
const githubAppId = process.env.GITHUB_APP_ID;
|
||||
const githubAppSecret = process.env.GITHUB_APP_SECRET;
|
||||
@@ -23,7 +26,7 @@ const githubAppSecret = process.env.GITHUB_APP_SECRET;
|
||||
|
||||
// P R O G R A M
|
||||
|
||||
export default (socket, action) => {
|
||||
export default async(socket, action) => {
|
||||
if (typeof socket !== "object" && typeof action !== "object")
|
||||
return;
|
||||
|
||||
@@ -88,6 +91,22 @@ export default (socket, action) => {
|
||||
newsletterSubscribe(action, socket);
|
||||
break;
|
||||
|
||||
|
||||
case action.message === "view different documentation version":
|
||||
send(socket, {
|
||||
element: "div",
|
||||
html: await apiPage({
|
||||
params: {
|
||||
wildcard: action.version.split("-")[0]
|
||||
},
|
||||
tag: action.version.split("-")[1]
|
||||
}),
|
||||
message: "replace html",
|
||||
parentElement: "main",
|
||||
selector: ".__slate"
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -99,56 +118,56 @@ export default (socket, action) => {
|
||||
|
||||
function generateContent(exampleNumber, displayTrendingContent) {
|
||||
if (exampleNumber === 1) {
|
||||
return getTrendingContent().then(response => {
|
||||
if (!response || !response.success || response.success !== true || !response.data)
|
||||
return "";
|
||||
return lbrytvAPI.getTrending()
|
||||
.then(response => {
|
||||
const renderedContentCollection = [];
|
||||
const urlsToResolve = [];
|
||||
|
||||
const rawContentCollection = [];
|
||||
const renderedContentCollection = [];
|
||||
const trendingContentData = response.data;
|
||||
response.forEach(r =>{
|
||||
urlsToResolve.push(r.canonical_url);
|
||||
});
|
||||
lbrytvAPI.resolve(urlsToResolve)
|
||||
.then(resolveResponse => {
|
||||
if (resolveResponse !== null) {
|
||||
let responses = Object.values(resolveResponse);
|
||||
|
||||
for (const data of trendingContentData)
|
||||
rawContentCollection.push(fetchMetadata({
|
||||
claim: data.url,
|
||||
example: exampleNumber,
|
||||
method: "resolve"
|
||||
}));
|
||||
for (let r in responses) {
|
||||
let part = responses[r];
|
||||
|
||||
Promise.all(rawContentCollection).then(collection => {
|
||||
for (const part of collection) {
|
||||
try {
|
||||
if (part.value && part.value.thumbnail.url) {
|
||||
renderedContentCollection.push(`
|
||||
<section class="playground-content__trend">
|
||||
<figure
|
||||
class="media__thumb"
|
||||
data-action="choose claim"
|
||||
data-claim-id="${part.claim_id}"
|
||||
data-name=${part.name}
|
||||
style="background-image: url(${makeImageSourceSecure(part.value.thumbnail.url)})">
|
||||
</figure>
|
||||
|
||||
<div class="media__title">
|
||||
${part.value.title || "Untitled"}
|
||||
</div>
|
||||
|
||||
<div class="media__subtitle">
|
||||
${part.signing_channel ? part.signing_channel.name : "Anon"}
|
||||
</div>
|
||||
</section>
|
||||
`);
|
||||
}
|
||||
}
|
||||
}
|
||||
renderedContentCollection.push(`
|
||||
<section class="playground-content__trend">
|
||||
<figure
|
||||
class="media__thumb"
|
||||
data-action="choose claim"
|
||||
data-claim-id="${part.name}"
|
||||
${part.value.thumbnail.url.length ? `style="background-image: url(${makeImageSourceSecure(part.value.thumbnail.url)})"` : ""}
|
||||
></figure>
|
||||
|
||||
<div class="media__title">
|
||||
${part.value.title}
|
||||
</div>
|
||||
|
||||
<div class="media__subtitle">
|
||||
${part.channel_name}
|
||||
</div>
|
||||
</section>
|
||||
`);
|
||||
} catch(err) {
|
||||
return; // TODO: Return nice error message
|
||||
}
|
||||
}
|
||||
|
||||
renderedContentCollection.push(`
|
||||
<script>
|
||||
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 1']").dataset.description
|
||||
</script>
|
||||
`);
|
||||
|
||||
displayTrendingContent(renderedContentCollection.join(""));
|
||||
<script>
|
||||
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 1']").dataset.description
|
||||
</script>
|
||||
`);
|
||||
displayTrendingContent(renderedContentCollection.join(""));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (exampleNumber === 3) {
|
||||
@@ -164,51 +183,49 @@ function generateContent(exampleNumber, displayTrendingContent) {
|
||||
"minecraft-in-real-life-iron-man#758dd6497cdfc401ae1f25984738d024d47b50af",
|
||||
"ethan-shows-kyle-warframe-skyvault#8a7401b88d5ed0376d98f16808194d4dcb05b284"
|
||||
];
|
||||
|
||||
const rawContentCollection = [];
|
||||
const renderedContentCollection = [];
|
||||
|
||||
for (const url of approvedUrls)
|
||||
rawContentCollection.push(fetchMetadata({ claim: url, method: "resolve", example: 1 }));
|
||||
lbrytvAPI.resolve(approvedUrls)
|
||||
.then(resolveResponse => {
|
||||
if (resolveResponse !== null) {
|
||||
let responses = Object.values(resolveResponse);
|
||||
|
||||
return Promise.all(rawContentCollection).then(collection => {
|
||||
for (const part of collection) {
|
||||
if (
|
||||
part &&
|
||||
part.value &&
|
||||
part.value.thumbnail.url &&
|
||||
part.channel_name
|
||||
) {
|
||||
renderedContentCollection.push(`
|
||||
<section class="playground-content__trend">
|
||||
<figure
|
||||
class="media__thumb"
|
||||
data-action="choose claim"
|
||||
data-claim-id="${part.claim_id}"
|
||||
data-name=${part.name}
|
||||
style="background-image: url(${makeImageSourceSecure(part.value.thumbnail.url)})">
|
||||
</figure>
|
||||
for (let r in responses) {
|
||||
let part = responses[r];
|
||||
|
||||
<div class="media__title">
|
||||
${part.value.title}
|
||||
</div>
|
||||
|
||||
<div class="media__subtitle">
|
||||
${part.channel_name}
|
||||
</div>
|
||||
</section>
|
||||
`);
|
||||
if (part.value && part.value.thumbnail.url) {
|
||||
renderedContentCollection.push(`
|
||||
<section class="playground-content__trend">
|
||||
<figure
|
||||
class="media__thumb"
|
||||
data-action="choose claim"
|
||||
data-claim-id="${part.claim_id}"
|
||||
data-name=${part.name}
|
||||
style="background-image: url(${makeImageSourceSecure(part.value.thumbnail.url)})">
|
||||
</figure>
|
||||
|
||||
<div class="media__title">
|
||||
${part.value.title || "Untitled"}
|
||||
</div>
|
||||
|
||||
<div class="media__subtitle">
|
||||
${part.signing_channel ? part.signing_channel.name : "Anon"}
|
||||
</div>
|
||||
</section>
|
||||
`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderedContentCollection.push(`
|
||||
<script>
|
||||
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 3']").dataset.description
|
||||
</script>
|
||||
`);
|
||||
|
||||
displayTrendingContent(renderedContentCollection.join(""));
|
||||
});
|
||||
renderedContentCollection.push(`
|
||||
<script>
|
||||
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 3']").dataset.description
|
||||
</script>
|
||||
`);
|
||||
displayTrendingContent(renderedContentCollection.join(""));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,15 +366,6 @@ function getGitHubUserToken(socket) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getTrendingContent() {
|
||||
try {
|
||||
const response = await got("https://api.lbry.com/file/list_trending");
|
||||
return JSON.parse(response.body); // eslint-disable-line padding-line-between-statements
|
||||
} catch(error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
function makeImageSourceSecure(url) {
|
||||
if (!url || !url.length)
|
||||
return url;
|
||||
@@ -434,7 +442,7 @@ async function verifyGitHubToken(data, socket) {
|
||||
const code = data.code;
|
||||
|
||||
try {
|
||||
let result = await got.post(`https://github.com/login/oauth/access_token?client_id=${githubAppId}&client_secret=${githubAppSecret}&code=${code}`, { json: true });
|
||||
const result = await got.post(`https://github.com/login/oauth/access_token?client_id=${githubAppId}&client_secret=${githubAppSecret}&code=${code}`, { json: true });
|
||||
|
||||
const response = {
|
||||
address: data.address,
|
||||
|
||||
+128
-39
@@ -7,6 +7,7 @@
|
||||
import asyncHtml from "choo-async/html";
|
||||
import dedent from "dedent";
|
||||
import got from "got";
|
||||
import Octokit from "@octokit/rest";
|
||||
|
||||
// U T I L S
|
||||
|
||||
@@ -14,31 +15,45 @@ import headerBlockchain from "~component/api/header-blockchain";
|
||||
import headerSdk from "~component/api/header-sdk";
|
||||
import redirects from "~data/redirects.json";
|
||||
|
||||
const blockchainApi = "https://raw.githubusercontent.com/lbryio/lbrycrd/master/contrib/devtools/generated/api_v1.json";
|
||||
const cache = new Map();
|
||||
const sdkApi = "https://raw.githubusercontent.com/lbryio/lbry/master/docs/api.json";
|
||||
const filePathBlockchain = "/contrib/devtools/generated/api_v1.json";
|
||||
const filePathSdk = "/lbry/docs/api.json";
|
||||
const rawGitHubBase = "https://raw.githubusercontent.com/lbryio/";
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: `token ${process.env.GITHUB_OAUTH_TOKEN}`
|
||||
});
|
||||
|
||||
|
||||
|
||||
// E X P O R T
|
||||
|
||||
export default async(state) => {
|
||||
// below is evil, I just inherited it -- Jeremy
|
||||
const apilabel = state.params.wildcard === "sdk" ?
|
||||
"SDK" :
|
||||
state.params.wildcard.charAt(0).toLocaleUpperCase() + state.params.wildcard.substring(1);
|
||||
const { tag } = state;
|
||||
const { wildcard } = state.params;
|
||||
|
||||
const repository = wildcard === "sdk" ?
|
||||
"lbry-sdk" :
|
||||
"lbrycrd";
|
||||
|
||||
state.lbry = {
|
||||
title: apilabel + " API Documentation",
|
||||
description: "See API documentation, signatures, and sample calls for the LBRY " + apilabel + " APIs."
|
||||
title: tag ? tag + " API Documentation" : "API Documentation",
|
||||
description: "See API documentation, signatures, and sample calls for the LBRY APIs."
|
||||
};
|
||||
|
||||
const tags = await getTags(repository);
|
||||
const currentTag = tag && tag.length ? tag : tags[0];
|
||||
|
||||
try {
|
||||
const apiResponse = await parseApiFile(state.params.wildcard);
|
||||
const apiResponse = await parseApiFile({ repo: repository, tag: currentTag });
|
||||
|
||||
return asyncHtml`
|
||||
<div class="__slate">
|
||||
<aside class="api-toc">
|
||||
<select class="api-toc__select" onchange="changeDocumentationVersion(value);">
|
||||
${renderVersionSelector(wildcard, tags, tag)}
|
||||
</select>
|
||||
|
||||
<div class="api-toc__search">
|
||||
<input class="api-toc__search-field" id="input-search" placeholder="Search" type="search"/>
|
||||
<div class="api-toc__search-clear" id="clear-search" title="Clear search query">×</div>
|
||||
@@ -46,35 +61,37 @@ export default async(state) => {
|
||||
</div>
|
||||
|
||||
<ul class="api-toc__commands" id="toc" role="navigation">
|
||||
${apilabel === "SDK" ? createSdkSidebar(apiResponse) : createApiSidebar(apiResponse)}
|
||||
${wildcard === "sdk" ? createSdkSidebar(apiResponse) : createApiSidebar(apiResponse)}
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<section class="api-content">
|
||||
<div class="api-documentation" id="toc-content">
|
||||
<div></div>
|
||||
|
||||
<nav class="api-content__items">
|
||||
${renderToggles(apilabel === "SDK")}
|
||||
${renderCodeLanguageToggles(wildcard)}
|
||||
</nav>
|
||||
|
||||
${createApiHeader(state.params.wildcard)}
|
||||
${apilabel === "SDK" ? createSdkContent(apiResponse) : createApiContent(apiResponse)}
|
||||
${createApiHeader(wildcard, currentTag)}
|
||||
${wildcard === "sdk" ? createSdkContent(apiResponse) : createApiContent(apiResponse)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="/assets/scripts/plugins/jets.js"></script>
|
||||
<script src="/assets/scripts/api.js"></script>
|
||||
|
||||
<script>
|
||||
initializeApiFunctionality();
|
||||
|
||||
if (window.location.pathname === "/api/blockchain")
|
||||
document.getElementById("toggle-cli").click();
|
||||
else
|
||||
document.getElementById("toggle-curl").click();
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script src="/assets/scripts/plugins/jets.js"></script>
|
||||
<script src="/assets/scripts/api.js"></script>
|
||||
|
||||
<script>
|
||||
if (window.location.pathname === "/api/blockchain")
|
||||
document.getElementById("toggle-cli").click();
|
||||
else
|
||||
document.getElementById("toggle-curl").click();
|
||||
</script>
|
||||
`;
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch(error) {
|
||||
const redirectUrl = redirects[state.href];
|
||||
|
||||
return asyncHtml`
|
||||
@@ -134,13 +151,13 @@ function createApiContent(apiDetails) {
|
||||
return apiContent;
|
||||
}
|
||||
|
||||
function createApiHeader(slug) {
|
||||
function createApiHeader(slug, apiVersion) {
|
||||
switch(slug) {
|
||||
case "blockchain":
|
||||
return headerBlockchain();
|
||||
return headerBlockchain(apiVersion);
|
||||
|
||||
case "sdk":
|
||||
return headerSdk();
|
||||
return headerSdk(apiVersion);
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -220,24 +237,70 @@ function createSdkSidebar(apiDetails) {
|
||||
return apiSidebar;
|
||||
}
|
||||
|
||||
async function parseApiFile(urlSlug) {
|
||||
let apiFileLink;
|
||||
async function getTags(repositoryName) {
|
||||
const { data } = await octokit.repos.listTags({
|
||||
owner: "lbryio",
|
||||
repo: repositoryName
|
||||
});
|
||||
|
||||
const tags = ["master"];
|
||||
|
||||
// NOTE:
|
||||
// The versioning in our repos do not make sense so extra
|
||||
// exclusion code is needed to make this work.
|
||||
//
|
||||
// Documentation is only available after specific versions.
|
||||
|
||||
switch(true) {
|
||||
case (urlSlug === "blockchain"):
|
||||
apiFileLink = blockchainApi;
|
||||
case repositoryName === "lbry-sdk":
|
||||
data.forEach(tag => {
|
||||
if (
|
||||
tag.name >= "v0.38.0" &&
|
||||
tag.name !== "v0.38.0rc7" &&
|
||||
tag.name !== "v0.38.0rc6" &&
|
||||
tag.name !== "v0.38.0rc5" &&
|
||||
tag.name !== "v0.38.0rc4" &&
|
||||
tag.name !== "v0.38.0rc3" &&
|
||||
tag.name !== "v0.38.0rc2" &&
|
||||
tag.name !== "v0.38.0rc1"
|
||||
) tags.push(tag.name);
|
||||
});
|
||||
break;
|
||||
|
||||
case (urlSlug === "sdk"):
|
||||
apiFileLink = sdkApi;
|
||||
case repositoryName === "lbrycrd":
|
||||
data.forEach(tag => {
|
||||
if (
|
||||
tag.name >= "v0.17.1.0" &&
|
||||
tag.name !== "v0.3.16" &&
|
||||
tag.name !== "v0.3.15" &&
|
||||
tag.name !== "v0.3-osx" &&
|
||||
tag.name !== "v0.2-alpha"
|
||||
) tags.push(tag.name);
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!apiFileLink)
|
||||
return Promise.reject(new Error("Failed to fetch API docs"));
|
||||
return tags;
|
||||
}
|
||||
|
||||
async function parseApiFile({ repo, tag }) {
|
||||
let apiFileLink = `${rawGitHubBase}${repo}/${tag}`;
|
||||
|
||||
switch(true) {
|
||||
case (repo === "lbrycrd"):
|
||||
apiFileLink = `${apiFileLink}${filePathBlockchain}`;
|
||||
break;
|
||||
|
||||
case (repo === "lbry-sdk"):
|
||||
apiFileLink = `${apiFileLink}${filePathSdk}`;
|
||||
break;
|
||||
|
||||
default:
|
||||
return Promise.reject(new Error("Failed to fetch API docs"));
|
||||
}
|
||||
|
||||
const response = await got(apiFileLink, { cache, json: true });
|
||||
|
||||
@@ -259,7 +322,7 @@ function renderArguments(args) {
|
||||
<li class="api-content__body-argument">
|
||||
<div class="left">
|
||||
<strong>${arg.name}</strong><br/>
|
||||
${arg.is_required === true ? "" : "<span>optional</span>" }<span>${arg.type}</span>
|
||||
${arg.is_required === true ? "" : "<span>optional</span>"}<span>${arg.type}</span>
|
||||
</div>
|
||||
|
||||
<div class="right">${typeof arg.description === "string" ? arg.description.replace(/</g, "<").replace(/>/g, ">") : ""}</div>
|
||||
@@ -307,7 +370,33 @@ function renderReturns(args) {
|
||||
return returnContent;
|
||||
}
|
||||
|
||||
function renderToggles(onSdkPage) {
|
||||
function renderVersionSelector(pageSlug, versions, desiredTag) {
|
||||
const options = [
|
||||
"<option disabled>Select a version</option>"
|
||||
];
|
||||
|
||||
let optionIndex = 0;
|
||||
|
||||
versions.forEach(version => {
|
||||
optionIndex++;
|
||||
let selectedOption = false;
|
||||
|
||||
if (desiredTag && desiredTag === version)
|
||||
selectedOption = true;
|
||||
else if (optionIndex === 1)
|
||||
selectedOption = true;
|
||||
|
||||
options.push(
|
||||
`<option value="${pageSlug}-${version}"${selectedOption ? " selected" : ""}>${version}</option>`
|
||||
);
|
||||
});
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function renderCodeLanguageToggles(pageSlug) {
|
||||
const onSdkPage = pageSlug === "sdk";
|
||||
|
||||
return [
|
||||
"<button class='api-content__item menu' id='toggle-menu'>menu</button>",
|
||||
!onSdkPage ? "<button class='api-content__item' id='toggle-cli' type='button'>cli</button>" : "",
|
||||
|
||||
@@ -37,7 +37,7 @@ export default (state, emit) => { // eslint-disable-line
|
||||
const customMetadata = {};
|
||||
|
||||
for (const key in markdownFileDetails.attributes.meta) {
|
||||
if (markdownFileDetails.attributes.meta.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(markdownFileDetails.attributes.meta, key)) {
|
||||
customMetadata[Object.keys(markdownFileDetails.attributes.meta[key])[0]] =
|
||||
markdownFileDetails.attributes.meta[key][Object.keys(markdownFileDetails.attributes.meta[key])[0]];
|
||||
}
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@ description: Learn how to build your own app via LBRY in this comprehensive guid
|
||||
|
||||
## Introduction
|
||||
|
||||
Want to build something on top of LBRY? This is the place to get started. If this is your first introduction to LBRY, you should read the [Overview](/overview) first. If you would rather build with us, check out our [Contributing Guide](/contribute).
|
||||
Want to build something on top of LBRY? This is the place to get started. If this is your first introduction to LBRY, you should read the [Overview](./overview.md) first. If you would rather build with us, check out our [Contributing Guide](./contribute.md).
|
||||
|
||||
There are exactly 1,000,006 app ideas that could work on the LBRY network, but it doesn't make sense for _everything_ to be built on it.
|
||||
|
||||
@@ -86,7 +86,7 @@ Unfortunately, most users will want more functionality in an app than typing int
|
||||
|
||||
You can build many types of apps. Your app doesn't have to use Electron, nor does it have to be targeted at consumers, use a UI, or even fetch digital content at all! In this section, we'll look into the different types of apps you could build, and the different components needed to build anything you want.
|
||||
|
||||
Most applications will use the [LBRY SDK](#sdk) as a way of accessing and communicating with the LBRY network. A look at the [APIs](/api/sdk) provided by the SDK will help you understand what it can and can't do.
|
||||
Most applications will use the [LBRY SDK](#sdk) as a way of accessing and communicating with the LBRY network. A look at the [APIs](https://lbry.tech/api/sdk) provided by the SDK will help you understand what it can and can't do.
|
||||
|
||||
Some applications do not need to access content available on the network (e.g. a wallet-only app, or a blockchain visualizer). These applications might use [lbrycrd](#lbrycrd), the full-node blockchain daemon, or [chainquery](#chainquery), which parses blockchain data into SQL.
|
||||
|
||||
@@ -142,7 +142,7 @@ Regardless of the type of desktop app, you'll want to follow the steps for [usin
|
||||
|
||||
The [official LBRY desktop app](https://github.com/lbryio/lbry-desktop) is built with Electron. It is very easy to build with, and allows web developers to easily start creating "native" desktop applications. You can use a plain html document with a `<script>` tag, or build out a large web app. The official desktop app uses [React](https://reactjs.org/).
|
||||
|
||||
If you want to write an electron app, check out the [electron-starter project](https://github.com/lbryio/electron-starter) for a bare bones setup that is very similar to how [lbry-desktop](https://github.com/lbryio/lbry-desktop) is structured. It's also a simple way to explore the [SDK API](<(https://https://lbry.tech/api/sdk)>).
|
||||
If you want to write an electron app, check out the [electron-starter project](https://github.com/lbryio/electron-starter) for a bare bones setup that is very similar to how [lbry-desktop](https://github.com/lbryio/lbry-desktop) is structured. It's also a simple way to explore the [SDK API](https://lbry.tech/api/sdk).
|
||||
|
||||
Check out [this video](https://spee.ch/6/lbry-electron-starter) for a brief overview and guide to get it running. If you just want the source code, go [here](https://github.com/lbryio/electron-starter). Or, if you really really want to see it in action _now_, just paste these commands into your terminal:
|
||||
|
||||
@@ -179,9 +179,9 @@ We do not currently have tooling available to build LBRY apps on iOS.
|
||||
|
||||
### SDK
|
||||
|
||||
The [LBRY SDK](https://github.com/lbryio/lbry) provides an API that enables easy access to all functionality of the LBRY network. Most applications will choose to use the SDK.
|
||||
The [LBRY SDK](https://github.com/lbryio/lbry-sdk) provides an API that enables easy access to all functionality of the LBRY network. Most applications will choose to use the SDK.
|
||||
|
||||
You can download the latest version from the [releases page](https://github.com/lbryio/lbry/releases) or via the following URLs, which will always download the latest SDK for each operating system:
|
||||
You can download the latest version from the [releases page](https://github.com/lbryio/lbry-sdk/releases) or via the following URLs, which will always download the latest SDK for each operating system:
|
||||
|
||||
| OS | URL |
|
||||
| --- | --- |
|
||||
@@ -195,7 +195,7 @@ Once that is downloaded, there are two steps to get it integrated into your app.
|
||||
|
||||
First, run `lbrynet start` in the directory you downloaded the SDK. This starts the API server and connects to the LBRY network.
|
||||
|
||||
Then, use an API wrapper to talk to the SDK or write your own. There are a number of simple [api wrappers](https://lbry.tech/resources/api-wrappers) available in several different languages, created by LBRY community members! These allow you to easily send commands to the SDK in the language of your choice.
|
||||
Then, use an API wrapper to talk to the SDK or write your own. There are a number of simple [API wrappers](https://lbry.tech/resources/api-wrappers) available in several different languages, created by LBRY community members! These allow you to easily send commands to the SDK in the language of your choice.
|
||||
|
||||
If a wrapper for the language you would like to use doesn't exist, it is still fairly easy to interact with. The SDK provides a JSON-RPC server at `localhost:5279` for interaction. You can call it via `cURL` or the HTTP functionality provided by the language you are using. You can look at an existing wrapper in another language for more detail.
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ If you want to contribute to LBRY, there's definitely something for you! The fir
|
||||
| Component | Language (Toolset) | What Is It | Intro Video
|
||||
--- | --- | --- | ---
|
||||
| [lbrycrd](https://github.com/lbryio/lbrycrd) | C++ | A full node for the LBRY blockchain, including a standalone wallet. Used by miners and some applications. Most consumer applications do not bundle [[lbrycrd]] directly, and instead bundle [[lbry-sdk]]. | [Video](/resources/video-lbrycrd)
|
||||
| [lbry-sdk](https://github.com/lbryio/lbry) | Python (asyncio) | A daemon that can be used directly or to develop other applications. Provides convenience [APIs](/api/sdk), bundles an SPV wallet ([[torba]]), and contains an implementation of the LBRY data network. | [Video](/resources/video-lbrysdk)
|
||||
| [torba](https://github.com/lbryio/torba) | Python | An [[SPV]] (Simple Payment Verification) wallet. Bundled with [[lbry-sdk]].
|
||||
| [wallet server](https://github.com/lbryio/lbry/tree/master/lbrynet/extras/wallet/server) | Protobuf, Python | The wallet server used by [[torba]]. | |
|
||||
| [schema](https://github.com/lbryio/lbry/tree/master/lbrynet/schema) | Protobuf, Python | Defines the structure of the metadata stored in the LBRY blockchain. | |
|
||||
| [lbry-sdk](https://github.com/lbryio/lbry-sdk) | Python (asyncio) | A daemon that can be used directly or to develop other applications. Provides convenience [APIs](/api/sdk), bundles an SPV wallet ([[torba]]), and contains an implementation of the LBRY data network. | [Video](/resources/video-lbrysdk)
|
||||
| [torba](https://github.com/lbryio/lbry-sdk) | Python | An [[SPV]] (Simple Payment Verification) wallet. Bundled with [[lbry-sdk]].
|
||||
| [wallet server](https://github.com/lbryio/lbry-sdk/tree/master/lbry/lbry/wallet/server) | Protobuf, Python | The wallet server used by [[torba]]. | |
|
||||
| [schema](https://github.com/lbryio/lbry-sdk/tree/master/lbry/lbry/schema) | Protobuf, Python | Defines the structure of the metadata stored in the LBRY blockchain. | |
|
||||
|
||||
### Official Applications
|
||||
| Application | Language (Toolset) | What Is It | Intro Video
|
||||
@@ -68,7 +68,7 @@ Several hundred extremely good-looking, wise and moral people, as well as our CT
|
||||
|
||||
Web and application designers are requested to be able to work directly on CSS in the project they'd be contributing to. Please follow the [Coding](#coding) instructions for any website or application you want to improve.
|
||||
|
||||
We're happy to provide assistance if you're used to working in HTMl and CSS but are having trouble getting started. Check out [our chat](https://chat.lbry.com) or [our forum](https://discourse.lbry.com).
|
||||
We're happy to provide assistance if you're used to working in HTML and CSS but are having trouble getting started. Check out [our chat](https://chat.lbry.com) or [our forum](https://discourse.lbry.com).
|
||||
|
||||
## Writing
|
||||
|
||||
|
||||
+11
-3
@@ -41,6 +41,10 @@ The sequence number of a block in the blockchain. The first block is at height 0
|
||||
|
||||
An open, distributed ledger that records transactions in a verifiable and change-resistant way. The LBRY blockchain serves as an index of the content available on the network, a payment system and record of purchases for priced content, and a source if cryptographic publisher identities.
|
||||
|
||||
### Canonical URL
|
||||
|
||||
Similar to the [Short URL](#short-url) but for claims that are signed by channels, both the channel Short URL and claim Short URL are returned (i.e. lbry://@LBRY-Social#d/two#f. A canonical URL will change if the channel is updated, therefore its less permanent than a Short URL which is less permanent than the [Permanent URL](https://spec.lbry.com/#urls).
|
||||
|
||||
### Chainquery
|
||||
|
||||
A tool that stores blockchain data in an SQL database, keeps the database up-to-date as the blockchain grows, and provides an API to access the data using standard SQL queries.
|
||||
@@ -128,7 +132,7 @@ The SDK is three things:
|
||||
- components that are not part of the spec but are useful for developing applications using the protocol
|
||||
- a daemon that participates in the LBRY data network and provides an API for interacting with the protocol
|
||||
|
||||
See [the source code](https://github.com/lbryio/lbry) or [the API documentation](/api/sdk).
|
||||
See [the source code](https://github.com/lbryio/lbry-sdk) or [the API documentation](/api/sdk).
|
||||
|
||||
### LBRY Credits
|
||||
|
||||
@@ -172,7 +176,7 @@ A file included with each LBRY project that contains basic information about tha
|
||||
|
||||
A long-running node that accepts blobs for upload and rehosts them on the network.
|
||||
|
||||
### Resolve (or URL Resolution)
|
||||
### Resolve (or URL Resolution) {#resolve}
|
||||
|
||||
The process of translating a URL into the associated claim ID and metadata. See [Resolution](/spec#resolution) for details.
|
||||
|
||||
@@ -184,6 +188,10 @@ A definition of the structure of the metadata that is stored in claims in the bl
|
||||
|
||||
A scheme to validate transactions without storing the whole blockchain.
|
||||
|
||||
### Short URL
|
||||
|
||||
The shortest [URL](https://spec.lbry.com/#urls), not including the [channel](#channel), that will [resolve](#resolve) to the correct claim (i.e. lbry://cats#c, returning lbry://cats#ca43e2b6db155177564e574b09dfedc7588816ef or lbry://@cats#0 returning lbry://@cats#0893dbed95307c4b27aadbcb1cc6cb593810b3f9). This is determined on a first come, first serve basis on claim id collisions. A short URL with more than one identifier may change to include only a single identifier if the previous claim, which had the single identifier, is deleted.
|
||||
|
||||
### SPV
|
||||
|
||||
SPV is an abbreviation for [Simplified Payment Verification](#simplified-payment-verification).
|
||||
@@ -218,7 +226,7 @@ A parallel LBRY blockchain, used for testing and development. Testnet is like [m
|
||||
|
||||
### Torba
|
||||
|
||||
An [SPV](#spv) wallet for the [blockchain](#blockchain). See the [source code](https://github.com/lbryio/torba).
|
||||
An [SPV](#spv) wallet for the [blockchain](#blockchain). See the [source code](https://github.com/lbryio/lbry-sdk).
|
||||
|
||||
### Transaction
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ While the blockchain is the innovation that makes LBRY _possible_, the [Data Net
|
||||
|
||||
At this level:
|
||||
|
||||
- [Metadata](/spec#metadata] stored in the blockchain is interpreted and validated.
|
||||
- [Metadata](/spec#metadata) stored in the blockchain is interpreted and validated.
|
||||
- [Data referenced by metadata](/spec#data) is accessed and distributed via a peer-to-peer network.
|
||||
- [Identities](/spec#channels) are created, signed, and validated.
|
||||
|
||||
Data network operations are provided by the [lbrysdk](https://github.com/lbryio/lbry). This SDK also provides local wallet functionality and a set of APIs to facilitate building applications.
|
||||
Data network operations are provided by the [lbrysdk](https://github.com/lbryio/lbry-sdk). This SDK also provides local wallet functionality and a set of APIs to facilitate building applications.
|
||||
|
||||
### Additional Resources
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ title: API Wrappers
|
||||
description: Find LBRY API wrappers for your favorite language.
|
||||
---
|
||||
|
||||
This document contains a comprehensive list of all available API wrappers for the LBRY protocol and blockchain. API wrappers allow for easier integration of the LBRY APIs into your codebase. They still require you to run either the [LBRY protocol](https://github.com/lbryio/lbry) or the [LBRY blockchain](https://github.com/lbryio/lbrycrd).
|
||||
This document contains a comprehensive list of all available API wrappers for the LBRY protocol and blockchain. API wrappers allow for easier integration of the LBRY APIs into your codebase. They still require you to run either the [LBRY protocol](https://github.com/lbryio/lbry-sdk) or the [LBRY blockchain](https://github.com/lbryio/lbrycrd).
|
||||
|
||||
Interested in creating one for a language not shown below? See our [bounties page](https://lbry.com/bounty/lbry-binding) for details.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ title: SDK Settings
|
||||
description: The daemon provided by the LBRY SDK has many settings. This resource lists them all and what they mean. Ready, set, settings!
|
||||
---
|
||||
|
||||
This document outlines how to configure SDK daemon settings and what options are available. They can be found on the lbry GitHub repository in [conf.py](https://github.com/lbryio/lbry/blob/master/lbrynet/conf.py).
|
||||
This document outlines how to configure SDK daemon settings and what options are available. They can be found on the lbry GitHub repository in [conf.py](https://github.com/lbryio/lbry-sdk/blob/master/lbry/lbry/conf.py).
|
||||
|
||||
## Daemon settings configuration
|
||||
|
||||
@@ -42,7 +42,8 @@ Configuration options are organized by their respective areas: Files, Wallet, Ne
|
||||
### Network
|
||||
| Setting | Format | Default value | Sample Values | Description |
|
||||
|----------------------------|---------|---------------------------|----------------------------|------------------------------------------------------------------------------------|
|
||||
| api | string | localhost:5279 | 0:0:0:0:5280 | IP address and port the SDK API will listen on |
|
||||
| api | string | localhost:5279 | 0:0:0:0:5280 | IP address and port the SDK API will listen on |
|
||||
| streaming_server | string | localhost:5280 | 0:0:0:0:5280 | IP address and port the media/streaming server will listen on |
|
||||
| cache_time | integer | 150 | 90 | How long to keep resolve data in cache |
|
||||
| data_rate | float | 0.0001 | 0.05 | What LBC rate, per MB, to offer DHT data at (currently disabled in the protocol) |
|
||||
| udp_port | integer | 4444 | 4445 | UDP port used to announce blobs |
|
||||
@@ -62,16 +63,11 @@ Configuration options are organized by their respective areas: Files, Wallet, Ne
|
||||
| node_rpc_timeout | integer | 5 | 10 | Time, in seconds, to allow connection over DHT |
|
||||
| network_interface | string | 0:0:0:0 | 127.0.0.1 | Interface to use for the DHT and blob exchange |
|
||||
| use_upnp | boolean | true | false | Attempt external port mapping via UPnP |
|
||||
|
||||
### Security
|
||||
|
||||
| Setting | Format | Default value | Sample Values | Description |
|
||||
|----------------|---------|---------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------|
|
||||
| allowed_origin | string | '' | '*' or localhost | IP address to allow API requests from |
|
||||
| use_auth_http | boolean | false | true | See [authentication instructions](https://github.com/lbryio/lbry/blob/master/lbrynet/daemon/auth/server.py#L179) for details |
|
||||
|
||||
| streaming_get | boolean | false | true | Allow calling localhost:5280/get/claimname requests |
|
||||
| save_files | boolean | true | false | Save files with each download |
|
||||
| save_blobs | boolean | true | false | Save blobs with each download |
|
||||
### Other
|
||||
| Setting | Format | Default value | Sample Values | Description |
|
||||
|--------------------|---------|---------------|--------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||
| components_to_skip | list | [] | ['reflector','hash_announcer'] | Disable components, [see entire list here](https://github.com/lbryio/lbry/wiki/Component-Dependencies-Table) |
|
||||
| components_to_skip | list | [] | ['reflector','hash_announcer'] | Disable components, [see entire list here](https://github.com/lbryio/lbry-sdk/wiki/Component-Dependencies-Table) |
|
||||
| share_usage_data | boolean | true | false | Share analytics data |
|
||||
@@ -33,7 +33,7 @@ For this example, we will use claim ID `d9317ac7842f88ba442fee749c4f834353c24206
|
||||
|
||||
## Parse the Metadata
|
||||
|
||||
Perform a `getclaimbyid` call to lbrycrd using the claim ID for the claim you want to look up. You should get a response with some parameters. The `value` parameter contains the claim contents as a protobuf-encoded binary string. Decode the value using the protobuf definitions in [lbryio/types](https://github.com/lbryio/types/tree/master/proto). You will get a Claim object.
|
||||
Perform a `getclaimbyid` call to lbrycrd using the claim ID for the claim you want to look up. You should get a response with some parameters. The `value` parameter contains the claim contents as a protobuf-encoded binary string. Decode the value using the protobuf definitions in [lbryio/types](https://github.com/lbryio/types/tree/master/v2/proto). You will get a Claim object.
|
||||
|
||||
|
||||
## Get the Stream Hash
|
||||
|
||||
@@ -33,7 +33,7 @@ For this example, we will use claimID `d9317ac7842f88ba442fee749c4f834353c24206`
|
||||
|
||||
## Parse the Metadata
|
||||
|
||||
Perform a `getclaimbyid` call to lbrycrd using the claimID for the claim you want to look up. You should get a response with some parameters. The `value` parameter contains the claim contents as a protobuf-encoded binary string. Decode the value using the protobuf definitions in [lbryio/types](https://github.com/lbryio/types/tree/master/proto). You will get a Claim object.
|
||||
Perform a `getclaimbyid` call to lbrycrd using the claimID for the claim you want to look up. You should get a response with some parameters. The `value` parameter contains the claim contents as a protobuf-encoded binary string. Decode the value using the protobuf definitions in [lbryio/types](https://github.com/lbryio/types/tree/master/v2/proto). You will get a Claim object.
|
||||
|
||||
|
||||
## Get the SD Hash
|
||||
|
||||
@@ -98,7 +98,7 @@ Alternatively, you can create a file `touch ~/.lbryum/config` and paste the foll
|
||||
|
||||
### lbry
|
||||
|
||||
Download source from [here](https://github.com/lbryio/lbry/releases), and run the following inside the environment:
|
||||
Download source from [here](https://github.com/lbryio/lbry-sdk/releases), and run the following inside the environment:
|
||||
```bash
|
||||
cd lbry
|
||||
pip2 install -r requirements.txt
|
||||
|
||||
@@ -86,7 +86,7 @@ This document should cover the following:
|
||||
* First, it should contain a single sentence: "This project follows the global contributing standards for all LBRY projects, to read those go < here >.”
|
||||
* A "Code Overview" section explaining some basic design choices and how to begin stepping through the code. An example would be explaining that Daemon.py is the primary entry point for the daemon code, and one can begin to trace through the code by looking for jsonrpc_xxx, where xxx is one of the api calls listed [here](https://lbry.com/api)
|
||||
* A "Testing" section explaining how to run tests and stating that tests are necessary
|
||||
* Information on how to submit pull requests, and what to expect afterwards (e.g. a link to our [branching doc](https://github.com/lbryio/lbry/wiki/Branching-and-Merging), commands to run before submitting PR, tests must pass, changelog entry, etc). If you find this gets repetitive, it may be best to link to a global doc
|
||||
* Information on how to submit pull requests, and what to expect afterwards (e.g. a link to our [branching doc](https://github.com/lbryio/lbry-sdk/wiki/Branching-and-Merging), commands to run before submitting PR, tests must pass, changelog entry, etc). If you find this gets repetitive, it may be best to link to a global doc
|
||||
* Anything else a new visitor to a repository should know about contributing to that specific repository (linting, generating documentation, etc)
|
||||
|
||||
## LICENSE
|
||||
|
||||
@@ -14,7 +14,7 @@ Check out [our video tutorial](/resources/video-lbrydesktop) to setup the [Deskt
|
||||
Check out [our video tutorial](/resources/video-lbryandroid) to setup the [Android app](https://github.com/lbryio/lbry-android) development environment.
|
||||
|
||||
## LBRY SDK
|
||||
Check out [our video tutorial](/resources/video-lbrysdk) to setup the [LBRY SDK](https://github.com/lbryio/lbry) development environment.
|
||||
Check out [our video tutorial](/resources/video-lbrysdk) to setup the [LBRY SDK](https://github.com/lbryio/lbry-sdk) development environment.
|
||||
|
||||
## LBRY Blockchain
|
||||
Check out [our video tutorial](/resources/video-lbrycrd) to setup the [LBRY Blockchain](https://github.com/lbryio/lbrycrd) development environment.
|
||||
+37
-36
@@ -11,71 +11,72 @@
|
||||
"author": "LBRY Team",
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "^7.4.4",
|
||||
"@inc/fastify-ws": "^1.1.0",
|
||||
"@octokit/rest": "^16.28.0",
|
||||
"@slack/client": "^5.0.1",
|
||||
"async": "^3.0.1",
|
||||
"async-es": "^3.0.1",
|
||||
"choo": "^6.13.3",
|
||||
"@inc/fastify-ws": "^2019.7.23",
|
||||
"@octokit/rest": "^16.28.7",
|
||||
"@slack/client": "^5.0.2",
|
||||
"async": "^3.1.0",
|
||||
"async-es": "^3.1.0",
|
||||
"choo": "6.13.3",
|
||||
"choo-async": "^0.1.1",
|
||||
"choo-devtools": "^2.5.1",
|
||||
"choo-devtools": "^3.0.0",
|
||||
"choo-ssr": "^0.2.1",
|
||||
"choo-websocket": "^2.0.0",
|
||||
"colorette": "^1.0.8",
|
||||
"colorette": "^1.1.0",
|
||||
"cors": "^2.8.5",
|
||||
"cron": "^1.7.1",
|
||||
"date-format-lite": "^17.7.0",
|
||||
"decamelize": "^3.2.0",
|
||||
"dedent": "^0.7.0",
|
||||
"dotenv": "^8.0.0",
|
||||
"fastify": "~2.4.1",
|
||||
"fastify": "~2.7.1",
|
||||
"fastify-compress": "^0.10.0",
|
||||
"fastify-helmet": "^3.0.0",
|
||||
"fastify-static": "^2.4.0",
|
||||
"fastify-helmet": "^3.0.1",
|
||||
"fastify-static": "^2.5.0",
|
||||
"front-matter": "^3.0.2",
|
||||
"fs-exists-sync": "^0.1.0",
|
||||
"got": "^9.6.0",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"graceful-fs": "^4.2.1",
|
||||
"link-module-alias": "^1.2.0",
|
||||
"make-promises-safe": "^5.0.0",
|
||||
"markdown-it": "^8.4.2",
|
||||
"markdown-it": "^9.0.1",
|
||||
"markdown-it-anchor": "^5.2.4",
|
||||
"prismjs": "^1.15.0",
|
||||
"prismjs": "^1.17.1",
|
||||
"redis": "^2.8.0",
|
||||
"slack-node": "^0.1.8",
|
||||
"socket.io": "^2.2.0",
|
||||
"stringify-object": "^3.3.0"
|
||||
"stringify-object": "^3.3.0",
|
||||
"request": "latest"
|
||||
},
|
||||
"description": "Documentation for the LBRY protocol and associated projects",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.4.4",
|
||||
"@babel/core": "^7.4.5",
|
||||
"@babel/cli": "^7.5.5",
|
||||
"@babel/core": "^7.5.5",
|
||||
"@babel/plugin-external-helpers": "7.2.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.4.4",
|
||||
"@babel/plugin-proposal-class-properties": "7.5.5",
|
||||
"@babel/plugin-proposal-decorators": "7.4.4",
|
||||
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
|
||||
"@babel/plugin-proposal-function-sent": "7.2.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "7.5.2",
|
||||
"@babel/plugin-proposal-function-sent": "7.5.0",
|
||||
"@babel/plugin-proposal-json-strings": "7.2.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "7.2.0",
|
||||
"@babel/plugin-proposal-throw-expressions": "7.2.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "7.2.0",
|
||||
"@babel/plugin-syntax-import-meta": "7.2.0",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@babel/register": "^7.4.4",
|
||||
"@inc/eslint-config": "^1.1.3",
|
||||
"@inc/sasslint-config": "^2019.5.7",
|
||||
"@babel/preset-env": "^7.5.5",
|
||||
"@babel/register": "^7.5.5",
|
||||
"@inc/eslint-config": "^2019.7.23",
|
||||
"@inc/sasslint-config": "^2019.7.23",
|
||||
"@lbry/color": "^1.1.1",
|
||||
"@lbry/components": "^2.7.2",
|
||||
"eslint": "^5.16.0",
|
||||
"husky": "^2.4.0",
|
||||
"@lbry/components": "^2019.6.22",
|
||||
"eslint": "^6.1.0",
|
||||
"husky": "^3.0.2",
|
||||
"nodemon": "^1.19.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pino-pretty": "^3.1.0",
|
||||
"sass": "^1.21.0",
|
||||
"pino-pretty": "^3.2.0",
|
||||
"sass": "^1.22.9",
|
||||
"sass-lint": "^1.13.1",
|
||||
"snazzy": "^8.0.0",
|
||||
"standardx": "^3.0.1",
|
||||
"updates": "^8.1.0"
|
||||
"standardx": "^4.0.0",
|
||||
"updates": "^8.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "10.2.x"
|
||||
@@ -93,15 +94,15 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"css": "sass --load-path=node_modules --update app/sass:app/dist --style compressed",
|
||||
"format": "eslint '**/*.js' --fix --ignore-pattern '/app/dist/'",
|
||||
"format": "eslint . --fix --ignore-pattern '/app/dist/'",
|
||||
"postinstall": "link-module-alias",
|
||||
"preinstall": "command -v link-module-alias; link-module-alias clean || true",
|
||||
"start": "npm i; npm run css; NODE_ENV=production node index.js",
|
||||
"preinstall": "command -v link-module-alias;link-module-alias clean || true",
|
||||
"start": "npm i;npm run css;NODE_ENV=production node index.js",
|
||||
"test": "run-s test:*",
|
||||
"test:dependencies": "updates --update ./ --exclude prismjs",
|
||||
"test:lint": "standardx --verbose | snazzy",
|
||||
"test:sass": "sass-lint --config ./node_modules/@inc/sasslint-config/config.json --verbose --no-exit",
|
||||
"watch": "npm run css; run-p watch:*",
|
||||
"watch": "npm run css;run-p watch:*",
|
||||
"watch:sass": "sass --load-path=node_modules --watch app/sass:app/dist --style compressed",
|
||||
"watch:server": "NODE_ENV=development nodemon --ignore 'app/dist'"
|
||||
},
|
||||
@@ -110,5 +111,5 @@
|
||||
"app/dist"
|
||||
]
|
||||
},
|
||||
"version": "5.3.1"
|
||||
"version": "5.3.2"
|
||||
}
|
||||
Reference in new issue
Block a user