-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic_site_generator.py
More file actions
1342 lines (1108 loc) · 42.4 KB
/
static_site_generator.py
File metadata and controls
1342 lines (1108 loc) · 42.4 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
#!/usr/bin/env python3
"""
Static Site Generator for Conference Papers
Generates a static website from conference paper folders created by run-conference.
Creates a landing page, technical documentation, and pages for each accepted paper
with their reviews.
"""
import json
import re
from pathlib import Path
from typing import List, Dict, Optional, Tuple
from datetime import datetime
import click
from rich.console import Console
import shutil
import markdown
from markdown.inlinepatterns import InlineProcessor
from markdown.extensions import Extension
import xml.etree.ElementTree as etree
import random
console = Console()
class GlitchTextInlineProcessor(InlineProcessor):
"""Inline processor to convert ~~text~~ to <a class="glitch-text">text</a>"""
def __init__(self, pattern, md, base_path=""):
super().__init__(pattern, md)
self.base_path = base_path
def handleMatch(self, m, data):
el = etree.Element("a")
el.set("class", "glitch-text")
# Set href to technical documentation page
tech_page = f"{self.base_path}technical_documentation.html"
el.set("href", tech_page)
# Add random delay between 0.1s and 0.9s
delay = random.uniform(0.1, 0.9)
# Add random flicker duration between 7s and 11s
flicker_duration = random.uniform(7.0, 11.0)
# Add random shift duration between 9s and 13s
shift_duration = random.uniform(9.0, 13.0)
el.set(
"style",
f"--delay: {delay:.2f}s; --flicker-duration: {flicker_duration:.2f}s; --shift-duration: {shift_duration:.2f}s",
)
el.text = m.group(1)
return el, m.start(0), m.end(0)
class GlitchTextExtension(Extension):
"""Extension to add GlitchTextInlineProcessor to markdown"""
def __init__(self, base_path=""):
super().__init__()
self.base_path = base_path
def extendMarkdown(self, md):
# Pattern matches ~~text~~
GLITCH_PATTERN = r"~~(.*?)~~"
glitch_pattern = GlitchTextInlineProcessor(GLITCH_PATTERN, md, self.base_path)
# Register with high priority to process before other patterns
md.inlinePatterns.register(glitch_pattern, "glitch_text", 175)
class PaperFolder:
"""Represents a paper folder with metadata and file paths"""
def __init__(self, folder_path: Path):
self.path = folder_path
self.folder_name = folder_path.name
self.timestamp, self.base_name = self._parse_folder_name()
self.version = self._extract_version()
self.paper_md = self._find_paper_md()
self.paper_pdf = self._find_paper_pdf()
self.reviews = self._find_reviews()
self.title = self._extract_title()
self.abstract = self._extract_abstract()
def _parse_folder_name(self) -> Tuple[str, str]:
"""Parse folder name into timestamp and base name"""
match = re.match(r"(\d{8}_\d{6})_(.+)", self.folder_name)
if match:
return match.group(1), match.group(2)
return "", self.folder_name
def _extract_version(self) -> int:
"""Extract version number from base name (e.g., _v2_v2 -> 2)"""
version_count = self.base_name.count("_v")
return version_count
def _get_base_paper_name(self) -> str:
"""Get the base paper name without version suffixes"""
# Remove all _v2, _v2_v2 type suffixes
base = re.sub(r"(_v\d+)+$", "", self.base_name)
return base
def _find_paper_md(self) -> Optional[Path]:
"""Find the paper markdown file"""
# Look for paper files in various naming patterns
patterns = ["paper*.md", "*.md"]
for pattern in patterns:
matches = list(self.path.glob(pattern))
if matches:
# Prefer files with 'paper' in the name
paper_files = [m for m in matches if "paper" in m.name.lower()]
if paper_files:
return paper_files[0]
return matches[0]
return None
def _find_paper_pdf(self) -> Optional[Path]:
"""Find the paper PDF file (prioritize scanned versions ending in _scan.pdf)"""
# First, try to find scanned PDFs (aged versions)
scan_matches = list(self.path.glob("*_scan.pdf"))
if scan_matches:
return scan_matches[0]
# If no scanned PDFs found, return None (only use scanned versions for the conference site)
return None
def _find_reviews(self) -> List[Path]:
"""Find all review JSON files"""
reviews_dir = self.path / "reviews"
if reviews_dir.exists():
return sorted(reviews_dir.glob("*.json"))
return []
def _extract_title(self) -> str:
"""Extract title from paper markdown frontmatter"""
if not self.paper_md or not self.paper_md.exists():
return self._humanize_title(self.base_name)
try:
with open(self.paper_md, "r") as f:
content = f.read()
# Look for YAML frontmatter
if content.startswith("---"):
frontmatter_end = content.find("---", 3)
if frontmatter_end > 0:
frontmatter = content[3:frontmatter_end]
for line in frontmatter.split("\n"):
if line.startswith("title:"):
title = line.split("title:", 1)[1].strip().strip("\"'")
return title
# Look for first heading
for line in content.split("\n"):
if line.startswith("# "):
return line.lstrip("# ").strip()
except Exception as e:
console.print(
f"[yellow]Warning: Could not extract title from {self.paper_md}: {e}[/yellow]"
)
return self._humanize_title(self.base_name)
def _humanize_title(self, text: str) -> str:
"""Convert folder name to readable title"""
# Remove version suffixes
text = re.sub(r"(_v\d+)+$", "", text)
# Replace underscores with spaces
text = text.replace("_", " ")
return text
def _extract_abstract(self) -> str:
"""Extract abstract from paper markdown"""
if not self.paper_md or not self.paper_md.exists():
return ""
try:
with open(self.paper_md, "r") as f:
content = f.read()
# Skip frontmatter
if content.startswith("---"):
frontmatter_end = content.find("---", 3)
if frontmatter_end > 0:
content = content[frontmatter_end + 3 :]
# Look for Abstract section
abstract_pattern = r"#{1,3}\s*Abstract\s*\n\n(.*?)(?=\n#{1,3}|\Z)"
match = re.search(abstract_pattern, content, re.DOTALL | re.IGNORECASE)
if match:
abstract = match.group(1).strip()
# Remove scratchpad if present
if "<scratchpad>" in abstract:
abstract = abstract.split("<scratchpad>")[0].strip()
return abstract
except Exception as e:
console.print(
f"[yellow]Warning: Could not extract abstract from {self.paper_md}: {e}[/yellow]"
)
return ""
def _extract_episodes(self) -> List[Tuple[int, int]]:
"""Extract episode references from title and abstract in format SxEE (e.g., 3x11, 7x02)
Returns:
List of (season, episode) tuples found in the title and abstract
"""
episodes = []
text = f"{self.title} {self.abstract}"
# Pattern matches formats like 3x11, 7x02, 1x01, etc.
pattern = r"(\d+)x(\d+)"
matches = re.finditer(pattern, text)
for match in matches:
season = int(match.group(1))
episode = int(match.group(2))
episodes.append((season, episode))
return episodes
def get_latest_episode(self) -> Optional[Tuple[int, int]]:
"""Get the latest episode mentioned in this paper (highest season, then highest episode)
Returns:
Tuple of (season, episode) or None if no episodes found
"""
episodes = self._extract_episodes()
if not episodes:
return None
# Sort by season first, then episode, and return the highest
return max(episodes, key=lambda ep: (ep[0], ep[1]))
def get_base_paper_series(self) -> str:
"""Get the base paper series name (without versions)"""
return re.sub(r"(_v\d+)+$", "", self.base_name)
def is_accepted(self) -> bool:
"""Check if this paper has all reviews marked as ACCEPT"""
if not self.reviews:
return False
try:
for review_path in self.reviews:
with open(review_path, "r") as f:
review_data = json.load(f)
decision = review_data.get("metadata", {}).get("decision", "")
if decision != "ACCEPT":
return False
return True
except Exception as e:
console.print(
f"[yellow]Warning: Could not check acceptance status for {self.path}: {e}[/yellow]"
)
return False
class StaticSiteGenerator:
"""Generates static HTML site from conference papers"""
def __init__(
self, papers_dir: Path, output_dir: Path, svg_file: Optional[Path] = None
):
self.papers_dir = papers_dir
self.output_dir = output_dir
self.svg_file = svg_file
self.svg_content: Optional[str] = None
self.papers: List[PaperFolder] = []
self.paper_series: Dict[str, List[PaperFolder]] = {} # Track all versions
# Load SVG content if provided
if svg_file and svg_file.exists():
self.svg_content = svg_file.read_text()
def scan_papers(self):
"""Scan papers directory and identify final accepted versions"""
console.print("[cyan]Scanning papers directory...[/cyan]")
all_folders = [f for f in self.papers_dir.iterdir() if f.is_dir()]
all_papers = [PaperFolder(f) for f in all_folders]
# Group by base paper series
for paper in all_papers:
series = paper.get_base_paper_series()
if series not in self.paper_series:
self.paper_series[series] = []
self.paper_series[series].append(paper)
# For each series, find the highest version that's accepted
for series, versions in self.paper_series.items():
# Sort by version number (highest first)
versions.sort(key=lambda p: p.version, reverse=True)
# Find first accepted version
for paper in versions:
if paper.is_accepted():
self.papers.append(paper)
break
else:
# If no accepted version, take the latest version
if versions:
console.print(
f"[yellow]Warning: No accepted version found for '{series}', using latest version[/yellow]"
)
self.papers.append(versions[0])
# Sort papers by episode order
# Papers with episodes come first (sorted by season, then episode)
# Papers without episodes come last (sorted by title)
def episode_sort_key(paper):
latest_ep = paper.get_latest_episode()
if latest_ep:
# Return (0, season, episode, title) for papers with episodes
return (0, latest_ep[0], latest_ep[1], paper.title)
else:
# Return (1, 0, 0, title) for papers without episodes (1 puts them at end)
return (1, 0, 0, paper.title)
self.papers.sort(key=episode_sort_key)
console.print(f"[green]Found {len(self.papers)} final papers[/green]")
def generate_site(
self,
landing_md: Optional[Path],
tech_md: Optional[Path],
custom_css: Optional[Path] = None,
):
"""Generate complete static site"""
console.print("\n[cyan]Generating static site...[/cyan]")
# Validate required markdown files
if not landing_md or not landing_md.exists():
console.print(
f"[red]Error: Landing page markdown file not found: {landing_md}[/red]"
)
raise FileNotFoundError(
f"Landing page markdown file required but not found: {landing_md}"
)
if not tech_md or not tech_md.exists():
console.print(
f"[red]Error: Technical documentation markdown file not found: {tech_md}[/red]"
)
raise FileNotFoundError(
f"Technical documentation markdown file required but not found: {tech_md}"
)
# Validate custom CSS if provided
if custom_css and not custom_css.exists():
console.print(f"[red]Error: Custom CSS file not found: {custom_css}[/red]")
raise FileNotFoundError(f"Custom CSS file not found: {custom_css}")
# Create output directory structure
self.output_dir.mkdir(exist_ok=True)
(self.output_dir / "papers").mkdir(exist_ok=True)
(self.output_dir / "iterations").mkdir(exist_ok=True)
(self.output_dir / "pdfs").mkdir(exist_ok=True)
(self.output_dir / "css").mkdir(exist_ok=True)
# Generate or copy CSS
self._generate_css(custom_css)
# Copy fonts directory if it exists
self._copy_fonts_directory()
# Copy favicon directory if it exists
self._copy_favicon_directory()
# Copy videos directory if it exists
self._copy_videos_directory()
# Generate landing page
self._generate_landing_page(landing_md)
# Generate tech documentation
self._generate_tech_page(tech_md)
# Generate paper pages and copy all versions
for paper in self.papers:
# Get all versions for this paper series
series_name = paper.get_base_paper_series()
all_versions = self.paper_series.get(series_name, [paper])
# Sort by version (lowest first for chronological order)
all_versions.sort(key=lambda p: p.version)
self._generate_paper_page(paper, all_versions)
# Copy PDFs for all versions
for version in all_versions:
self._copy_paper_pdf(version)
# Generate iteration pages
self._generate_iteration_pages(paper, all_versions)
console.print(
f"\n[green]✓ Site generated successfully in {self.output_dir}[/green]"
)
def _generate_css(self, custom_css: Optional[Path] = None):
"""Generate CSS stylesheet or copy custom CSS file
Args:
custom_css: Optional path to custom CSS file. If provided, copies this file
instead of generating the default CSS.
"""
css_output_path = self.output_dir / "css" / "style.css"
if custom_css:
console.print(f"[cyan]Using custom CSS: {custom_css}[/cyan]")
shutil.copy2(custom_css, css_output_path)
return
console.print("[cyan]Generating default CSS...[/cyan]")
css = """
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: #333;
background: white;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
}
.content {
padding: 0;
margin-bottom: 30px;
}
.content h1 {
font-size: 2.5em;
color: #667eea;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 3px solid #667eea;
}
.inline-link {
color: #667eea;
text-decoration: none;
font-weight: 500;
transition: color 0.2s;
}
.inline-link:hover {
color: #764ba2;
text-decoration: underline;
}
.paper-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
gap: 30px;
margin-top: 30px;
}
.paper-card {
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
transition: transform 0.2s, box-shadow 0.2s;
border-left: 4px solid #667eea;
}
.paper-card:hover {
transform: translateY(-4px);
box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.paper-card h3 {
color: #667eea;
margin-bottom: 15px;
font-size: 1.3em;
}
.paper-card .abstract {
color: #666;
font-size: 0.95em;
margin-bottom: 15px;
line-height: 1.6;
}
.paper-card a.read-more {
color: #667eea;
text-decoration: none;
font-weight: 500;
display: inline-block;
margin-top: 10px;
}
.paper-card a.read-more:hover {
color: #764ba2;
}
.paper-details h2 {
color: #667eea;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #667eea;
}
.paper-details .abstract {
background: #f8f9fa;
padding: 20px;
border-radius: 6px;
margin: 20px 0;
line-height: 1.8;
}
.links {
margin: 30px 0;
display: flex;
flex-direction: column;
gap: 15px;
align-items: flex-start;
}
.btn {
display: inline-block;
padding: 12px 24px;
background: #667eea;
color: white;
text-decoration: none;
border-radius: 6px;
font-weight: 500;
transition: background 0.2s, transform 0.2s;
}
.btn:hover {
background: #764ba2;
transform: translateY(-2px);
}
.btn.secondary {
background: #6c757d;
}
.btn.secondary:hover {
background: #5a6268;
}
.reviews-list {
margin-top: 30px;
}
.reviews-list h3 {
color: #667eea;
margin-bottom: 15px;
}
.review-item {
background: #f8f9fa;
padding: 15px 20px;
margin-bottom: 10px;
border-radius: 6px;
border-left: 4px solid #667eea;
}
.review-item .decision {
display: inline-block;
padding: 4px 12px;
background: #28a745;
color: white;
border-radius: 4px;
font-size: 0.85em;
font-weight: 600;
margin-left: 10px;
}
.review-item .decision.accept {
background: #28a745;
}
.review-item .decision.reject {
background: #dc3545;
}
.iteration-info {
color: #666;
font-style: italic;
margin-bottom: 20px;
}
.iteration-details h3 {
color: #667eea;
margin-top: 30px;
margin-bottom: 15px;
}
.iteration-details h4 {
color: #555;
margin-top: 20px;
margin-bottom: 10px;
}
.review-content {
background: #f8f9fa;
padding: 30px;
border-radius: 8px;
margin: 20px 0;
}
.review-content .decision {
display: inline-block;
padding: 4px 12px;
color: white;
border-radius: 4px;
font-size: 0.85em;
font-weight: 600;
}
.review-content .decision.accept {
background: #28a745;
}
.review-content .decision.reject {
background: #dc3545;
}
.review-content ul {
margin-left: 20px;
margin-bottom: 15px;
}
.review-content li {
margin-bottom: 8px;
}
footer {
text-align: center;
padding: 40px 0;
color: #666;
margin-top: 60px;
border-top: 1px solid #ddd;
}
.markdown-content h1 {
font-size: 2.5em;
color: #667eea;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 3px solid #667eea;
}
.markdown-content h2 {
color: #667eea;
margin-top: 30px;
margin-bottom: 15px;
font-size: 1.8em;
}
.markdown-content h3 {
color: #555;
margin-top: 25px;
margin-bottom: 12px;
font-size: 1.4em;
}
.markdown-content p {
margin-bottom: 15px;
}
.markdown-content ul,
.markdown-content ol {
margin-left: 30px;
margin-bottom: 15px;
}
.markdown-content code {
background: #f8f9fa;
padding: 2px 6px;
border-radius: 3px;
font-family: 'Courier New', monospace;
}
.markdown-content pre {
background: #f8f9fa;
padding: 15px;
border-radius: 6px;
overflow-x: auto;
margin-bottom: 15px;
}
.papers-heading {
margin-top: 50px;
margin-bottom: 30px;
color: #667eea;
font-size: 2em;
padding-bottom: 10px;
border-bottom: 2px solid #667eea;
}
.abstract-heading {
color: #667eea;
margin-top: 30px;
margin-bottom: 15px;
font-size: 1.8em;
}
.paper-details h1 {
font-size: 2.5em;
color: #667eea;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 3px solid #667eea;
}
.review-content h1 {
font-size: 2.2em;
color: #667eea;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 3px solid #667eea;
}
.review-content h2 {
color: #667eea;
margin-top: 30px;
margin-bottom: 15px;
font-size: 1.5em;
}
@media (max-width: 768px) {
.paper-grid {
grid-template-columns: 1fr;
}
.content h1,
.markdown-content h1 {
font-size: 2em;
}
.container {
padding: 20px 15px;
}
}
"""
css_path = self.output_dir / "css" / "style.css"
css_path.write_text(css)
def _copy_fonts_directory(self):
"""Copy fonts directory to output directory if it exists"""
fonts_dir = Path("fonts")
if not fonts_dir.exists():
console.print(
"[yellow]Warning: fonts directory not found, skipping font copy[/yellow]"
)
return
output_fonts_dir = self.output_dir / "fonts"
if output_fonts_dir.exists():
# Remove existing fonts directory to ensure clean copy
shutil.rmtree(output_fonts_dir)
console.print("[cyan]Copying fonts directory...[/cyan]")
shutil.copytree(fonts_dir, output_fonts_dir)
console.print(f"[green]✓ Copied fonts directory to {output_fonts_dir}[/green]")
def _copy_favicon_directory(self):
"""Copy favicon directory to output directory if it exists"""
favicon_dir = Path("favicon")
if not favicon_dir.exists():
console.print(
"[yellow]Warning: favicon directory not found, skipping favicon copy[/yellow]"
)
return
output_favicon_dir = self.output_dir / "favicon"
if output_favicon_dir.exists():
# Remove existing favicon directory to ensure clean copy
shutil.rmtree(output_favicon_dir)
console.print("[cyan]Copying favicon directory...[/cyan]")
shutil.copytree(favicon_dir, output_favicon_dir)
# Update site.webmanifest to use correct paths
manifest_path = output_favicon_dir / "site.webmanifest"
if manifest_path.exists():
import json as json_module
with open(manifest_path, "r") as f:
manifest = json_module.load(f)
# Update icon paths to be relative to the favicon directory
if "icons" in manifest:
for icon in manifest["icons"]:
if "src" in icon and icon["src"].startswith("/"):
icon["src"] = "favicon" + icon["src"]
with open(manifest_path, "w") as f:
json_module.dump(manifest, f, indent=2)
console.print(
f"[green]✓ Copied favicon directory to {output_favicon_dir}[/green]"
)
def _copy_videos_directory(self):
"""Copy videos directory to output directory if it exists"""
videos_dir = Path("videos")
if not videos_dir.exists():
console.print(
"[yellow]Warning: videos directory not found, skipping videos copy[/yellow]"
)
return
output_videos_dir = self.output_dir / "videos"
# Skip if source and destination are the same
if videos_dir.resolve() == output_videos_dir.resolve():
console.print(
"[yellow]Skipping videos directory (already in output directory)[/yellow]"
)
return
if output_videos_dir.exists():
# Remove existing videos directory to ensure clean copy
shutil.rmtree(output_videos_dir)
console.print("[cyan]Copying videos directory...[/cyan]")
shutil.copytree(videos_dir, output_videos_dir)
console.print(f"[green]✓ Copied videos directory to {output_videos_dir}[/green]")
def _generate_landing_page(self, landing_md: Path):
"""Generate landing page"""
console.print("[cyan]Generating landing page...[/cyan]")
# Read landing page content and convert to HTML
landing_content = markdown.markdown(
landing_md.read_text(), extensions=[GlitchTextExtension()]
)
# Insert "Read more" link to technical documentation after first paragraph
# Split content into paragraphs and insert link after first </p>
first_p_end = landing_content.find("</p>")
if first_p_end != -1:
tech_link = '\n<p><a href="technical_documentation.html" class="inline-link">Read more</a></p>'
landing_content = (
landing_content[:first_p_end]
+ landing_content[first_p_end : first_p_end + 4]
+ tech_link
+ landing_content[first_p_end + 4 :]
)
# Generate paper list
papers_html = '<div class="paper-grid">'
for paper in self.papers:
# Convert abstract markdown to HTML
abstract_html = markdown.markdown(
paper.abstract, extensions=[GlitchTextExtension()]
)
papers_html += f"""
<div class="paper-card">
<h3>{paper.title}</h3>
<div class="abstract">{abstract_html}</div>
<a href="papers/{paper.folder_name}.html" class="read-more">Read more →</a>
</div>
"""
papers_html += "</div>"
html = self._wrap_html(
title="Slayerfest",
content=f"""
<div class="markdown-content">
{landing_content}
</div>
<h2 class="papers-heading">Accepted Papers</h2>
{papers_html}
""",
)
(self.output_dir / "index.html").write_text(html)
def _generate_tech_page(self, tech_md: Path):
"""Generate technical documentation page"""
console.print("[cyan]Generating technical documentation...[/cyan]")
content = markdown.markdown(
tech_md.read_text(),
extensions=["fenced_code", "tables", GlitchTextExtension()],
)
# Check if conference Video exists and replace "Conference Video" placeholder
video_path = Path("docs/videos/conference_run.webm")
if not video_path.exists():
video_path = Path("videos/conference_run.webm")
if video_path.exists():
video_html = """<div>
<video controls loop muted autoplay playbackRate="4">
<source src="videos/conference_run.webm" type="video/webm">
</video>
</div>"""
# Replace the code block containing "Conference Video" with the Video
content = re.sub(r"<code>Conference Video</code>", video_html, content)
html = self._wrap_html(
title="Technical Documentation",
content=f"""
<div class="markdown-content">
{content}
</div>
<div class="links">
<a href="/" class="btn secondary">← Back to Conference</a>
</div>
""",
css_path="css/style.css",
)
(self.output_dir / "technical_documentation.html").write_text(html)
def _generate_paper_page(self, paper: PaperFolder, all_versions: List[PaperFolder]):
"""Generate individual paper page with review iterations"""
console.print(f"[cyan]Generating page for: {paper.title}[/cyan]")
# Generate iterations section
iterations_html = '<div class="reviews-list"><h3>Review Iterations</h3>'
for iteration_num, version in enumerate(all_versions, 1):
if not version.reviews:
continue
# Determine overall decision for this iteration
all_accept = True
try:
for review_path in version.reviews:
with open(review_path, "r") as f:
review_data = json.load(f)
decision = review_data.get("metadata", {}).get(
"decision", "UNKNOWN"
)
if decision != "ACCEPT":
all_accept = False
break
except Exception as e:
console.print(
f"[yellow]Warning: Could not read reviews for version {version.folder_name}: {e}[/yellow]"
)
all_accept = False
overall_decision = "ACCEPT" if all_accept else "REJECT"
decision_class = "accept" if all_accept else "reject"
iterations_html += f"""
<div class="review-item">
<a href="../iterations/{paper.get_base_paper_series()}_iteration_{iteration_num}.html">
Iteration {iteration_num}
</a>
<span class="decision {decision_class}">{overall_decision}</span>
</div>
"""
iterations_html += "</div>"
# Generate links
pdf_link = ""
if paper.paper_pdf:
pdf_filename = f"{paper.folder_name}.pdf"
pdf_link = (
f'<a href="../pdfs/{pdf_filename}" class="btn">Download Final PDF</a>'
)
# Convert abstract markdown to HTML (use ../ since we're in papers/ subdirectory)
abstract_html = markdown.markdown(
paper.abstract, extensions=[GlitchTextExtension(base_path="../")]
)
content = f"""
<div class="paper-details">
<h1>{paper.title}</h1>
<div class="abstract">
<h2 class="abstract-heading">Abstract</h2>
{abstract_html}
</div>
<div class="links">
{pdf_link}
<a href="/" class="btn secondary">← Back to Conference</a>
</div>