Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1c6549dd2 | ||
|
|
362c14c83c | ||
|
|
053aad7833 | ||
|
|
026bb01b81 | ||
|
|
e020eb3c13 | ||
|
|
1be0995bbf | ||
|
|
d8b37ed0e6 | ||
|
|
1b56526711 | ||
|
|
707f616224 | ||
|
|
5277050c37 | ||
|
|
698222cf32 | ||
|
|
1c0888e0cf | ||
|
|
39ea483f08 | ||
|
|
6ae0984edf | ||
|
|
d5932ce67c | ||
|
|
777d9f0f83 | ||
|
|
b3ae6ca0d6 | ||
|
|
ebbcb02c87 |
No files matched your search
@@ -65,12 +65,12 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
switch(true) {
|
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 =
|
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>";
|
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case result.error:
|
case Boolean(result.error):
|
||||||
document.querySelector("developer-program").innerHTML =
|
document.querySelector("developer-program").innerHTML =
|
||||||
`<p>${result.error}</p>`;
|
`<p>${result.error}</p>`;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ const handleExamples = debounce(event => {
|
|||||||
|
|
||||||
switch(data.action) {
|
switch(data.action) {
|
||||||
case "choose claim":
|
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"))
|
if (document.querySelector(".playground-navigation__example:nth-child(3)").classList.contains("active"))
|
||||||
document.getElementById("fetch-claim-uri").value = event.dataset.name + "#" + event.dataset.claimId;
|
document.getElementById("fetch-claim-uri").value = event.dataset.name + "#" + event.dataset.claimId;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default pagePath => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "/api/blockchain":
|
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;
|
break;
|
||||||
|
|
||||||
case "/api/sdk":
|
case "/api/sdk":
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import stringifyObject from "stringify-object";
|
|||||||
|
|
||||||
import messageSlack from "./slack";
|
import messageSlack from "./slack";
|
||||||
import publishMeme from "./publish-meme";
|
import publishMeme from "./publish-meme";
|
||||||
|
import lbrytvAPI from "~helper/lbrytv-sdk";
|
||||||
|
|
||||||
import randomString from "./random-string";
|
import randomString from "./random-string";
|
||||||
import { send } from "~socket";
|
import { send } from "~socket";
|
||||||
import uploadImage from "./upload-image";
|
import uploadImage from "./upload-image";
|
||||||
@@ -76,10 +78,10 @@ export default async(data, socket) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(true) {
|
switch(resolveMethod) {
|
||||||
// T I P
|
// T I P
|
||||||
// E X A M P L E
|
// E X A M P L E
|
||||||
case resolveMethod === "support_create":
|
case "support_create":
|
||||||
if (!approvedContentIdsForTipping.includes(claimAddress)) {
|
if (!approvedContentIdsForTipping.includes(claimAddress)) {
|
||||||
return send(socket, {
|
return send(socket, {
|
||||||
example: data.example,
|
example: data.example,
|
||||||
@@ -103,7 +105,7 @@ export default async(data, socket) => {
|
|||||||
|
|
||||||
// P U B L I S H
|
// P U B L I S H
|
||||||
// E X A M P L E
|
// E X A M P L E
|
||||||
case resolveMethod === "publish":
|
case "publish":
|
||||||
apiRequestMethod = "PUT";
|
apiRequestMethod = "PUT";
|
||||||
|
|
||||||
// Required for publishing
|
// Required for publishing
|
||||||
@@ -194,10 +196,36 @@ export default async(data, socket) => {
|
|||||||
|
|
||||||
// R E S O L V E
|
// R E S O L V E
|
||||||
// E X A M P L E
|
// E X A M P L E
|
||||||
case resolveMethod === "resolve":
|
case "resolve":
|
||||||
apiRequestMethod = "GET";
|
apiRequestMethod = "GET";
|
||||||
body.uri = claimAddress;
|
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;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
};
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// P A C K A G E S
|
// P A C K A G E S
|
||||||
|
|
||||||
import color from "colorette";
|
import * as color from "colorette";
|
||||||
import compress from "fastify-compress";
|
import compress from "fastify-compress";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import fastify from "fastify";
|
import fastify from "fastify";
|
||||||
|
|||||||
+86
-106
@@ -11,6 +11,7 @@ import html from "choo/html";
|
|||||||
|
|
||||||
import apiPage from "~view/api";
|
import apiPage from "~view/api";
|
||||||
import fetchMetadata from "~helper/fetch-metadata";
|
import fetchMetadata from "~helper/fetch-metadata";
|
||||||
|
import lbrytvAPI from "~helper/lbrytv-sdk";
|
||||||
import { generateGitHubFeed } from "~helper/github";
|
import { generateGitHubFeed } from "~helper/github";
|
||||||
import messageSlack from "~helper/slack";
|
import messageSlack from "~helper/slack";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
@@ -117,67 +118,56 @@ export default async(socket, action) => {
|
|||||||
|
|
||||||
function generateContent(exampleNumber, displayTrendingContent) {
|
function generateContent(exampleNumber, displayTrendingContent) {
|
||||||
if (exampleNumber === 1) {
|
if (exampleNumber === 1) {
|
||||||
return getTrendingContent().then(response => {
|
return lbrytvAPI.getTrending()
|
||||||
if (!response || !response.success || response.success !== true || !response.data)
|
.then(response => {
|
||||||
return "";
|
const renderedContentCollection = [];
|
||||||
|
const urlsToResolve = [];
|
||||||
|
|
||||||
const rawContentCollection = [];
|
response.forEach(r =>{
|
||||||
const renderedContentCollection = [];
|
urlsToResolve.push(r.canonical_url);
|
||||||
const trendingContentData = response.data;
|
|
||||||
|
|
||||||
for (const data of trendingContentData) {
|
|
||||||
rawContentCollection.push(fetchMetadata({
|
|
||||||
claim: data.url,
|
|
||||||
example: exampleNumber,
|
|
||||||
method: "resolve"
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.all(rawContentCollection)
|
|
||||||
.then(collection => {
|
|
||||||
for (const part of collection) {
|
|
||||||
if (part && part.value.tags && part.value.tags.includes("mature"))
|
|
||||||
continue;
|
|
||||||
if (part === undefined)
|
|
||||||
continue;
|
|
||||||
try {
|
|
||||||
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.signing_channel ? part.signing_channel.name : "Anon"}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
`);
|
|
||||||
} catch(err) {
|
|
||||||
console.error(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(""));
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
});
|
lbrytvAPI.resolve(urlsToResolve)
|
||||||
|
.then(resolveResponse => {
|
||||||
|
if (resolveResponse !== null) {
|
||||||
|
let responses = Object.values(resolveResponse);
|
||||||
|
|
||||||
|
for (let r in responses) {
|
||||||
|
let part = responses[r];
|
||||||
|
|
||||||
|
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 1']").dataset.description
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
displayTrendingContent(renderedContentCollection.join(""));
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exampleNumber === 3) {
|
if (exampleNumber === 3) {
|
||||||
@@ -193,50 +183,49 @@ function generateContent(exampleNumber, displayTrendingContent) {
|
|||||||
"minecraft-in-real-life-iron-man#758dd6497cdfc401ae1f25984738d024d47b50af",
|
"minecraft-in-real-life-iron-man#758dd6497cdfc401ae1f25984738d024d47b50af",
|
||||||
"ethan-shows-kyle-warframe-skyvault#8a7401b88d5ed0376d98f16808194d4dcb05b284"
|
"ethan-shows-kyle-warframe-skyvault#8a7401b88d5ed0376d98f16808194d4dcb05b284"
|
||||||
];
|
];
|
||||||
|
|
||||||
const rawContentCollection = [];
|
|
||||||
const renderedContentCollection = [];
|
const renderedContentCollection = [];
|
||||||
|
|
||||||
for (const url of approvedUrls)
|
lbrytvAPI.resolve(approvedUrls)
|
||||||
rawContentCollection.push(fetchMetadata({ claim: url, method: "resolve", example: 1 }));
|
.then(resolveResponse => {
|
||||||
|
if (resolveResponse !== null) {
|
||||||
|
let responses = Object.values(resolveResponse);
|
||||||
|
|
||||||
return Promise.all(rawContentCollection).then(collection => {
|
for (let r in responses) {
|
||||||
for (const part of collection) {
|
let part = responses[r];
|
||||||
if (
|
|
||||||
part &&
|
|
||||||
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">
|
if (part.value && part.value.thumbnail.url) {
|
||||||
${part.value.title}
|
renderedContentCollection.push(`
|
||||||
</div>
|
<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__subtitle">
|
<div class="media__title">
|
||||||
${part.signing_channel.name || "Anon"}
|
${part.value.title || "Untitled"}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
`);
|
<div class="media__subtitle">
|
||||||
|
${part.signing_channel ? part.signing_channel.name : "Anon"}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
renderedContentCollection.push(`
|
||||||
|
<script>
|
||||||
renderedContentCollection.push(`
|
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 3']").dataset.description
|
||||||
<script>
|
</script>
|
||||||
document.getElementById("playground-example-description").innerHTML = document.querySelector("[data-action='playground, example 3']").dataset.description
|
`);
|
||||||
</script>
|
displayTrendingContent(renderedContentCollection.join(""));
|
||||||
`);
|
})
|
||||||
|
.catch(error => {
|
||||||
displayTrendingContent(renderedContentCollection.join(""));
|
console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,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) {
|
function makeImageSourceSecure(url) {
|
||||||
if (!url || !url.length)
|
if (!url || !url.length)
|
||||||
return url;
|
return url;
|
||||||
|
|||||||
+61
-42
@@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// I M P O R T S
|
// I M P O R T S
|
||||||
|
|
||||||
import asyncHtml from "choo-async/html";
|
import asyncHtml from "choo-async/html";
|
||||||
@@ -20,24 +18,17 @@ const filePathBlockchain = "/contrib/devtools/generated/api_v1.json";
|
|||||||
const filePathSdk = "/lbry/docs/api.json";
|
const filePathSdk = "/lbry/docs/api.json";
|
||||||
const rawGitHubBase = "https://raw.githubusercontent.com/lbryio/";
|
const rawGitHubBase = "https://raw.githubusercontent.com/lbryio/";
|
||||||
|
|
||||||
if (!process.env.GITHUB_OAUTH_TOKEN) // No point in rendering this page
|
|
||||||
throw new Error("Missing GitHub token");
|
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
auth: `token ${process.env.GITHUB_OAUTH_TOKEN}`
|
auth: `token ${process.env.GITHUB_OAUTH_TOKEN}`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// E X P O R T
|
// E X P O R T
|
||||||
|
|
||||||
export default async(state) => {
|
export default async state => {
|
||||||
const { tag } = state;
|
const { tag } = state;
|
||||||
const { wildcard } = state.params;
|
const { wildcard } = state.params;
|
||||||
|
|
||||||
const repository = wildcard === "sdk" ?
|
const repository = wildcard === "sdk" ? "lbry-sdk" : "lbrycrd";
|
||||||
"lbry-sdk" :
|
|
||||||
"lbrycrd";
|
|
||||||
|
|
||||||
state.lbry = {
|
state.lbry = {
|
||||||
title: tag ? tag + " API Documentation" : "API Documentation",
|
title: tag ? tag + " API Documentation" : "API Documentation",
|
||||||
@@ -123,8 +114,6 @@ export default async(state) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// H E L P E R S
|
// H E L P E R S
|
||||||
|
|
||||||
function createApiContent(apiDetails) {
|
function createApiContent(apiDetails) {
|
||||||
@@ -133,20 +122,33 @@ function createApiContent(apiDetails) {
|
|||||||
apiDetails.forEach(apiDetail => {
|
apiDetails.forEach(apiDetail => {
|
||||||
let apiDetailsReturns = "";
|
let apiDetailsReturns = "";
|
||||||
|
|
||||||
if (apiDetail.returns)
|
if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
|
||||||
apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
|
|
||||||
|
|
||||||
apiContent.push(`
|
apiContent.push(`
|
||||||
<div class="api-content__body">
|
<div class="api-content__body">
|
||||||
<h2 id="${apiDetail.name}">${apiDetail.name}</h2>
|
<h2 id="${apiDetail.name}">${apiDetail.name}</h2>
|
||||||
<p>${apiDetail.description}</p>
|
<p>${apiDetail.description}</p>
|
||||||
|
|
||||||
${apiDetail.arguments.length ? `<h3>Arguments</h3><ul class="api-content__body-arguments">${renderArguments(apiDetail.arguments).join("")}</ul>` : ""}
|
${
|
||||||
${apiDetail.returns ? `<h3>Returns</h3><pre><code>${dedent(apiDetailsReturns)}</code></pre>` : ""}
|
apiDetail.arguments.length ?
|
||||||
|
`<h3>Arguments</h3><ul class="api-content__body-arguments">${renderArguments(
|
||||||
|
apiDetail.arguments
|
||||||
|
).join("")}</ul>` :
|
||||||
|
""
|
||||||
|
}
|
||||||
|
${
|
||||||
|
apiDetail.returns ?
|
||||||
|
`<h3>Returns</h3><pre><code>${dedent(apiDetailsReturns)}</code></pre>` :
|
||||||
|
""
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="api-content__example">
|
<div class="api-content__example">
|
||||||
${apiDetail.examples && apiDetail.examples.length ? renderExamples(apiDetail.examples).join("") : `<pre><code>// example(s) for ${apiDetail.name} to come later</code></pre>`}
|
${
|
||||||
|
apiDetail.examples && apiDetail.examples.length ?
|
||||||
|
renderExamples(apiDetail.examples).join("") :
|
||||||
|
`<pre><code>// example(s) for ${apiDetail.name} to come later</code></pre>`
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@@ -232,7 +234,12 @@ function createSdkSidebar(apiDetails) {
|
|||||||
apiSidebar.push(`
|
apiSidebar.push(`
|
||||||
<ul class="api-toc__section">
|
<ul class="api-toc__section">
|
||||||
<li class="api-toc__title">${title}</li>
|
<li class="api-toc__title">${title}</li>
|
||||||
${(commands.map(command => `<li class="api-toc__command"><a href="#${command.name}" title="Go to ${command.name} section">${command.name}</a></li>`)).join("")}
|
${commands
|
||||||
|
.map(
|
||||||
|
command =>
|
||||||
|
`<li class="api-toc__command"><a href="#${command.name}" title="Go to ${command.name} section">${command.name}</a></li>`
|
||||||
|
)
|
||||||
|
.join("")}
|
||||||
</ul>
|
</ul>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@@ -246,7 +253,7 @@ async function getTags(repositoryName) {
|
|||||||
repo: repositoryName
|
repo: repositoryName
|
||||||
});
|
});
|
||||||
|
|
||||||
const tags = [];
|
const tags = ["master"];
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// The versioning in our repos do not make sense so extra
|
// The versioning in our repos do not make sense so extra
|
||||||
@@ -266,7 +273,8 @@ async function getTags(repositoryName) {
|
|||||||
tag.name !== "v0.38.0rc3" &&
|
tag.name !== "v0.38.0rc3" &&
|
||||||
tag.name !== "v0.38.0rc2" &&
|
tag.name !== "v0.38.0rc2" &&
|
||||||
tag.name !== "v0.38.0rc1"
|
tag.name !== "v0.38.0rc1"
|
||||||
) tags.push(tag.name);
|
)
|
||||||
|
tags.push(tag.name);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -278,7 +286,8 @@ async function getTags(repositoryName) {
|
|||||||
tag.name !== "v0.3.15" &&
|
tag.name !== "v0.3.15" &&
|
||||||
tag.name !== "v0.3-osx" &&
|
tag.name !== "v0.3-osx" &&
|
||||||
tag.name !== "v0.2-alpha"
|
tag.name !== "v0.2-alpha"
|
||||||
) tags.push(tag.name);
|
)
|
||||||
|
tags.push(tag.name);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -293,11 +302,11 @@ async function parseApiFile({ repo, tag }) {
|
|||||||
let apiFileLink = `${rawGitHubBase}${repo}/${tag}`;
|
let apiFileLink = `${rawGitHubBase}${repo}/${tag}`;
|
||||||
|
|
||||||
switch(true) {
|
switch(true) {
|
||||||
case (repo === "lbrycrd"):
|
case repo === "lbrycrd":
|
||||||
apiFileLink = `${apiFileLink}${filePathBlockchain}`;
|
apiFileLink = `${apiFileLink}${filePathBlockchain}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (repo === "lbry-sdk"):
|
case repo === "lbry-sdk":
|
||||||
apiFileLink = `${apiFileLink}${filePathSdk}`;
|
apiFileLink = `${apiFileLink}${filePathSdk}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -317,8 +326,7 @@ async function parseApiFile({ repo, tag }) {
|
|||||||
function renderArguments(args) {
|
function renderArguments(args) {
|
||||||
const argumentContent = [];
|
const argumentContent = [];
|
||||||
|
|
||||||
if (!args || args.length === 0)
|
if (!args || args.length === 0) return argumentContent;
|
||||||
return argumentContent;
|
|
||||||
|
|
||||||
args.forEach(arg => {
|
args.forEach(arg => {
|
||||||
argumentContent.push(`
|
argumentContent.push(`
|
||||||
@@ -328,7 +336,11 @@ function renderArguments(args) {
|
|||||||
${arg.is_required === true ? "" : "<span>optional</span>"}<span>${arg.type}</span>
|
${arg.is_required === true ? "" : "<span>optional</span>"}<span>${arg.type}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right">${typeof arg.description === "string" ? arg.description.replace(/</g, "<").replace(/>/g, ">") : ""}</div>
|
<div class="right">${
|
||||||
|
typeof arg.description === "string" ?
|
||||||
|
arg.description.replace(/</g, "<").replace(/>/g, ">") :
|
||||||
|
""
|
||||||
|
}</div>
|
||||||
</li>
|
</li>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@@ -352,11 +364,15 @@ function renderExamples(args) {
|
|||||||
${arg.lbrynet ? `<pre data-api-example-type="lbrynet"><code>${arg.lbrynet}</code></pre>` : ""}
|
${arg.lbrynet ? `<pre data-api-example-type="lbrynet"><code>${arg.lbrynet}</code></pre>` : ""}
|
||||||
${arg.python ? `<pre data-api-example-type="python"><code>${arg.python}</code></pre>` : ""}
|
${arg.python ? `<pre data-api-example-type="python"><code>${arg.python}</code></pre>` : ""}
|
||||||
|
|
||||||
${arg.output ? `
|
${
|
||||||
|
arg.output ?
|
||||||
|
`
|
||||||
<h3>Output</h3><br/>
|
<h3>Output</h3><br/>
|
||||||
<pre><code>${arg.output}</code></pre>
|
<pre><code>${arg.output}</code></pre>
|
||||||
<hr/>
|
<hr/>
|
||||||
` : ""}
|
` :
|
||||||
|
""
|
||||||
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -366,17 +382,14 @@ function renderExamples(args) {
|
|||||||
function renderReturns(args) {
|
function renderReturns(args) {
|
||||||
let returnContent = [];
|
let returnContent = [];
|
||||||
|
|
||||||
if (!args || args.length === 0)
|
if (!args || args.length === 0) return returnContent;
|
||||||
return returnContent;
|
|
||||||
|
|
||||||
returnContent = dedent(JSON.parse(JSON.stringify(args)));
|
returnContent = dedent(JSON.parse(JSON.stringify(args)));
|
||||||
return returnContent;
|
return returnContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderVersionSelector(pageSlug, versions, desiredTag) {
|
function renderVersionSelector(pageSlug, versions, desiredTag) {
|
||||||
const options = [
|
const options = ["<option disabled>Select a version</option>"];
|
||||||
"<option disabled>Select a version</option>"
|
|
||||||
];
|
|
||||||
|
|
||||||
let optionIndex = 0;
|
let optionIndex = 0;
|
||||||
|
|
||||||
@@ -384,13 +397,13 @@ function renderVersionSelector(pageSlug, versions, desiredTag) {
|
|||||||
optionIndex++;
|
optionIndex++;
|
||||||
let selectedOption = false;
|
let selectedOption = false;
|
||||||
|
|
||||||
if (desiredTag && desiredTag === version)
|
if (desiredTag && desiredTag === version) selectedOption = true;
|
||||||
selectedOption = true;
|
else if (optionIndex === 1) selectedOption = true;
|
||||||
else if (optionIndex === 1)
|
|
||||||
selectedOption = true;
|
|
||||||
|
|
||||||
options.push(
|
options.push(
|
||||||
`<option value="${pageSlug}-${version}"${selectedOption ? " selected" : ""}>${version}</option>`
|
`<option value="${pageSlug}-${version}"${
|
||||||
|
selectedOption ? " selected" : ""
|
||||||
|
}>${version}</option>`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -402,9 +415,15 @@ function renderCodeLanguageToggles(pageSlug) {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
"<button class='api-content__item menu' id='toggle-menu'>menu</button>",
|
"<button class='api-content__item menu' id='toggle-menu'>menu</button>",
|
||||||
!onSdkPage ? "<button class='api-content__item' id='toggle-cli' type='button'>cli</button>" : "",
|
!onSdkPage ?
|
||||||
|
"<button class='api-content__item' id='toggle-cli' type='button'>cli</button>" :
|
||||||
|
"",
|
||||||
"<button class='api-content__item' id='toggle-curl' type='button'>curl</button>",
|
"<button class='api-content__item' id='toggle-curl' type='button'>curl</button>",
|
||||||
onSdkPage ? "<button class='api-content__item' id='toggle-lbrynet' type='button'>lbrynet</button>" : "",
|
onSdkPage ?
|
||||||
onSdkPage ? "<button class='api-content__item' id='toggle-python' type='button'>python</button>" : ""
|
"<button class='api-content__item' id='toggle-lbrynet' type='button'>lbrynet</button>" :
|
||||||
|
"",
|
||||||
|
onSdkPage ?
|
||||||
|
"<button class='api-content__item' id='toggle-python' type='button'>python</button>" :
|
||||||
|
""
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
+4
-4
@@ -5,7 +5,7 @@ description: Learn how to build your own app via LBRY in this comprehensive guid
|
|||||||
|
|
||||||
## Introduction
|
## 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.
|
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.
|
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.
|
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/).
|
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:
|
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:
|
||||||
|
|
||||||
@@ -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.
|
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ While the blockchain is the innovation that makes LBRY _possible_, the [Data Net
|
|||||||
|
|
||||||
At this level:
|
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.
|
- [Data referenced by metadata](/spec#data) is accessed and distributed via a peer-to-peer network.
|
||||||
- [Identities](/spec#channels) are created, signed, and validated.
|
- [Identities](/spec#channels) are created, signed, and validated.
|
||||||
|
|
||||||
|
|||||||
@@ -66,13 +66,6 @@ Configuration options are organized by their respective areas: Files, Wallet, Ne
|
|||||||
| streaming_get | boolean | false | true | Allow calling localhost:5280/get/claimname requests |
|
| streaming_get | boolean | false | true | Allow calling localhost:5280/get/claimname requests |
|
||||||
| save_files | boolean | true | false | Save files with each download |
|
| save_files | boolean | true | false | Save files with each download |
|
||||||
| save_blobs | boolean | true | false | Save blobs with each download |
|
| save_blobs | boolean | true | false | Save blobs with each download |
|
||||||
### 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-sdk/blob/master/lbrynet/daemon/auth/server.py#L179) for details |
|
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
| Setting | Format | Default value | Sample Values | Description |
|
| Setting | Format | Default value | Sample Values | Description |
|
||||||
|--------------------|---------|---------------|--------------------------------|---------------------------------------------------------------------------------------------------------------|
|
|--------------------|---------|---------------|--------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ For this example, we will use claim ID `d9317ac7842f88ba442fee749c4f834353c24206
|
|||||||
|
|
||||||
## Parse the Metadata
|
## 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
|
## Get the Stream Hash
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ For this example, we will use claimID `d9317ac7842f88ba442fee749c4f834353c24206`
|
|||||||
|
|
||||||
## Parse the Metadata
|
## 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
|
## Get the SD Hash
|
||||||
|
|||||||
+2
-1
@@ -44,7 +44,8 @@
|
|||||||
"redis": "^2.8.0",
|
"redis": "^2.8.0",
|
||||||
"slack-node": "^0.1.8",
|
"slack-node": "^0.1.8",
|
||||||
"socket.io": "^2.2.0",
|
"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",
|
"description": "Documentation for the LBRY protocol and associated projects",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in new issue
Block a user