-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathapp.js
More file actions
1644 lines (1478 loc) · 73.7 KB
/
app.js
File metadata and controls
1644 lines (1478 loc) · 73.7 KB
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
(function () {
var saved = localStorage.getItem("theme");
if (!saved) saved = window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
document.documentElement.setAttribute("data-theme", saved);
})();
(function () {
"use strict";
let data = null;
let currentView = "discover";
let currentApp = null;
const $ = (sel, ctx = document) => ctx.querySelector(sel);
const $$ = (sel, ctx = document) => [...ctx.querySelectorAll(sel)];
const icons = {
discover: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`,
macos: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>`,
ios: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="5" y="2" width="14" height="20" rx="3"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>`,
android: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="5" y="9" width="14" height="11" rx="2"/><path d="M8 9V6a4 4 0 0 1 8 0v3"/><line x1="9" y1="5" x2="7" y2="2"/><line x1="15" y1="5" x2="17" y2="2"/><circle cx="9" cy="6" r="0.5" fill="currentColor"/><circle cx="15" cy="6" r="0.5" fill="currentColor"/></svg>`,
web: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>`,
"developer-tools": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,
cli: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>`,
productivity: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>`,
utilities: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>`,
education: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M2 10l10-5 10 5-10 5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg>`,
entertainment: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="2" y="2" width="20" height="20" rx="2.18"/><line x1="7" y1="2" x2="7" y2="22"/><line x1="17" y1="2" x2="17" y2="22"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="2" y1="7" x2="7" y2="7"/><line x1="2" y1="17" x2="7" y2="17"/><line x1="17" y1="7" x2="22" y2="7"/><line x1="17" y1="17" x2="22" y2="17"/></svg>`,
games: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="2" y="6" width="20" height="12" rx="3"/><line x1="6" y1="10" x2="6" y2="14"/><line x1="4" y1="12" x2="8" y2="12"/><circle cx="16" cy="10" r="1" fill="currentColor"/><circle cx="19" cy="12" r="1" fill="currentColor"/></svg>`,
music: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>`,
"photo-video": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,
"graphics-design": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg>`,
"social-networking": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,
finance: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>`,
"health-fitness": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 0 0 0-7.78z"/></svg>`,
lifestyle: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,
news: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"/><line x1="10" y1="6" x2="18" y2="6"/><line x1="10" y1="10" x2="18" y2="10"/><line x1="10" y1="14" x2="14" y2="14"/></svg>`,
business: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2"/></svg>`,
reference: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/></svg>`,
travel: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>`,
"food-drink": `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M18 8h1a4 4 0 0 1 0 8h-1"/><path d="M2 8h16v9a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4V8z"/><line x1="6" y1="1" x2="6" y2="4"/><line x1="10" y1="1" x2="10" y2="4"/><line x1="14" y1="1" x2="14" y2="4"/></svg>`,
navigation: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><polygon points="3 11 22 2 13 21 11 13 3 11"/></svg>`,
sports: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="10"/><path d="M12 2a10 10 0 0 0 0 20"/><path d="M2 12h20"/><path d="M12 2c2.5 3.5 4 7.5 4 10s-1.5 6.5-4 10"/></svg>`,
weather: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"/></svg>`,
shopping: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>`,
books: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>`,
medical: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><line x1="12" y1="2" x2="12" y2="22"/><line x1="2" y1="12" x2="22" y2="12"/></svg>`,
stores: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>`,
github: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"/></svg>`,
request: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" y1="22" x2="4" y2="15"/></svg>`,
};
const cardGradientsDark = [
["#1a1a2e", "#16213e", "#0f3460"],
["#1a1a1a", "#2d132c", "#3a1c3f"],
["#0d1117", "#161b22", "#1a2332"],
["#1a1a2e", "#0a3d62", "#1e5f74"],
["#1a0a2e", "#2b1055", "#3c1053"],
["#0a2e1a", "#0b4228", "#165a3a"],
];
const cardGradientsLight = [
["#d4e4f7", "#c5d8f0", "#a8c4e0"],
["#e8daf0", "#dcc8e8", "#ccb0dc"],
["#d6e2ef", "#c8d8e8", "#b8cade"],
["#d0e8ee", "#b8dce6", "#a0d0dc"],
["#ddd4f0", "#cec0e8", "#baa8dc"],
["#d0ead8", "#b8dcc4", "#a0d0b0"],
];
function getCardGradients() {
return document.documentElement.getAttribute("data-theme") === "light"
? cardGradientsLight
: cardGradientsDark;
}
function sortApps(apps) {
return [...apps].sort((a, b) => {
const starsA = a.stars || 0, starsB = b.stars || 0;
if (starsB !== starsA) return starsB - starsA;
const iconA = a.icon ? 1 : 0, iconB = b.icon ? 1 : 0;
if (iconB !== iconA) return iconB - iconA;
return (a.name || "").localeCompare(b.name || "");
});
}
function formatNumber(n) {
if (n >= 1000000) return (n / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
if (n >= 1000) return (n / 1000).toFixed(1).replace(/\.0$/, "") + "K";
return String(n);
}
function appIconSrc(app) {
return app._generatedIcon || app.icon || null;
}
function iconStyle(app) {
const s = app.iconStyle || {};
const parts = [];
if (s.scale) parts.push(`transform:scale(${s.scale})`);
if (s.objectFit) parts.push(`object-fit:${s.objectFit}`);
if (s.objectPosition) parts.push(`object-position:${s.objectPosition}`);
if (s.padding) parts.push(`padding:${s.padding}`);
return parts.join(";");
}
function iconContainerStyle(app) {
const s = app.iconStyle || {};
const parts = [];
if (s.bgColor) parts.push(`background:${s.bgColor}`);
if (s.borderRadius) parts.push(`border-radius:${s.borderRadius}`);
return parts.length ? ` style="${parts.join(";")}"` : "";
}
function renderIcon(app) {
const src = appIconSrc(app);
if (src) {
const s = app.iconStyle || {};
const imgSt = app._generatedIcon
? `object-fit:cover;border-radius:22%${s.objectPosition ? ";object-position:" + s.objectPosition : ""}${s.scale ? ";transform:scale(" + s.scale + ")" : ""}`
: iconStyle(app);
const st = imgSt ? ` style="${imgSt}"` : "";
return `<img src="${src}" alt="${app.name}"${st} onerror="this.parentElement.innerHTML='${app.iconEmoji || "📦"}'">`;
}
return app.iconEmoji || "📦";
}
function smartMedia(url, cls, alt) {
const isLikelyImage = /\.(png|jpe?g|gif|svg|webp)(\?|$)/i.test(url);
if (isLikelyImage) {
return `<img class="${cls}" src="${url}" alt="${alt}" loading="lazy">`;
}
const isLikelyVideo = /\.(mp4|webm|mov)(\?|$)/i.test(url);
if (isLikelyVideo) {
return `<video class="${cls}" src="${url}" autoplay loop muted playsinline></video>`;
}
return `<img class="${cls}" src="${url}" alt="${alt}" loading="lazy" onerror="var v=document.createElement('video');v.className=this.className;v.src=this.src;v.autoplay=v.loop=v.muted=v.playsInline=true;this.replaceWith(v)">`;
}
function starBadge(stars) {
return `<span class="star-count"><svg viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>${formatNumber(stars)}</span>`;
}
function ownerBadge(app) {
const label = app.developer || app._owner;
if (!label) return "";
return `<span class="owner-badge">${label}</span>`;
}
function isPaidApp(app) {
return app.price && app.price !== "Free" && app.price !== "free";
}
function getBuyUrl(app) {
return app.buyUrl || app.homepage || app.github;
}
function escapeHtml(str) {
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
}
function getTimeAgo(date) {
const seconds = Math.floor((new Date() - date) / 1000);
const intervals = [
{ label: "y", seconds: 31536000 },
{ label: "mo", seconds: 2592000 },
{ label: "w", seconds: 604800 },
{ label: "d", seconds: 86400 },
{ label: "h", seconds: 3600 },
{ label: "m", seconds: 60 },
];
for (const i of intervals) {
const count = Math.floor(seconds / i.seconds);
if (count >= 1) return count + i.label + " ago";
}
return "just now";
}
function renderReviews(app) {
const comments = app._comments || [];
const hasGithub = app.github && app.github.includes("github.com");
if (comments.length === 0 && !hasGithub) return "";
const issuesUrl = hasGithub ? app.github + "/issues?q=%5Bwvw%5D" : "";
const newIssueUrl = hasGithub ? app.github + "/issues/new?title=" + encodeURIComponent("[wvw]: ") : "";
const clickToRate = hasGithub ? `
<div class="reviews-actions">
<div class="click-to-rate">
<span class="click-to-rate-label">Click to Rate:</span>
<a href="${newIssueUrl}" target="_blank" rel="noopener" class="rate-stars">
${[1, 2, 3, 4, 5].map(() => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`).join("")}
</a>
</div>
<div class="review-links">
<a href="${newIssueUrl}" target="_blank" rel="noopener" class="review-link">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>
Write a Review
</a>
<a href="${issuesUrl}" target="_blank" rel="noopener" class="review-link">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="10"/><path d="M12 17h.01"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 2-3 4"/></svg>
App Support
</a>
</div>
</div>` : "";
const reactionEmojis = { thumbsUp: "\u{1F44D}", thumbsDown: "\u{1F44E}", laugh: "\u{1F604}", hooray: "\u{1F389}", confused: "\u{1F615}", heart: "\u2764\uFE0F", rocket: "\u{1F680}", eyes: "\u{1F440}" };
const reviewCards = comments.map((c) => {
const timeAgo = getTimeAgo(new Date(c.created_at));
const body = escapeHtml(c.body || "");
const truncated = body.length > 200 ? body.substring(0, 200) + "\u2026" : body;
const reactions = c.reactions ? Object.entries(reactionEmojis)
.filter(([key]) => c.reactions[key] > 0)
.map(([key, emoji]) => `<span class="review-reaction">${emoji} ${c.reactions[key]}</span>`)
.join("") : "";
return `
<div class="review-card">
<div class="review-card-header">
<img class="review-avatar" src="${c.avatar}" alt="" onerror="this.style.display='none'">
<div class="review-header-info">
<span class="review-author">${escapeHtml(c.user)}</span>
<span class="review-time">${timeAgo}</span>
</div>
</div>
<div class="review-card-title">${escapeHtml(c.title)}</div>
<div class="review-card-body">${truncated}</div>
${reactions ? `<div class="review-reactions">${reactions}</div>` : ""}
${c.url ? `<a href="${c.url}" target="_blank" rel="noopener" class="review-more">more</a>` : ""}
</div>`;
}).join("");
return `
<div class="detail-section reviews-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">Ratings & Reviews</h3>
${hasGithub ? `<a href="${issuesUrl}" target="_blank" rel="noopener" class="see-all-link">See All</a>` : ""}
</div>
${clickToRate}
${reviewCards ? `
<div class="review-cards-wrapper">
<button class="review-scroll-btn review-scroll-left" aria-label="Scroll left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="15 18 9 12 15 6"/></svg>
</button>
<div class="review-cards">${reviewCards}</div>
<button class="review-scroll-btn review-scroll-right" aria-label="Scroll right">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="9 6 15 12 9 18"/></svg>
</button>
</div>` : ""}
</div>`;
}
function getButtonLabel(app) {
if (isPaidApp(app)) return app.price;
if (app.brew || app.downloadUrl || app.installCommand) return "Get";
return "View";
}
function getAppDeveloperLabel(app) {
return app.developer || app._developer || app._owner || app._store || data.store.developer;
}
function getAppPublisherTerms(app) {
return [app.developer, app._developer, app._owner, data.store.developer]
.filter(Boolean)
.map((value) => value.toLowerCase());
}
function getPublisherMatchType(app, query) {
if (!query) return 0;
const terms = getAppPublisherTerms(app);
if (terms.some((value) => value === query)) return 2;
if (terms.some((value) => value.includes(query))) return 1;
return 0;
}
function matchesSearchText(app, query) {
if (!query) return true;
return (
app.name.toLowerCase().includes(query) ||
app.subtitle.toLowerCase().includes(query) ||
app.description.toLowerCase().includes(query) ||
(app.features && app.features.some((f) => f.toLowerCase().includes(query)))
);
}
function parseSearchQuery(query) {
const byMatch = query.match(/(?:^|\s)by:(?:"([^"]+)"|(.+?))(?=\s+\w+:|$)/i);
const publisherQuery = byMatch ? (byMatch[1] || byMatch[2] || "").trim().toLowerCase() : "";
const textQuery = (byMatch ? query.replace(byMatch[0], " ") : query).trim().toLowerCase();
return { publisherQuery, textQuery };
}
function appRow(app) {
return `
<div class="app-row" data-app="${app.id}">
<div class="app-icon"${iconContainerStyle(app)}>${renderIcon(app)}</div>
<div class="app-info">
<div class="app-name"><span class="app-name-text">${app.name}</span>${ownerBadge(app)}</div>
<div class="app-subtitle">${app.subtitle}</div>
<div class="app-meta">
<span class="app-meta-tag">${app.platform}</span>
${app.stars ? starBadge(app.stars) : ""}
</div>
</div>
<button class="get-btn${isPaidApp(app) ? " buy-btn" : ""}" data-action="get" data-app="${app.id}">${getButtonLabel(app)}</button>
</div>`;
}
function appCard(app, index) {
const grads = getCardGradients();
const g = grads[index % grads.length];
const showcasePick = showcaseData ? (showcaseData.picks || []).find((p) => p.id === app.id && p.showcase_image) : null;
const hasScreenshot = showcasePick || (app.screenshots && app.screenshots.length > 0);
const screenshotImg = showcasePick
? `<img class="card-screenshot" src="${showcasePick.showcase_image}" alt="${app.name}" loading="lazy">`
: (app.screenshots && app.screenshots.length > 0 ? smartMedia(app.screenshots[0], "card-screenshot", app.name) : "");
return `
<div class="card" data-app="${app.id}">
<div class="card-image">
<div class="card-image-bg" style="background:linear-gradient(135deg, ${g[0]}, ${g[1]}, ${g[2]})">
${screenshotImg}
<div class="card-icon-fallback">${(() => { const s = app.iconStyle || {}; const src = appIconSrc(app); return src ? `<img src="${src}" style="width:80px;height:80px;border-radius:18px;object-fit:cover${s.objectPosition ? ";object-position:" + s.objectPosition : ""}${s.scale ? ";transform:scale(" + s.scale + ")" : ""}" onerror="this.outerHTML='📦'">` : (app.iconEmoji || "📦"); })()}</div>
</div>
</div>
<div class="card-body">
<div class="card-label">${app.platform === "macOS" ? "macOS APP" : app.platform === "Web" ? "WEB APP" : "TOOL"}</div>
<div class="card-title">${app.name}</div>
<div class="card-subtitle">${app.subtitle}</div>
</div>
</div>`;
}
// Sidebar
function buildSidebar() {
const nav = $("#sidebarNav");
const items = [
{ id: "discover", name: "Discover", icon: icons.discover },
{ id: "stores", name: "Stores", icon: icons.stores },
];
let html = "";
items.forEach((item) => {
html += `<div class="nav-item${currentView === item.id ? " active" : ""}" data-view="${item.id}">
<span class="nav-icon">${item.icon}</span>${item.name}
</div>`;
});
html += `<div class="nav-separator"></div>`;
html += `<div class="nav-section-label">Categories</div>`;
const defaultIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="3" y="3" width="18" height="18" rx="2"/></svg>`;
const categories = (data.categories || [])
.filter((c) => c.id !== "all")
.filter((c) => data.apps.some((a) => a.category && a.category.includes(c.id)))
.map((c) => ({ id: c.id, name: c.name, icon: icons[c.id] || defaultIcon }));
categories.forEach((cat) => {
html += `<div class="nav-item${currentView === cat.id ? " active" : ""}" data-view="${cat.id}">
<span class="nav-icon">${cat.icon}</span>${cat.name}
</div>`;
});
html += `<div class="nav-separator"></div>`;
html += `<div class="nav-item" data-view="github">
<span class="nav-icon">${icons.github}</span>GitHub
</div>`;
nav.innerHTML = html;
}
function renderFeaturedBanner(f) {
const app = data.apps.find((a) => a.id === f.id);
const showcasePick = showcaseData ? (showcaseData.picks || []).find((p) => p.id === f.id && p.showcase_image) : null;
const bgStyle = showcasePick
? `style="background-image:url('${showcasePick.showcase_image}');background-size:cover;background-position:center"`
: "";
return `
<div class="featured-banner" data-app="${f.id}" ${bgStyle}>
<div class="featured-content">
<div class="featured-label">${f.headline}</div>
<div class="featured-title">${f.title}</div>
<div class="featured-subtitle">${f.subtitle}</div>
${app ? `
<div class="featured-app-row">
<div class="featured-app-icon"${iconContainerStyle(app)}>${renderIcon(app)}</div>
<div class="featured-app-info">
<div class="featured-app-name">${app.name}</div>
<div class="featured-app-sub">${app.subtitle}</div>
</div>
<button class="featured-get-btn${isPaidApp(app) ? " buy-btn" : ""}" data-action="get" data-app="${app.id}">${getButtonLabel(app)}</button>
</div>` : ""}
</div>
</div>`;
}
function pickMustTry(apps, count) {
const featuredIds = new Set((Array.isArray(data.featured) ? data.featured : []).map((f) => f.id));
const showcaseIds = new Set(showcaseData ? (showcaseData.picks || []).filter((p) => p.showcase_image).map((p) => p.id) : []);
const scored = apps.map((a) => {
let score = 0;
if (showcaseIds.has(a.id)) score += 50;
if (a.screenshots && a.screenshots.length > 0) score += 30;
if (a.icon) score += 10;
if (a.features && a.features.length > 0) score += 5;
if (a.longDescription) score += 5;
score += Math.min(Math.log10((a.stars || 0) + 1) * 10, 40);
if (featuredIds.has(a.id)) score -= 20;
return { app: a, score };
}).sort((a, b) => b.score - a.score);
const picked = [];
const usedStores = new Set();
const usedCategories = new Set();
for (const { app } of scored) {
if (picked.length >= count) break;
const dominated = usedStores.has(app._source) && app.category.every((c) => usedCategories.has(c));
if (dominated && picked.length >= 2) continue;
picked.push(app);
usedStores.add(app._source);
(app.category || []).forEach((c) => usedCategories.add(c));
}
if (picked.length < count) {
for (const { app } of scored) {
if (picked.length >= count) break;
if (!picked.includes(app)) picked.push(app);
}
}
return picked.slice(0, count);
}
function showcaseCard(pick) {
const app = data.apps.find((a) => a.id === pick.id);
if (!app) return "";
const bgImg = pick.showcase_image || pick.screenshot;
const bg = bgImg
? `background-image:url('${bgImg}');background-size:cover;background-position:center`
: `background:linear-gradient(135deg, ${getCardGradients()[0].join(", ")})`;
return `
<div class="showcase-card" data-app="${pick.id}" style="${bg}">
<div class="showcase-overlay">
<div class="showcase-card-icon">${(() => { const s = app.iconStyle || {}; const src = appIconSrc(app); return src ? `<img src="${src}" style="width:40px;height:40px;border-radius:10px;object-fit:cover${s.objectPosition ? ";object-position:" + s.objectPosition : ""}${s.scale ? ";transform:scale(" + s.scale + ")" : ""}" onerror="this.outerHTML='${app.iconEmoji || "📦"}'">` : (app.iconEmoji || "📦"); })()}</div>
<div class="showcase-card-info">
<div class="showcase-card-name">${app.name}</div>
<div class="showcase-card-sub">${app.subtitle}</div>
</div>
</div>
</div>`;
}
// Discover Page
function renderDiscover() {
const apps = data.apps;
const featuredList = Array.isArray(data.featured) ? data.featured : [data.featured];
const activeCats = (data.categories || [])
.filter((c) => c.id !== "all")
.filter((c) => apps.some((a) => a.category && a.category.includes(c.id)));
const dots = featuredList.length > 1
? `<div class="carousel-dots">${featuredList.map((_, i) => `<button class="carousel-dot${i === 0 ? " active" : ""}" data-slide="${i}"></button>`).join("")}</div>`
: "";
let html = `
<div class="mobile-page-title">World Vibe Web</div>
<div class="carousel">
<div class="carousel-track">
${featuredList.map((f) => renderFeaturedBanner(f)).join("")}
</div>
${dots}
</div>
<div class="section">
<div class="section-header">
<h2>Best New Apps and Updates</h2>
</div>
<div class="app-list">
${sortApps(apps).slice(0, 6).map((a) => appRow(a)).join("")}
</div>
</div>
${(() => {
const paidApps = apps.filter((a) => isPaidApp(a));
if (paidApps.length === 0) return "";
return `
<div class="section">
<div class="section-header">
<h2>Best Paid Apps</h2>
</div>
<div class="app-list">
${sortApps(paidApps).map((a) => appRow(a)).join("")}
</div>
</div>`;
})()}
<div class="section">
<div class="section-header">
<h2>The Latest Must-Try Apps</h2>
</div>
<div class="cards-grid">
${pickMustTry(apps, 4).map((a, i) => appCard(a, i)).join("")}
</div>
</div>
${activeCats.map((cat) => {
const catApps = apps.filter((a) => a.category && a.category.includes(cat.id));
const showAll = catApps.length > 6;
const picks = showcaseData ? (showcaseData.picks || []).filter((p) => p.category === cat.id) : [];
return `
<div class="section">
<div class="section-header">
<h2>${cat.name}</h2>
${showAll ? `<span class="see-all" data-view="${cat.id}">See All</span>` : ""}
</div>
${picks.length > 0 ? `
<div class="showcase-picks">
${picks.map((p) => showcaseCard(p)).join("")}
</div>` : ""}
<div class="app-list">
${sortApps(catApps).slice(0, 6).map((a) => appRow(a)).join("")}
</div>
</div>`;
}).join("")}
`;
return html;
}
// Category Page
function renderCategory(categoryId) {
const cat = data.categories.find((c) => c.id === categoryId);
const apps = data.apps.filter((a) => a.category.includes(categoryId));
if (apps.length === 0) {
return `
<div class="page-header"><h1>${cat ? cat.name : "Category"}</h1></div>
<div class="empty-state">
<div class="empty-state-icon">📭</div>
<h3>No apps yet</h3>
<p>Check back later for new apps in this category.</p>
</div>`;
}
const picks = showcaseData ? (showcaseData.picks || []).filter((p) => p.category === categoryId) : [];
return `
<div class="page-header"><h1>${cat ? cat.name : "Category"}</h1></div>
${picks.length > 0 ? `
<div class="showcase-picks" style="margin-bottom:20px">
${picks.map((p) => showcaseCard(p)).join("")}
</div>` : ""}
<div class="app-list">
${sortApps(apps).map((a) => appRow(a)).join("")}
</div>`;
}
// App Detail Page
function renderAppDetail(appId) {
const app = data.apps.find((a) => a.id === appId);
if (!app) return `<div class="empty-state"><h3>App not found</h3></div>`;
return `
<div class="app-detail">
<div class="back-btn" data-action="back">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
Back
</div>
<div class="app-detail-header">
<div class="app-detail-icon"${iconContainerStyle(app)}>${renderIcon(app)}</div>
<div class="app-detail-title-area">
<div class="app-detail-title">${app.name}</div>
${app._owner ? `<div class="app-detail-owner">by <a href="https://github.com/${app._owner}" target="_blank" rel="noopener">${app._owner}</a></div>` : ""}
<div class="app-detail-subtitle">${app.subtitle}</div>
<div class="app-detail-actions">
<button class="app-detail-get-btn${isPaidApp(app) ? " buy-btn" : ""}" data-action="get" data-app="${app.id}">
${getButtonLabel(app)}
</button>
<a href="${app.github}" target="_blank" rel="noopener" class="github-link">
${icons.github} View on GitHub
</a>
<button class="share-btn" data-action="share" aria-label="Share">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"/><polyline points="16 6 12 2 8 6"/><line x1="12" y1="2" x2="12" y2="15"/></svg>
</button>
</div>
</div>
</div>
<div class="app-detail-stats">
${app.stars !== undefined ? `<div class="stat"><div class="stat-value">${formatNumber(app.stars)}</div><div class="stat-label">Stars</div></div>` : ""}
${app.forks !== undefined ? `<div class="stat"><div class="stat-value">${formatNumber(app.forks)}</div><div class="stat-label">Forks</div></div>` : ""}
<div class="stat"><div class="stat-value">${app.price}</div><div class="stat-label">Price</div></div>
<div class="stat"><div class="stat-value">${app.platform}</div><div class="stat-label">Platform</div></div>
<div class="stat"><div class="stat-value">${app.language}</div><div class="stat-label">Language</div></div>
</div>
${app.screenshots && app.screenshots.length > 0 ? `
<div class="detail-section">
<h3>Preview</h3>
<div class="screenshots-scroll">
${app.screenshots.map((s) => smartMedia(s, "screenshot-img", app.name)).join("")}
</div>
</div>` : ""}
<div class="detail-section">
<h3>Description</h3>
<p>${app.longDescription || app.description}</p>
</div>
${app.features && app.features.length > 0 ? `
<div class="detail-section">
<h3>What's New</h3>
<ul class="features-list">
${app.features.map((f) => `<li>${f}</li>`).join("")}
</ul>
</div>` : ""}
${app.brew ? `
<div class="detail-section">
<div class="brew-section">
<div class="brew-section-title">Install with Homebrew</div>
<div class="brew-command" data-copy="${app.brew}">
<span class="prompt">$</span>
<span class="cmd">${app.brew}</span>
<span class="copy-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></span>
</div>
</div>
</div>` : ""}
${app.installCommand ? `
<div class="detail-section">
<div class="brew-section">
<div class="brew-section-title">Quick Install</div>
<div class="brew-command" data-copy="${app.installCommand}">
<span class="prompt">$</span>
<span class="cmd">${app.installCommand}</span>
<span class="copy-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></span>
</div>
</div>
</div>` : ""}
${renderReviews(app)}
<div class="detail-section">
<h3>Information</h3>
<div class="info-grid">
<div class="info-item">
<span class="info-label">Developer</span>
<span class="info-value">${app.developer || data.store.developer}</span>
</div>
${app._owner ? `<div class="info-item">
<span class="info-label">Published by</span>
<span class="info-value"><a href="https://github.com/${app._owner}" target="_blank" rel="noopener">${app._owner}</a></span>
</div>` : ""}
${app._source ? `<div class="info-item">
<span class="info-label">Source Store</span>
<span class="info-value"><a href="${app._storeUrl || 'https://github.com/' + app._source}" target="_blank" rel="noopener">${app._store || app._source}</a></span>
</div>` : ""}
<div class="info-item">
<span class="info-label">Compatibility</span>
<span class="info-value">${app.requirements}</span>
</div>
<div class="info-item">
<span class="info-label">Language</span>
<span class="info-value">${app.language}</span>
</div>
<div class="info-item">
<span class="info-label">Price</span>
<span class="info-value">${app.price}</span>
</div>
<div class="info-item">
<span class="info-label">Source Code</span>
<span class="info-value"><a href="${app.github}" target="_blank" rel="noopener">${app.github.replace("https://github.com/", "")}</a></span>
</div>
${app.homepage ? `
<div class="info-item">
<span class="info-label">Website</span>
<span class="info-value"><a href="${app.homepage}" target="_blank" rel="noopener">${app.homepage.replace("https://", "")}</a></span>
</div>` : ""}
</div>
</div>
<div class="detail-section security-section">
<h3>App Security</h3>
<div class="security-notice">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="security-icon"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
<div>
<p>This app may be <strong>vibe-coded</strong> — possibly built with AI-assisted development. While the source code is open and available on GitHub, World Vibe Web does not audit, verify, or guarantee the safety of any listed app.</p>
<p>Before installing, review the source code yourself${app.github ? ` at <a href="${app.github}" target="_blank" rel="noopener">${app.github.replace("https://github.com/", "")}</a>` : ""}. Run apps in sandboxed environments when possible. <strong>Install at your own risk.</strong></p>
</div>
</div>
</div>
${(() => {
const relatedBySource = data.apps.filter(
(a) => a.id !== app.id && a._source && app._source && a._source === app._source
);
const sameStore = relatedBySource.slice(0, 6);
const hasStorePage = app._source && storesData.some((store) => store.source === app._source);
if (sameStore.length === 0) return "";
return `
<div class="detail-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">More by ${getAppDeveloperLabel(app)}</h3>
${hasStorePage && relatedBySource.length > sameStore.length ? `<button class="see-all-link" type="button" data-store="${encodeURIComponent(app._source)}">See All</button>` : ""}
</div>
<div class="app-list">
${sameStore.map((a) => appRow(a)).join("")}
</div>
</div>`;
})()}
${(() => {
const related = data.apps.filter(
(a) => a.id !== app.id &&
a.category && app.category &&
a.category.some((c) => app.category.includes(c))
).slice(0, 6);
if (related.length === 0) return "";
return `
<div class="detail-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">You Might Also Like</h3>
</div>
<div class="app-list">
${related.map((a) => appRow(a)).join("")}
</div>
</div>`;
})()}
</div>`;
}
// Search results
function renderSearch(query) {
const { publisherQuery, textQuery } = parseSearchQuery(query);
const matchingApps = data.apps
.map((app) => ({
app,
publisherMatchType: publisherQuery ? getPublisherMatchType(app, publisherQuery) : 0,
}))
.filter(({ app, publisherMatchType }) =>
(!publisherQuery || publisherMatchType > 0) && matchesSearchText(app, textQuery)
);
const exactPublisherMatches = publisherQuery
? matchingApps.filter(({ publisherMatchType }) => publisherMatchType === 2).map(({ app }) => app)
: [];
const partialPublisherMatches = publisherQuery
? matchingApps.filter(({ publisherMatchType }) => publisherMatchType === 1).map(({ app }) => app)
: [];
const results = !publisherQuery ? matchingApps.map(({ app }) => app) : exactPublisherMatches.concat(partialPublisherMatches);
if (results.length === 0) {
return `
<div class="page-header"><h1>Search: "${query}"</h1></div>
<div class="empty-state">
<div class="empty-state-icon">🔍</div>
<h3>No results</h3>
<p>Try a different search term.</p>
</div>`;
}
return `
<div class="page-header"><h1>Search: "${query}"</h1></div>
${publisherQuery ? `
<div class="app-list">
${exactPublisherMatches.map((a) => appRow(a)).join("")}
</div>
${partialPublisherMatches.length > 0 ? `
<div class="section">
<div class="section-header">
<h2>Related Publisher Matches</h2>
</div>
<div class="app-list">
${partialPublisherMatches.map((a) => appRow(a)).join("")}
</div>
</div>` : ""}` : `
<div class="app-list">
${results.map((a) => appRow(a)).join("")}
</div>`}`;
}
// Stores Page
function renderStores() {
if (storesData.length === 0) {
return `
<div class="page-header"><h1>Stores</h1></div>
<div class="empty-state">
<div class="empty-state-icon">🏪</div>
<h3>No stores yet</h3>
<p>Stores will appear here once the catalog is built.</p>
</div>`;
}
const totalApps = data.apps ? data.apps.length : 0;
const totalStars = storesData.reduce((sum, s) => sum + s.totalStars, 0);
return `
<div class="page-header"><h1>Stores</h1></div>
<div class="stores-overview">
<div class="stores-overview-stat">
<div class="stores-overview-value">${storesData.length}</div>
<div class="stores-overview-label">Stores</div>
</div>
<div class="stores-overview-stat">
<div class="stores-overview-value">${totalApps}</div>
<div class="stores-overview-label">Apps</div>
</div>
<div class="stores-overview-stat">
<div class="stores-overview-value">${formatNumber(totalStars)}</div>
<div class="stores-overview-label">Stars</div>
</div>
</div>
<p style="color:var(--text-secondary);font-size:14px;margin-bottom:24px;line-height:1.5">
World Vibe Web aggregates apps from independent stores. Each store maintains its own <code style="font-size:12px;background:var(--bg-tertiary);padding:2px 6px;border-radius:4px">apps.json</code> and contributes to the unified catalog.
</p>
<div class="stores-list">
${storesData.map((s) => {
const iconStack = (s.icons || []).slice(0, 4).map((ic, i) =>
`<img src="${ic.icon}" class="store-stack-icon" style="z-index:${4 - i};margin-left:${i ? '-10px' : '0'};${ic.iconStyle && ic.iconStyle.borderRadius ? 'border-radius:' + ic.iconStyle.borderRadius : 'border-radius:22%'}" onerror="this.style.display='none'">`
).join("");
const fallbackAvatar = !s.icons || s.icons.length === 0
? `<div class="store-card-avatar-letter">${s.name.charAt(0).toUpperCase()}</div>` : "";
const isUrl = s.source.startsWith("http");
const sourceLink = isUrl ? s.source : `https://github.com/${s.source}`;
const sourceLabel = isUrl ? s.source.replace(/^https?:\/\//, "").replace(/\/+$/, "") : s.owner;
return `
<div class="store-card" data-store="${encodeURIComponent(s.source)}" style="cursor:pointer">
<div class="store-card-header">
<div class="store-icon-stack">${iconStack}${fallbackAvatar}</div>
<div class="store-card-info">
<div class="store-card-name">${s.name}</div>
<div class="store-card-developer">by ${s.developer}</div>
</div>
</div>
<div class="store-card-stats">
<div class="store-card-stat"><span class="store-stat-value">${s.appCount}</span><span class="store-stat-label">Apps</span></div>
<div class="store-card-stat"><span class="store-stat-value">${formatNumber(s.totalStars)}</span><span class="store-stat-label">Stars</span></div>
</div>
<div class="store-card-actions">
${s.url ? `<a href="${s.url}" target="_blank" rel="noopener" class="store-card-btn primary">Visit Store</a>` : ""}
<a href="${sourceLink}" target="_blank" rel="noopener" class="store-card-btn secondary">${icons.github} View Repo</a>
</div>
</div>`;
}).join("")}
</div>`;
}
// App Requests Page
function renderRequests() {
const requestUrl = "https://github.com/f/wvw.dev/issues?q=is%3Aissue+label%3Aapp-request";
const newRequestUrl = "https://github.com/f/wvw.dev/issues/new?template=app-request.yml";
return `
<div class="page-header"><h1>App Requests</h1></div>
<p style="color:var(--text-secondary);font-size:14px;margin-bottom:24px;line-height:1.5">
Can't find an app on WVW? Request it here. The community and maintainers will review requests and help get apps listed.
</p>
<div style="display:flex;gap:10px;margin-bottom:32px">
<a href="${newRequestUrl}" target="_blank" rel="noopener" class="store-card-btn primary" style="padding:10px 20px;font-size:14px">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>
Request an App
</a>
<a href="${requestUrl}" target="_blank" rel="noopener" class="store-card-btn secondary" style="padding:10px 20px;font-size:14px">
${icons.github} View All Requests
</a>
</div>
<div class="requests-info">
<div class="requests-info-card">
<div class="requests-info-icon">1</div>
<h4>Submit a Request</h4>
<p>Fill out the form with the app name, GitHub URL, platform, and why it should be listed.</p>
</div>
<div class="requests-info-card">
<div class="requests-info-icon">2</div>
<h4>Someone Vibecodes It</h4>
<p>A developer from the community picks up the request and vibecodes the app into existence.</p>
</div>
<div class="requests-info-card">
<div class="requests-info-icon">3</div>
<h4>App Gets Listed</h4>
<p>The app developer or a contributor adds the app's store to WVW.</p>
</div>
</div>`;
}
// Store Detail Page
function renderStoreDetail(storeSource) {
const store = storesData.find((s) => s.source === storeSource);
if (!store) return `<div class="empty-state"><div class="empty-state-icon">🏪</div><h3>Store not found</h3></div>`;
const apps = data.apps.filter((a) => a._source === storeSource);
const featuredList = Array.isArray(data.featured) ? data.featured : [];
const featuredApps = apps.filter((a) => featuredList.some((f) => f.id === a.id));
const isUrl = store.source.startsWith("http");
const sourceLink = isUrl ? store.source : `https://github.com/${store.source}`;
const categories = [...new Set(apps.flatMap((a) => a.category || []))];
const catNames = categories.map((cid) => {
const cat = (data.categories || []).find((c) => c.id === cid);
return cat ? cat.name : cid;
});
const storeIcons = (store.icons || []).slice(0, 4);
const iconGrid = storeIcons.length > 0
? `<div class="store-detail-icon-grid">${storeIcons.map((ic) =>
`<img src="${ic.icon}" class="store-detail-grid-icon" style="${ic.iconStyle && ic.iconStyle.borderRadius ? "border-radius:" + ic.iconStyle.borderRadius : "border-radius:22%"}" onerror="this.style.display='none'">`
).join("")}</div>`
: `<div class="store-detail-avatar-letter">${store.name.charAt(0).toUpperCase()}</div>`;
return `
<div class="app-detail">
<div class="back-btn" data-action="back-stores">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
Stores
</div>
<div class="store-detail-header">
<div class="store-detail-icon-area">
${iconGrid}
</div>
<div class="store-detail-title-area">
<div class="store-detail-title">${store.name}</div>
<div class="store-detail-developer">by ${store.developer}</div>
${featuredApps.length > 0 ? `<div class="store-detail-featured-badge"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg> Featured Store</div>` : ""}
<div class="store-detail-actions">
${store.url ? `<a href="${store.url}" target="_blank" rel="noopener" class="store-card-btn primary">Visit Store</a>` : ""}
<a href="${sourceLink}" target="_blank" rel="noopener" class="store-card-btn secondary">${icons.github} View Repo</a>
<button class="share-btn" data-action="share" aria-label="Share">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"/><polyline points="16 6 12 2 8 6"/><line x1="12" y1="2" x2="12" y2="15"/></svg>
</button>
</div>
</div>
</div>
<div class="app-detail-stats">
<div class="stat"><div class="stat-value">${store.appCount}</div><div class="stat-label">Apps</div></div>
<div class="stat"><div class="stat-value">${formatNumber(store.totalStars)}</div><div class="stat-label">Stars</div></div>
<div class="stat"><div class="stat-value">${categories.length}</div><div class="stat-label">Categories</div></div>
</div>
${catNames.length > 0 ? `
<div class="store-detail-tags">
${catNames.map((n) => `<span class="store-detail-tag">${n}</span>`).join("")}
</div>` : ""}
${(() => {
const allPicks = showcaseData ? (showcaseData.picks || []).filter((p) => apps.some((a) => a.id === p.id)) : [];
const showcasePicks = allPicks.sort(() => 0.5 - Math.random()).slice(0, 2);
if (showcasePicks.length === 0) return "";
return `
<div class="detail-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">Showcased</h3>
</div>
<div class="showcase-picks">
${showcasePicks.map((p) => showcaseCard(p)).join("")}
</div>
</div>`;
})()}
${featuredApps.length > 0 ? `
<div class="detail-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">Featured</h3>
</div>
<div class="cards-grid">
${featuredApps.map((a, i) => appCard(a, i)).join("")}
</div>
</div>` : ""}
<div class="detail-section">
<div class="section-header">
<h3 style="font-size:22px;margin-bottom:0">All Apps</h3>
</div>
<div class="app-list">
${apps.map((a) => appRow(a)).join("")}
</div>
</div>
</div>`;
}
// Router
const isLocal = location.hostname === "localhost" || location.hostname === "127.0.0.1";
let suppressHash = false;
function buildPath(view, appId) {
if (view === "stores" && appId) {
const slug = appId.startsWith("http") ? encodeURIComponent(appId) : appId;
return `/stores/${slug}`;
}
if (appId) return `/${view}/${appId}`;
if (view === "discover") return `/`;
return `/${view}`;
}
function parseRoute() {