ポール ウェッブ 6 mēnešus atpakaļ
vecāks
revīzija
6d692a8b91
8 mainītis faili ar 116 papildinājumiem un 82 dzēšanām
  1. 1
    0
      README.md
  2. 38
    0
      app/models/find.js
  3. 18
    2
      app/models/resolve.js
  4. 10
    9
      app/views/channel.js
  5. 1
    5
      app/views/content.js
  6. 39
    57
      app/views/home.js
  7. 7
    7
      package.json
  8. 2
    2
      sass/app/_layout.scss

+ 1
- 0
README.md Parādīt failu

@@ -7,5 +7,6 @@
7 7
 ### Notes
8 8
 
9 9
 - either lbrynet or the LBRY app should be running
10
+  - currently using the `0.37.0rc2` release
10 11
 - the app takes a couple seconds to render things from the API
11 12
 - to run the app type `npm run watch`

+ 38
- 0
app/models/find.js Parādīt failu

@@ -0,0 +1,38 @@
1
+"use strict";
2
+
3
+
4
+
5
+//  I M P O R T
6
+
7
+import m from "mithril";
8
+
9
+//  P A C K A G E
10
+
11
+const { Lbry } = require("lbry-redux");
12
+
13
+
14
+
15
+//  E X P O R T
16
+
17
+export default suppliedData => {
18
+  return new Promise(resolve => {
19
+    const query = {};
20
+    let method = "resolve";
21
+
22
+    if (suppliedData.channel) {
23
+      const id = suppliedData.channel.split("#")[1];
24
+
25
+      query.channel_id = id;
26
+      query.page = 1;
27
+      query.page_size = 20;
28
+
29
+      method = "claim_search";
30
+    } else {
31
+      query.urls = suppliedData;
32
+    }
33
+
34
+    Lbry[method](query)
35
+      .then(result => resolve(result))
36
+      .catch(() => resolve());
37
+  });
38
+};

+ 18
- 2
app/models/resolve.js Parādīt failu

@@ -16,11 +16,26 @@ const { Lbry } = require("lbry-redux");
16 16
 
17 17
 const Resolve = {
18 18
   query: suppliedData => {
19
-    const id = suppliedData.split("#")[1];
19
+    const lbryQuery = {};
20
+    let method = "resolve";
21
+
22
+    if (suppliedData.channel) {
23
+      const id = suppliedData.channel.split("#")[1];
24
+
25
+      lbryQuery.channel_id = id;
26
+      lbryQuery.page = 1;
27
+      lbryQuery.page_size = 20;
28
+
29
+      method = "claim_search";
30
+    } else {
31
+      lbryQuery.urls = suppliedData.urls;
32
+    }
33
+
34
+    // const id = suppliedData.split("#")[1];
20 35
 
21 36
     // curl -d'{"method": "claim_search", "params": {"channel_id": "feb61536c007cdf4faeeaab4876cb397feaf6b51", "page": 1, "page_size": 20}}' http://localhost:5279
22 37
 
23
-    return Lbry.claim_search({ channel_id: id, page: 1, page_size: 20 })
38
+    return Lbry[method](lbryQuery)
24 39
       .then(result => {
25 40
         // console.info(result);
26 41
 
@@ -36,6 +51,7 @@ const Resolve = {
36 51
       })
37 52
       .catch(error => {
38 53
         console.error(error); // eslint-disable-line no-console
54
+        return;
39 55
       });
40 56
   },
41 57
   result: []

+ 10
- 9
app/views/channel.js Parādīt failu

@@ -16,7 +16,7 @@ import Wrapper from "~component/wrapper";
16 16
 //  E X P O R T
17 17
 
18 18
 export default {
19
-  onmatch: args => Resolve.query(args.channelName),
19
+  onmatch: args => Resolve.query({ channel: args.channelName }),
20 20
   render: () => {
21 21
     // const creatorData = Resolve.result;
22 22
 
@@ -44,9 +44,7 @@ export default {
44 44
 
45 45
     const { result } = Resolve;
46 46
 
47
-    // console.info(result);
48
-
49
-    return m(Wrapper,[
47
+    return m(Wrapper, [
50 48
       (
51 49
         <content-list>
52 50
           {
@@ -65,7 +63,10 @@ export default {
65 63
 //  H E L P E R
66 64
 
67 65
 function renderContent(suppliedData) {
68
-  const { stream } = suppliedData.value;
66
+  const { value } = suppliedData;
67
+
68
+  if (!value)
69
+    return;
69 70
 
70 71
   // console.log(suppliedData.name);
71 72
   // console.log(suppliedData.claim_id);
@@ -76,15 +77,15 @@ function renderContent(suppliedData) {
76 77
       <a
77 78
         href={"/content/" + encodeURIComponent(suppliedData.name) + "/" + encodeURIComponent(suppliedData.claim_id)}
78 79
         oncreate={m.route.link}
79
-        title={"View '" + stream.title + "' by " + stream.author}
80
+        title={"View '" + value.title + "' by " + value.author}
80 81
       >
81 82
         <figure>
82 83
           <img
83
-            alt={"'" + stream.title + "' by " + stream.author}
84
-            src={stream.thumbnail_url}
84
+            alt={"'" + value.title + "' by " + value.author}
85
+            src={value.thumbnail.url}
85 86
           />
86 87
           <figcaption>
87
-            {stream.title}
88
+            {value.title}
88 89
           </figcaption>
89 90
         </figure>
90 91
       </a>

+ 1
- 5
app/views/content.js Parādīt failu

@@ -73,13 +73,9 @@ export default {
73 73
     return m(Wrapper, [
74 74
       (
75 75
         <content>
76
-          <video src={`https://api.lbry.tv/content/claims/${claimName}/${claimId}/stream`}></video>
76
+          <video src={`https://api.lbry.tv/content/claims/${claimName}/${claimId}/stream`}/>
77 77
         </content>
78 78
       )
79 79
     ]);
80 80
   }
81 81
 };
82
-
83
-
84
-
85
-//  H E L P E R

+ 39
- 57
app/views/home.js Parādīt failu

@@ -8,6 +8,8 @@ import m from "mithril";
8 8
 
9 9
 //  U T I L S
10 10
 
11
+// import FindStuff from "~model/find";
12
+// import Resolve from "~model/resolve";
11 13
 import Trending from "~model/trending";
12 14
 import Wrapper from "~component/wrapper";
13 15
 import sdkStatus from "~model/sdk-init";
@@ -60,13 +62,15 @@ export default {
60 62
 // claim.value.stream.source
61 63
 // contentType (video/mp4)
62 64
 
63
-function renderChannelLink(data, fullData) {
65
+function renderChannelLink(data) { // , fullData
66
+  // const channelContent = fullData[data];
64 67
   const channelName = data.split("|")[1].trim();
65 68
   const channelNameHash = channelName.split("#")[1];
66 69
   const channelNameSolo = channelName.split("#")[0];
67 70
   const formattedChannelName = `<span class="name">${channelNameSolo.replace("@", "")}</span><span class="hash">#${channelNameHash}</span>`;
68 71
 
69
-  // console.log(fullData[data]);
72
+  // console.log(data);
73
+  // console.log(channelContent);
70 74
   // console.log("————————————");
71 75
 
72 76
   return (
@@ -81,60 +85,38 @@ function renderChannelLink(data, fullData) {
81 85
     </channel>
82 86
   );
83 87
 
84
-  // onclick={e => console.log(e.srcElement.parentNode.dataset.channelName)}
85
-  // href={"/channel/" + channelName}
88
+  // {
89
+  //   Object.keys(channelContent).map(key => {
90
+  //     const test = channelContent[key];
91
+  //     return FindStuff(test).then(result => renderChannelThumbnails(result)); // eslint-disable-line padding-line-between-statements
92
+  //   })
93
+  // }
86 94
 }
87 95
 
88
-function resolveII(suppliedUrl) {
89
-  return m.request({
90
-    background: true, // commenting this out is not a good idea...
91
-    data: {
92
-      authorization: "b5125d5be5ef2b8f3a2fba18a349c8375a85e613",
93
-      method: "resolve",
94
-      uri: suppliedUrl
95
-    },
96
-    headers: {
97
-      "Content-Type": "application/json"
98
-    },
99
-    method: "POST",
100
-    // url: "https://daemon.lbry.tech/resolve",
101
-    url: "http://localhost:5200/resolve"
102
-    // useBody: true
103
-  }).then(result => {
104
-    result = result.result[suppliedUrl];
105
-    return result;
106
-  });
107
-}
108
-
109
-function resolve(url) {
110
-  return Lbry.resolve({ urls: url }) // This can be a list of urls
111
-    .then(response => {
112
-      const test = Object.keys(response);
113
-      const cool = [];
114
-
115
-      // console.log(Object.keys(response));
116
-
117
-      for (const uh of test) {
118
-        const thing = response[uh];
119
-        const { metadata } = thing.claim.value.stream;
120
-        // console.log(thing);
121
-
122
-        cool.push(`
123
-          <figure>
124
-            <img alt=${metadata.title} src=${metadata.thumbnail}/>
125
-            <figcaption>${metadata.title} by ${metadata.author}</figcaption>
126
-          </figure>
127
-        `);
128
-      }
129
-
130
-      // console.log("————————————");
131
-      // console.log(cool);
132
-      return cool;
133
-
134
-      // claimData.innerText = JSON.stringify(res[url].claim, null, 2);
135
-    })
136
-    .catch(error => {
137
-      console.error(error);
138
-      // claimData.innerText = JSON.stringify(error, null, 2);
139
-    });
140
-}
96
+// function renderChannelThumbnails(suppliedData) {
97
+//   const { claim } = suppliedData;
98
+//   const { value } = claim;
99
+
100
+//   if (!claim || !value)
101
+//     return;
102
+
103
+//   return (
104
+//     <content-item>
105
+//       <a
106
+//         href={"/content/" + encodeURIComponent(claim.name) + "/" + encodeURIComponent(claim.claim_id)}
107
+//         oncreate={m.route.link}
108
+//         title={"View '" + value.title + "' by " + value.author}
109
+//       >
110
+//         <figure>
111
+//           <img
112
+//             alt={"'" + value.title + "' by " + value.author}
113
+//             src={value.thumbnail.url}
114
+//           />
115
+//           <figcaption>
116
+//             {value.title}
117
+//           </figcaption>
118
+//         </figure>
119
+//       </a>
120
+//     </content-item>
121
+//   );
122
+// }

+ 7
- 7
package.json Parādīt failu

@@ -9,12 +9,12 @@
9 9
     "name": "Paul Anthony Webb"
10 10
   },
11 11
   "dependencies": {
12
-    "electron": "^4.1.4",
12
+    "electron": "^5.0.0",
13 13
     "find-process": "^1.4.1",
14 14
     "got": "^9.6.0",
15 15
     "lbry-redux": "lbryio/lbry-redux",
16 16
     "mithril": "^1.1.6",
17
-    "node-fetch": "^2.3.0",
17
+    "node-fetch": "^2.4.0",
18 18
     "url": "^0.11.0"
19 19
   },
20 20
   "description": "",
@@ -38,11 +38,11 @@
38 38
     "electron-reload": "^1.4.0",
39 39
     "eslint": "^5.16.0",
40 40
     "eslint-plugin-react": "^7.12.4",
41
-    "husky": "^1.3.1",
41
+    "husky": "^2.1.0",
42 42
     "link-module-alias": "^1.2.0",
43 43
     "npm-run-all": "^4.1.5",
44 44
     "rimraf": "^2.6.3",
45
-    "rollup": "^1.10.0",
45
+    "rollup": "^1.10.1",
46 46
     "rollup-plugin-babel": "^4.3.2",
47 47
     "rollup-plugin-commonjs": "^9.3.4",
48 48
     "rollup-plugin-eslint": "^5.1.0",
@@ -53,11 +53,11 @@
53 53
     "rollup-plugin-serve": "^1.0.1",
54 54
     "rollup-plugin-uglify": "^6.0.2",
55 55
     "rollup-watch": "^4.3.1",
56
-    "sass": "^1.18.0",
57
-    "sass-lint": "^1.12.1",
56
+    "sass": "^1.19.0",
57
+    "sass-lint": "^1.13.1",
58 58
     "snazzy": "^8.0.0",
59 59
     "standardx": "^3.0.1",
60
-    "updates": "^8.0.1"
60
+    "updates": "^8.0.2"
61 61
   },
62 62
   "engines": {
63 63
     "node": ">=11.0.0"

+ 2
- 2
sass/app/_layout.scss Parādīt failu

@@ -6,8 +6,8 @@ body, {
6 6
 
7 7
 html {
8 8
   &::before {
9
-    top: 0; left: 0;
10
-    bottom: 0; right: 0;
9
+    top: 0; right: 0;
10
+    bottom: 0; left: 0;
11 11
 
12 12
     animation: gradientMove 9s ease infinite;
13 13
     background: linear-gradient(314deg, $lbry-teal-2, $lbry-blue-3);

Notiek ielāde…
Atcelt
Saglabāt