-
Notifications
You must be signed in to change notification settings - Fork 39
/
generate.py
936 lines (895 loc) · 56.6 KB
/
generate.py
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
import json
import os
import re
from math import floor
from PIL import Image
import dominate
import yaml
from dominate.tags import *
from dominate.util import raw
from more_itertools import peekable
def to_snake_case(name):
name = "".join(name.split())
name = re.sub(r'\W+', '', name)
name = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
name = re.sub(r'__([A-Z])', r'_\1', name)
name = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', name)
return name.lower()
def strip_a_tags(s):
return re.sub(r'(?i)</?a[^>]*>', '', s)
dropdowns = []
pages = []
item_links = []
with open(os.path.join('data', 'pages.yaml'), 'r', encoding='utf_8') as pages_yaml:
yml = yaml.safe_load(pages_yaml)
item_links = yml['item_links']
for dropdown in yml['dropdowns']:
dropdown_urls = []
for page in dropdown['pages']:
with open(os.path.join('data', 'checklists', page), 'r', encoding='utf_8') as data:
yml = yaml.safe_load(data)
pages.append(yml)
dropdown_urls.append((yml['title'], yml['id'], yml.get('map_icon', yml.get('icon', None))))
dropdowns.append((dropdown['name'], dropdown_urls))
page_ids = set()
all_ids = set()
for page in pages:
if page['id'] in page_ids:
print("Duplicate page id '" + page['id'] + "' found. All page ids must be unique.")
quit(1)
else:
page_ids.add(page['id'])
if 'table_widths' in page:
t_w = page['table_widths']
if sum(t_w) != 12:
print("table_widths on page " + page['id'] + ' does not add up to 12')
item_nums = set()
for section in page['sections']:
items = peekable(section['items'])
for item in items:
if isinstance(item, str):
continue
def f(item):
if not isinstance(item['id'], str):
print("Please make item id " + str(item['id']) + ' a string by wrapping it in quotes. Found on page ' + page['id'] + ' in section "' + section['title'] + '"')
quit(1)
if (page['id'] + '_' + item['id']) in all_ids:
print("Duplicate item id '" + str(item['id']) + "' in section '" + str(section['title']) + "' found in page '" + page['id'] + "'. All item ids must be unique within each page.")
quit(1)
all_ids.add(page['id'] + '_' + item['id'])
f(item)
if isinstance(items.peek(0), list):
item = next(items)
for subitem in item:
f(subitem)
def make_doc(title, description):
doc = dominate.document(title=title)
doc.set_attribute('lang', 'en')
with doc.head:
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
link(rel="apple-touch-icon", sizes="180x180", href="/img/apple-touch-icon.png")
link(rel="icon", type="image/png", sizes="32x32", href="/img/favicon-32x32.png")
link(rel="icon", type="image/png", sizes="16x16", href="/img/favicon-16x16.png")
link(rel="manifest", href="/img/site.webmanifest")
meta(name="theme-color", content="#ffffff")
meta(name="apple-mobile-web-app-capable", content="yes")
meta(name="mobile-web-app-capable", content="yes")
meta(name="description", content="Cheat sheet for Elden Ring. Checklist of things to do, items to get etc.")
meta(name="author", content="Ben Lambeth")
meta(name="mobile-web-app-capable", content="yes")
link(href="/css/bootstrap.min.css", rel="stylesheet", id="bootstrap")
link(rel="stylesheet", href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css")
link(href="/css/main.css", rel="stylesheet")
return doc
def title_row():
with div(cls="row"):
with div(cls="col-md-12 text-center"):
h1("Roundtable Hold", cls="mt-3")
text = p(cls="lead d-print-none")
text += "Contribute at the "
text += a("Github Page",
href="https://github.com/RoundtableHold/roundtablehold.github.io")
def hide_completed_button():
with div(id="btnHideCompleted", cls="mb-3 d-print-none"):
with div(cls="form-check form-switch"):
input_(cls="form-check-input", type="checkbox",
id='toggleHideCompleted')
label("Hide Completed", cls="form-check-label",
_for='toggleHideCompleted')
def make_nav(page, is_map = False):
with nav(cls="navbar navbar-expand-xl bg-dark navbar-dark d-print-none" + (' sticky-top' if not is_map else ''), id="top_nav"):
with div(cls="container-fluid"):
# with div(cls='order-sm-last d-none d-sm-block ms-auto'):
with button(type="button", cls="navbar-toggler", data_bs_toggle="collapse", data_bs_target="#nav-collapse", aria_expanded="false", aria_controls="nav-collapse", aria_label="Toggle navigation"):
span(cls="navbar-toggler-icon")
a('Roundtable Guides', cls="navbar-brand me-auto ms-2" + (' active' if page == 'index' else ''), href="/index.html")
with form(cls="d-none d-sm-flex order-2 order-xl-3"):
input_(cls='form-control me-2', type='search', placeholder='Search', aria_label='search', name='search')
button(type='submit', cls='btn', formaction='/search.html', formmethod='get', formnovalidate='true').add(i(cls='bi bi-search'))
with div(cls='d-sm-none order-2'):
a(href='/search.html', cls='nav-link me-0').add(i(cls='bi bi-search sb-icon-search'))
with div(cls="collapse navbar-collapse order-3 order-xl-2 ms-xl-2", id="nav-collapse"):
with ul(cls="nav navbar-nav navbar-nav-scroll mr-auto"):
# with li(cls="nav-item"):
# a(href="/index.html", cls="nav-link hide-buttons" + (' active' if page == 'index' else '')).add(i(cls="bi bi-house-fill"))
for name, l in dropdowns:
page_in_dropdown = page in [to_snake_case(guide[0]) for guide in l]
with li(cls="dropdown nav-item"):
a(name, cls="nav-link dropdown-toggle" + (' active' if page_in_dropdown else ''), href="#", data_bs_toggle="dropdown", aria_haspopup="true", aria_expanded="false").add(span(cls="caret"))
with ul(cls="dropdown-menu"):
for guide in l:
li(cls='tab-li').add(a(guide[0], cls="dropdown-item show-buttons" + (' active' if page == to_snake_case(guide[0]) else ''), href='/checklists/' + to_snake_case(guide[0]) + '.html'))
with li(cls='nav-item tab-li'):
a(href="/map.html", cls="nav-link hide-buttons" + (' active' if page == 'map' else '')).add(i(cls="bi bi-map"), " Map")
with li(cls="nav-item tab-li"):
a(href="/options.html", cls="nav-link hide-buttons" + (' active' if page == 'options' else '')).add(i(cls="bi bi-gear-fill"), " Options")
# def make_sidebar_nav(page):
# with aside(cls="bd-sidebar"):
# with nav(cls='bd-links sidebar-nav collapse collapse-horizontal show', id='sidebar'):
# with ul(id="sidebar_nav", cls="list-unstyled mb-0 py-3 pt-md-1"):
# with li(cls="mb-1"):
# link = a(href="/index.html", cls="dropdown-item hide-buttons" + (' show' if page == 'index' else ''))
# link += i(cls="bi bi-house-fill")
# link += " Home"
# for name, l in dropdowns:
# with li(cls="mb-1"):
# page_in_dropdown = page in [to_snake_case(guide[0]) for guide in l]
# button(name, cls="btn d-inline-flex align-items-center rounded" + (' collapsed' if not page_in_dropdown else ''), data_bs_toggle="collapse", data_bs_target='#' + to_snake_case(name) + '_dropdown', aria_expanded=('true' if page_in_dropdown else 'false'))
# with div(id=to_snake_case(name) + '_dropdown', cls='collapse' + (' show' if page_in_dropdown else '')):
# with ul(cls='list-unstyled fw-normal pb-1 small'):
# for guide in l:
# li().add(a(guide[0], cls="d-inline-flex align-items-center rounded" + (' active' if page == to_snake_case(guide[0]) else ''), href='/checklists/' + guide[1]))
# with li():
# link = a(href="/options.html", cls="dropdown-item hide-buttons" + (' active' if page == 'options' else ''))
# link += i(cls="bi bi-gear-fill")
# link += " Options"
def make_footer(page=None):
script(src="/js/jquery.min.js")
script(src="/js/jstorage.min.js")
script(src='/js/progress.js')
script(src='/js/item_links.js')
script(src='/js/common.js')
script(src="/js/bootstrap.bundle.min.js")
script(src="/js/jets.min.js")
script(src="/js/jquery.highlight.js")
raw("""
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-B7FMWDCTF5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-B7FMWDCTF5');
</script>
""")
if page:
script(type="text/javascript").add_raw_string("""
(function($) {{
'use strict';
$(function() {{
var jet = new Jets({{
searchTag: "#{page_id}_search",
contentTag: "#{page_id}_list ul",
didSearch: function(search_phrase) {{
search_phrase = search_phrase.trim().toLowerCase().replace(/\\s\\s+/g, ' ').replace(/\\\\/g, '\\\\\\\\');
$(".card").each(function(index, el) {{
if (!search_phrase) {{
$(el).removeClass('d-none');
return;
}}
var hasResults = $(el).find('.searchable').filter('[data-jets *= "' + search_phrase + '"]').length;
if (! hasResults ) {{
$(el).addClass('d-none');
}} else {{
$(el).removeClass('d-none');
}}
}});
}}
}});
$("#{page_id}_search").keyup(function() {{
$("#{page_id}_list").unhighlight();
$("#{page_id}_list").highlight($(this).val());
}});
}});
}})( jQuery );
""".format(page_id=page['id']))
def make_index():
doc = make_doc("Roundtable Guides", "Elden Ring Guides and Progress Tracker")
with doc:
make_nav('index')
with div(cls="container"):
with div(cls="row"):
with div(cls="col-md-12 text-center"):
h1("Roundtable Guides", cls="mt-4")
with div(cls="row gy-3"):
with div(cls='col-md-8 col-12'):
with div(cls='row row-cols-1 row-cols-md-2 gy-3'):
with div(cls="col"):
with div(cls="card shadow h-100"):
with div(cls="card-body"):
h5('Welcome to Roundtable Guides', cls='card-title text-center')
p('Guides, Walkthroughs, and Progress Tracking for Elden Ring. Written and maintained by the players. This site is still a work in-progress. We are working on it every day.', cls='card-text')
with div(cls='col'):
with div(cls='card shadow h-100'):
with div(cls='card-body'):
h5('Get the Apps!', cls='card-title text-center')
with div(style='width: 180px;', cls='badge'):
with a(href='https://apps.apple.com/us/app/elden-ring-guides/id1620436088?itsct=apps_box_badge&itscg=30200'):
img(src="https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/en-us?size=250x83&releaseDate=1650585600&h=3eb10370b9c49cf5b5dde5ca0352f23a", alt="Download on the App Store", style='margin: 6%; width: 88%;')
with div(style='width: 180px;', cls='badge'):
with a(href='https://play.google.com/store/apps/details?id=com.roundtablehold.eldenringguides&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1', style='width: 100%;'):
img(src='https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png', style='width: 100%;')
with div(cls="col"):
with div(cls="card shadow h-100"):
with div(cls="card-body"):
h5('Our other resources', cls='card-title text-center')
p('Join the Roundtable Hold ', cls='card-text').add(a('Discord community', href='https://discord.gg/BzJzFeBjHr'))
p('More guides are over on ', cls='card-text').add(a('/r/Roundtable_Guides', href='https://www.reddit.com/r/Roundtable_Guides/'))
p('Video guides on the ', cls='card-text').add(a('YouTube channel', href='https://www.youtube.com/channel/UCE-I15Z8HQBNCFHq2V0bbsA'))
with div(cls="col"):
with div(cls='card shadow h-100'):
with div(cls="card-body"):
h5('I have feedback, how can I contribute?', cls='card-title text-center')
text = p(cls='card-text')
text += 'Contributing is easy! And does not require you to know how to code. You can find instructions on the'
text += a('Github repository', href='https://github.com/RoundtableHold/roundtablehold.github.io')
text += ' You can also simply '
text += a('report issues', href='https://github.com/RoundtableHold/roundtablehold.github.io/issues')
text += " and we'll fix them."
with div(cls="col"):
with div(cls="card shadow h-100"):
with div(cls="card-body"):
h5('Can I use this for multiple characters?', cls='card-title text-center')
p('Yes! Use the profile selector and buttons in the options tab at the top of the page to setup multiple profiles.', cls='card-text')
with div(cls="col"):
with div(cls="card shadow h-100"):
with div(cls="card-body"):
h5('How does the checklist status get saved?', cls='card-title text-center')
p("The checklists are saved to your browser's local storage. Be careful when clearing your browser's cache as it will also destroy your saved progress.", cls='card-text')
with div(cls="col-md-4 col-12"):
with div(cls='card shadow'):
with div(cls="card-body uncolor-links"):
h5('Progress', cls='card-title text-center')
with ul(id='progress_list', cls='nav flex-column'):
hr()
for name, l in dropdowns:
for guide in l:
li(cls='tab-li').add(a(guide[0], href="/checklists/" + to_snake_case(guide[0]) + '.html')).add(span(id=guide[1] + "_progress_total", cls='d-print-none'))
hr()
make_footer()
script(src="/js/index.js")
with open(os.path.join('docs', 'index.html'), 'w', encoding='utf_8') as index:
index.write(doc.render())
def make_options():
doc = make_doc('Options | Roundtable Guides', 'Elden Ring Guides and Progress Tracker')
with doc:
make_nav('options')
with div(cls="container"):
with div(cls="row"):
with div(cls="col-md-12 text-center"):
h1("Roundtable Guides", cls="mt-4")
with div(cls="row"):
h2("Options")
with div(cls="row"):
div(cls="col col-12 col-md-6").add(h4("Theme selection:"))
div(cls="col col-12 col-md-6").add(select(cls="form-select", id="themes"))
with div(cls="row"):
div(cls="col col-12 col-md-4").add(h4("Profile management:"))
with form(cls="form-inline input-group pull-right gap-1"):
with div(cls="col col-12 col-md-4"):
select(cls="form-select", id="profiles")
with div(cls="col col-12 col-md-4"):
with div(cls="btn-group"):
button("Add", cls="btn btn-primary", type="button", id="profileAdd")
with div(cls="btn-group"):
button("Edit", cls="btn btn-primary", type="button", id="profileEdit")
with div(cls="btn-group"):
button("NG+", cls="btn btn-primary", type="button", id="profileNG+")
with div(cls="row"):
div(cls="col col-12 col-md-4").add(h4("Data import/export:"))
with div(cls="col col-12 col-md-8"):
with form(cls="form-inline gap-1 m-1"):
with div(cls="btn-group pull-left"):
button("Import file", cls="btn btn-primary", type="button", id="profileImport")
with div(cls="btn-group pull-left"):
button("Export file", cls="btn btn-primary", type="button", id="profileExport")
with div(cls="btn-group pull-right"):
button("Import textbox", cls="btn btn-primary", type="button", id="profileImportText")
with div(cls="btn-group pull-right mt-1 mt-md-0"):
button("Export clipboard", cls="btn btn-primary", type="button", id="profileExportText")
with div(cls='row'):
div(id='alert-div')
with div(cls='row'):
with div(cls="col col-12"):
textarea(id="profileText", cls="form-control")
with div(id="profileModal", cls="modal fade", tabindex="-1", role="dialog"):
with div(cls="modal-dialog", role="document"):
with div(cls="modal-content"):
with div(cls="modal-header"):
h3("Profile", id="profileModalTitle", cls="modal-title")
button(type="button", cls="btn-close", data_bs_dismiss="modal", aria_label="Close")
with div(cls="modal-body"):
with form(cls="form-horizontal"):
with div(cls="control-group"):
label("Name", cls="control-label", _for="profileModalName")
div(cls="controls").add(input_(type="text", cls="form-control", id="profileModalName", placeholder="Enter Profile name"))
with div(cls="modal-footer"):
button("Close", id="profileModalClose", cls="btn btn-secondary", data_bs_dismiss="modal")
a("Add", href="#", id="profileModalAdd", cls="btn btn-primary", data_bs_dismiss="modal")
a("Update", href="#", id="profileModalUpdate", cls="btn btn-primary")
a("Delete", href="#", id="profileModalDelete", cls="btn btn-primary")
with div(id="NG+Modal", cls="modal fade", tabindex="-1", role="dialog"):
with div(cls="modal-dialog", role="document"):
with div(cls="modal-content"):
with div(cls="modal-header"):
h3("Begin next journey?", id="profileModalTitleNG", cls="modal-title")
button(type="button", cls="btn-close", data_bs_dismiss="modal", aria_label="Close")
div('If you begin the next journey, all progress on the "Playthrough" and "Misc" tabs of this profile will be reset, while achievement and collection checklists will be kept.', cls="modal-body")
with div(cls="modal-footer"):
a("No", href="#", cls="btn btn-primary", data_bs_dismiss="modal")
a("Yes", href="#", cls="btn btn-danger", id="NG+ModalYes")
with div(id='importTextModal', cls='modal fade', tabindex='-1', role='dialog'):
with div(cls='modal-dialog', role='document'):
with div(cls='modal-content'):
with div(cls='modal-header'):
h3('Import profile?', cls='modal-title')
button(type='button', cls='btn-close', data_bs_dismiss='modal', aria_label='Close')
div('If you import this profile all of your current progress will be lost.', cls='modal-body')
with div(cls='modal-footer'):
a('No', href='#', cls='btn btn-primary', data_bs_dismiss='modal')
a('Yes', href='#', cls='btn btn-danger', id='importTextYes')
with div(id='importFileModal', cls='modal fade', tabindex='-1', role='dialog'):
with div(cls='modal-dialog', role='document'):
with div(cls='modal-content'):
with div(cls='modal-header'):
h3('Import profile?', cls='modal-title')
button(type='button', cls='btn-close', data_bs_dismiss='modal', aria_label='Close')
div('If you import this profile all of your current progress will be lost.')
with div(cls='modal-footer'):
a('No', href='#', cls='btn btn-primary', data_bs_dismiss='modal')
a('Yes', href='#', cls='btn btn-danger', id='importFileYes')
with div(id='deleteModal', cls='modal fade', tabindex='-1', role='dialog'):
with div(cls='modal-dialog', role='document'):
with div(cls='modal-content'):
with div(cls='modal-header'):
h3('Are you sure?', cls='modal-title')
button(type='button', cls='btn-close', data_bs_dismiss='modal', aria_label='Close')
div('You will lose all progress in this profile. Please back it up first.')
with div(cls='modal-footer'):
a('No', href='#', cls='btn btn-primary', data_bs_dismiss='modal')
a('Yes', href='#', cls='btn btn-danger', id='deleteYes')
div(cls="hiddenfile").add(input_(name="upload", type="file", id="fileInput"))
make_footer()
script(src="/js/options.js")
with open(os.path.join('docs', 'options.html'), 'w', encoding='utf_8') as index:
index.write(doc.render())
img_size = '70'
def add_icon(icon, classes):
p = os.path.join('docs', icon[1:])
im = Image.open(p)
width, height = im.size
if width > height:
img(data_src=icon, loading='lazy', cls=classes, style="width: 70px; height: {}px".format(int(height * (70 / width))))
else:
img(data_src=icon, loading='lazy', cls=classes, style="height: 70px; width: {}px".format(int(width * (70 / height))))
def make_checklist(page):
page['num_ids'] = 0
doc = make_doc(page['title'] + " | Roundtable Guides", 'Elden Ring Guides and Progress Tracker')
with doc:
make_nav(to_snake_case(page['title']))
# whole page
with div(cls="container uncolor-links"):
# title_row()
# Filter buttons
with div(cls="row text-center"):
h = h1(cls='mt-4')
h += page['title']
h += span(id=page['id'] + "_overall_total", cls='d-print-none')
hide_completed_button()
if 'description' in page:
p(raw(page['description']))
with nav(cls="text-muted toc d-print-none"):
with strong(cls="d-block h5").add(a(data_bs_toggle="collapse", role="button", href="#toc_" + page['id'], cls="toc-button")):
i(cls='bi bi-plus-lg')
raw('Table Of Contents')
with ul(id="toc_" + page['id'], cls="toc_page collapse"):
for s_idx, section in enumerate(page['sections']):
with li():
a(section['title'], href="#" + page['id'] + '_section_' + str(s_idx), cls="toc_link")
span(id=page['id'] + "_nav_totals_" + str(s_idx))
with div(cls="input-group d-print-none"):
input_(type="search", id=page['id'] + "_search", cls="form-control my-3", placeholder="Start typing to filter results...")
with div(id=page['id']+"_list"):
for s_idx, section in enumerate(page['sections']):
section['num_ids'] = 0
with div(cls='card shadow-sm mb-3', id=page['id'] + '_section_' + str(s_idx)).add(div(cls='card-body')):
with h4(cls="mt-1"):
with button(href="#" + page['id'] + '_' + str(s_idx) + "Col", data_bs_toggle="collapse", data_bs_target="#" + page['id'] + '_' + str(s_idx) + "Col", cls="btn btn-primary btn-sm me-2 collapse-button d-print-none", role="button"):
i(cls='bi bi-chevron-up d-print-none')
if 'icon' in section:
add_icon(section['icon'], 'me-1')
if 'link' in section:
a(section['title'], href=section['link'], cls='d-print-inline')
else:
span(section['title'], cls='d-print-inline')
span(id=page['id'] + "_totals_" + str(s_idx), cls="mt-0 badge rounded-pill d-print-none")
if 'table' in section:
with div(id=page['id'] + '_' + str(s_idx) + "Col", cls="collapse show row", aria_expanded="true"):
if isinstance(section['table'], list):
table_cols = len(section['table'])
size = floor(12 / table_cols)
else:
table_cols = section['table']
size = floor(12 / table_cols)
table_widths = section['table_widths'] if 'table_widths' in section else page['table_widths']
items = peekable(section['items'])
if isinstance(items.peek(), str):
item = next(items)
h5(item)
with ul(cls='list-group list-group-flush mb-0'):
if isinstance(section['table'], list):
with li(cls="list-group-item d-md-block d-none").add(div(cls="row form-check checkbox d-flex")):
with div(cls="col-auto d-flex align-items-center"):
input_(cls="form-check-input invisible pe-0 me-0", type='checkbox')
with div(cls='col-auto d-flex align-items-center order-last'):
a(href='#', cls='invisible').add(i(cls='bi bi-geo-alt'))
with div(cls="col d-flex align-items-center d-md-block").add(div(cls="row")):
for idx, header in enumerate(section['table']):
col_size = str(table_widths[idx])
div(cls="ms-0 ps-0 d-flex align-items-center col-md-" + col_size).add(label(strong(header), cls='ms-0 ps-0'))
for item in items:
id = str(item['id'])
with li(cls="list-group-item searchable", data_id=page['id'] + '_' + id, id='item_' + id):
if isinstance(item, str):
h5(item)
continue
with div(cls="row form-check checkbox d-flex"):
with div(cls="col-auto d-flex align-items-center"):
input_(cls="form-check-input pe-0 me-0", type="checkbox", value="",
id=page['id'] + '_' + id, data_section_idx=str(s_idx))
page['num_ids'] += 1
section['num_ids'] += 1
with div(cls='col-auto d-flex align-items-center order-last'):
href = '/map.html?'
if 'map_link' in item:
href += 'x={}&y={}'.format(item['map_link'][0], item['map_link'][1])
else:
href += 'target={}_{}'.format(page['id'], item['id'])
href += '&id={}&link={}&title={}'.format(page['id'] + '_' + id, '/checklists/' + to_snake_case(page['title']) + '.html%23item_' + id, item['map_title'] if 'map_title' in item else item['data'][0])
a(href=href, cls=('invisible' if (('cords' not in item) and ('map_link' not in item)) else '')).add(i(cls='bi bi-geo-alt'))
with div(cls="col d-flex align-items-center d-md-block d-none").add(div(cls="row")):
for pos in range(table_cols):
col_size = str(table_widths[pos])
with div(cls="ms-0 ps-0 d-flex align-items-center col-md-" + col_size):
with label(cls="form-check-label item_content ms-0 ps-0", _for=page['id'] + '_' + id):
if pos == 0 and 'icon' in item:
add_icon(item['icon'], 'me-1')
if item['data'][pos]:
raw(item['data'][pos])
with div(cls='col d-md-none'):
with label(cls="form-check-label item_content ms-0 ps-0", _for=page['id'] + '_' + id):
if 'icon' in item:
add_icon(item['icon'], 'float-end')
for pos in range(table_cols):
col_size = str(table_widths[pos])
if isinstance(section['table'], list) and item['data'][pos]:
strong(section['table'][pos] + ': ', cls="me-1")
if item['data'][pos]:
raw(item['data'][pos])
br()
else:
with div(id=page['id'] + '_' + str(s_idx) + "Col", cls="collapse show", aria_expanded="true"):
items = peekable(section['items'])
if isinstance(items.peek(), str):
item = next(items)
h5(raw(item))
u = ul(cls="list-group-flush mb-0 ps-0 ps-md-4")
for item in items:
if isinstance(item, str):
h5(raw(item))
u = ul(cls="list-group-flush mb-0")
continue
def f(item):
id = str(item['id'])
with li(data_id=page['id'] + "_" + id, cls="list-group-item searchable ps-0", id='item_' + id):
with div(cls="form-check checkbox d-flex align-items-center"):
input_(cls="form-check-input", type="checkbox", value="", id=page['id'] + '_' + id, data_section_idx=str(s_idx))
with label(cls="form-check-label item_content", _for=page['id'] + '_' + id):
if 'icon' in item:
add_icon(item['icon'], 'float-md-none float-end me-md-1')
raw(item['data'][0])
if 'cords' in item or 'map_link' in item:
href = '/map.html?'
if 'map_link' in item:
href += 'x={}&y={}'.format(item['map_link'][0], item['map_link'][1])
else:
href += 'target={}_{}'.format(page['id'], id)
href += '&id={}&link={}&title={}'.format(page['id'] + '_' + id, '/checklists/' + to_snake_case(page['title']) + '.html%23item_' + id, item['map_title'] if 'map_title' in item else item['data'][0])
a(href=href, cls='ms-2').add(i(cls='bi bi-geo-alt'))
page['num_ids'] += 1
section['num_ids'] += 1
with u:
f(item)
if isinstance(items.peek(0), list):
item = next(items)
with u.add(ul(cls='list-group-flush')):
for subitem in item:
f(subitem)
a(cls="btn btn-primary btn-sm fadingbutton back-to-top d-print-none").add(raw("Back to Top "), span(cls="bi bi-arrow-up"))
script(raw("window.current_page_id = \"{}\";\n".format(page['id'])))
make_footer(page)
script(src="/js/checklists.js")
with open(os.path.join('docs', 'checklists', to_snake_case(page['title']) + '.html'), 'w', encoding='utf_8') as index:
index.write(doc.render())
def make_search():
doc = make_doc("Search | Roundtable Guides", 'Elden Ring Guides and Progress Tracker')
with doc:
make_nav('search')
# whole page
with div(cls="container uncolor-links"):
with div(cls='row text-center'):
h3('Search', cls='mt-4')
with div(cls='row mt-4'):
with form(cls="d-flex"):
input_(cls='form-control me-2', type='search', placeholder='Search', aria_label='search', id='page_search', name='search')
button(id='search_submit', cls='btn').add(i(cls='bi bi-search'))
with div(cls='row mt-4 d-flex justify-content-center d-none', id='spinner'):
with div(cls='spinner-border text-primary', role='status'):
span('Loading...', cls='visually-hidden')
with div(cls='row mt-4').add(div(cls='col')):
with div(cls='list-group list-group-flush mb-0'):
for page in pages:
for s_idx, section in enumerate(page['sections']):
items = peekable(section['items'])
if 'table' in section:
if isinstance(section['table'], list):
table_cols = len(section['table'])
size = floor(12 / table_cols)
else:
table_cols = section['table']
size = floor(12 / table_cols)
table_widths = section['table_widths'] if 'table_widths' in section else page['table_widths']
for item in items:
with a(cls='d-none list-group-item list-group-item-action searchable', href='/checklists/' + to_snake_case(page['title']) + '.html#item_' + str(item['id']), id='/checklists/' + to_snake_case(page['title']) + '.html#item_' + str(item['id'])):
if isinstance(item,str):
continue
with div(cls='row d-md-flex d-none'):
for pos in range(table_cols):
col_size = str(table_widths[pos])
with div(cls='d-flex align-items-center col-md-' + col_size):
if pos == 0 and 'icon' in item:
add_icon(item['icon'], 'me-1')
if item['data'][pos]:
raw(strip_a_tags(item['data'][pos]))
with div(cls='row d-md-none').add(div(cls='col')):
if 'icon' in item:
add_icon(item['icon'], 'float-end')
for pos in range(table_cols):
col_size = str(table_widths[pos])
if isinstance(section['table'], list) and item['data'][pos]:
strong(strip_a_tags(section['table'][pos]) + ': ', cls='me-1')
if item['data'][pos]:
raw(strip_a_tags(item['data'][pos]))
br()
else:
for item in items:
if isinstance(item, str):
continue
def f(item):
with a(cls='d-none list-group-item list-group-item-action searchable', href='/checklists/' + to_snake_case(page['title']) + '.html#item_' + str(item['id']), id='/checklists/' + to_snake_case(page['title']) + '.html#item_' + str(item['id'])):
with div(cls='d-flex align-items-center'):
if 'icon' in item:
add_icon(item['icon'], 'float-md-none float-end me-md-1')
raw(strip_a_tags(item['data'][0]))
f(item)
if isinstance(items.peek(0), list):
item_id = str(item['id'])
item = next(items)
for subitem in item:
f(subitem)
make_footer()
script(src='/js/lunr.js')
script(src='/js/search.js')
with open(os.path.join('docs', 'search.html'), 'w', encoding='utf_8') as out:
out.write(doc.render())
def to_list(x):
if isinstance(x, list):
return set(x)
return set([x])
def make_item_links():
links_json = {}
for l in item_links:
if 'source' in l:
for t in to_list(l['target']):
if (str(t)) not in all_ids:
print('Potential typo in item links. "' + str(t) + '" is not a valid id')
for s in to_list(l['source']):
if (str(s)) not in all_ids:
print('Potential typo in item links. "' + str(s) + '" is not a valid id')
t = to_list(l['target'])
t.discard(s)
links_json.setdefault(s, {}).setdefault('targets', []).extend(list(t))
links_json.setdefault(s, {}).setdefault('targets', []).sort()
if 'source_or' in l:
for t in to_list(l['target']):
if (str(t)) not in all_ids:
print('Potential typo in item links. "' + str(t) + '" is not a valid id')
for s in to_list(l['source_or']):
if (str(s)) not in all_ids:
print('Potential typo in item links. "' + str(s) + '" is not a valid id')
ss = to_list(l['source_or'])
ss.discard(s)
t = to_list(l['target'])
t.discard(s)
links_json.setdefault(s, {}).setdefault('orsources', []).extend(list(ss))
links_json.setdefault(s, {}).setdefault('orsources', []).sort()
links_json.setdefault(s, {}).setdefault('ortargets', []).extend(list(t))
links_json.setdefault(s, {}).setdefault('ortargets', []).sort()
if 'source_and' in l:
for t in to_list(l['target']):
if (str(t)) not in all_ids:
print('Potential typo in item links. "' + str(t) + '" is not a valid id')
for s in to_list(l['source_and']):
if (str(s)) not in all_ids:
print('Potential typo in item links. "' + str(s) + '" is not a valid id')
ss = to_list(l['source_and'])
ss.discard(s)
t = to_list(l['target'])
t.discard(s)
links_json.setdefault(s, {}).setdefault('andsources', []).extend(list(ss))
links_json.setdefault(s, {}).setdefault('andsources', []).sort()
links_json.setdefault(s, {}).setdefault('andtargets', []).extend(list(t))
links_json.setdefault(s, {}).setdefault('andtargets', []).sort()
if 'link_all' in l:
for s in to_list(l['link_all']):
if (str(s)) not in all_ids:
print('Potential typo in item links. "' + str(s) + '" is not a valid id')
t = to_list(l['link_all'])
t.discard(s)
links_json.setdefault(s, {}).setdefault('targets', []).extend(list(t))
links_json.setdefault(s, {}).setdefault('targets', []).sort()
with open(os.path.join('docs', 'js', 'item_links.js'), 'w', encoding='UTF-8') as links_f:
links_f.write('const item_links = ')
json.dump(links_json, links_f, indent=2, sort_keys=True)
def make_progress_js():
with open(os.path.join('docs', 'js', 'progress.js'), 'w', encoding='utf_8') as f:
f.write('window.progress = {\n')
for page in pages:
f.write(' "{}": {{\n'.format(page['id']))
f.write(' "total": [0, {}],\n'.format(page['num_ids']))
f.write(' "sections": [\n')
for section in page['sections']:
f.write(' [0, {}],\n'.format(section['num_ids']))
f.write(' ],\n },\n')
f.write('};\n')
def make_index_js():
with open(os.path.join('docs', 'js', 'index.js'), 'w', encoding='utf_8') as f:
f.write(
"""
(function($) {
'use strict';
$(function() {
""")
f.write('var all_ids = new Set([\n')
all_ids_list = list(all_ids)
all_ids_list.sort()
for id in all_ids_list:
f.write('"' + id + '",\n')
f.write(']);\n')
f.write('function calculateProgress() {\n')
for page in pages:
f.write('const ' + page['id'] + '_total = ' + str(page['num_ids']) + ';\n')
f.write('var ' + page['id'] + '_checked = 0;\n')
f.write('for (var id in profiles[profilesKey][profiles.current].checklistData) {\n')
f.write('if (profiles[profilesKey][profiles.current].checklistData[id] === true && all_ids.has(id)) {\n')
for page in pages:
f.write('if (id.startsWith("{page_id}")) {{\n'.format(page_id=page['id']))
f.write(page['id'] + '_checked += 1;\n}\n')
f.write('}\n')
f.write('}\n')
for page in pages:
f.write('if ({page_id}_checked >= {page_id}_total){{\n'.format(page_id=page['id']))
f.write('$("#{page_id}_progress_total").html("DONE");\n'.format(page_id=page['id']))
f.write('} else {\n')
f.write('$("#{page_id}_progress_total").html({page_id}_checked + "/" + {page_id}_total);\n'.format(page_id=page['id']))
f.write('}\n')
f.write('}\n')
f.write('calculateProgress();\n')
f.write(' });\n')
f.write('})( jQuery );\n')
def make_search_index():
search_idx = []
for page in pages:
for section in page['sections']:
items = peekable(section['items'])
for item in items:
if isinstance(item, str):
continue
def f(item):
search_idx.append({
'id': '/checklists/{page_href}#item_{id}'.format(page_href=to_snake_case(page['title']) + '.html', id=item['id']),
'text': re.sub(r'(<([^>]+)>)', '', ' '.join(item['data'])),
})
f(item)
if isinstance(items.peek(0), list):
item = next(items)
for subitem in item:
f(subitem)
# id = item_id + '_' + str(subitem['id'])
# search_idx.append({
# 'id': '/checklists/{page_href}#item_{id}'.format(page_href=to_snake_case(page['title']) + '.html', id=id),
# 'text': re.sub(r'(<([^>]+)>)', '', ' '.join(subitem['data'])),
# })
with open(os.path.join('docs', 'search_index.json'), 'w') as s_idx:
json.dump(search_idx, s_idx, indent=2, sort_keys=True)
def get_icon(page, section, item):
icon = ''
icon_size = 35
if 'map_icon' in item:
icon = item['map_icon']
if 'map_icon_size' in item:
icon_size = item['map_icon_size']
elif 'map_icon' in section:
icon = section['map_icon']
if 'map_icon_size' in section:
icon_size = section['map_icon_size']
elif 'map_icon' in page:
icon = page['map_icon']
if 'map_icon_size' in page:
icon_size = page['map_icon_size']
elif 'icon' in item:
icon = item['icon']
if 'map_icon_size' in item:
icon_size = item['map_icon_size']
elif 'icon' in section:
icon = section['icon']
if 'map_icon_size' in section:
icon_size = section['map_icon_size']
elif 'icon' in page:
icon = page['icon']
if 'map_icon_size' in page:
icon_size = page['map_icon_size']
else:
print("Missing icon for {}".format(page['id'] + '_' + item['id']))
return (icon, icon_size)
def make_feature(page, section, item):
icon, icon_size = get_icon(page, section, item)
return {
'type': 'Feature',
'id': page['id'] + '_' + item['id'],
'geometry': {
'type': 'Point',
'coordinates': item['cords'],
},
'properties': {
'title': item['map_title'] if 'map_title' in item else item['data'][0],
'id': page['id'] + '_' + item['id'],
'group': page['id'],
'icon': icon,
'icon_size': icon_size,
'link': '/checklists/' + to_snake_case(page['title']) + '.html#item_' + item['id']
}
}
pages_in_map = set()
def make_geojson():
layers = []
icons = set()
for page in pages:
geojson = {}
geojson['type'] = 'FeatureCollection'
geojson['id'] = page['id']
geojson['features'] = []
has_features = False
for section in page['sections']:
items = peekable(section['items'])
for item in items:
if isinstance(item, str):
continue
if 'cords' in item:
has_features = True
geojson['features'].append(make_feature(page, section, item))
icons.add(get_icon(page, section, item)[0])
if isinstance(items.peek(0), list):
item = next(items)
for subitem in item:
if 'cords' in subitem:
has_features = True
geojson['features'].append(make_feature(page, section, subitem))
icons.add(get_icon(page, section, item)[0])
if has_features:
layers.append(geojson)
pages_in_map.add(page['id'])
with open(os.path.join('docs', 'map', 'src', 'js', 'features.js'), 'w') as outf:
outf.write('const feature_data = ')
json.dump(layers, outf, indent=2, sort_keys=True)
outf.write(';\nconst icon_urls = ')
l = list(icons)
l.sort()
json.dump(l, outf, indent=2, sort_keys=True)
def make_map():
doc = make_doc('Map | Roundtable Guides', 'Elden Ring Guides and Progress Tracker')
with doc.head:
link(rel='stylesheet', href='/map/src/css/ol.css')
link(rel='stylesheet', href='/map/src/css/map.css')
with doc:
with div(cls='container-fluid h-100 d-flex flex-column p-0 m-0 g-0'):
with div(cls='row m-0 p-0 g-0'):
make_nav('map', True)
with div(cls='row h-100 flex-grow-1 p-0 m-0 g-0'):
div(id='map', cls='m-0 p-0 g-0')
with div(cls='offcanvas offcanvas-end m-0 p-0 g-0 w-auto show d-none d-lg-block', id='layer-menu', data_bs_stroll="true", data_bs_backdrop="false", tabindex="-1"):
with button(cls='btn btn-primary btn-sml offcanvas-btn position-absolute p-1', type='button', data_bs_toggle='offcanvas', data_bs_target='#layer-menu', style='height: 50px;'):
i(cls='bi bi-caret-left-fill m-0 p-0')
i(cls='bi bi-caret-right-fill m-0 p-0')
# h3('Map', cls='offcanvas-title')
with div(cls='offcanvas-body overflow-auto h-100'):
with div(cls='d-flex align-items-center justify-content-between'):
h3('Layers', cls='offcanvas-title')
button(type='button', cls='btn-close text-reset', data_bs_dismiss='offcanvas')
hr()
# with div(cls='row mb-2'):
# with div(cls='col-auto order-last'):
# button(type='button', cls='btn-close text-reset d-lg-none', data_bs_dismiss='offcanvas')
# with div(cls='col text-center'):
# h3('Layers')
with div(cls='mb-2 d-flex justify-content-evenly'):
button('Show All', type='button', cls='btn btn-secondary btn-sm', id='show-all')
button('Hide All', type='button', cls='btn btn-secondary btn-sm', id='hide-all')
for name, l in dropdowns:
should_print_category = False
for guide in l:
if guide[1] in pages_in_map:
should_print_category = True
break
if should_print_category:
h4(name)
for guide in l:
if guide[1] in pages_in_map:
with div(cls='form-check ps-0'):
input_(type='checkbox', cls='btn-check category-filter', id=guide[1], autocomplete='off')
b = label(cls='btn btn-sm btn-secondary w-100 text-start', _for=guide[1])
if guide[2]:
b += img(data_src=guide[2], loading='lazy', height=25, width=25, cls='me-1')
b += guide[0]
b += span(id=guide[1] + '_progress_total')
hr()
with div(cls='form-check'):
input_(cls='form-check-input', type='checkbox', value='', id='hideCompleted')
label('Hide Completed', cls='form-check-label', _for='hideCompleted')
# l = label(cls='form-check-label layer-button', _for=guide[1])
# l += input_(cls='form-check-input category-filter', type='checkbox', value='', id=guide[1], hidden='')
# if guide[2]:
# l += img(data_src=guide[2], loading='lazy', height=20, width=20, cls='me-1')
# l += guide[0]
# l += span(id=guide[1] + "_progress_total")
# with li(cls="dropdown nav-item"):
# a(name, cls="nav-link dropdown-toggle" + (' active' if page_in_dropdown else ''), href="#", data_bs_toggle="dropdown", aria_haspopup="true", aria_expanded="false").add(span(cls="caret"))
# with ul(cls="dropdown-menu"):
# for guide in l:
# li(cls='tab-li').add(a(guide[0], cls="dropdown-item show-buttons" + (' active' if page == to_snake_case(guide[0]) else ''), href='/checklists/' + to_snake_case(guide[0]) + '.html'))
with div(id='popup', cls='card shadow'):
# a(href='#', id='popup-closer', cls='ol-popup-closer')
with div(cls="card-body form-check checkbox d-flex align-items-center popup-content"):
input_(cls="form-check-input", type="checkbox", value="", id='popup-checkbox')
label(cls="form-check-label item_content ms-2", _for='popup-checkbox', id='popup-title')
a(href="#", id='popup-link', cls='ms-3').add(i(cls='bi bi-link-45deg'))
with div(cls='d-none', id='dev-mode-copy'):
a('map_link', type='button', cls='btn btn-primary btn-sm', id='dev-mode-copy-button')
make_footer()
script(src='/map/src/js/ol.js')
script(src='/map/src/js/features.js')
script(src='/map/src/js/map.js')
with open(os.path.join('docs', 'map.html'), 'w', encoding='utf_8') as f:
f.write(doc.render())
make_index()
make_options()
for page in pages:
make_checklist(page)
make_search()
make_search_index()
make_progress_js()
make_index_js()
make_item_links()
make_geojson()
make_map()