From f5507daef13e69629943fe1559d7bb6d8745a101 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Mon, 23 Oct 2023 18:55:31 +0300 Subject: [PATCH 1/3] feat: Render markdown agendas with bs5 styles So that the look is consistent with the rest of the datatracker. --- ietf/meeting/views.py | 25 ++++++++++++++++--------- ietf/static/css/ietf.scss | 2 +- ietf/templates/base.html | 2 +- ietf/templates/minimal.html | 21 +++++++++++++++++++++ 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 ietf/templates/minimal.html diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py index c23569f0b..fe12e3faa 100644 --- a/ietf/meeting/views.py +++ b/ietf/meeting/views.py @@ -279,15 +279,22 @@ def materials_document(request, document, num=None, ext=None): if len(file_ext) == 2 and file_ext[1] == '.md' and mtype == 'text/plain': sorted_accept = sort_accept_tuple(request.META.get('HTTP_ACCEPT')) for atype in sorted_accept: - if atype[0] == 'text/markdown': - content_type = content_type.replace('plain', 'markdown', 1) - break; - elif atype[0] == 'text/html': - bytes = "\n\n\n%s\n\n\n" % markdown.markdown(bytes.decode(encoding=chset)) - content_type = content_type.replace('plain', 'html', 1) - break; - elif atype[0] == 'text/plain': - break; + if atype[0] == "text/markdown": + content_type = content_type.replace("plain", "markdown", 1) + break + elif atype[0] == "text/html": + bytes = render( + request, + "minimal.html", + { + "content": markdown.markdown(bytes.decode(encoding=chset)), + "title": basename, + }, + ) + content_type = content_type.replace("plain", "html", 1) + break + elif atype[0] == "text/plain": + break response = HttpResponse(bytes, content_type=content_type) response['Content-Disposition'] = 'inline; filename="%s"' % basename diff --git a/ietf/static/css/ietf.scss b/ietf/static/css/ietf.scss index 06a0de80b..3c6e891e2 100644 --- a/ietf/static/css/ietf.scss +++ b/ietf/static/css/ietf.scss @@ -99,7 +99,7 @@ url("npm:bootstrap-icons/font/fonts/bootstrap-icons.woff") format("woff"); @import "bootstrap-icons/font/bootstrap-icons"; // Leave room for fixed-top navbar... -body { +body.navbar-offset { padding-top: 60px; } diff --git a/ietf/templates/base.html b/ietf/templates/base.html index 77a2fa9d9..19ed04369 100644 --- a/ietf/templates/base.html +++ b/ietf/templates/base.html @@ -31,7 +31,7 @@ {% analytical_head_bottom %} - {% analytical_body_top %} Skip to main content diff --git a/ietf/templates/minimal.html b/ietf/templates/minimal.html new file mode 100644 index 000000000..d341fed5a --- /dev/null +++ b/ietf/templates/minimal.html @@ -0,0 +1,21 @@ +{# Copyright The IETF Trust 2015-2023, All Rights Reserved #} + +{% load static %} +{% load origin %} +{% origin %} + + + + + {{ title }} + + + + + {# load this in the head, to prevent flickering #} + + + + {{ content }} + + \ No newline at end of file From fd03ab13d767f0f49a01a4207230711bd59daff8 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Mon, 23 Oct 2023 17:44:12 -0700 Subject: [PATCH 2/3] Small fixes --- ietf/templates/base.html | 2 +- ietf/templates/minimal.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ietf/templates/base.html b/ietf/templates/base.html index 19ed04369..bc315dd56 100644 --- a/ietf/templates/base.html +++ b/ietf/templates/base.html @@ -31,7 +31,7 @@ {% analytical_head_bottom %} - {% analytical_body_top %} Skip to main content diff --git a/ietf/templates/minimal.html b/ietf/templates/minimal.html index d341fed5a..87f661f50 100644 --- a/ietf/templates/minimal.html +++ b/ietf/templates/minimal.html @@ -15,7 +15,7 @@ {# load this in the head, to prevent flickering #} - + {{ content }} \ No newline at end of file From d246879069f161e011c0e9dc18c8116af65effd0 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 27 Oct 2023 17:29:09 -0700 Subject: [PATCH 3/3] Fix code review comments --- ietf/meeting/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py index fe12e3faa..3e7b89d58 100644 --- a/ietf/meeting/views.py +++ b/ietf/meeting/views.py @@ -283,8 +283,7 @@ def materials_document(request, document, num=None, ext=None): content_type = content_type.replace("plain", "markdown", 1) break elif atype[0] == "text/html": - bytes = render( - request, + bytes = render_to_string( "minimal.html", { "content": markdown.markdown(bytes.decode(encoding=chset)),