From bce70e74bc089a721ebd88bbbfa6237b9e9018ba Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Thu, 24 Aug 2023 11:53:10 -0500 Subject: [PATCH 01/16] feat: import iab agendas from iab website (#6197) * feat: import iab agendas from wiki * chore: adjust command help text --- .../management/commands/import_iab_agendas.py | 240 ++++++++++++++++++ ietf/templates/group/meetings.html | 4 + 2 files changed, 244 insertions(+) create mode 100644 ietf/meeting/management/commands/import_iab_agendas.py diff --git a/ietf/meeting/management/commands/import_iab_agendas.py b/ietf/meeting/management/commands/import_iab_agendas.py new file mode 100644 index 000000000..a1b78003e --- /dev/null +++ b/ietf/meeting/management/commands/import_iab_agendas.py @@ -0,0 +1,240 @@ +# Copyright The IETF Trust 2023, All Rights Reserved + +import datetime +import os +import shutil +import subprocess +import tempfile + +from pathlib import Path + +from django.core.management.base import BaseCommand +from django.conf import settings + +from ietf.doc.models import Document, DocAlias, DocEvent +from ietf.meeting.models import Meeting, Session + + +def agendas_to_import(): + return [ + "2018-09-05.md", + "2018-09-12.md", + "2018-09-26.md", + "2018-10-03.md", + "2018-10-10.md", + "2018-10-24.md", + "2018-11-04.md", + "2018-11-05.md", + "2018-11-08.md", + "2018-11-21.md", + "2018-11-28.md", + "2018-12-05.md", + "2018-12-19.md", + "2019-01-09.md", + "2019-01-16.md", + "2019-01-23.md", + "2019-02-06.md", + "2019-02-13.md", + "2019-02-27.md", + "2019-03-06.md", + "2019-03-13.md", + "2019-03-24.md", + "2019-03-25.md", + "2019-03-28.md", + "2019-04-10.md", + "2019-04-17.md", + "2019-05-01.md", + "2019-05-08.md", + "2019-05-29.md", + "2019-06-12.md", + "2019-06-26.md", + "2019-07-10.md", + "2019-07-21.md", + "2019-07-25.md", + "2019-08-07.md", + "2019-08-21.md", + "2019-08-28.md", + "2019-09-04.md", + "2019-09-18.md", + "2019-10-02.md", + "2019-10-16.md", + "2019-10-30.md", + "2019-11-17.md", + "2019-11-18.md", + "2019-11-21.md", + "2019-12-04.md", + "2019-12-11.md", + "2019-12-18.md", + "2020-01-08.md", + "2020-01-15.md", + "2020-01-22.md", + "2020-02-05.md", + "2020-02-12.md", + "2020-02-19.md", + "2020-03-04.md", + "2020-03-11.md", + "2020-03-18.md", + "2020-04-01.md", + "2020-04-08.md", + "2020-04-15.md", + "2020-04-29.md", + "2020-05-13.md", + "2020-05-20.md", + "2020-05-27.md", + "2020-06-10.md", + "2020-06-17.md", + "2020-07-01.md", + "2020-07-15.md", + "2020-08-12.md", + "2020-08-26.md", + "2020-09-09.md", + "2020-09-23.md", + "2020-10-07.md", + "2020-10-14.md", + "2020-10-21.md", + "2020-11-04.md", + "2020-12-02.md", + "2020-12-16.md", + "2021-01-06.md", + "2021-01-13.md", + "2021-01-20.md", + "2021-01-27.md", + "2021-02-03.md", + "2021-02-10.md", + "2021-02-17.md", + "2021-02-24.md", + "2021-03-03.md", + "2021-03-24.md", + "2021-03-31.md", + "2021-04-07.md", + "2021-04-14.md", + "2021-04-21.md", + "2021-05-05.md", + "2021-05-12.md", + "2021-05-19.md", + "2021-05-26.md", + "2021-06-02.md", + "2021-06-16.md", + "2021-06-23.md", + "2021-06-30.md", + "2021-07-14.md", + "2021-07-21.md", + "2021-08-11.md", + "2021-08-25.md", + "2021-09-01.md", + "2021-09-08.md", + "2021-09-22.md", + "2021-10-06.md", + "2021-10-20.md", + "2021-10-27.md", + "2021-11-17.md", + "2021-12-01.md", + "2021-12-08.md", + "2021-12-15.md", + "2022-01-12.md", + "2022-01-19.md", + "2022-02-02.md", + "2022-02-16.md", + "2022-02-23.md", + "2022-03-02.md", + "2022-03-09.md", + "2022-03-20.md", + "2022-04-06.md", + "2022-04-13.md", + "2022-04-20.md", + "2022-04-27.md", + "2022-05-04.md", + "2022-05-11.md", + "2022-06-01.md", + "2022-06-15.md", + "2022-06-22.md", + "2022-06-29.md", + "2022-07-06.md", + "2022-07-24.md", + "2022-07-26.md", + "2022-08-10.md", + "2022-08-24.md", + "2022-09-07.md", + "2022-09-21.md", + "2022-09-28.md", + "2022-10-05.md", + "2022-10-12.md", + "2022-10-26.md", + "2022-11-06.md", + "2022-11-08.md", + "2022-11-10.md", + "2022-11-23.md", + "2022-12-07.md", + "2022-12-14.md", + ] + + +class Command(BaseCommand): + help = "Performs a one-time import of older IAB agendas" + + def handle(self, *args, **options): + if Document.objects.filter(name="agenda-interim-2018-iab-26-20180905").exists(): + print("Command has already been run - exiting") + exit(0) + + tmpdir = tempfile.mkdtemp() + process = subprocess.Popen( + ["git", "clone", "https://github.com/kesara/iab-scraper.git", tmpdir], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + stdout, stderr = process.communicate() + if not Path(tmpdir).joinpath("iab_agendas", "2018-09-05.md").exists(): + print("Git clone of the iab-scraper directory did not go as expected") + print("stdout:", stdout) + print("stderr:", stderr) + print(f"Clean up {tmpdir} manually") + exit(-1) + + agendas = agendas_to_import() + for agenda in agendas: + [year, month, day] = [int(part) for part in agenda[:10].split("-")] + agenda_date = datetime.date(year, month, day) + meeting = Meeting.objects.get( + date=agenda_date, type_id="interim", session__group__acronym="iab" + ) + counter = int(meeting.number.split("-")[3]) + agenda_docname = ( + f"agenda-interim-{year}-iab-{counter:02d}-{agenda_date:%Y%m%d}" + ) + agenda_filename = f"{agenda_docname}-00.md" + # Create Document + doc = Document.objects.create( + name=agenda_docname, + type_id="agenda", + title=f"Agenda {meeting.number} {agenda_date:%Y-%m-%d}", + group_id=7, # The IAB group + rev="00", + uploaded_filename=agenda_filename, + ) + DocAlias.objects.create(name=doc.name).docs.add(doc) + e = DocEvent.objects.create( + type="comment", + doc=doc, + rev="00", + by_id=1, # The "(System)" person + desc="Agenda moved into datatracker from iab wordpress website", + ) + doc.save_with_history([e]) + + session = Session.objects.get(meeting=meeting) + # Add Document to Session + session.sessionpresentation_set.create(document=doc, rev=doc.rev) + + # Put file in place + source = Path(tmpdir).joinpath("iab_agendas", agenda) + dest = Path(settings.AGENDA_PATH).joinpath( + meeting.number, "agenda", agenda_filename + ) + if dest.exists(): + print(f"WARNING: {dest} already exists - not overwriting it.") + else: + os.makedirs(dest.parent, exist_ok=True) + shutil.copy(source, dest) + + shutil.rmtree(tmpdir) diff --git a/ietf/templates/group/meetings.html b/ietf/templates/group/meetings.html index eddf374de..a344e74d8 100644 --- a/ietf/templates/group/meetings.html +++ b/ietf/templates/group/meetings.html @@ -135,6 +135,10 @@ {% if not s.canceled %} + + Agenda + Minutes From 2bcb2c04f986ba512e590505ee8f1d9b75f5e95a Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Thu, 24 Aug 2023 15:45:17 -0300 Subject: [PATCH 02/16] chore: Fix (mostly harmless) quoting error (#6209) --- ietf/name/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/name/models.py b/ietf/name/models.py index 4eda88afd..fd6e2a6d2 100644 --- a/ietf/name/models.py +++ b/ietf/name/models.py @@ -150,4 +150,4 @@ class ExtResourceName(NameModel): class SlideSubmissionStatusName(NameModel): "Pending, Accepted, Rejected" class TelechatAgendaSectionName(NameModel): - "roll_call", "minutes", "action_items" + """roll_call, minutes, action_items""" From 16c250fa33ad650a61f3dcdd8cdb4e5ecad2addc Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 24 Aug 2023 21:46:03 +0300 Subject: [PATCH 03/16] fix: Add theme switcher to document view (#6202) * fix: Add theme switcher to document view And reduce duplication in the page structure while I'm here. Fixes #6200 * Fix tests --- ietf/static/css/document_html.scss | 43 ++++++++++++++--- ietf/static/js/theme.js | 17 ++++--- ietf/templates/doc/document_html.html | 66 ++++++++++++++++++--------- 3 files changed, 91 insertions(+), 35 deletions(-) diff --git a/ietf/static/css/document_html.scss b/ietf/static/css/document_html.scss index d35390897..d34cae4ac 100644 --- a/ietf/static/css/document_html.scss +++ b/ietf/static/css/document_html.scss @@ -1,7 +1,27 @@ @use "sass:map"; -$font-family-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; -$font-family-monospace: "Noto Sans Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; +$font-family-sans-serif: "Inter", +system-ui, +-apple-system, +"Segoe UI", +Roboto, +"Helvetica Neue", +"Noto Sans", +"Liberation Sans", +Arial, +sans-serif, +"Apple Color Emoji", +"Segoe UI Emoji", +"Segoe UI Symbol", +"Noto Color Emoji"; +$font-family-monospace: "Noto Sans Mono", +SFMono-Regular, +Menlo, +Monaco, +Consolas, +"Liberation Mono", +"Courier New", +monospace; @import "bootstrap/scss/functions"; @@ -25,7 +45,7 @@ $color-mode-type: data; @import "bootstrap/scss/forms"; @import "bootstrap/scss/buttons"; @import "bootstrap/scss/transitions"; -// @import "bootstrap/scss/dropdown"; +@import "bootstrap/scss/dropdown"; @import "bootstrap/scss/button-group"; @import "bootstrap/scss/nav"; @import "bootstrap/scss/navbar"; @@ -65,12 +85,16 @@ $color-mode-type: data; scrollbar-width: none; } -.sidebar-toggle[aria-expanded="true"] { +.sidebar-toggle[aria-expanded="true"] .sidebar-shown { display: none; } -.sidebar-toggle[aria-expanded="false"] { - display: inherit; +.sidebar-toggle[aria-expanded="false"] .sidebar-collapsed { + display: none; +} + +.sidebar-toolbar { + z-index: 1; } // Toggle classes for dark/light modes @@ -94,6 +118,11 @@ $color-mode-type: data; } } +// Show theme toggler checkbox +.dropdown-menu .active .bi { + display: block !important; +} + @media screen { @include media-breakpoint-down(md) { body { @@ -354,7 +383,7 @@ tbody.meta tr { page-break-inside: avoid; } -/* + /* a:link, a:visited { // color: inherit; diff --git a/ietf/static/js/theme.js b/ietf/static/js/theme.js index d244eec28..d10a47256 100644 --- a/ietf/static/js/theme.js +++ b/ietf/static/js/theme.js @@ -3,6 +3,7 @@ * Copyright 2011-2023 The Bootstrap Authors * Licensed under the Creative Commons Attribution 3.0 Unported License. * + * Based on the below, with some changes for the datatracker: * https://github.com/twbs/bootstrap/blob/main/site/static/docs/5.3/assets/js/color-modes.js */ @@ -45,9 +46,10 @@ // Commented-out lines are from the original bs5 js, which uses a more complicated pref dropdown. // Kept them here for easier future diffing. const themeSwitcherText = document.querySelector('#bd-theme-text') - // const activeThemeIcon = document.querySelector('.theme-icon-active use') + const activeThemeIcon = document.querySelector('.theme-icon-active') const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`) - // const svgOfActiveBtn = btnToActive.querySelector('svg use').getAttribute('href') + const iconPattern = new RegExp(/\bbi-[\w-]+\b/); + const iconOfActiveBtn = btnToActive.querySelector('i').className.match(iconPattern)[0] document.querySelectorAll('[data-bs-theme-value]').forEach(element => { element.classList.remove('active') @@ -56,10 +58,13 @@ btnToActive.classList.add('active') btnToActive.setAttribute('aria-pressed', 'true') - // activeThemeIcon.setAttribute('href', svgOfActiveBtn) - // const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` - // themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) - + if (activeThemeIcon) { + activeThemeIcon.className = activeThemeIcon.className.replace(iconPattern, iconOfActiveBtn) + } + if (themeSwitcherText) { + const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` + themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) + } if (focus) { themeSwitcher.focus() } diff --git a/ietf/templates/doc/document_html.html b/ietf/templates/doc/document_html.html index b55f385e9..b1c54ce73 100644 --- a/ietf/templates/doc/document_html.html +++ b/ietf/templates/doc/document_html.html @@ -51,17 +51,50 @@ {% analytical_body_top %} - +