From 156cbf680e4390344331f53a3492fb30a8e22601 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Tue, 16 Feb 2021 22:41:31 +0000 Subject: [PATCH 1/5] Change styling to get closer to tools. Implement most of the info items. - Legacy-Id: 18836 --- ietf/doc/utils.py | 64 ++++++++++++++++++++++++++ ietf/doc/views_doc.py | 63 ++++--------------------- ietf/settings.py | 1 + ietf/templates/doc/document_draft.html | 2 +- ietf/templates/doc/document_html.html | 22 +++++---- 5 files changed, 88 insertions(+), 64 deletions(-) diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index 055e16876..dbc8011c1 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -848,6 +848,70 @@ def join_justified(left, right, width=72): break return lines +def build_file_urls(doc): + if doc.get_state_slug() == "rfc": + name = doc.canonical_name() + base_path = os.path.join(settings.RFC_PATH, name + ".") + possible_types = settings.RFC_FILE_TYPES + found_types = [t for t in possible_types if os.path.exists(base_path + t)] + + base = "https://www.rfc-editor.org/rfc/" + + file_urls = [] + for t in found_types: + label = "plain text" if t == "txt" else t + file_urls.append((label, base + name + "." + t)) + + if "pdf" not in found_types and "txt" in found_types: + file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf")) + + if "txt" in found_types: + file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name)) + if doc.tags.filter(slug="verified-errata").exists(): + file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=doc.rfc_number()))) + file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=name))+"bibtex")) + else: + base_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.name + "-" + doc.rev + ".") + possible_types = settings.IDSUBMIT_FILE_TYPES + found_types = [t for t in possible_types if os.path.exists(base_path + t)] + base = settings.IETF_ID_ARCHIVE_URL + file_urls = [] + for t in found_types: + label = "plain text" if t == "txt" else t + file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t)) + + if "pdf" not in found_types: + file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf")) + file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev)) + file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=doc.name, rev=doc.rev)))) + file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=doc.name,rev=doc.rev))+"bibtex")) + + return file_urls, found_types + +def build_doc_supermeta_block(doc): + # TODO: rework all of these using f-strings + + items = [] + #items.append = '[Docs]' + + file_urls, found_types = build_file_urls(doc) + file_urls = [('txt',url) if label=='plain text' else (label,url) for label,url in file_urls] + + if file_urls: + items.append('[' + '|'.join([f'{label}' for label,url in file_urls if 'htmlized' not in label]) + ']') + + items.append('[Tracker]') + if doc.group.acronym != 'none': + items.append('[WG]') + items.append('[Email]') + if doc.rev != "00": + items.append('[Diff1]') + items.append('[Diff2]') + items.append('[Nits]') + + #[Docs] [formats] [Tracker]{% if doc.group.acronym != 'none' %} [WG]{% endif%} [Email] [Diff1]{% if doc.rev != "00" %} [Diff2]{% endif %} [Nits] + return ' '.join(items) + def build_doc_meta_block(doc, path): def add_markup(path, doc, lines): is_hst = doc.is_dochistory() diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 3a32a5f19..172095d6b 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -60,7 +60,8 @@ from ietf.doc.utils import (add_links_in_new_revision_events, augment_events_wit needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot, get_initial_notify, make_notify_changed_event, make_rev_history, default_consensus, add_events_message_info, get_unicode_document_content, build_doc_meta_block, - augment_docs_and_user_with_user_info, irsg_needed_ballot_positions ) + augment_docs_and_user_with_user_info, irsg_needed_ballot_positions, build_doc_supermeta_block, + build_file_urls ) from ietf.group.models import Role, Group from ietf.group.utils import can_manage_group_type, can_manage_materials, group_features_role_filter from ietf.ietfauth.utils import ( has_role, is_authorized_in_doc_stream, user_is_person, @@ -210,31 +211,12 @@ def document_main(request, name, rev=None): latest_revision = None + file_urls, found_types = build_file_urls(doc) + + content = doc.text_or_error() # pyflakes:ignore + content = markup_txt.markup(maybe_split(content, split=split_content)) + if doc.get_state_slug() == "rfc": - # content - content = doc.text_or_error() # pyflakes:ignore - content = markup_txt.markup(maybe_split(content, split=split_content)) - - # file types - base_path = os.path.join(settings.RFC_PATH, name + ".") - possible_types = settings.RFC_FILE_TYPES - found_types = [t for t in possible_types if os.path.exists(base_path + t)] - - base = "https://www.rfc-editor.org/rfc/" - - file_urls = [] - for t in found_types: - label = "plain text" if t == "txt" else t - file_urls.append((label, base + name + "." + t)) - - if "pdf" not in found_types and "txt" in found_types: - file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf")) - - if "txt" in found_types: - file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name)) - if doc.tags.filter(slug="verified-errata").exists(): - file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=rfc_number))) - if not found_types: content = "This RFC is not currently available online." split_content = False @@ -242,37 +224,8 @@ def document_main(request, name, rev=None): content = "This RFC is not available in plain text format." split_content = False else: - content = doc.text_or_error() # pyflakes:ignore - content = markup_txt.markup(maybe_split(content, split=split_content)) - - # file types - base_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.name + "-" + doc.rev + ".") - possible_types = settings.IDSUBMIT_FILE_TYPES - found_types = [t for t in possible_types if os.path.exists(base_path + t)] - - # if not snapshot and doc.get_state_slug() == "active": - # base = settings.IETF_ID_URL - # else: - # base = settings.IETF_ID_ARCHIVE_URL - base = settings.IETF_ID_ARCHIVE_URL - - file_urls = [] - for t in found_types: - label = "plain text" if t == "txt" else t - file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t)) - - if "pdf" not in found_types: - file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf")) - #file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev)) - file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev)) - file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=doc.name, rev=doc.rev)))) - - # latest revision latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision") - # bibtex - file_urls.append(("bibtex", "bibtex")) - # ballot iesg_ballot_summary = None irsg_ballot_summary = None @@ -717,8 +670,10 @@ def document_html(request, name, rev=None): else: doc = doc.fake_history_obj(rev) if doc.type_id in ['draft',]: + doc.supermeta = build_doc_supermeta_block(doc) doc.meta = build_doc_meta_block(doc, settings.HTMLIZER_URL_PREFIX) + # TODO: not using top - clean put building and passing it return render(request, "doc/document_html.html", {"doc":doc, "top":top, "navbar_mode":"navbar-static-top", }) def check_doc_email_aliases(): diff --git a/ietf/settings.py b/ietf/settings.py index e5ca7c9a6..65f034c8c 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -549,6 +549,7 @@ INTERNAL_IPS = ( # no slash at end IDTRACKER_BASE_URL = "https://datatracker.ietf.org" RFCDIFF_BASE_URL = "https://www.ietf.org/rfcdiff" +IDNITS_BASE_URL = "https://www.ietf.org/tools/idnits" # The name of the method to use to invoke the test suite TEST_RUNNER = 'ietf.utils.test_runner.IetfTestRunner' diff --git a/ietf/templates/doc/document_draft.html b/ietf/templates/doc/document_draft.html index e051366a3..6af5417bf 100644 --- a/ietf/templates/doc/document_draft.html +++ b/ietf/templates/doc/document_draft.html @@ -652,7 +652,7 @@ IPR {% if doc.related_ipr %} {{doc.related_ipr|length}}{% endif %} References Referenced by - Nits + Nits -
-
+
{% endblock %} From fc6579c7123be9d539ab9f2c0063dac0ce99a607 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Tue, 23 Feb 2021 23:16:07 +0000 Subject: [PATCH 2/5] Remove datatracker menu, simplify the base, and focus primarily on styling for just this page. Add the colorbar and tooltips. - Legacy-Id: 18861 --- ietf/doc/utils.py | 33 +++-- ietf/doc/views_doc.py | 23 +++- ietf/templates/doc/document_html.html | 105 +++++++++++---- ietf/templates/doc/htmlized_base.html | 177 ++++++++++++++++++++++++++ 4 files changed, 299 insertions(+), 39 deletions(-) create mode 100644 ietf/templates/doc/htmlized_base.html diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index dbc8011c1..8e72b415a 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -889,27 +889,38 @@ def build_file_urls(doc): return file_urls, found_types def build_doc_supermeta_block(doc): - # TODO: rework all of these using f-strings - items = [] - #items.append = '[Docs]' + items.append(f'[Search]') file_urls, found_types = build_file_urls(doc) file_urls = [('txt',url) if label=='plain text' else (label,url) for label,url in file_urls] if file_urls: - items.append('[' + '|'.join([f'{label}' for label,url in file_urls if 'htmlized' not in label]) + ']') + file_labels = { + 'txt' : 'Plaintext version of this document', + 'xml' : 'XML source for this document', + 'pdf' : 'PDF version of this document', + 'html' : 'HTML version of this document, from XML2RFC', + 'bibtex' : 'BibTex entry for this document', + } + parts=[] + for label,url in file_urls: + if 'htmlized' not in label: + file_label=file_labels.get(label,'') + title_attribute = f' title="{file_label}"' if file_label else '' + partstring = f'{label}' + parts.append(partstring) + items.append('[' + '|'.join(parts) + ']') - items.append('[Tracker]') + items.append(f'[Tracker]') if doc.group.acronym != 'none': - items.append('[WG]') - items.append('[Email]') + items.append(f'[WG]') + items.append(f'[Email]') if doc.rev != "00": - items.append('[Diff1]') - items.append('[Diff2]') - items.append('[Nits]') + items.append(f'[Diff1]') + items.append(f'[Diff2]') + items.append(f'[Nits]') - #[Docs] [formats] [Tracker]{% if doc.group.acronym != 'none' %} [WG]{% endif%} [Email] [Diff1]{% if doc.rev != "00" %} [Diff2]{% endif %} [Nits] return ' '.join(items) def build_doc_meta_block(doc, path): diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 172095d6b..8123d8f3e 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -660,7 +660,6 @@ def document_html(request, name, rev=None): if not os.path.exists(doc.get_file_name()): raise Http404("File not found: %s" % doc.get_file_name()) - top = render_document_top(request, doc, "status", name) if not rev and not name.startswith('rfc'): rev = doc.rev if rev: @@ -673,8 +672,26 @@ def document_html(request, name, rev=None): doc.supermeta = build_doc_supermeta_block(doc) doc.meta = build_doc_meta_block(doc, settings.HTMLIZER_URL_PREFIX) - # TODO: not using top - clean put building and passing it - return render(request, "doc/document_html.html", {"doc":doc, "top":top, "navbar_mode":"navbar-static-top", }) + doccolor = 'bgwhite' # Unknown + if doc.type_id=='draft': + if doc.is_rfc(): + if doc.related_that('obs'): + doccolor = 'bgbrown' + else: + doccolor = { + 'ps' : 'bgblue', + 'exp' : 'bgyellow', + 'inf' : 'bgorange', + 'ds' : 'bgcyan', + 'hist' : 'bggrey', + 'std' : 'bggreen', + 'bcp' : 'bgmagenta', + 'unkn' : 'bgwhite', + }.get(doc.std_level_id, 'bgwhite') + else: + doccolor = 'bgred' # Draft + + return render(request, "doc/document_html.html", {"doc":doc, "doccolor":doccolor }) def check_doc_email_aliases(): pattern = re.compile(r'^expand-(.*?)(\..*?)?@.*? +(.*)$') diff --git a/ietf/templates/doc/document_html.html b/ietf/templates/doc/document_html.html index 4e7fcca7f..4154ac1e5 100644 --- a/ietf/templates/doc/document_html.html +++ b/ietf/templates/doc/document_html.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "doc/htmlized_base.html" %} {# Copyright The IETF Trust 2016, All Rights Reserved #} {% load origin %} {% load static %} @@ -12,15 +12,28 @@ {% endblock %} {% block morecss %} -.inline { display: inline; } -.rfcmarkup pre { - font-size: 10pt; - font-family: courier; - overflow: visible; -} -.rfcmarkup pre.meta-info { - width: 100ex; + +.bgwhite { background-color: white; } +.bgred { background-color: #F44; } +.bggrey { background-color: #666; } +.bgbrown { background-color: #840; } +.bgorange { background-color: #FA0; } +.bgyellow { background-color: #EE0; } +.bgmagenta{ background-color: #F4F; } +.bgblue { background-color: #66F; } +.bgcyan { background-color: #4DD; } +.bggreen { background-color: #4F4; } + +.colorbar { + height: 6px; + position: absolute; + width: 100%; + margin-left:-0.5em; + margin-bottom:0; } + +.draftcontent { margin-top:0px !important;} + {% endblock %} {% block title %} @@ -36,34 +49,76 @@ {% block content %} {% origin %} -
+
+
+
+ +
+ {% if doc.meta %} -
+
{{ doc.supermeta|safe }}
 
 {{ doc.meta|safe }}
{% endif %} - {% comment %} - {% if doc.is_dochistory %} - {% if doc.rev != doc.doc.rev %} -
A newer version of the document below exists
- {% elif doc.doc.is_rfc %} -
The draft below has been published as RFC {{doc.doc.rfc_number}}
- {% endif %} - {% endif %} - {% endcomment %} - -
+
{{ doc.htmlized|default:"Generation of htmlized text failed"|safe }}
-
+
{% endblock %} -{% block footer %} -
+{% block js %} + {% endblock %} diff --git a/ietf/templates/doc/htmlized_base.html b/ietf/templates/doc/htmlized_base.html new file mode 100644 index 000000000..f34e8bc77 --- /dev/null +++ b/ietf/templates/doc/htmlized_base.html @@ -0,0 +1,177 @@ + {% load ietf_filters static %} +{# Copyright The IETF Trust 2021, All Rights Reserved #} +{% load origin %}{% origin %} +{% load bootstrap3 %} + + + + + {% block title %}No title{% endblock %} + + + + + + + + + + + {% if debug %} + + {% endif %} + + + + {% block pagehead %}{% endblock %} + + {% if server_mode and server_mode == "production" %} + + {% else %} + + {% endif %} + + + + + +
+ {% comment %} {% bootstrap_messages %} {% endcomment %} + {% for message in messages %} +
{{ message }}
+ {% endfor %} +
+ {% block content %}{{ content|safe }}{% endblock %} + {% block content_end %}{% endblock %} +
+ + {% block footer %} + + {% endblock %} + +
+ + {% include "debug.html" %} + + + {% comment %} + + + {% endcomment %} + + + + + {% block js %}{% endblock %} + {% if debug %} + + {% endif %} + + + From 2421e41f3faa7a44b54e27c0c4e8131570fa5f38 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 24 Feb 2021 18:26:45 +0000 Subject: [PATCH 3/5] Minor tweaks - Legacy-Id: 18863 --- ietf/doc/utils.py | 2 +- ietf/templates/doc/document_html.html | 2 +- ietf/templates/doc/htmlized_base.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index 8e72b415a..783e52162 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -890,7 +890,7 @@ def build_file_urls(doc): def build_doc_supermeta_block(doc): items = [] - items.append(f'[Search]') + items.append(f'[Search]') file_urls, found_types = build_file_urls(doc) file_urls = [('txt',url) if label=='plain text' else (label,url) for label,url in file_urls] diff --git a/ietf/templates/doc/document_html.html b/ietf/templates/doc/document_html.html index 4154ac1e5..2f5d58a0d 100644 --- a/ietf/templates/doc/document_html.html +++ b/ietf/templates/doc/document_html.html @@ -27,7 +27,7 @@ .colorbar { height: 6px; position: absolute; - width: 100%; + width: 80ex; margin-left:-0.5em; margin-bottom:0; } diff --git a/ietf/templates/doc/htmlized_base.html b/ietf/templates/doc/htmlized_base.html index f34e8bc77..9d1a5def8 100644 --- a/ietf/templates/doc/htmlized_base.html +++ b/ietf/templates/doc/htmlized_base.html @@ -69,7 +69,7 @@ margin-left: -0.5em; background-color: #f8f8f8; border: 1px solid #e0e0e0; - width: 100%; + width: 98.5ex; padding-top: 0; } From ae4c2d1fca283c6569d86a652e1b8fb6b96d243f Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 24 Feb 2021 19:10:23 +0000 Subject: [PATCH 4/5] Updated test (minor) to match changes in generation of page - Legacy-Id: 18864 --- ietf/doc/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index ec6546618..afdd714d9 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -672,7 +672,7 @@ Man Expires September 22, 2015 [Page 3] q = PyQuery(r.content) self.assertEqual(len(q('.rfcmarkup pre')), 4) self.assertEqual(len(q('.rfcmarkup span.h1')), 2) - self.assertEqual(len(q('.rfcmarkup a[href]')), 31) + self.assertEqual(len(q('.rfcmarkup a[href]')), 41) r = self.client.get(urlreverse("ietf.doc.views_doc.document_html", kwargs=dict(name=draft.name, rev=draft.rev))) self.assertEqual(r.status_code, 200) From 1781f53626e568ddbc0d4391644161586572c923 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Thu, 25 Feb 2021 21:44:25 +0000 Subject: [PATCH 5/5] De-bootstrapped the page - simplified the styling. - Legacy-Id: 18865 --- ietf/templates/doc/document_html.html | 29 ++-- ietf/templates/doc/htmlized_base.html | 232 ++++++++++++-------------- 2 files changed, 118 insertions(+), 143 deletions(-) diff --git a/ietf/templates/doc/document_html.html b/ietf/templates/doc/document_html.html index 2f5d58a0d..da692403c 100644 --- a/ietf/templates/doc/document_html.html +++ b/ietf/templates/doc/document_html.html @@ -24,14 +24,6 @@ .bgcyan { background-color: #4DD; } .bggreen { background-color: #4F4; } -.colorbar { - height: 6px; - position: absolute; - width: 80ex; - margin-left:-0.5em; - margin-bottom:0; -} - .draftcontent { margin-top:0px !important;} {% endblock %} @@ -44,21 +36,21 @@ {% endif %} {% endblock %} -{% block bodyAttrs %}style="padding-top: 0;"{% endblock %} +{% block bodyAttrs %}onload="addHeaderTags()" style="padding-top: 0;"{% endblock %} {% block content %} {% origin %} -
-
+
+
+ style="height: 6px; min-height: 6px; width: 96ex; position: absolute; margin-top:0; " + class="meta-info {{doccolor}}" + title="Click for colour legend." > 
{% if doc.meta %} -
-
{{ doc.supermeta|safe }}
+      
+
{{ doc.supermeta|safe }}
 
 {{ doc.meta|safe }}
{% endif %} -
+
{{ doc.htmlized|default:"Generation of htmlized text failed"|safe }}
-
{% endblock %} diff --git a/ietf/templates/doc/htmlized_base.html b/ietf/templates/doc/htmlized_base.html index 9d1a5def8..f602cdada 100644 --- a/ietf/templates/doc/htmlized_base.html +++ b/ietf/templates/doc/htmlized_base.html @@ -1,127 +1,124 @@ {% load ietf_filters static %} {# Copyright The IETF Trust 2021, All Rights Reserved #} {% load origin %}{% origin %} -{% load bootstrap3 %} {% block title %}No title{% endblock %} - - - - - - - - - - {% if debug %} - - {% endif %} @@ -141,12 +138,7 @@ -
- {% comment %} {% bootstrap_messages %} {% endcomment %} - {% for message in messages %} -
{{ message }}
- {% endfor %} -
+
{% block content %}{{ content|safe }}{% endblock %} {% block content_end %}{% endblock %}
@@ -155,23 +147,15 @@ {% endblock %} -
+
- {% include "debug.html" %} - - {% comment %} {% endcomment %} - - {% block js %}{% endblock %} - {% if debug %} - - {% endif %}