Skip to content

Commit fc6579c

Browse files
committed
Remove datatracker menu, simplify the base, and focus primarily on styling for just this page. Add the colorbar and tooltips.
- Legacy-Id: 18861
1 parent 156cbf6 commit fc6579c

4 files changed

Lines changed: 300 additions & 40 deletions

File tree

ietf/doc/utils.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -889,27 +889,38 @@ def build_file_urls(doc):
889889
return file_urls, found_types
890890

891891
def build_doc_supermeta_block(doc):
892-
# TODO: rework all of these using f-strings
893-
894892
items = []
895-
#items.append = '[Docs]'
893+
items.append(f'<a href="{ settings.IDTRACKER_BASE_URL }" title="Document search and retrieval page">[Search]</a>')
896894

897895
file_urls, found_types = build_file_urls(doc)
898896
file_urls = [('txt',url) if label=='plain text' else (label,url) for label,url in file_urls]
899897

900898
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>]')
899+
file_labels = {
900+
'txt' : 'Plaintext version of this document',
901+
'xml' : 'XML source for this document',
902+
'pdf' : 'PDF version of this document',
903+
'html' : 'HTML version of this document, from XML2RFC',
904+
'bibtex' : 'BibTex entry for this document',
905+
}
906+
parts=[]
907+
for label,url in file_urls:
908+
if 'htmlized' not in label:
909+
file_label=file_labels.get(label,'')
910+
title_attribute = f' title="{file_label}"' if file_label else ''
911+
partstring = f'<a href="{url}"{title_attribute}>{label}</a>'
912+
parts.append(partstring)
913+
items.append('[' + '|'.join(parts) + ']')
914+
915+
items.append(f'[<a href="{ urlreverse("ietf.doc.views_doc.document_main",kwargs=dict(name=doc.canonical_name())) }" title="Datatracker information for this document">Tracker</a>]')
904916
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>]')
917+
items.append(f'[<a href="{urlreverse("ietf.group.views.group_home",kwargs=dict(acronym=doc.group.acronym))}" title="The working group handling this document">WG</a>]')
918+
items.append(f'[<a href="mailto:{doc.name}@ietf.org?subject={doc.name}" title="Send email to the document authors">Email</a>]')
907919
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>]')
920+
items.append(f'[<a href="{settings.RFCDIFF_BASE_URL}?difftype=--hwdiff&url2={doc.name}-{doc.rev}.txt" title="Inline diff (wdiff)">Diff1</a>]')
921+
items.append(f'[<a href="{settings.RFCDIFF_BASE_URL}?url2={doc.name}-{doc.rev}.txt" title="Side-by-side diff">Diff2</a>]')
922+
items.append(f'[<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>]')
911923

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>]
913924
return ' '.join(items)
914925

915926
def build_doc_meta_block(doc, path):

ietf/doc/views_doc.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ def document_html(request, name, rev=None):
660660
if not os.path.exists(doc.get_file_name()):
661661
raise Http404("File not found: %s" % doc.get_file_name())
662662

663-
top = render_document_top(request, doc, "status", name)
664663
if not rev and not name.startswith('rfc'):
665664
rev = doc.rev
666665
if rev:
@@ -673,8 +672,26 @@ def document_html(request, name, rev=None):
673672
doc.supermeta = build_doc_supermeta_block(doc)
674673
doc.meta = build_doc_meta_block(doc, settings.HTMLIZER_URL_PREFIX)
675674

676-
# TODO: not using top - clean put building and passing it
677-
return render(request, "doc/document_html.html", {"doc":doc, "top":top, "navbar_mode":"navbar-static-top", })
675+
doccolor = 'bgwhite' # Unknown
676+
if doc.type_id=='draft':
677+
if doc.is_rfc():
678+
if doc.related_that('obs'):
679+
doccolor = 'bgbrown'
680+
else:
681+
doccolor = {
682+
'ps' : 'bgblue',
683+
'exp' : 'bgyellow',
684+
'inf' : 'bgorange',
685+
'ds' : 'bgcyan',
686+
'hist' : 'bggrey',
687+
'std' : 'bggreen',
688+
'bcp' : 'bgmagenta',
689+
'unkn' : 'bgwhite',
690+
}.get(doc.std_level_id, 'bgwhite')
691+
else:
692+
doccolor = 'bgred' # Draft
693+
694+
return render(request, "doc/document_html.html", {"doc":doc, "doccolor":doccolor })
678695

679696
def check_doc_email_aliases():
680697
pattern = re.compile(r'^expand-(.*?)(\..*?)?@.*? +(.*)$')
Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "base.html" %}
1+
{% extends "doc/htmlized_base.html" %}
22
{# Copyright The IETF Trust 2016, All Rights Reserved #}
33
{% load origin %}
44
{% load static %}
@@ -12,15 +12,28 @@
1212
{% endblock %}
1313

1414
{% block morecss %}
15-
.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;
15+
16+
.bgwhite { background-color: white; }
17+
.bgred { background-color: #F44; }
18+
.bggrey { background-color: #666; }
19+
.bgbrown { background-color: #840; }
20+
.bgorange { background-color: #FA0; }
21+
.bgyellow { background-color: #EE0; }
22+
.bgmagenta{ background-color: #F4F; }
23+
.bgblue { background-color: #66F; }
24+
.bgcyan { background-color: #4DD; }
25+
.bggreen { background-color: #4F4; }
26+
27+
.colorbar {
28+
height: 6px;
29+
position: absolute;
30+
width: 100%;
31+
margin-left:-0.5em;
32+
margin-bottom:0;
2333
}
34+
35+
.draftcontent { margin-top:0px !important;}
36+
2437
{% endblock %}
2538

2639
{% block title %}
@@ -36,34 +49,76 @@
3649
{% block content %}
3750
{% origin %}
3851

39-
<div class="col-md-8 rfcmarkup">
52+
<div class="col-md-6 rfcmarkup">
53+
<div class="row" style="height: 0px; margin-top:0;">
54+
<div onmouseover="this.style.cursor='pointer';"
55+
onclick="showElem('legend');"
56+
onmouseout="hideElem('legend')"
57+
style="height: 6px; position: absolute; margin-top:0; "
58+
class="colorbar {{doccolor}}"
59+
title="Click for colour legend." ></div>
60+
<div id="legend"
61+
class="docinfo noprint pre legend"
62+
style="position:absolute; top: 4px; left: 4ex; visibility:hidden; background-color: white; padding: 4px 9px 5px 7px; border: solid #345 1px; "
63+
onmouseover="showElem('legend');"
64+
onmouseout="hideElem('legend');">
65+
</div>
66+
</div>
67+
4068
{% if doc.meta %}
41-
<div class="hidden-print">
69+
<div class="row hidden-print" style="margin-top:6px;">
4270
<pre class="meta-info">{{ doc.supermeta|safe }}
4371

4472
{{ doc.meta|safe }}</pre>
4573
</div>
4674
{% endif %}
4775

48-
{% comment %}
49-
{% if doc.is_dochistory %}
50-
{% if doc.rev != doc.doc.rev %}
51-
<pre class="meta-info alert-warning text-center">A newer version of the document below exists</pre>
52-
{% elif doc.doc.is_rfc %}
53-
<pre class="meta-info alert-info text-center">The draft below has been published as <a href="{% url 'ietf.doc.views_doc.document_html' name=doc.doc.canonical_name %}">RFC {{doc.doc.rfc_number}}</a></pre>
54-
{% endif %}
55-
{% endif %}
56-
{% endcomment %}
57-
58-
<div>
76+
<div class="row draftcontent">
5977
{{ doc.htmlized|default:"Generation of htmlized text failed"|safe }}
6078
</div>
6179

6280
</div>
63-
<div class="col-md-4"></div>
81+
<div class="col-md-6"></div>
6482

6583
{% endblock %}
6684

67-
{% block footer %}
68-
<div></div>
85+
{% block js %}
86+
<script type="text/javascript"><!--
87+
function addHeaderTags() {
88+
var spans = document.getElementsByTagName("span");
89+
for (var i=0; i < spans.length; i++) {
90+
var elem = spans[i];
91+
if (elem) {
92+
var level = elem.getAttribute("class");
93+
if (level == "h1" || level == "h2" || level == "h3" || level == "h4" || level == "h5" || level == "h6") {
94+
elem.innerHTML = "<"+level+">"+elem.innerHTML+"</"+level+">";
95+
}
96+
}
97+
}
98+
}
99+
var legend_html = "Colour legend:<br /> \
100+
<table> \
101+
<tr><td>Unknown:</td> <td><span class='cplate bgwhite'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
102+
<tr><td>Draft:</td> <td><span class='cplate bgred'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
103+
<tr><td>Informational:</td> <td><span class='cplate bgorange'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
104+
<tr><td>Experimental:</td> <td><span class='cplate bgyellow'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
105+
<tr><td>Best Common Practice:</td> <td><span class='cplate bgmagenta'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
106+
<tr><td>Proposed Standard:</td> <td><span class='cplate bgblue'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
107+
<tr><td>Draft Standard (old designation):</td> <td><span class='cplate bgcyan'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
108+
<tr><td>Internet Standard:</td> <td><span class='cplate bggreen'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
109+
<tr><td>Historic:</td> <td><span class='cplate bggrey'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
110+
<tr><td>Obsolete:</td> <td><span class='cplate bgbrown'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> \
111+
</table>";
112+
function showElem(id) {
113+
var elem = document.getElementById(id);
114+
elem.innerHTML = eval(id+"_html");
115+
elem.style.visibility='visible';
116+
}
117+
function hideElem(id) {
118+
var elem = document.getElementById(id);
119+
elem.style.visibility='hidden';
120+
elem.innerHTML = "";
121+
}
122+
// -->
123+
</script>
69124
{% endblock %}

0 commit comments

Comments
 (0)