Browse Source

Started work on channel page

master
ポール ウェッブ 1 month ago
parent
commit
ff8daf1679
6 changed files with 119 additions and 67 deletions
  1. 44
    0
      app/models/resolve.js
  2. 1
    1
      app/models/trending.js
  3. 52
    0
      app/views/channel.js
  4. 17
    63
      app/views/home.js
  5. 2
    0
      app/views/index.js
  6. 3
    3
      package.json

+ 44
- 0
app/models/resolve.js View File

@@ -0,0 +1,44 @@
1
+"use strict";
2
+
3
+
4
+
5
+//  I M P O R T
6
+
7
+import m from "mithril";
8
+
9
+
10
+
11
+//  P R O G R A M
12
+
13
+const Resolve = {
14
+  query: suppliedData => {
15
+    return m.request({
16
+      data: {
17
+        authorization: "b5125d5be5ef2b8f3a2fba18a349c8375a85e613",
18
+        method: "resolve",
19
+        uri: suppliedData
20
+      },
21
+      headers: {
22
+        "Content-Type": "application/json"
23
+      },
24
+      method: "POST",
25
+      // url: "https://daemon.lbry.tech/resolve",
26
+      url: "http://localhost:5200/resolve"
27
+      // useBody: true
28
+    }).then(result => {
29
+      result = result.result[suppliedData];
30
+      Resolve.result = result;
31
+    })
32
+      .catch(error => {
33
+        console.error(error);
34
+        return null;
35
+      });
36
+  },
37
+  result: []
38
+};
39
+
40
+
41
+
42
+//  E X P O R T
43
+
44
+export default Resolve;

+ 1
- 1
app/models/trending.js View File

@@ -15,7 +15,7 @@ const Trending = {
15 15
   loadList: () => {
16 16
     return m.request({
17 17
       method: "GET",
18
-      url: "https://api.lbry.com/file/list_homepage"
18
+      url: "https://api.lbry.com/file/list_homepage" // same as: https://api.lbry.com/discover/list
19 19
     }).then(result => {
20 20
       const data = result.data.Uris;
21 21
       const keys = Object.keys(data);

+ 52
- 0
app/views/channel.js View File

@@ -0,0 +1,52 @@
1
+"use strict";
2
+
3
+
4
+
5
+//  I M P O R T
6
+
7
+import m from "mithril";
8
+
9
+//  U T I L
10
+
11
+import Resolve from "~model/resolve";
12
+import Wrapper from "~component/wrapper";
13
+
14
+
15
+
16
+//  E X P O R T
17
+
18
+export default {
19
+  onmatch: args => Resolve.query(args.channelName),
20
+  render: () => {
21
+    const creatorData = Resolve.result;
22
+
23
+    // console.log(creatorData);
24
+    console.log("Name:", creatorData.certificate.name);
25
+    console.log("TXID:", creatorData.certificate.txid);
26
+    console.log("Claims:", creatorData.claims_in_channel);
27
+    console.log("——————————");
28
+
29
+    return m(Wrapper,
30
+      <section class="ancillary inner-wrap">
31
+        <p><a href="/">Go home, Roger</a></p>
32
+      </section>
33
+    );
34
+  }
35
+
36
+  // Lbry.resolve({ urls: url }) // This can be a list of urls
37
+  //   .then(res => {
38
+  //     claimData.innerText = JSON.stringify(res[url].claim, null, 2);
39
+  //   })
40
+  //   .catch(error => {
41
+  //     claimData.innerText = JSON.stringify(error, null, 2);
42
+  // });
43
+
44
+  // curl -d'{"method": "channel_list", "params": { account: "bFiP69zpGKXgKVyguvTEfYT1JVKPi85WUp"}}' http://localhost:5279
45
+
46
+  // view: () => m(Wrapper,
47
+  //   <section class="ancillary inner-wrap">
48
+  //     <img alt="WTF bro" src="/images/what.png"/>
49
+  //     <p><a href="/">Go home, Roger</a></p>
50
+  //   </section>
51
+  // )
52
+};

+ 17
- 63
app/views/home.js View File

@@ -2,13 +2,10 @@
2 2
 
3 3
 
4 4
 
5
-// import util from "util";
6
-// const util = require("util");
7
-
8
-//  I M P O R T S
5
+//  I M P O R T
9 6
 
10 7
 import m from "mithril";
11
-const { Lbry } = require("lbry-redux");
8
+
12 9
 // import { Lbry } from "lbry-redux";
13 10
 
14 11
 //  U T I L S
@@ -17,6 +14,10 @@ import Trending from "~model/trending";
17 14
 import Wrapper from "~component/wrapper";
18 15
 import sdkStatus from "~model/sdk-init";
19 16
 
17
+//  P A C K A G E
18
+
19
+// const { Lbry } = require("lbry-redux");
20
+
20 21
 // console.log(sdkStatus);
21 22
 
22 23
 
@@ -76,67 +77,20 @@ function renderChannelLink(data, fullData) {
76 77
   // console.log(fullData[data]);
77 78
   // console.log("————————————");
78 79
 
79
-  // resolve(fullData[data]);
80
-
81
-
82
-
83
-  // check out streaming branch
84
-  // const test = resolve(fullData[data]);
85
-
86
-  // console.log("————————————");
87
-  // console.log(process.binding("util").getPromiseDetails(test));
88
-  // console.log("————————————");
89
-
90
-  // return test.then(result => {
91
-  //   console.log(result);
92
-
93
-  //   return (
94
-  //     <channel data-channel-name={channelName}>
95
-  //       {m.trust(formattedChannelName)}
96
-  //     </channel>
97
-  //   );
98
-  // });
99
-
100
-  // return (
101
-  //   <div>
102
-  //     {
103
-  //       test ?
104
-  //         <channel data-channel-name={channelName}>
105
-  //           {m.trust(formattedChannelName)}
106
-  //         </channel> :
107
-  //         m("div", { style: "color: white; text-align: center;" }, "Waiting for OTHER query to finish...")
108
-  //     }
109
-  //   </div>
110
-  // );
111
-
112
-
113
-
114
-  // const oop = [];
115
-
116
-  // for (const test of fullData[data])
117
-  //   oop.push(resolveII(test));
118
-
119
-  // return (
120
-  //   <div>
121
-  //     {
122
-  //       Promise.all(oop).then(values => {
123
-  //         console.log(values);
124
-
125
-  //         return (
126
-  //           <channel data-channel-name={channelName}>
127
-  //             {m.trust(formattedChannelName)}
128
-  //           </channel>
129
-  //         );
130
-  //       })
131
-  //     }
132
-  //   </div>
133
-  // );
134
-
135 80
   return (
136
-    <channel data-channel-name={channelName}>
137
-      {m.trust(formattedChannelName)}
81
+    <channel>
82
+      <a
83
+        href={"/channel/" + encodeURIComponent(channelName)}
84
+        oncreate={m.route.link}
85
+        title={"Visit " + channelNameSolo + "'s channel"}
86
+      >
87
+        {m.trust(formattedChannelName)}
88
+      </a>
138 89
     </channel>
139 90
   );
91
+
92
+  // onclick={e => console.log(e.srcElement.parentNode.dataset.channelName)}
93
+  // href={"/channel/" + channelName}
140 94
 }
141 95
 
142 96
 // https://api.lbry.tv/content/claims/house/a05f51fe630f51e2568c329222ffb5e0bea5fb2d/stream

+ 2
- 0
app/views/index.js View File

@@ -4,6 +4,7 @@
4 4
 
5 5
 //  U T I L S
6 6
 
7
+import Channel from "./channel";
7 8
 import Home from "./home";
8 9
 import Nope from "./nope";
9 10
 
@@ -13,5 +14,6 @@ import Nope from "./nope";
13 14
 
14 15
 export default {
15 16
   "/": Home,
17
+  "/channel/:channelName": Channel,
16 18
   "/:404...": Nope
17 19
 };

+ 3
- 3
package.json View File

@@ -42,12 +42,12 @@
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.9.3",
45
+    "rollup": "^1.10.0",
46 46
     "rollup-plugin-babel": "^4.3.2",
47 47
     "rollup-plugin-commonjs": "^9.3.4",
48 48
     "rollup-plugin-eslint": "^5.1.0",
49 49
     "rollup-plugin-livereload": "^1.0.0",
50
-    "rollup-plugin-node-resolve": "^4.2.2",
50
+    "rollup-plugin-node-resolve": "^4.2.3",
51 51
     "rollup-plugin-pathmodify": "^1.0.1",
52 52
     "rollup-plugin-replace": "^2.2.0",
53 53
     "rollup-plugin-serve": "^1.0.1",
@@ -57,7 +57,7 @@
57 57
     "sass-lint": "^1.12.1",
58 58
     "snazzy": "^8.0.0",
59 59
     "standardx": "^3.0.1",
60
-    "updates": "^8.0.0"
60
+    "updates": "^8.0.1"
61 61
   },
62 62
   "engines": {
63 63
     "node": ">=11.0.0"

Loading…
Cancel
Save