From 156cbf680e4390344331f53a3492fb30a8e22601 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Tue, 16 Feb 2021 22:41:31 +0000 Subject: [PATCH] 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 %}