Repository navigation
Expand file tree
/
Copy pathsettings.html
More file actions
1268 lines (1175 loc) · 56.8 KB
/
Copy pathsettings.html
File metadata and controls
1268 lines (1175 loc) · 56.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nb-web Settings</title>
<link rel="icon" type="image/svg+xml" href="/nw-logo.svg">
<style>
/* Inherit CSS vars from the parent frame's document.documentElement */
:root {
--bg: #1a1e24;
--bg2: #22272e;
--bg3: #2b3038;
--border: rgba(255,255,255,0.08);
--text: #cdd9e5;
--text-muted: rgba(205,217,229,0.5);
--text-dim: rgba(205,217,229,0.3);
--accent: #3d8fd4;
--font-mono: 'JetBrains Mono','Fira Code',monospace;
}
[data-theme="light"] {
--bg: #f5f5f5;
--bg2: #ffffff;
--bg3: #ebebeb;
--border: #dedede;
--text: #1a1a1a;
--text-muted: rgba(26,26,26,0.5);
--text-dim: rgba(26,26,26,0.3);
--accent: #3d8fd4;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--bg);
color: var(--text);
font-family: system-ui, sans-serif;
font-size: 14px;
padding: 36px 44px 60px;
line-height: 1.6;
}
h1 { font-size: 1.3rem; margin-bottom: .2em; }
.subtitle { color: var(--text-muted); font-size: 0.85em; margin-bottom: 2em; }
section { margin-bottom: 2.4em; }
h2 {
font-size: 0.72em;
font-weight: 700;
letter-spacing: .07em;
text-transform: uppercase;
color: var(--text-dim);
border-bottom: 1px solid var(--border);
padding-bottom: 5px;
margin-bottom: 1.2em;
}
.field { margin-bottom: 1.1em; }
label {
display: block;
font-size: 0.82em;
color: var(--text-muted);
margin-bottom: 4px;
}
input[type="text"], input[type="number"], textarea {
width: 100%; max-width: 480px;
background: var(--bg3);
border: 1px solid var(--border);
color: var(--text);
border-radius: 4px;
padding: 6px 10px;
font-size: 0.9em;
font-family: inherit;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
outline: 1px solid var(--accent);
}
textarea { resize: vertical; min-height: 60px; font-family: var(--font-mono); font-size: 0.85em; }
input[type="number"] { width: 7em; }
.hint { font-size: 0.78em; color: var(--text-dim); margin-top: 3px; }
.terminal-toggle {
display: flex; align-items: center; gap: 5px;
font-size: 0.82em; color: var(--text-muted);
white-space: nowrap; cursor: pointer;
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button.save-btn {
background: var(--accent);
color: #fff;
border: none;
border-radius: 4px;
padding: 7px 20px;
cursor: pointer;
font-size: 0.9em;
}
button.save-btn:hover { opacity: .88; }
.status {
font-size: 0.82em;
color: var(--text-muted);
min-width: 6em;
}
.status.ok { color: #57ab5a; }
.status.err { color: #e5534b; }
.theme-toggle {
display: flex; gap: 8px;
}
.theme-btn {
background: var(--bg3);
border: 1px solid var(--border);
color: var(--text);
border-radius: 4px;
padding: 5px 14px;
cursor: pointer;
font-size: 0.88em;
}
.theme-btn.active {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.nb-setting-row {
display: flex; align-items: baseline; gap: 12px;
padding: 6px 0;
border-bottom: 1px solid var(--border);
font-size: 0.88em;
}
.nb-setting-key { width: 180px; flex-shrink: 0; color: var(--text-muted); font-family: var(--font-mono); font-size: 0.9em; }
.nb-setting-value { color: var(--text); }
.nb-settings-loading { color: var(--text-dim); font-size: 0.88em; }
.sec-index {
display: flex; flex-wrap: wrap; gap: 6px;
margin-bottom: 2.4em;
}
.sec-index a {
background: var(--bg3);
border: 1px solid var(--border);
color: var(--text-muted);
border-radius: 12px;
padding: 3px 11px;
font-size: 0.78em;
text-decoration: none;
white-space: nowrap;
}
.sec-index a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
button.tool-btn {
background: var(--bg3);
border: 1px solid var(--border);
color: var(--text);
border-radius: 4px;
padding: 6px 16px;
cursor: pointer;
font-size: 0.88em;
}
button.tool-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
button.tool-btn:disabled { opacity: 0.5; cursor: default; }
.tool-output {
margin-top: .8em;
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 4px;
padding: 8px 12px;
font-family: var(--font-mono);
font-size: 0.82em;
white-space: pre;
color: var(--text-muted);
max-height: 200px;
overflow-y: auto;
}
.plugin-row {
display: flex; align-items: center; gap: 10px;
padding: 7px 0;
border-bottom: 1px solid var(--border);
font-size: 0.88em;
}
.plugin-row:last-child { border-bottom: none; }
.plugin-name { flex: 1; font-weight: 500; min-width: 0; }
.plugin-url { flex: 2; font-family: var(--font-mono); font-size: 0.8em; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.plugin-badge {
font-size: 0.72em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
border-radius: 3px; padding: 1px 6px; flex-shrink: 0;
}
.plugin-badge-core { background: rgba(87,171,90,.15); color: #57ab5a; border: 1px solid rgba(87,171,90,.3); }
.plugin-badge-bundled { background: rgba(61,143,212,.12); color: var(--accent); border: 1px solid rgba(61,143,212,.25); }
.plugin-badge-ecosystem { background: rgba(229,141,75,.12); color: #e58d4b; border: 1px solid rgba(229,141,75,.25); }
.plugin-badge-plugin { background: rgba(205,217,229,.08); color: var(--text-muted); border: 1px solid var(--border); }
.plugin-toggle { font-size: 0.8em; color: var(--text-muted); cursor: pointer; flex-shrink: 0; }
a.plugin-homepage {
font-size: 0.8em; color: var(--text-dim); text-decoration: none; flex-shrink: 0;
}
a.plugin-homepage:hover { color: var(--accent); }
button.plugin-remove {
background: none; border: 1px solid var(--border); color: var(--text-dim);
border-radius: 3px; padding: 2px 8px; cursor: pointer; font-size: 0.8em; flex-shrink: 0;
}
button.plugin-remove:hover { border-color: #e5534b; color: #e5534b; }
.plugin-disabled .plugin-name { opacity: 0.5; }
.plugin-group-label {
font-size: 0.72em; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
color: var(--text-dim); padding: 8px 0 4px; margin-top: .4em;
}
.plugin-group-label:first-child { margin-top: 0; padding-top: 0; }
.repo-row {
display: flex; align-items: center; gap: 10px;
padding: 7px 0;
border-bottom: 1px solid var(--border);
font-size: 0.88em;
}
.repo-row:last-child { border-bottom: none; }
.repo-name { flex: 1; font-weight: 500; min-width: 0; }
.repo-badge {
font-size: 0.72em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
border-radius: 3px; padding: 1px 6px; flex-shrink: 0;
}
.repo-badge-app { background: rgba(87,171,90,.15); color: #57ab5a; border: 1px solid rgba(87,171,90,.3); }
.repo-badge-plugin { background: rgba(229,141,75,.12); color: #e58d4b; border: 1px solid rgba(229,141,75,.25); }
.repo-badge-upstream { background: rgba(205,217,229,.08); color: var(--text-muted); border: 1px solid var(--border); }
.repo-status { font-size: 0.85em; color: var(--text-muted); flex-shrink: 0; }
.repo-status-dirty { color: #e58d4b; }
.repo-status-missing { color: #e5534b; }
a.repo-remote {
font-size: 0.8em; color: var(--text-dim); text-decoration: none; flex-shrink: 0;
}
a.repo-remote:hover { color: var(--accent); }
a.repo-plugins-link {
font-size: 0.78em; color: var(--text-dim); text-decoration: none; flex-shrink: 0;
border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px;
}
a.repo-plugins-link:hover { color: var(--accent); border-color: var(--accent); }
a.repo-graphify-link {
font-size: 0.78em; color: var(--text-dim); text-decoration: none; flex-shrink: 0;
border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px;
}
a.repo-graphify-link:hover { color: var(--accent); border-color: var(--accent); }
#nbz-drop {
display: flex; align-items: center; justify-content: center;
height: 72px;
border: 2px dashed var(--border);
border-radius: 6px;
cursor: pointer;
font-size: 0.88em;
color: var(--text-dim);
transition: border-color .15s, color .15s;
margin-bottom: 10px;
}
#nbz-drop.drag-over { border-color: var(--accent); color: var(--accent); }
#nbz-preview {
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 4px;
padding: 8px 12px;
font-size: 0.85em;
margin-bottom: 10px;
}
</style>
<script src="/nb-auth.js"></script>
</head>
<body>
<h1>nb-web Settings</h1>
<p class="subtitle">Saved to <code>nb-settings.json</code> alongside app.py.</p>
<nav class="sec-index">
<a href="#sec-appearance">Appearance</a>
<a href="#sec-codeblocks">Codeblocks</a>
<a href="#sec-git">Git</a>
<a href="#sec-terminal">Terminal</a>
<a href="#sec-import">Import</a>
<a href="#sec-archive">Archive</a>
<a href="#sec-plugins">Plugins</a>
<a href="#sec-nb">nb settings</a>
<a href="#sec-server">Server</a>
</nav>
<!-- ── Appearance ───────────────────────────────────────────────── -->
<section id="sec-appearance">
<h2>Appearance</h2>
<div class="field">
<label>Page theme</label>
<div class="theme-toggle">
<button class="theme-btn" id="theme-dark">☾ Dark</button>
<button class="theme-btn" id="theme-light">☀ Light</button>
</div>
<p class="hint">Switches the whole app, including nav and menus. Applies immediately and is remembered across sessions.</p>
</div>
<div class="field">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer">
<input type="checkbox" id="folders-first" style="width:15px;height:15px;cursor:pointer">
Folders first
</label>
<p class="hint">Show folders above notes in the list. Default: on.</p>
</div>
<div class="field">
<label>Render progress bar</label>
<div class="row" style="gap:6px;flex-wrap:wrap">
<button class="theme-btn" id="rb-auto">Auto</button>
<button class="theme-btn" id="rb-always">Always</button>
<button class="theme-btn" id="rb-never">Never</button>
</div>
<p class="hint">Amber progress strip shown above the preview while inline includes are fetching. <strong>Auto</strong> shows it only when 5+ includes are pending. <strong>Always</strong> shows it for any render. <strong>Never</strong> disables it.</p>
</div>
</section>
<!-- ── Codeblocks ────────────────────────────────────────────────── -->
<section id="sec-codeblocks">
<h2>Codeblocks</h2>
<p class="hint" style="margin-bottom:1em">Launch URLs enable the ⎋ button on each block type. Leave blank to hide the button.</p>
<div class="field">
<label for="hledger-web-cmd">hledger command</label>
<div class="row" style="flex-wrap:nowrap;gap:10px">
<input type="text" id="hledger-web-cmd" placeholder="hledger web --port 5002" autocomplete="off" style="flex:1;max-width:none">
<label class="terminal-toggle"><input type="checkbox" id="hledger-terminal"> terminal</label>
</div>
<p class="hint">Clicking "hledger" in any block launches this command. Unchecked: starts as web service, opens in new browser tab (add <code>--serve</code> to suppress auto-browser). Checked: runs in the nb-web terminal panel (for TUI apps like <code>hledger ui</code>).</p>
</div>
<div class="field">
<label for="tw-web-cmd">tw command</label>
<div class="row" style="flex-wrap:nowrap;gap:10px">
<input type="text" id="tw-web-cmd" placeholder="~/dev/tw-web/target/release/taskwarrior-web" autocomplete="off" style="flex:1;max-width:none">
<label class="terminal-toggle"><input type="checkbox" id="tw-terminal"> terminal</label>
</div>
<p class="hint">Clicking "task" in any tw block launches this command. Unchecked: opens in new browser tab. Checked: runs in the nb-web terminal panel (e.g. <code>tasksh</code>).</p>
</div>
<div class="row">
<button class="save-btn" id="save-integrations">Save</button>
<span class="status" id="status-integrations"></span>
</div>
</section>
<!-- ── Git ──────────────────────────────────────────────────────── -->
<section id="sec-git">
<h2>Git</h2>
<div class="field">
<label for="default-git-remote">Default remote URL</label>
<input type="text" id="default-git-remote" placeholder="git@codeberg.org:you/nb-notes.git" autocomplete="off">
<p class="hint">Each notebook is pushed to this remote on a branch named after itself — one repo, one branch per notebook. Leave blank to skip.</p>
</div>
<div class="row">
<button class="save-btn" id="save-git">Save</button>
<span class="status" id="status-git"></span>
</div>
<div class="field" style="margin-top:1.2em">
<label>Wire all remotes</label>
<p class="hint" style="margin-bottom:.5em">Sets up origin remote and pushes every notebook that doesn't already have one. Uses the URL above.</p>
<div class="row">
<button class="tool-btn" id="btn-wire-remotes">Wire all remotes</button>
<span class="status" id="status-wire"></span>
</div>
<pre id="wire-output" class="tool-output" hidden></pre>
</div>
</section>
<!-- ── Terminal ─────────────────────────────────────────────────── -->
<section id="sec-terminal">
<h2>Terminal</h2>
<div class="field">
<label for="pty-height">Default panel height (px)</label>
<input type="number" id="pty-height" min="60" max="1200" step="10">
</div>
<div class="field">
<label for="pty-cwd">Starting directory</label>
<input type="text" id="pty-cwd" placeholder="~/notes (blank = home)" autocomplete="off">
</div>
<div class="field">
<label for="pty-init">Init script</label>
<textarea id="pty-init" placeholder="One shell command per line, run on terminal open"></textarea>
<p class="hint">Example: <code>source ~/.profile</code></p>
</div>
<div class="row">
<button class="save-btn" id="save-terminal">Save</button>
<span class="status" id="status-terminal"></span>
</div>
</section>
<!-- ── Import ────────────────────────────────────────────────────── -->
<section id="sec-contacts">
<h2>Contacts</h2>
<div class="field">
<label for="contact-vcf-source">VCF source file</label>
<input type="text" id="contact-vcf-source" placeholder="~/Downloads/contacts.vcf">
<p class="hint">Path to the .vcf file used by the 📇 VCF browser. Tilde expansion supported.</p>
</div>
<div class="field">
<label for="contact-tag">Default import tag</label>
<input type="text" id="contact-tag" placeholder="djp">
<p class="hint">Tag prepended to every contact note created via the VCF browser (without #). Leave blank to skip.</p>
</div>
<div class="row">
<button class="save-btn" id="save-contacts">Save</button>
<span class="status" id="status-contacts"></span>
</div>
</section>
<section id="sec-import">
<h2>Import</h2>
<div class="field">
<label for="import-max-mb">Max file size (MB)</label>
<input type="number" id="import-max-mb" min="1" max="500" step="1">
<p class="hint">Files larger than this are rejected before upload. Default: 25 MB.</p>
</div>
<div class="field">
<label for="import-max-files">Max files per batch</label>
<input type="number" id="import-max-files" min="1" max="200" step="1">
<p class="hint">Drag-and-drop or picker selections above this count are rejected. Default: 20.</p>
</div>
<div class="row">
<button class="save-btn" id="save-import">Save</button>
<span class="status" id="status-import"></span>
</div>
</section>
<!-- ── Archive ───────────────────────────────────────────────────── -->
<section id="sec-archive">
<h2>Archive</h2>
<p class="hint" style="margin-bottom:1em">Import a <code>.nbz</code> notebook archive. To create an archive, open <strong>Menu → Notebooks</strong>, select a notebook, and use the Archive section there.</p>
<div class="field">
<label>Import .nbz</label>
<label id="nbz-drop">
<span id="nbz-drop-label">Drop .nbz here or click to pick</span>
<input id="nbz-file" type="file" accept=".nbz,.zip" style="display:none">
</label>
<div id="nbz-preview" hidden>
<div id="nbz-preview-name" style="font-weight:600;margin-bottom:2px"></div>
<div id="nbz-preview-meta" style="color:var(--text-dim)"></div>
<div id="nbz-preview-desc" style="margin-top:4px;font-style:italic"></div>
</div>
<div id="nbz-pw-row" hidden style="margin-bottom:10px">
<label style="font-size:0.82em;color:var(--text-muted);display:block;margin-bottom:4px">🔒 Encrypted archive — enter password</label>
<input type="password" id="nbz-pw" autocomplete="off" placeholder="Password">
<p id="nbz-pw-err" class="hint" style="color:#e74c3c;display:none"></p>
</div>
<div id="nbz-name-row" hidden style="margin-bottom:10px">
<label style="font-size:0.82em;color:var(--text-muted);display:block;margin-bottom:4px">Import as</label>
<input type="text" id="nbz-name" autocomplete="off">
<p id="nbz-conflict" class="hint" style="color:#e58d4b;display:none">⚠ Name already in use — choose another.</p>
</div>
<div class="row">
<button class="tool-btn" id="nbz-dry-run" disabled>Dry run</button>
<button class="tool-btn" id="nbz-go" disabled>Import</button>
<span class="status" id="nbz-status"></span>
</div>
<pre id="nbz-dry-report" hidden style="margin-top:.8em;background:var(--bg3);border:1px solid var(--border);border-radius:4px;padding:10px 14px;font-size:0.8em;white-space:pre-wrap;color:var(--text-muted);max-height:320px;overflow-y:auto"></pre>
</div>
</section>
<!-- ── Plugins ───────────────────────────────────────────────────── -->
<section id="sec-plugins">
<h2>Plugins</h2>
<p class="hint" style="margin-bottom:1em">Plugins extend nb-web with new codeblock types, list views, and UI. Files are saved to <code>~/.nb/.web/plugins/</code> and loaded on page start.</p>
<div class="field">
<label>Install plugin</label>
<div class="row" style="flex-wrap:nowrap;gap:8px;margin-bottom:6px">
<input type="text" id="plugin-install-url" placeholder="https://… or /local/path/to/plugin.js" autocomplete="off" style="flex:1;max-width:none">
<button class="tool-btn" id="btn-plugin-browse" title="Browse for a local .js file">Browse…</button>
<input type="file" id="plugin-file-input" accept=".js" style="display:none">
<input type="text" id="plugin-install-name" placeholder="Display name" autocomplete="off" style="width:150px;flex-shrink:0">
<button class="tool-btn" id="btn-plugin-install">Install</button>
</div>
<p class="hint">HTTP/HTTPS URL, local absolute path, or browse to a .js file. Name is inferred from filename if blank.</p>
<span class="status" id="status-plugin-install"></span>
</div>
<div id="plugin-list-wrap">
<div id="plugin-list" style="margin-top:.4em"></div>
</div>
</section>
<!-- ── nb settings (read-only view) ────────────────────────────── -->
<section id="sec-nb">
<h2>nb settings (read-only)</h2>
<div id="nb-settings-list" class="nb-settings-loading">Loading…</div>
<p class="hint" style="margin-top:.8em">
Change with <code>nb settings set <key> <value></code> in your terminal.
</p>
</section>
<!-- ── Config repo (admin+) ──────────────────────────────────────── -->
<section id="sec-config-repo" hidden data-min-level="admin">
<h2>Config repo</h2>
<p class="hint">Git repo at <code>~/.nb/</code> — tracks dotfolders (.users, .tools, .changes, .images, .rules) and global templates.</p>
<div class="row" style="margin-bottom:.6em">
<label style="min-width:80px">Remote</label>
<input type="text" id="config-remote-url" placeholder="git@github.com:you/nb-config.git" autocomplete="off" style="flex:1">
<button class="tool-btn" id="btn-config-remote-save">Save</button>
<span class="status" id="status-config-remote"></span>
</div>
<div class="row" style="margin-bottom:.6em">
<input type="text" id="config-commit-msg" placeholder="Commit message (optional)" autocomplete="off" style="flex:1">
<button class="tool-btn" id="btn-config-commit">Commit</button>
<button class="tool-btn" id="btn-config-sync">Sync</button>
<span class="status" id="status-config-sync"></span>
</div>
<div id="config-status-wrap" style="margin-bottom:.4em">
<span id="config-status-summary" style="font-size:.85em;color:var(--text-dim)">Loading…</span>
</div>
<pre id="config-output" class="tool-output" hidden></pre>
<pre id="config-log" class="tool-output" hidden></pre>
<div class="row" style="margin-top:.4em">
<button class="tool-btn" id="btn-config-log">Show log</button>
</div>
</section>
<!-- ── Server ────────────────────────────────────────────────────── -->
<section id="sec-server">
<h2>Server</h2>
<div class="row">
<button class="tool-btn" id="btn-restart">Restart server</button>
<span class="status" id="status-restart"></span>
</div>
</section>
<!-- ── System repos (tech+) ─────────────────────────────────────── -->
<section id="sec-repos" hidden data-min-level="tech">
<h2>Repos</h2>
<p class="hint" style="margin-bottom:1em">App/plugin/upstream repos from <code>.manifest.md</code> — local git hygiene only (dirty state, ahead/behind, sync). Not a diff or log viewer; use the ↗ link to each repo's actual remote for anything deeper. The <code>nb-notes</code> config repo has its own section above.</p>
<div id="repo-list">Loading…</div>
</section>
<script>
// ── Sync theme with parent frame ──────────────────────────────
// Source of truth is the real NbTheme engine (theme.js) on the parent window --
// NOT the parent's data-theme attribute (theme.js strips that on every apply(),
// "CSS-fallback ... JS vars now drive everything") and NOT localStorage['nb-theme']
// (an orphaned key nothing else reads -- the real one is 'nb-theme-mode'). This
// panel previously wrote both of those and so had zero effect on the live app,
// even though its own in-iframe preview appeared to toggle. Fixed 2026-08-07.
function _getMode() {
try { return window.parent.NbTheme.getMode(); }
catch { return localStorage.getItem('nb-theme-mode') || 'dark'; }
}
function _applyTheme(mode) {
if (mode === 'light') document.documentElement.setAttribute('data-theme', 'light');
else document.documentElement.removeAttribute('data-theme');
}
_applyTheme(_getMode());
// ── Theme buttons ─────────────────────────────────────────────
function _updateThemeBtns() {
const m = _getMode();
document.getElementById('theme-dark').classList.toggle('active', m !== 'light');
document.getElementById('theme-light').classList.toggle('active', m === 'light');
}
_updateThemeBtns();
async function _setTheme(mode) {
try { await window.parent.NbTheme.apply(window.parent.NbTheme.getSlug(), mode); }
catch { localStorage.setItem('nb-theme-mode', mode); }
_applyTheme(mode); // this iframe's own preview -- only knows the default dark/light
// palette above, not custom theme slugs (Groovy etc.)
_updateThemeBtns(); // must come after the await -- apply() is async, and reading
// the mode back before it resolves shows the pre-click state
}
document.getElementById('theme-dark').addEventListener('click', () => _setTheme('dark'));
document.getElementById('theme-light').addEventListener('click', () => _setTheme('light'));
// ── Folders first ─────────────────────────────────────────────
(function() {
const cb = document.getElementById('folders-first');
function _getFF() {
try { return window.parent.localStorage.getItem('nb-folders-first') !== 'false'; }
catch { return localStorage.getItem('nb-folders-first') !== 'false'; }
}
cb.checked = _getFF();
cb.addEventListener('change', () => {
const val = cb.checked;
try { window.parent.NbMain?.setFoldersFirst(val); } catch {}
localStorage.setItem('nb-folders-first', val);
});
})();
// ── Render bar ────────────────────────────────────────────────
(function() {
const KEY = 'nbRenderBar';
const btns = { auto: document.getElementById('rb-auto'),
always: document.getElementById('rb-always'),
never: document.getElementById('rb-never') };
function _getRB() {
try { return window.parent.localStorage.getItem(KEY) || 'auto'; }
catch { return localStorage.getItem(KEY) || 'auto'; }
}
function _setRB(val) {
try { window.parent.localStorage.setItem(KEY, val); } catch {}
localStorage.setItem(KEY, val);
_updateRBBtns(val);
}
function _updateRBBtns(val) {
Object.entries(btns).forEach(([k, el]) => el.classList.toggle('active', k === val));
}
_updateRBBtns(_getRB());
btns.auto.addEventListener('click', () => _setRB('auto'));
btns.always.addEventListener('click', () => _setRB('always'));
btns.never.addEventListener('click', () => _setRB('never'));
})();
// ── Load nb-web settings ──────────────────────────────────────
async function loadNbWebSettings() {
try {
const r = await fetch('/api/nb-settings');
const d = await r.json();
document.getElementById('hledger-web-cmd').value = d.hledger_web_cmd || '';
document.getElementById('hledger-terminal').checked = d.hledger_terminal || false;
document.getElementById('tw-web-cmd').value = d.tw_web_cmd || '';
document.getElementById('tw-terminal').checked = d.tw_terminal || false;
document.getElementById('pty-height').value = d.pty_height || 320;
document.getElementById('pty-cwd').value = d.pty_cwd || '';
document.getElementById('pty-init').value = d.pty_init || '';
document.getElementById('import-max-mb').value = d.import_max_mb || 25;
document.getElementById('import-max-files').value = d.import_max_files || 20;
document.getElementById('default-git-remote').value = d.default_git_remote || '';
document.getElementById('contact-vcf-source').value = d.vcf_source || '';
document.getElementById('contact-tag').value = d.contact_tag || '';
} catch(e) {
console.error('Failed to load nb-web settings', e);
}
}
async function saveNbWebSettings(keys, statusId) {
const status = document.getElementById(statusId);
const all = {
hledger_web_cmd: document.getElementById('hledger-web-cmd').value.trim(),
hledger_terminal: document.getElementById('hledger-terminal').checked,
tw_web_cmd: document.getElementById('tw-web-cmd').value.trim(),
tw_terminal: document.getElementById('tw-terminal').checked,
pty_height: parseInt(document.getElementById('pty-height').value) || 320,
pty_cwd: document.getElementById('pty-cwd').value.trim(),
pty_init: document.getElementById('pty-init').value,
import_max_mb: parseInt(document.getElementById('import-max-mb').value) || 25,
import_max_files: parseInt(document.getElementById('import-max-files').value) || 20,
default_git_remote: document.getElementById('default-git-remote').value.trim(),
vcf_source: document.getElementById('contact-vcf-source').value.trim(),
contact_tag: document.getElementById('contact-tag').value.trim().replace(/^#/, ''),
};
const patch = {};
keys.forEach(k => { patch[k] = all[k]; });
status.textContent = 'Saving…';
status.className = 'status';
try {
const r = await fetch('/api/nb-settings', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(patch),
});
const d = await r.json();
if (d.error) { status.textContent = '✗ ' + d.error; status.className = 'status err'; }
else { status.textContent = '✓ Saved'; status.className = 'status ok'; }
} catch(e) {
status.textContent = '✗ ' + e.message;
status.className = 'status err';
}
}
document.getElementById('save-integrations').addEventListener('click', () =>
saveNbWebSettings(['hledger_web_cmd', 'hledger_terminal', 'tw_web_cmd', 'tw_terminal'], 'status-integrations'));
document.getElementById('save-terminal').addEventListener('click', () =>
saveNbWebSettings(['pty_height', 'pty_cwd', 'pty_init'], 'status-terminal'));
document.getElementById('save-contacts').addEventListener('click', () =>
saveNbWebSettings(['vcf_source', 'contact_tag'], 'status-contacts'));
document.getElementById('save-import').addEventListener('click', () =>
saveNbWebSettings(['import_max_mb', 'import_max_files'], 'status-import'));
document.getElementById('save-git').addEventListener('click', () =>
saveNbWebSettings(['default_git_remote'], 'status-git'));
// ── Load nb CLI settings (read-only) ──────────────────────────
async function loadNbSettings() {
const el = document.getElementById('nb-settings-list');
try {
const r = await fetch('/api/config');
const d = await r.json();
const entries = Object.entries(d.settings || {});
if (!entries.length) { el.textContent = 'No settings returned.'; return; }
el.innerHTML = entries.map(([k, v]) =>
`<div class="nb-setting-row">
<span class="nb-setting-key">${k}</span>
<span class="nb-setting-value">${v || '<em style="color:var(--text-dim)">not set</em>'}</span>
</div>`).join('');
} catch(e) {
el.textContent = 'Could not load nb settings.';
}
}
// ── Wire all remotes ─────────────────────────────────────────
document.getElementById('btn-wire-remotes').addEventListener('click', async () => {
const btn = document.getElementById('btn-wire-remotes');
const status = document.getElementById('status-wire');
const output = document.getElementById('wire-output');
btn.disabled = true;
status.textContent = 'Working…'; status.className = 'status';
output.hidden = true;
try {
const d = await fetch('/api/nb/git-wire', { method: 'POST' }).then(r => r.json());
const lines = (d.results || []).map(r => {
const icon = r.status === 'ok' ? '✓' : r.status === 'skip' ? '·' : '✗';
return `${icon} ${r.notebook.padEnd(16)} ${r.message}`;
});
output.textContent = lines.join('\n') || '(no notebooks found)';
output.hidden = false;
status.textContent = '✓ Done'; status.className = 'status ok';
} catch(e) {
status.textContent = '✗ ' + e.message; status.className = 'status err';
} finally { btn.disabled = false; }
});
// ── Restart server ────────────────────────────────────────────
document.getElementById('btn-restart').addEventListener('click', async () => {
const btn = document.getElementById('btn-restart');
const status = document.getElementById('status-restart');
btn.disabled = true;
status.textContent = 'Restarting…'; status.className = 'status';
await fetch('/api/restart', { method: 'POST' }).catch(() => {});
const poll = () => fetch('/api/notebooks')
.then(() => location.reload())
.catch(() => setTimeout(poll, 400));
setTimeout(poll, 700);
});
// ── Archive import ───────────────────────────────────────────
(function() {
const _esc = s => String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
const drop = document.getElementById('nbz-drop');
const fileIn = document.getElementById('nbz-file');
const dropLbl = document.getElementById('nbz-drop-label');
const preview = document.getElementById('nbz-preview');
const prevName = document.getElementById('nbz-preview-name');
const prevMeta = document.getElementById('nbz-preview-meta');
const prevDesc = document.getElementById('nbz-preview-desc');
const nameRow = document.getElementById('nbz-name-row');
const nameIn = document.getElementById('nbz-name');
const conflict = document.getElementById('nbz-conflict');
const dryBtn = document.getElementById('nbz-dry-run');
const dryReport = document.getElementById('nbz-dry-report');
const goBtn = document.getElementById('nbz-go');
const status = document.getElementById('nbz-status');
const pwRow = document.getElementById('nbz-pw-row');
const pwIn = document.getElementById('nbz-pw');
const pwErr = document.getElementById('nbz-pw-err');
let _file = null, _previewData = null, _isEncrypted = false;
drop.addEventListener('dragover', e => { e.preventDefault(); drop.classList.add('drag-over'); });
drop.addEventListener('dragleave', () => drop.classList.remove('drag-over'));
drop.addEventListener('drop', e => { e.preventDefault(); drop.classList.remove('drag-over'); if (e.dataTransfer.files[0]) _onFile(e.dataTransfer.files[0]); });
fileIn.addEventListener('change', () => { if (fileIn.files[0]) _onFile(fileIn.files[0]); });
nameIn.addEventListener('input', () => { conflict.style.display = 'none'; });
async function _onFile(file) {
_file = file; _previewData = null; _isEncrypted = false;
dropLbl.textContent = file.name;
preview.hidden = true; nameRow.hidden = true;
pwRow.hidden = true; pwIn.value = ''; pwErr.style.display = 'none';
dryReport.hidden = true; dryBtn.disabled = true; goBtn.disabled = true;
status.textContent = 'Reading…'; status.className = 'status';
const fd = new FormData(); fd.append('archive', file);
try {
const r = await fetch('/api/nb/import-preview', { method: 'POST', body: fd });
const d = await r.json();
if (!d.ok) { status.textContent = '✗ ' + d.error; status.className = 'status err'; return; }
_previewData = d;
status.textContent = ''; status.className = 'status';
const m = d.meta, date = (m.archived_at||'').slice(0,10);
if (d.encrypted) {
// Metadata readable without password; password required to extract notebook
_isEncrypted = true;
pwRow.hidden = false; pwIn.focus();
goBtn.disabled = true; // re-enabled when password is typed
}
const tags = [
m.note_count != null && `${m.note_count} notes`,
date,
m.includes_git && 'git history',
d.encrypted && '🔒 encrypted',
].filter(Boolean).join(' · ');
prevName.textContent = m.name;
prevMeta.textContent = tags;
prevDesc.textContent = m.description || '';
prevDesc.hidden = !m.description;
preview.hidden = false;
nameIn.value = d.suggested;
conflict.style.display = d.conflict ? 'block' : 'none';
nameRow.hidden = false;
dryBtn.disabled = false;
goBtn.disabled = _isEncrypted && !pwIn.value;
} catch(e) {
status.textContent = '✗ ' + e.message; status.className = 'status err';
}
}
pwIn.addEventListener('input', () => {
if (_isEncrypted) {
goBtn.disabled = !pwIn.value.trim();
pwErr.style.display = 'none';
}
});
function _buildFormData(nameOverride) {
const name = nameOverride !== undefined ? nameOverride : nameIn.value.trim();
const fd = new FormData();
fd.append('archive', _file);
if (name) fd.append('name', name);
if (_isEncrypted && pwIn.value) fd.append('password', pwIn.value);
return fd;
}
async function _unlockAndPreview() {
const pw = pwIn.value;
if (!pw) { pwIn.focus(); return; }
pwErr.style.display = 'none';
goBtn.disabled = true; goBtn.textContent = 'Unlocking…';
const fd = new FormData();
fd.append('archive', _file);
fd.append('password', pw);
try {
const r = await fetch('/api/nb/import-preview', { method: 'POST', body: fd });
const d = await r.json();
if (!d.ok) {
pwErr.textContent = d.error || 'Wrong password.';
pwErr.style.display = 'block';
pwIn.select(); pwIn.focus();
goBtn.textContent = 'Unlock'; goBtn.disabled = false;
return;
}
_previewData = d; _isEncrypted = true;
pwRow.hidden = true; // password accepted — hide field, keep in memory via _isEncrypted
const m = d.meta, date = (m.archived_at||'').slice(0,10);
const tags = [
m.note_count != null && `${m.note_count} notes`,
date,
'🔒 encrypted',
].filter(Boolean).join(' · ');
prevName.textContent = m.name;
prevMeta.textContent = tags;
prevDesc.textContent = m.description || '';
prevDesc.hidden = !m.description;
preview.hidden = false;
nameIn.value = d.suggested;
conflict.style.display = d.conflict ? 'block' : 'none';
nameRow.hidden = false;
goBtn.textContent = 'Import'; goBtn.disabled = false;
dryBtn.disabled = false;
} catch(e) {
pwErr.textContent = e.message; pwErr.style.display = 'block';
goBtn.textContent = 'Unlock'; goBtn.disabled = false;
}
}
function _renderDryReport(d) {
const lines = [];
const nb = d.notebook_dest || d.notebook;
if (d.notebook_conflict) {
lines.push(`⚠ Notebook "${d.notebook}" already exists — choose a different name.`);
} else {
lines.push(`Notebook: "${nb}" (${(d.notebook_files||[]).length} files)`);
}
dryReport.textContent = lines.join('\n');
dryReport.hidden = false;
}
dryBtn.addEventListener('click', async () => {
if (!_file) return;
dryBtn.disabled = true; dryBtn.textContent = 'Checking…';
dryReport.hidden = true;
status.textContent = ''; status.className = 'status';
try {
const r = await fetch('/api/nb/import-dry-run', { method: 'POST', body: _buildFormData() });
const d = await r.json();
if (!d.ok) { status.textContent = '✗ ' + (d.error || 'Dry run failed.'); status.className = 'status err'; }
else { _renderDryReport(d); }
} catch(e) {
status.textContent = '✗ ' + e.message; status.className = 'status err';
}
dryBtn.disabled = false; dryBtn.textContent = 'Dry run';
});
goBtn.addEventListener('click', async () => {
if (!_file) return;
if (_isEncrypted && !pwIn.value) {
pwErr.textContent = 'Password required to import the notebook.';
pwErr.style.display = 'block'; pwIn.focus(); return;
}
const name = nameIn.value.trim();
if (!name) { nameIn.focus(); return; }
goBtn.disabled = true; dryBtn.disabled = true; goBtn.textContent = 'Importing…';
dryReport.hidden = true;
status.textContent = ''; status.className = 'status';
try {
const r = await fetch('/api/nb/import', { method: 'POST', body: _buildFormData() });
const d = await r.json();
if (d.ok) {
status.textContent = `✓ Imported "${_esc(d.notebook)}" (${d.note_count} notes)`;
status.className = 'status ok';
goBtn.textContent = 'Import'; goBtn.disabled = false; dryBtn.disabled = false;
} else if (d.conflict) {
conflict.style.display = 'block';
goBtn.disabled = false; dryBtn.disabled = false; goBtn.textContent = 'Import';
} else if (d.encrypted) {
pwErr.textContent = d.error || 'Wrong password.'; pwErr.style.display = 'block';
pwIn.select(); pwIn.focus();
goBtn.disabled = false; dryBtn.disabled = false; goBtn.textContent = 'Import';
} else {
status.textContent = '✗ ' + (d.error || 'Import failed.'); status.className = 'status err';
goBtn.disabled = false; dryBtn.disabled = false; goBtn.textContent = 'Import';
}
} catch(e) {
status.textContent = '✗ ' + e.message; status.className = 'status err';
goBtn.disabled = false; dryBtn.disabled = false; goBtn.textContent = 'Import';
}
});
})();
// ── Plugin manager ────────────────────────────────────────────
const _PLUGIN_TYPE_ORDER = ['core', 'bundled', 'ecosystem', 'plugin'];
const _PLUGIN_GROUP_LABELS = {
core: 'Core',
bundled: 'Bundled',
ecosystem: 'Ecosystem',
plugin: 'Installed',
};
async function _renderPluginList(plugins) {
const el = document.getElementById('plugin-list');
if (!plugins || !plugins.length) {
el.innerHTML = '<p class="hint">No plugins installed.</p>';
return;
}
// Group by type in declared order
const groups = {};
_PLUGIN_TYPE_ORDER.forEach(t => { groups[t] = []; });
plugins.forEach(p => {
const t = p.type || 'plugin';
if (!groups[t]) groups[t] = [];
groups[t].push(p);
});
let html = '';
_PLUGIN_TYPE_ORDER.forEach(type => {
const items = groups[type];
if (!items.length) return;
html += `<div class="plugin-group-label">${_PLUGIN_GROUP_LABELS[type] || type}</div>`;
items.forEach(p => {
const isCore = p.type === 'core';
const isRemovable = !isCore && p.type !== 'bundled';
const badge = `<span class="plugin-badge plugin-badge-${p.type || 'plugin'}">${p.type || 'plugin'}</span>`;
const label = p.name || p.url.split('/').pop();
const homepageLink = p.homepage
? `<a class="plugin-homepage" href="${p.homepage}" target="_blank" title="${p.homepage}">↗</a>`
: '';
const toggleEl = isCore
? `<span class="plugin-toggle" style="cursor:default;opacity:.4">locked</span>`
: `<label class="plugin-toggle" title="${p.enabled ? 'Disable' : 'Enable'}">
<input type="checkbox" ${p.enabled ? 'checked' : ''} data-url="${p.url}" class="plugin-enabled-cb" style="cursor:pointer">
${p.enabled ? 'on' : 'off'}
</label>`;
const rmBtn = isRemovable
? `<button class="plugin-remove" data-url="${p.url}">Remove</button>` : '';
html += `
<div class="plugin-row ${p.enabled ? '' : 'plugin-disabled'}">
<span class="plugin-name">${label}</span>
${badge}
${homepageLink}
<span class="plugin-url" title="${p.url}">${p.url}</span>
${toggleEl}
${rmBtn}
</div>`;
});
});
el.innerHTML = html;
el.querySelectorAll('.plugin-enabled-cb').forEach(cb => {
cb.addEventListener('change', async () => {
cb.disabled = true;
const d = await fetch('/api/plugins/toggle', {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: cb.dataset.url, enabled: cb.checked}),