Change styling to get closer to tools. Implement most of the info items.
- Legacy-Id: 18836
This commit is contained in:
parent
762064236e
commit
156cbf680e
|
@ -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'<a href="{url}">{label}</a>' for label,url in file_urls if 'htmlized' not in label]) + ']')
|
||||
|
||||
items.append('[<a href="' + urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=doc.name)) + '">Tracker</a>]')
|
||||
if doc.group.acronym != 'none':
|
||||
items.append('[<a href="' + urlreverse('ietf.group.views.group_home',kwargs=dict(acronym=doc.group.acronym)) + '">WG</a>]')
|
||||
items.append('[<a href="mailto:' + doc.name + '@ietf.org?subject=' + doc.name + '">Email</a>]')
|
||||
if doc.rev != "00":
|
||||
items.append('[<a href="' + settings.RFCDIFF_BASE_URL + '?difftype=--hwdiff&url2=' + doc.name + '-' + doc.rev + '.txt" title="Inline diff (wdiff)">Diff1</a>]')
|
||||
items.append('[<a href="' + settings.RFCDIFF_BASE_URL + '?url2=' + doc.name + '-' + doc.rev + '.txt" title="Side-by-side diff">Diff2</a>]')
|
||||
items.append('[<a href="' + settings.IDNITS_BASE_URL + '?url=' + settings.IETF_ID_ARCHIVE_URL + doc.name + '-' + doc.rev + '.txt" title="Run an idnits check of this document">Nits</a>]')
|
||||
|
||||
#[Docs] [formats] [<a href="{% url 'ietf.doc.views_doc.document_main' name=doc.name %}">Tracker</a>]{% if doc.group.acronym != 'none' %} [<a href="{% url 'ietf.group.views.group_home' acronym=doc.group.acronym %}">WG</a>]{% endif%} [<a href="mailto:{{doc.name}}@ietf.org?subject={{doc.name}} ">Email</a>] [<a href="{{settings.RFCDIFF_BASE_URL}}?difftype=--hwdiff&url2={{doc.name}}-{{doc.rev}}.txt" title="Inline diff (wdiff)">Diff1</a>]{% if doc.rev != "00" %} [<a href="{{settings.RFCDIFF_BASE_URL}}?url2={{doc.name}}-{{doc.rev}}.txt" title="Side-by-side diff">Diff2</a>]{% endif %} [<a href="{{settings.IDNITS_BASE_URL}}?url={{settings.IETF_ID_ARCHIVE_URL}}{{doc.name}}-{{doc.rev}}.txt" title="Run an idnits check of this document">Nits</a>]
|
||||
return ' '.join(items)
|
||||
|
||||
def build_doc_meta_block(doc, path):
|
||||
def add_markup(path, doc, lines):
|
||||
is_hst = doc.is_dochistory()
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -652,7 +652,7 @@
|
|||
<a class="btn btn-default btn-xs" href="{% url "ietf.ipr.views.search" %}?submit=draft&id={{ doc.name }}" rel="nofollow"><span class="fa fa-bolt"></span> IPR {% if doc.related_ipr %} <span class="badge">{{doc.related_ipr|length}}</span>{% endif %}</a>
|
||||
<a class="btn btn-default btn-xs" href="{% url 'ietf.doc.views_doc.document_references' doc.canonical_name %}" rel="nofollow"><span class="fa fa-long-arrow-left"></span> References</a>
|
||||
<a class="btn btn-default btn-xs" href="{% url 'ietf.doc.views_doc.document_referenced_by' doc.canonical_name %}" rel="nofollow"><span class="fa fa-long-arrow-right"></span> Referenced by</a>
|
||||
<a class="btn btn-default btn-xs" href="https://www.ietf.org/tools/idnits?url=https://www.ietf.org/archive/id/{{ doc.filename_with_rev }}" rel="nofollow" target="_blank"><span class="fa fa-exclamation"></span> Nits</a>
|
||||
<a class="btn btn-default btn-xs" href="{{settings.IDNITS_BASE_URL}}?url=https://www.ietf.org/archive/id/{{ doc.filename_with_rev }}" rel="nofollow" target="_blank"><span class="fa fa-exclamation"></span> Nits</a>
|
||||
<div class="dropdown inline">
|
||||
<button class="btn btn-default btn-xs dropdown-toggle" type="button" id="ddSearchMenu" data-toggle="dropdown" aria-expanded="true">
|
||||
<span class="fa fa-search"></span> Search lists <span class="caret"></span>
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
|
||||
{% block morecss %}
|
||||
.inline { display: inline; }
|
||||
.rfcmarkup pre {
|
||||
font-size: 10pt;
|
||||
font-family: courier;
|
||||
overflow: visible;
|
||||
}
|
||||
.rfcmarkup pre.meta-info {
|
||||
width: 100ex;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
|
@ -27,16 +35,13 @@
|
|||
|
||||
{% block content %}
|
||||
{% origin %}
|
||||
<div class="hidden-print">
|
||||
{{ top | safe }}
|
||||
</div>
|
||||
|
||||
{# {% include "doc/revisions_list.html" %} #}
|
||||
<div class="col-md-2"></div>
|
||||
|
||||
<div class="col-md-8 rfcmarkup">
|
||||
{% if doc.meta %}
|
||||
<div class="hidden-print">
|
||||
<pre class="meta-info">{{ doc.meta|safe }}</pre>
|
||||
<pre class="meta-info">{{ doc.supermeta|safe }}
|
||||
|
||||
{{ doc.meta|safe }}</pre>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -55,8 +60,7 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-4"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue