-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRetroTerminalPage.jsx
More file actions
1446 lines (1354 loc) · 50 KB
/
RetroTerminalPage.jsx
File metadata and controls
1446 lines (1354 loc) · 50 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
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { useProjects } from '../utils/projectParser';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import { vocabulary } from '../data/vocabulary';
import Seo from '../components/Seo';
import piml from 'piml';
import {
ArrowLeft,
FloppyDisk,
TerminalWindow,
FileText,
Globe,
Monitor,
Clock,
ChatText,
X,
User,
Folder,
Book,
Brain,
Gear,
} from '@phosphor-icons/react';
import 'katex/dist/katex.min.css';
// --- Assets & Constants ---
const QUOTES = [
'The work is mysterious and important.',
'Praise Kier.',
'A handshake is available upon request.',
'Please try to enjoy each fact equally.',
'Defiant jazz is not permitted.',
'The board is watching.',
'Your outie has a life.',
'Serve Kier, and you shall be served.',
'Visualise the data.',
'Refine the temper.',
];
// --- Audio Utility ---
const useRetroAudio = () => {
const audioCtxRef = useRef(null);
const initAudio = useCallback(() => {
if (!audioCtxRef.current) {
audioCtxRef.current = new (
window.AudioContext || window.webkitAudioContext
)();
}
if (audioCtxRef.current.state === 'suspended') {
audioCtxRef.current.resume();
}
}, []);
const playTone = useCallback((freq, type, duration, vol = 0.1) => {
if (!audioCtxRef.current) return;
const osc = audioCtxRef.current.createOscillator();
const gain = audioCtxRef.current.createGain();
osc.type = type;
osc.frequency.setValueAtTime(freq, audioCtxRef.current.currentTime);
gain.gain.setValueAtTime(vol, audioCtxRef.current.currentTime);
gain.gain.exponentialRampToValueAtTime(
0.01,
audioCtxRef.current.currentTime + duration,
);
osc.connect(gain);
gain.connect(audioCtxRef.current.destination);
osc.start();
osc.stop(audioCtxRef.current.currentTime + duration);
}, []);
const playClick = useCallback(
() => playTone(800, 'square', 0.05, 0.05),
[playTone],
);
const playKeystroke = useCallback(
() => playTone(600 + Math.random() * 200, 'triangle', 0.03, 0.03),
[playTone],
);
const playEnter = useCallback(
() => playTone(400, 'sine', 0.2, 0.1),
[playTone],
);
const playError = useCallback(
() => playTone(150, 'sawtooth', 0.3, 0.1),
[playTone],
);
const playBoot = useCallback(() => {
if (!audioCtxRef.current) return;
const osc = audioCtxRef.current.createOscillator();
const gain = audioCtxRef.current.createGain();
osc.frequency.setValueAtTime(100, audioCtxRef.current.currentTime);
osc.frequency.exponentialRampToValueAtTime(
800,
audioCtxRef.current.currentTime + 2,
);
gain.gain.setValueAtTime(0, audioCtxRef.current.currentTime);
gain.gain.linearRampToValueAtTime(0.2, audioCtxRef.current.currentTime + 1);
gain.gain.linearRampToValueAtTime(0, audioCtxRef.current.currentTime + 3);
osc.connect(gain);
gain.connect(audioCtxRef.current.destination);
osc.start();
osc.stop(audioCtxRef.current.currentTime + 3);
}, []);
return {
initAudio,
playClick,
playKeystroke,
playEnter,
playError,
playBoot,
};
};
// --- Sub-Components ---
const BootScreen = ({ onComplete, initAudio }) => {
const [step, setStep] = useState(0);
useEffect(() => {
const sequence = [
{
t: 100,
action: () => {
initAudio();
setStep(1);
},
}, // Blank start
{ t: 300, action: () => setStep(2) }, // Logo/Init
{ t: 400, action: () => setStep(4) }, // Fast Progress
{ t: 200, action: () => onComplete() }, // Done
];
let accumulatedTime = 0;
sequence.forEach(({ t, action }) => {
accumulatedTime += t;
setTimeout(action, accumulatedTime);
});
}, [onComplete, initAudio]);
return (
<div className="h-screen w-full flex flex-col items-center justify-center bg-[#000505] text-[#4fffa8] font-mono select-none cursor-none">
{step >= 2 && (
<div className="mb-12 flex flex-col items-center animate-pulse">
<div className="w-16 h-16 border-4 border-[#4fffa8] rounded-full flex items-center justify-center mb-4">
<div className="text-3xl font-black italic">L</div>
</div>
<h1 className="text-2xl tracking-[0.5em] font-bold uppercase">
Fezminal
</h1>
</div>
)}
{step >= 2 && (
<div className="w-64">
<div className="h-1 w-full bg-[#00333b]">
<div
className="h-full bg-[#4fffa8] transition-all duration-[500ms] ease-linear"
style={{ width: step >= 4 ? '100%' : '0%' }}
/>
</div>
</div>
)}
</div>
);
};
const ClockWidget = () => {
const [time, setTime] = useState(new Date());
useEffect(() => {
const timer = setInterval(() => setTime(new Date()), 1000);
return () => clearInterval(timer);
}, []);
const secondsDegrees = (time.getSeconds() / 60) * 360 + 90;
const minsDegrees = (time.getMinutes() / 60) * 360 + 90;
const hourDegrees =
((time.getHours() % 12) / 12) * 360 + (time.getMinutes() / 60) * 30 + 90;
return (
<div className="flex flex-col items-center gap-4">
{/* Analog Clock */}
<div className="w-20 h-20 border-2 border-[#4fffa8] rounded-full relative bg-[#001a1f] shadow-[0_0_10px_rgba(79,255,168,0.2)]">
<div
className="absolute top-1/2 left-1/2 w-[35%] h-[2px] bg-[#4fffa8] origin-[0%_50%] rounded-full"
style={{ transform: `translate(0, -50%) rotate(${hourDegrees}deg)` }}
/>
<div
className="absolute top-1/2 left-1/2 w-[45%] h-[1px] bg-[#4fffa8] origin-[0%_50%] rounded-full"
style={{ transform: `translate(0, -50%) rotate(${minsDegrees}deg)` }}
/>
<div
className="absolute top-1/2 left-1/2 w-[48%] h-[1px] bg-[#ff4f4f] origin-[0%_50%]"
style={{
transform: `translate(0, -50%) rotate(${secondsDegrees}deg)`,
}}
/>
<div className="absolute top-1/2 left-1/2 w-1 h-1 bg-[#4fffa8] -translate-x-1/2 -translate-y-1/2 rounded-full" />
</div>
{/* Digital Clock */}
<div className="font-mono text-xl font-bold tracking-widest text-[#4fffa8]">
{time.toLocaleTimeString([], { hour12: false })}
</div>
</div>
);
};
const VocabModal = ({ termKey, onClose, playClick }) => {
const [ContentComponent, setContentComponent] = useState(null);
const [title, setTitle] = useState('');
useEffect(() => {
const loadVocab = async () => {
const entry = vocabulary[termKey];
if (entry) {
setTitle(entry.title);
try {
const module = await entry.loader();
// The vocab files export a React component as default
setContentComponent(() => module.default);
} catch (e) {
console.error(e);
setContentComponent(() => () => (
<div className="text-red-500">Error loading definition data.</div>
));
}
} else {
setTitle('Unknown Term');
setContentComponent(() => () => (
<div className="text-yellow-500">
Definition not found in local database.
</div>
));
}
};
loadVocab();
}, [termKey]);
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm">
<div className="w-full max-w-2xl bg-[#001a1f] border-2 border-[#4fffa8] shadow-[0_0_20px_rgba(79,255,168,0.3)] animate-in fade-in zoom-in duration-200 flex flex-col max-h-[80vh]">
<div className="flex justify-between items-center p-4 border-b border-[#005f6b] bg-[#001014]">
<h3 className="text-xl font-bold text-[#4fffa8] uppercase tracking-widest">
{title}
</h3>
<button
onClick={onClose}
className="text-[#005f6b] hover:text-[#ff4f4f] transition-colors"
>
<X size={24} weight="bold" />
</button>
</div>
<div className="p-6 overflow-y-auto prose prose-invert prose-p:text-[#e8f7f7] prose-headings:text-[#4fffa8] prose-a:text-[#4fffa8]">
{ContentComponent ? <ContentComponent /> : 'Loading definition...'}
</div>
<div className="p-4 border-t border-[#005f6b] bg-[#001014] text-right">
<button
onClick={onClose}
className="px-6 py-2 bg-[#4fffa8] text-[#001a1f] font-bold uppercase tracking-widest text-xs hover:bg-white transition-colors"
>
Acknowledge
</button>
</div>
</div>
</div>
);
};
const FileViewer = ({ file, type, onClose, playClick, onVocabClick }) => {
const [content, setContent] = useState(null);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (type === 'post') {
if (file.isSeries) {
const seriesContent = `
# ${file.title}
${file.description || ''}
## Series Index
${file.posts.map((p, i) => `${i + 1}. [${p.title}](/blog/${p.slug})`).join('\n')}
`;
setContent(seriesContent);
setLoading(false);
return;
}
setLoading(true);
const fetchPath = file.content
? null
: `/posts/${file.filename || file.slug + '.txt'}`;
if (fetchPath) {
fetch(fetchPath)
.then((res) => {
if (!res.ok) throw new Error('Failed to load');
return res.text();
})
.then((text) => {
const cleanText = text.replace(/^---[\s\S]*?---/, '').trim();
setContent(cleanText);
setLoading(false);
})
.catch((err) => {
console.error(err);
setContent('Error: Data file corrupted or missing from archives.');
setLoading(false);
});
} else {
setContent(file.content || file.excerpt);
setLoading(false);
}
} else if (type === 'about') {
// About content passed directly
setContent(file.content);
}
}, [file, type]);
const MarkdownComponents = {
a: ({ href, children, ...props }) => {
const isVocab = href && href.startsWith('/vocab/');
const handleClick = (e) => {
if (isVocab) {
e.preventDefault();
const term = href.replace('/vocab/', '');
onVocabClick(term);
playClick();
}
};
if (isVocab) {
return (
<a
href={href}
onClick={handleClick}
className="text-[#4fffa8] underline decoration-dashed cursor-pointer"
{...props}
>
{children}
</a>
);
}
return (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
className="text-[#4fffa8] hover:text-white"
{...props}
>
{children}
</a>
);
},
};
return (
<div className="h-full flex flex-col bg-[#001a1f] text-[#e8f7f7] animate-in fade-in slide-in-from-bottom-4 duration-300">
{/* File Header */}
<div className="border-b border-[#005f6b] p-6 flex justify-between items-start bg-[#001014] shrink-0">
<div>
<div className="text-xs uppercase tracking-[0.2em] text-[#4fffa8] mb-2 flex items-center gap-2">
{type === 'about' ? <User size={16} /> : <FileText size={16} />}
{type === 'project'
? 'Project_Manifest'
: type === 'about'
? 'Personnel_File'
: 'Blog_Transmission'}
</div>
<h2 className="text-3xl font-bold tracking-tight text-white mb-1">
{file.title || file.name}
</h2>
{file.date && (
<div className="text-xs text-[#005f6b] font-mono">
{new Date(file.date).toLocaleDateString()}
</div>
)}
</div>
<div className="flex gap-4">
{type === 'project' && (
<>
<Link
to={`/projects/${file.slug}`}
target="_blank"
className="px-4 py-2 border border-[#4fffa8] text-[#4fffa8] text-xs uppercase tracking-widest hover:bg-[#4fffa8] hover:text-[#001a1f] transition-colors flex items-center gap-2"
>
<Monitor size={16} />
GUI View
</Link>
{file.url && (
<a
href={file.url}
target="_blank"
rel="noopener noreferrer"
onClick={playClick}
className="px-4 py-2 border border-[#4fffa8] bg-[#4fffa8] text-[#001a1f] text-xs uppercase tracking-widest hover:bg-white transition-colors flex items-center gap-2"
>
<Globe size={16} />
Launch
</a>
)}
</>
)}
{onClose && (
<button
onClick={() => {
playClick();
onClose();
}}
className="px-4 py-2 border border-[#4fffa8] text-[#4fffa8] text-xs uppercase tracking-widest hover:bg-[#4fffa8] hover:text-[#001a1f] transition-colors"
>
Close_File
</button>
)}
</div>
</div>
{/* File Content */}
<div className="flex-grow p-8 overflow-y-auto font-mono leading-relaxed space-y-6">
{type === 'project' && file.shortDescription && (
<div className="text-[#4fffa8] text-xl font-bold mb-2">
{file.shortDescription}
</div>
)}
{file.description && type === 'project' && (
<div className="border-l-2 border-[#4fffa8] pl-4 py-1 text-lg opacity-90">
{file.description}
</div>
)}
{type === 'project' && (
<div className="space-y-6">
<div className="grid grid-cols-2 gap-4">
<div className="bg-[#00252b] p-4">
<h4 className="text-[10px] uppercase tracking-widest text-[#4fffa8] mb-2">
Status
</h4>
<div className="text-sm">{file.status || 'Archived'}</div>
</div>
<div className="bg-[#00252b] p-4">
<h4 className="text-[10px] uppercase tracking-widest text-[#4fffa8] mb-2">
Stack
</h4>
<div className="flex flex-wrap gap-2">
{file.technologies?.map((tech) => (
<span
key={tech}
className="text-xs border border-[#005f6b] px-1"
>
{tech}
</span>
))}
</div>
</div>
</div>
</div>
)}
{(type === 'post' || type === 'about') && (
<div className="max-w-3xl pb-20 prose prose-invert prose-p:text-[#e8f7f7] prose-headings:text-[#4fffa8] prose-a:text-[#4fffa8] prose-code:text-[#ff4f4f] prose-pre:bg-[#00252b] prose-pre:border prose-pre:border-[#005f6b]">
{loading ? (
<div className="animate-pulse text-[#4fffa8]">
Decryption in progress...
</div>
) : (
<ReactMarkdown
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeKatex]}
components={MarkdownComponents}
>
{content || file.excerpt || 'No content data available.'}
</ReactMarkdown>
)}
</div>
)}
</div>
</div>
);
};
const TerminalOutput = ({ history, isMinimized, scrollRef }) => {
const bottomRef = useRef(null);
useEffect(() => {
bottomRef.current?.scrollIntoView({ behavior: 'smooth' });
}, [history]);
if (isMinimized) return null;
return (
<div className="h-1/3 border-t border-[#00333b] bg-[#001014] flex flex-col shrink-0 transition-all duration-300">
<div className="bg-[#00252b] px-4 py-1 text-[10px] uppercase tracking-widest text-[#4fffa8] flex justify-between items-center border-b border-[#00333b]">
<span>Terminal Output</span>
<span>Active Process: SHELL</span>
</div>
<div
ref={scrollRef}
className="flex-grow overflow-y-auto p-4 font-mono text-sm space-y-2"
>
{history.map((entry, i) => (
<div key={i}>
<div className="opacity-50 text-xs mb-1">{entry.timestamp}</div>
{entry.command && (
<div className="text-[#80a0a0]">
<span className="text-[#4fffa8] mr-2">{'>'}</span>
{entry.command}
</div>
)}
<div className="text-[#e8f7f7] whitespace-pre-wrap pl-4 border-l border-[#00333b] ml-1">
{entry.response}
</div>
</div>
))}
<div ref={bottomRef} />
</div>
</div>
);
};
const CommandLine = ({ onCommand, playKeystroke, playEnter, onScroll }) => {
const [input, setInput] = useState('');
const inputRef = useRef(null);
const handleSubmit = (e) => {
e.preventDefault();
if (!input.trim()) return;
playEnter();
onCommand(input.trim());
setInput('');
};
const handleChange = (e) => {
setInput(e.target.value);
playKeystroke();
};
const handleKeyDown = (e) => {
if (e.key === 'ArrowUp') {
e.preventDefault();
onScroll('up');
} else if (e.key === 'ArrowDown') {
e.preventDefault();
onScroll('down');
}
};
useEffect(() => {
const focusInterval = setInterval(() => {
if (document.activeElement !== inputRef.current) {
inputRef.current?.focus();
}
}, 100);
return () => clearInterval(focusInterval);
}, []);
return (
<div className="h-12 bg-[#001014] border-t border-[#00333b] flex items-center px-4 font-mono text-sm z-30 shrink-0">
<span className="text-[#4fffa8] mr-2 shrink-0">{'>'}</span>
<form onSubmit={handleSubmit} className="flex-grow">
<input
ref={inputRef}
type="text"
value={input}
onChange={handleChange}
onKeyDown={handleKeyDown}
className="w-full bg-transparent border-none outline-none text-[#e8f7f7] placeholder-[#00333b] uppercase caret-[#4fffa8]"
placeholder="TYPE 'HELP' FOR COMMANDS..."
spellCheck="false"
autoComplete="off"
/>
</form>
</div>
);
};
const Workstation = ({
initAudio,
playClick,
playKeystroke,
playEnter,
playError,
}) => {
const [activeTab, setActiveTab] = useState('projects');
const [selectedFile, setSelectedFile] = useState(null);
const [searchQuery, setSearchQuery] = useState('');
const [aboutContent, setAboutContent] = useState('');
const [vagueIssues, setVagueIssues] = useState([]);
// Terminal State
const [terminalHistory, setTerminalHistory] = useState([
{
timestamp: new Date().toLocaleTimeString(),
response: "WELCOME TO FEZMINAL OS v2.0.26. TYPE 'HELP' FOR INSTRUCTIONS.",
},
]);
const [isTerminalMinimized, setIsTerminalMinimized] = useState(false);
const terminalScrollRef = useRef(null);
// Vocab Modal State
const [vocabTerm, setVocabTerm] = useState(null);
// Footer Widget State
const [showClock, setShowClock] = useState(true);
const { projects, loading: loadingProjects } = useProjects();
const [posts, setPosts] = useState([]);
const navigate = useNavigate();
// Vocab List
const vocabList = Object.keys(vocabulary)
.map((key) => ({
id: key,
title: vocabulary[key].title,
name: vocabulary[key].title, // Normalized prop
type: 'vocab',
}))
.sort((a, b) => a.title.localeCompare(b.title));
useEffect(() => {
// Fetch posts
fetch('/posts/posts.json')
.then((res) => res.json())
.then((data) => {
const processedItems = data.map((item) => {
if (item.series) {
// This is a series container
return {
...item,
isSeries: true,
// Flatten the nested posts array to the top level for FileViewer compatibility
posts: item.series.posts.map((p) => ({
...p,
// Ensure filename is clean
filename: p.filename?.startsWith('/')
? p.filename.substring(1)
: p.filename,
})),
category: 'series', // Ensure category is set for styling
// Inherit tags from first post or use own
tags:
item.tags ||
(item.series.posts &&
item.series.posts[0] &&
item.series.posts[0].tags) ||
[],
description:
item.description || (item.series && item.series.description),
};
} else {
// Individual post
return {
...item,
filename: item.filename?.startsWith('/')
? item.filename.substring(1)
: item.filename,
};
}
});
// Sort by updated/date
processedItems.sort(
(a, b) =>
new Date(b.updated || b.date) - new Date(a.updated || a.date),
);
setPosts(processedItems);
})
.catch((err) => console.error(err));
// Fetch About
fetch('/about-me/about.txt')
.then((res) => res.text())
.then((text) => setAboutContent(text))
.catch((err) => console.error(err));
// Fetch Vague Issues
fetch('/the_vague/issues.piml')
.then((res) => res.text())
.then((text) => {
const parsed = piml.parse(text);
setVagueIssues(parsed.issues || []);
})
.catch((err) => console.error(err));
}, []);
const handleScroll = (direction) => {
if (terminalScrollRef.current) {
const scrollAmount = 50;
terminalScrollRef.current.scrollTop +=
direction === 'up' ? -scrollAmount : scrollAmount;
}
};
const getFilteredData = () => {
if (activeTab === 'projects')
return searchQuery
? projects.filter((p) =>
p.title.toLowerCase().includes(searchQuery.toLowerCase()),
)
: projects;
if (activeTab === 'blog')
return searchQuery
? posts.filter((p) =>
p.title.toLowerCase().includes(searchQuery.toLowerCase()),
)
: posts;
if (activeTab === 'vocab')
return searchQuery
? vocabList.filter((v) =>
v.title.toLowerCase().includes(searchQuery.toLowerCase()),
)
: vocabList;
if (activeTab === 'vague')
return searchQuery
? vagueIssues.filter((v) =>
v.title.toLowerCase().includes(searchQuery.toLowerCase()),
)
: vagueIssues;
return [];
};
const filteredData = getFilteredData();
const addLog = (command, response) => {
setTerminalHistory((prev) => [
...prev,
{
timestamp: new Date().toLocaleTimeString(),
command,
response,
},
]);
};
const handleCommand = (cmd) => {
const parts = cmd.trim().split(' ');
const command = parts[0].toLowerCase();
const args = parts.slice(1).join(' ');
// Command Logic
if (command === 'help') {
const helpText = `AVAILABLE COMMANDS:
-------------------
LIST / LS : List files in current directory
OPEN / VIEW <ID>: Open file by ID (e.g. OPEN 1) or Name
SEARCH / FIND : Filter current list by <TEXT>
BACK / CLOSE : Close current file / Return to list
RUN / LAUNCH : Open external live project URL
VISIT / GUI : Open project in standard GUI mode
TERM : Toggle terminal window visibility
FULLSCREEN : Toggle terminal fullscreen mode
PROJECTS : Switch to Macrodata directory
BLOG : Switch to Handbook directory
VOCAB : Switch to Knowledge directory
ABOUT : View Personnel File
VAGUE : Switch to The Vague Archives
SYSTEM : Switch to System Config directory
CLEAR : Clear terminal history
EXIT : Return to standard homepage`;
addLog(cmd, helpText);
} else if (command === 'term') {
setIsTerminalMinimized((prev) => !prev);
addLog(
cmd,
isTerminalMinimized ? 'TERMINAL RESTORED' : 'TERMINAL MINIMIZED',
);
} else if (command === 'list' || command === 'ls') {
if (activeTab === 'about' || activeTab === 'system') {
addLog(cmd, 'NO LISTABLE ITEMS IN THIS DIRECTORY.');
} else {
setSearchQuery('');
const itemsList = filteredData
.map(
(item, idx) =>
`[${String(idx + 1).padStart(2, '0')}] ${item.title || item.name}`,
)
.join('\n');
addLog(
cmd,
`LISTING ALL ${activeTab.toUpperCase()} FILES...\n\n${itemsList}\n\nTOTAL: ${filteredData.length} ITEMS.`,
);
}
} else if (command === 'search' || command === 'find') {
if (activeTab === 'about' || activeTab === 'system') {
addLog(cmd, 'SEARCH NOT AVAILABLE IN THIS DIRECTORY.');
} else {
setSearchQuery(args);
const itemsList = getFilteredData()
.map(
(item, idx) =>
`[${String(idx + 1).padStart(2, '0')}] ${item.title || item.name}`,
)
.join('\n');
addLog(
cmd,
args
? `FILTERING BY "${args.toUpperCase()}"...\n\n${itemsList}\n\nFOUND ${getFilteredData().length} MATCHES.`
: 'CLEARED SEARCH FILTER.',
);
}
} else if (command === 'open' || command === 'view') {
if (activeTab === 'about' || activeTab === 'system') {
addLog(cmd, 'NO FILES TO OPEN IN THIS DIRECTORY.');
return;
}
if (!args) {
addLog(cmd, 'ERROR: SPECIFY FILE ID OR NAME.');
playError();
return;
}
const index = parseInt(args) - 1;
if (!isNaN(index) && index >= 0 && index < filteredData.length) {
const item = filteredData[index];
if (activeTab === 'vocab') {
setVocabTerm(item.id);
addLog(cmd, `OPENING DEFINITION: ${item.title.toUpperCase()}...`);
} else {
handleFileClick(item, activeTab === 'projects' ? 'project' : 'post');
addLog(cmd, `OPENING FILE ID ${args}: ${item.title || item.name}...`);
}
return;
}
const match = filteredData.find((f) =>
(f.title || f.name).toLowerCase().includes(args.toLowerCase()),
);
if (match) {
if (activeTab === 'vocab') {
setVocabTerm(match.id);
addLog(cmd, `OPENING DEFINITION: ${match.title.toUpperCase()}...`);
} else {
handleFileClick(match, activeTab === 'projects' ? 'project' : 'post');
addLog(
cmd,
`OPENING "${(match.title || match.name).toUpperCase()}"...`,
);
}
} else {
addLog(cmd, `ERROR: FILE "${args.toUpperCase()}" NOT FOUND.`);
playError();
}
} else if (command === 'back' || command === 'close') {
if (selectedFile) {
setSelectedFile(null);
addLog(cmd, 'FILE CLOSED.');
} else {
addLog(cmd, 'NO FILE OPEN.');
}
} else if (command === 'run' || command === 'launch') {
if (selectedFile && selectedFile.type === 'project' && selectedFile.url) {
window.open(selectedFile.url, '_blank');
addLog(cmd, 'LAUNCHING EXTERNAL ARTIFACT...');
} else {
addLog(cmd, 'ERROR: NO EXECUTABLE ARTIFACT LOADED.');
playError();
}
} else if (command === 'visit' || command === 'gui') {
if (selectedFile && selectedFile.type === 'project') {
window.open(`/projects/${selectedFile.slug}`, '_blank');
addLog(cmd, 'OPENING ARTIFACT IN GUI VISUALIZER...');
} else {
addLog(cmd, 'ERROR: NO PROJECT LOADED TO VISIT.');
playError();
}
} else if (command === 'projects' || command === 'cd projects') {
handleTabChange('projects');
addLog(cmd, 'DIRECTORY CHANGED: MACRODATA (PROJECTS)');
} else if (command === 'blog' || command === 'cd blog') {
handleTabChange('blog');
addLog(cmd, 'DIRECTORY CHANGED: HANDBOOK (BLOG)');
} else if (command === 'vocab' || command === 'cd vocab') {
handleTabChange('vocab');
addLog(cmd, 'DIRECTORY CHANGED: KNOWLEDGE (VOCAB)');
} else if (command === 'about' || command === 'cd about') {
handleTabChange('about');
addLog(cmd, 'DIRECTORY CHANGED: PERSONNEL FILE');
} else if (command === 'vague' || command === 'cd vague') {
handleTabChange('vague');
addLog(cmd, 'DIRECTORY CHANGED: THE VAGUE ARCHIVES');
} else if (command === 'system' || command === 'cd system') {
handleTabChange('system');
addLog(cmd, 'DIRECTORY CHANGED: SYSTEM CONFIG');
} else if (command === 'exit') {
navigate('/');
} else if (command === 'clear') {
setTerminalHistory([]);
setSearchQuery('');
} else if (command === 'fullscreen') {
toggleFullscreen();
addLog(cmd, 'TOGGLING FULLSCREEN MODE...');
} else {
addLog(cmd, `UNKNOWN COMMAND: ${command}`);
playError();
}
};
const toggleFullscreen = () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {});
} else {
document.exitFullscreen().catch(() => {});
}
};
const handleFileClick = (file, type) => {
playClick();
setSelectedFile({ ...file, type });
};
const handleTabChange = (tab) => {
playClick();
setActiveTab(tab);
setSelectedFile(null);
setSearchQuery('');
};
const renderList = () => {
if (activeTab === 'about') {
return (
<FileViewer
file={{
title: 'PERSONNEL FILE: A. SAMIL BULBUL',
content: aboutContent,
date: new Date().toISOString(),
}}
type="about"
playClick={playClick}
onVocabClick={(term) => {
setVocabTerm(term);
playClick();
}}
/>
);
}
if (activeTab === 'projects') {
if (loadingProjects)
return (
<div className="p-8 text-[#4fffa8] animate-pulse">
Scanning Archives...
</div>
);
return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4 p-6 pb-20">
{filteredData.map((p, idx) => (
<button
key={p.slug}
onClick={() => handleFileClick(p, 'project')}
className="group text-left border border-[#005f6b] bg-[#00252b] p-4 hover:border-[#4fffa8] hover:bg-[#00333b] transition-all relative overflow-hidden flex flex-col h-full"
>
<div className="absolute top-0 right-0 p-1 opacity-20 group-hover:opacity-100 transition-opacity font-mono text-2xl font-bold">
{String(idx + 1).padStart(2, '0')}
</div>
<div className="flex justify-between items-start mb-2">
<h3 className="font-bold text-[#e8f7f7] uppercase tracking-wide truncate pr-6">
{p.title}
</h3>
</div>
<p className="text-xs text-[#80a0a0] line-clamp-2 mb-4 flex-grow">
{p.shortDescription || p.description}
</p>
<div className="flex flex-col gap-2 mt-auto">
{' '}
<div className="text-[10px] uppercase tracking-widest text-[#4fffa8] flex justify-between w-full">
<span>{p.technologies?.[0] || 'Unknown'}</span>
<span>{p.size || '1'}KB</span>
</div>
<div className="pt-2 border-t border-[#005f6b]/30 flex justify-between">
<span className="text-[9px] uppercase font-bold text-[#4fffa8]/60 group-hover:text-[#4fffa8] transition-colors">
[View Manifest]
</span>
{p.url && (
<a
href={p.url}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => {
e.stopPropagation();
playClick();
}}
className="text-[9px] uppercase font-bold text-[#ff4f4f] hover:text-white transition-colors flex items-center gap-1"
>
<Globe size={10} />
Launch Ext
</a>
)}
</div>
</div>