Compare commits

...
Author SHA1 Message Date
Niko Storni 39ea483f08 fix resolution of claims 2019-09-23 23:01:28 +02:00
Niko Storni 6ae0984edf add trending call
use new resolve and trending
remove old trending func
2019-09-23 19:42:21 +02:00
Niko Storni d5932ce67c port resolve call to lbrytv 2019-09-23 19:27:04 +02:00
Thomas Zarebczan 777d9f0f83 Yolo fix to rewards
Will run locally if this doesn't work...
2019-09-12 14:48:54 -04:00
Thomas Zarebczan b3ae6ca0d6 remove auth settings 2019-09-12 12:10:16 -04:00
Thomas Zarebczan ebbcb02c87 Merge pull request #296 from lbryio/devprogram-fixes
Developer program fixes
2019-09-10 13:29:25 -04:00
netop://ウエハ cc965191f2 Better error messaging 2019-09-09 17:37:58 -05:00
netop://ウエハ 48190d18be Debugging 2019-09-09 16:59:22 -05:00
netop://ウエハ 201f8a4a09 Closes #291 2019-09-09 16:57:22 -05:00
netop://ウエハ ed6cfb239a Debugging 2019-09-09 15:55:32 -05:00
Thomas Zarebczan 7beeffd008 add short and canonical url definitions 2019-09-09 14:32:59 -04:00
Thomas Zarebczan 8bfeafa137 Merge pull request #295 from dittaeva/patch-1
Update contribute.md HTMl > HTML
2019-09-09 09:42:34 -04:00
Guttorm Flatabø 85226a20d0 Update contribute.md HTMl > HTML 2019-09-09 15:26:38 +02:00
Niko ee65417441 Merge pull request #294 from lbryio/fix_some_bugs
Fixed some bugs
2019-09-02 04:44:07 +02:00
11 changed files with 281 additions and 130 deletions

No files matched your search

+14 -7
View File
@@ -65,25 +65,32 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
.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>";
+1 -1
View File
@@ -257,7 +257,7 @@ const handleExamples = debounce(event => {
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;
+32 -4
View File
@@ -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";
@@ -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
@@ -194,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;
+119
View File
@@ -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
View File
@@ -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";
+15
View File
@@ -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 {
+87 -107
View File
@@ -11,6 +11,7 @@ import html from "choo/html";
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";
@@ -117,67 +118,56 @@ export default async(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;
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;
response.forEach(r =>{
urlsToResolve.push(r.canonical_url);
});
});
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) {
@@ -193,50 +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
) {
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.signing_channel.name || "Anon"}
</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);
});
}
}
@@ -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) {
if (!url || !url.length)
return url;
+1 -1
View File
@@ -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
+9 -1
View File
@@ -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.
@@ -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).
-7
View File
@@ -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 |
| save_files | boolean | true | false | Save files 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
| Setting | Format | Default value | Sample Values | Description |
|--------------------|---------|---------------|--------------------------------|---------------------------------------------------------------------------------------------------------------|
+2 -1
View File
@@ -44,7 +44,8 @@
"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": {