Skip to content

Commit 156cbf6

Browse files
committed
Change styling to get closer to tools. Implement most of the info items.
- Legacy-Id: 18836
1 parent 7620642 commit 156cbf6

File tree

5 files changed

+87
-63
lines changed

5 files changed

+87
-63
lines changed

ietf/doc/utils.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,70 @@ def join_justified(left, right, width=72):
848848
break
849849
return lines
850850

851+
def build_file_urls(doc):
852+
if doc.get_state_slug() == "rfc":
853+
name = doc.canonical_name()
854+
base_path = os.path.join(settings.RFC_PATH, name + ".")
855+
possible_types = settings.RFC_FILE_TYPES
856+
found_types = [t for t in possible_types if os.path.exists(base_path + t)]
857+
858+
base = "https://www.rfc-editor.org/rfc/"
859+
860+
file_urls = []
861+
for t in found_types:
862+
label = "plain text" if t == "txt" else t
863+
file_urls.append((label, base + name + "." + t))
864+
865+
if "pdf" not in found_types and "txt" in found_types:
866+
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
867+
868+
if "txt" in found_types:
869+
file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name))
870+
if doc.tags.filter(slug="verified-errata").exists():
871+
file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=doc.rfc_number())))
872+
file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=name))+"bibtex"))
873+
else:
874+
base_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.name + "-" + doc.rev + ".")
875+
possible_types = settings.IDSUBMIT_FILE_TYPES
876+
found_types = [t for t in possible_types if os.path.exists(base_path + t)]
877+
base = settings.IETF_ID_ARCHIVE_URL
878+
file_urls = []
879+
for t in found_types:
880+
label = "plain text" if t == "txt" else t
881+
file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t))
882+
883+
if "pdf" not in found_types:
884+
file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf"))
885+
file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev))
886+
file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=doc.name, rev=doc.rev))))
887+
file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=doc.name,rev=doc.rev))+"bibtex"))
888+
889+
return file_urls, found_types
890+
891+
def build_doc_supermeta_block(doc):
892+
# TODO: rework all of these using f-strings
893+
894+
items = []
895+
#items.append = '[Docs]'
896+
897+
file_urls, found_types = build_file_urls(doc)
898+
file_urls = [('txt',url) if label=='plain text' else (label,url) for label,url in file_urls]
899+
900+
if file_urls:
901+
items.append('[' + '|'.join([f'<a href="{url}">{label}</a>' for label,url in file_urls if 'htmlized' not in label]) + ']')
902+
903+
items.append('[<a href="' + urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=doc.name)) + '">Tracker</a>]')
904+
if doc.group.acronym != 'none':
905+
items.append('[<a href="' + urlreverse('ietf.group.views.group_home',kwargs=dict(acronym=doc.group.acronym)) + '">WG</a>]')
906+
items.append('[<a href="mailto:' + doc.name + '@ietf.org?subject=' + doc.name + '">Email</a>]')
907+
if doc.rev != "00":
908+
items.append('[<a href="' + settings.RFCDIFF_BASE_URL + '?difftype=--hwdiff&url2=' + doc.name + '-' + doc.rev + '.txt" title="Inline diff (wdiff)">Diff1</a>]')
909+
items.append('[<a href="' + settings.RFCDIFF_BASE_URL + '?url2=' + doc.name + '-' + doc.rev + '.txt" title="Side-by-side diff">Diff2</a>]')
910+
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>]')
911+
912+
#[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>]
913+
return ' '.join(items)
914+
851915
def build_doc_meta_block(doc, path):
852916
def add_markup(path, doc, lines):
853917
is_hst = doc.is_dochistory()

ietf/doc/views_doc.py

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
6161
get_initial_notify, make_notify_changed_event, make_rev_history, default_consensus,
6262
add_events_message_info, get_unicode_document_content, build_doc_meta_block,
63-
augment_docs_and_user_with_user_info, irsg_needed_ballot_positions )
63+
augment_docs_and_user_with_user_info, irsg_needed_ballot_positions, build_doc_supermeta_block,
64+
build_file_urls )
6465
from ietf.group.models import Role, Group
6566
from ietf.group.utils import can_manage_group_type, can_manage_materials, group_features_role_filter
6667
from ietf.ietfauth.utils import ( has_role, is_authorized_in_doc_stream, user_is_person,
@@ -210,69 +211,21 @@ def document_main(request, name, rev=None):
210211

211212
latest_revision = None
212213

213-
if doc.get_state_slug() == "rfc":
214-
# content
215-
content = doc.text_or_error() # pyflakes:ignore
216-
content = markup_txt.markup(maybe_split(content, split=split_content))
217-
218-
# file types
219-
base_path = os.path.join(settings.RFC_PATH, name + ".")
220-
possible_types = settings.RFC_FILE_TYPES
221-
found_types = [t for t in possible_types if os.path.exists(base_path + t)]
222-
223-
base = "https://www.rfc-editor.org/rfc/"
224-
225-
file_urls = []
226-
for t in found_types:
227-
label = "plain text" if t == "txt" else t
228-
file_urls.append((label, base + name + "." + t))
214+
file_urls, found_types = build_file_urls(doc)
229215

230-
if "pdf" not in found_types and "txt" in found_types:
231-
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
232-
233-
if "txt" in found_types:
234-
file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name))
235-
if doc.tags.filter(slug="verified-errata").exists():
236-
file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=rfc_number)))
216+
content = doc.text_or_error() # pyflakes:ignore
217+
content = markup_txt.markup(maybe_split(content, split=split_content))
237218

219+
if doc.get_state_slug() == "rfc":
238220
if not found_types:
239221
content = "This RFC is not currently available online."
240222
split_content = False
241223
elif "txt" not in found_types:
242224
content = "This RFC is not available in plain text format."
243225
split_content = False
244226
else:
245-
content = doc.text_or_error() # pyflakes:ignore
246-
content = markup_txt.markup(maybe_split(content, split=split_content))
247-
248-
# file types
249-
base_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.name + "-" + doc.rev + ".")
250-
possible_types = settings.IDSUBMIT_FILE_TYPES
251-
found_types = [t for t in possible_types if os.path.exists(base_path + t)]
252-
253-
# if not snapshot and doc.get_state_slug() == "active":
254-
# base = settings.IETF_ID_URL
255-
# else:
256-
# base = settings.IETF_ID_ARCHIVE_URL
257-
base = settings.IETF_ID_ARCHIVE_URL
258-
259-
file_urls = []
260-
for t in found_types:
261-
label = "plain text" if t == "txt" else t
262-
file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t))
263-
264-
if "pdf" not in found_types:
265-
file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf"))
266-
#file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev))
267-
file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev))
268-
file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=doc.name, rev=doc.rev))))
269-
270-
# latest revision
271227
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
272228

273-
# bibtex
274-
file_urls.append(("bibtex", "bibtex"))
275-
276229
# ballot
277230
iesg_ballot_summary = None
278231
irsg_ballot_summary = None
@@ -717,8 +670,10 @@ def document_html(request, name, rev=None):
717670
else:
718671
doc = doc.fake_history_obj(rev)
719672
if doc.type_id in ['draft',]:
673+
doc.supermeta = build_doc_supermeta_block(doc)
720674
doc.meta = build_doc_meta_block(doc, settings.HTMLIZER_URL_PREFIX)
721675

676+
# TODO: not using top - clean put building and passing it
722677
return render(request, "doc/document_html.html", {"doc":doc, "top":top, "navbar_mode":"navbar-static-top", })
723678

724679
def check_doc_email_aliases():

ietf/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def skip_unreadable_post(record):
549549
# no slash at end
550550
IDTRACKER_BASE_URL = "https://datatracker.ietf.org"
551551
RFCDIFF_BASE_URL = "https://www.ietf.org/rfcdiff"
552+
IDNITS_BASE_URL = "https://www.ietf.org/tools/idnits"
552553

553554
# The name of the method to use to invoke the test suite
554555
TEST_RUNNER = 'ietf.utils.test_runner.IetfTestRunner'

ietf/templates/doc/document_draft.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@
652652
<a class="btn btn-default btn-xs" href="{% url "ietf.ipr.views.search" %}?submit=draft&amp;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>
653653
<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>
654654
<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>
655-
<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>
655+
<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>
656656
<div class="dropdown inline">
657657
<button class="btn btn-default btn-xs dropdown-toggle" type="button" id="ddSearchMenu" data-toggle="dropdown" aria-expanded="true">
658658
<span class="fa fa-search"></span> Search lists <span class="caret"></span>

ietf/templates/doc/document_html.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313

1414
{% block morecss %}
1515
.inline { display: inline; }
16+
.rfcmarkup pre {
17+
font-size: 10pt;
18+
font-family: courier;
19+
overflow: visible;
20+
}
21+
.rfcmarkup pre.meta-info {
22+
width: 100ex;
23+
}
1624
{% endblock %}
1725

1826
{% block title %}
@@ -27,16 +35,13 @@
2735

2836
{% block content %}
2937
{% origin %}
30-
<div class="hidden-print">
31-
{{ top | safe }}
32-
</div>
33-
34-
{# {% include "doc/revisions_list.html" %} #}
35-
<div class="col-md-2"></div>
38+
3639
<div class="col-md-8 rfcmarkup">
3740
{% if doc.meta %}
3841
<div class="hidden-print">
39-
<pre class="meta-info">{{ doc.meta|safe }}</pre>
42+
<pre class="meta-info">{{ doc.supermeta|safe }}
43+
44+
{{ doc.meta|safe }}</pre>
4045
</div>
4146
{% endif %}
4247

@@ -55,8 +60,7 @@
5560
</div>
5661

5762
</div>
58-
<div class="col-md-1"></div>
59-
<div class="col-md-1"></div>
63+
<div class="col-md-4"></div>
6064

6165
{% endblock %}
6266

0 commit comments

Comments
 (0)