Skip to content

Commit 9391941

Browse files
committed
Split the /doc/ tabs into separate pages. Use
<link rel="prefetch"> to ask the tabs to be prefetched when the first tab is loaded, as documented at https://developer.mozilla.org/en/Link_prefetching_FAQ . This fixes ietf-tools#533. - Legacy-Id: 2613
1 parent 96faec1 commit 9391941

11 files changed

Lines changed: 316 additions & 185 deletions

fenner/ietf/idrfc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
(r'^active/$', views_search.active),
4141
url(r'^ad/(?P<name>[^/]+)/$', views_search.by_ad, name="doc_search_by_ad"),
4242

43-
url(r'^(?P<name>[^/]+)/$', views_doc.document_main, name="doc_view"),
43+
url(r'^(?P<name>[^/]+)/((?P<tab>ballot|writeup|history)/)?$', views_doc.document_main, name="doc_view"),
4444
(r'^(?P<name>[^/]+)/doc.json$', views_doc.document_debug),
4545
(r'^(?P<name>[^/]+)/_ballot.data$', views_doc.document_ballot),
4646
(r'^(?P<name>[^/]+)/ballot.tsv$', views_doc.ballot_tsv),

fenner/ietf/idrfc/views_doc.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _get_html(key, filename):
7474
(c1,c2) = markup_txt.markup(raw_content)
7575
return (c1,c2)
7676

77-
def document_main_rfc(request, rfc_number):
77+
def document_main_rfc(request, rfc_number, tab):
7878
rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
7979
doc = RfcWrapper(rfci)
8080

@@ -93,18 +93,24 @@ def document_main_rfc(request, rfc_number):
9393

9494
history = _get_history(doc, None)
9595

96-
return render_to_response('idrfc/doc_main_rfc.html',
96+
template = "idrfc/doc_tab_%s" % tab
97+
if tab == "document":
98+
template += "_rfc"
99+
return render_to_response(template + ".html",
97100
{'content1':content1, 'content2':content2,
98-
'doc':doc, 'info':info,
101+
'doc':doc, 'info':info, 'tab':tab,
102+
'include_text':request.GET.get( 'include_text' ),
99103
'history':history},
100104
context_instance=RequestContext(request));
101105

102106
@decorator_from_middleware(GZipMiddleware)
103-
def document_main(request, name):
107+
def document_main(request, name, tab):
108+
if tab is None:
109+
tab = "document"
104110
r = re.compile("^rfc([1-9][0-9]*)$")
105111
m = r.match(name)
106112
if m:
107-
return document_main_rfc(request, int(m.group(1)))
113+
return document_main_rfc(request, int(m.group(1)), tab)
108114
id = get_object_or_404(InternetDraft, filename=name)
109115
doc = IdWrapper(id)
110116

@@ -138,9 +144,13 @@ def document_main(request, name):
138144
versions = _get_versions(id)
139145
history = _get_history(doc, versions)
140146

141-
return render_to_response('idrfc/doc_main_id.html',
147+
template = "idrfc/doc_tab_%s" % tab
148+
if tab == "document":
149+
template += "_id"
150+
return render_to_response(template + ".html",
142151
{'content1':content1, 'content2':content2,
143-
'doc':doc, 'info':info,
152+
'doc':doc, 'info':info, 'tab':tab,
153+
'include_text':request.GET.get( 'include_text' ),
144154
'versions':versions, 'history':history},
145155
context_instance=RequestContext(request));
146156

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{ doc.title }}
2+
{% if info.is_rfc %}
3+
({{doc.maturity_level}}, {{doc.publication_date|date:"Y"}}){% if doc.obsoleted_by %}; Obsoleted by {{doc.obsoleted_by}}{% endif %}
4+
{% else %}
5+
({{info.type}}; {{doc.publication_date|date:"Y"}})
6+
{% endif %}

fenner/ietf/templates/idrfc/doc_main.html

Lines changed: 17 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -55,164 +55,38 @@
5555
{% if doc.in_ietf_process %}
5656
<link rel="alternate" type="application/atom+xml" href="/feed/comments/{% if info.is_rfc %}rfc{{doc.rfc_number}}{% else %}{{doc.draft_name}}{% endif %}/" />
5757
{% endif %}
58-
<meta name="description" content="{% block doc_meta_description %}{% endblock %}" />
58+
<meta name="description" content="{% include "idrfc/doc_description.html" %}" />
59+
{% ifequal tab "document" %}
60+
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
61+
<link rel="prefetch" href="ballot/" />
62+
<link rel="prefetch" href="writeup/" />
63+
{% endif %}
64+
<link rel="prefetch" href="history/" />
65+
{% endifequal %}
5966
{% endblock %}
6067

68+
{% block title %}{% include "idrfc/doc_title.html" %}{% endblock title %}
69+
6170
{% block content %}
62-
<h1>{% block doc_h1 %}{% endblock %}</h1>
71+
<h1>{{ doc.title }}<br/>{% include "idrfc/doc_title.html" %}</h1>
6372

6473
<div id="mytabs" class="yui-navset">
6574
<ul class="yui-nav">
66-
<li class="selected"><a href="#doc"><em>Document</em></a></li>
67-
<li{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}{%else%} class="disabled"{%endif%}><a href="#ballot"><em>IESG Evaluation Record</em></a></li>
68-
<li {% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}{%else%}class="disabled" {%endif%}><a href="#writeup"><em>IESG Writeups</em></a></li>
69-
<li><a href="#history"><em>History</em></a></li>
75+
<li{% ifequal tab "document" %} class="selected"{% endifequal %}><a href="{{ doc.get_absolute_url }}"><em>Document</em></a></li>
76+
<li{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}{% ifequal tab "ballot" %} class="selected"{% endifequal %}{%else%} class="disabled"{%endif%}><a href="{{ doc.get_absolute_url }}ballot/"><em>IESG Evaluation Record</em></a></li>
77+
<li{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}{% ifequal tab "writeup" %} class="selected"{% endifequal %}{%else%} class="disabled"{%endif%}><a href="{{ doc.get_absolute_url }}writeup/"><em>IESG Writeups</em></a></li>
78+
<li{% ifequal tab "history" %} class="selected"{% endifequal %}><a href="{{ doc.get_absolute_url }}history/"><em>History</em></a></li>
7079
</ul>
7180
<div class="yui-content">
7281

73-
<div id="doc">
74-
<div class="ietf-box metabox">
75-
<table id="metatable">
76-
{% block doc_metatable %}{% endblock %}
77-
</table>
78-
79-
<div style="padding-top:6px;padding-bottom:6px;padding-left:2px;">
80-
{% block doc_metalinks %}{% endblock %}
81-
</div>
82-
83-
{% block doc_metabuttons %}
84-
{% if user|in_group:"Area_Director,Secretariat" %}
85-
<div style="padding-bottom:2px;">
86-
{% ifequal doc.draft_status "Expired" %}
87-
{% if not doc.resurrect_requested_by %}
88-
<span id="doc_request_resurrect_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_request_resurrect name=doc.draft_name %}">Request resurrect</a></span></span>
89-
{% endif %}
90-
{% if user|in_group:"Secretariat" %}
91-
<span id="doc_resurrect_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_resurrect name=doc.draft_name %}">Resurrect</a></span></span>
92-
{% endif %}
93-
{% else %}
94-
{% if doc.in_ietf_process %}
95-
<span id="doc_edit_state_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_change_state name=doc.draft_name %}">Change state</a></span></span>
96-
97-
<span id="doc_edit_info_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_edit_info name=doc.draft_name %}">Edit</a></span></span>
98-
{% else %}
99-
<span id="doc_add_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_edit_info name=doc.draft_name %}">Add</a></span></span>
100-
{% endif %}
101-
{% endifequal %}
102-
103-
{# links to old system #}
104-
<span id="doc_edit_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child">
105-
{% if doc.in_ietf_process %}
106-
<a href="https://datatracker.ietf.org/cgi-bin/idtracker.cgi?command=view_id&amp;{% if info.is_rfc %}dTag={{doc.rfc_number}}&amp;rfc_flag=1{% else %}dTag={{doc.tracker_id}}{% endif %}" rel="nofollow" target="_blank">Edit (old IESG Tracker)</a>
107-
{% else %}
108-
<a href="https://datatracker.ietf.org/cgi-bin/idtracker.cgi?command=add_id_confirm&amp;{% if info.is_rfc %}dTag={{doc.rfc_number}}&amp;rfc_flag=1{% else %}dTag={{doc.tracker_id}}&amp;rfc_flag=0{% endif %}&amp;ballot_id=0" rel="nofollow" target="_blank">Add (old IESG Tracker)</a>
109-
{% endif %}
110-
</span></span>
111-
{# end links to old #}
112-
113-
</div>
114-
{% endif %}{# if user in group #}
115-
{% endblock doc_metabuttons%}
116-
</div> <!-- metabox -->
117-
</div> <!-- doc -->
118-
119-
<div id="ballot">
120-
<div id="ballot_content">
121-
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
122-
{% with 1 as doc_ballot_edit_button %}
123-
{% with doc.ietf_process.iesg_ballot as ballot %}
124-
{% include "idrfc/doc_ballot.html" %}
125-
{% endwith %}
126-
{% endwith %}
127-
{% endif %}
128-
</div>
129-
</div>
130-
131-
<div id="writeup">
132-
<div id="writeup_content">
133-
---- following is a DRAFT of message to be sent AFTER approval ---
134-
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
135-
{% if user|in_group:"Area_Director,Secretariat" %}
136-
<div style="background:#E0E0FF">
137-
<p align=right>
138-
<span id="doc_edit_announce_button" class="yui-button yui-link-button"><span class="first-child">
139-
<a href="{% url doc_ballot_approvaltext name=doc.draft_name %}">Edit Announcement Text</a>
140-
</span></span>
141-
</p>
142-
{% endif %}
143-
{% endif %}
144-
<pre>
145-
{{ doc.ietf_process.iesg_ballot.approval_text|escape|urlize }}
146-
</pre>
147-
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
148-
{% if user|in_group:"Area_Director,Secretariat" %}
149-
</div>
150-
151-
<div style="background:#E0E0FF">
152-
<p align=right>
153-
<span id="doc_ballot_edit_button" class="yui-button yui-link-button"><span class="first-child">
154-
<a href="{% url doc_ballot_writeupnotes name=doc.draft_name %}">Edit Ballot Text</a>
155-
</span></span>
156-
</p>
157-
{% endif %}
158-
{% endif %}
159-
<pre>
160-
{{ doc.ietf_process.iesg_ballot.ballot_writeup|escape|urlize }}
161-
</pre>
162-
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
163-
{% if user|in_group:"Area_Director,Secretariat" %}
164-
</div>
165-
{% endif %}
166-
{% endif %}
167-
</div>
168-
</div>
169-
170-
<div id="history">
171-
<div id="history_content">
172-
{% if not info.is_rfc %}
173-
{% include "idrfc/doc_diffs.html" %}
174-
{% endif %}
175-
<h2 style="margin-top:1em;">Document history</h2>
176-
{% if user|in_group:"Area_Director,Secretariat" and doc.in_ietf_process %}
177-
<div style="margin-bottom:8px" id="history_actions">
178-
<span id="doc_add_comment_button" class="yui-button yui-link-button" style="margin-left:2px;"><span class="first-child"><a href="{% url doc_add_comment name=doc.draft_name %}">Add comment</a></span></span>
179-
</div>
180-
{% endif %}
181-
182-
{% include "idrfc/doc_history.html" %}
183-
</div>
184-
</div>
82+
{% block tab_content %}{% endblock %}
18583

18684
</div> <!-- yui-content -->
18785
</div> <!-- mytabs -->
18886

189-
<script type="text/javascript">
190-
//<![CDATA[
191-
document.getElementById('ballot_content').style.display = 'none';
192-
document.getElementById('writeup_content').style.display = 'none';
193-
document.getElementById('history_content').style.display = 'none';
194-
//]]>
195-
</script>
196-
197-
<div id="rfcText1">
198-
{% block doc_text1 %}{% endblock %}
199-
</div> <!-- rfcText1 -->
200-
{% endblock %}{# content #}
87+
{% endblock content %}
20188

20289
{% block scripts %}
203-
var tabView = new YAHOO.widget.TabView('mytabs');
204-
tabView.subscribe('activeIndexChange', function(e) {
205-
if (e.newValue == 0) {
206-
document.getElementById('rfcText1').style.display = 'block';
207-
document.getElementById('rfcText2').style.display = 'block';
208-
} else {
209-
document.getElementById('rfcText1').style.display = 'none';
210-
document.getElementById('rfcText2').style.display = 'none';
211-
} });
212-
document.getElementById('writeup_content').style.display = 'block';
213-
document.getElementById('ballot_content').style.display = 'block';
214-
document.getElementById('history_content').style.display = 'block';
215-
21690
function toggleComment(n) {
21791
var el = document.getElementById("commentF"+n);
21892
var el2 = document.getElementById("commentS"+n);
@@ -228,27 +102,3 @@ <h2 style="margin-top:1em;">Document history</h2>
228102
}
229103
}
230104
{% endblock scripts %}
231-
232-
{% block content_end %}
233-
<div id="rfcText2">
234-
{% block doc_text2 %}{% endblock %}
235-
</div>
236-
237-
<script type="text/javascript">
238-
//<![CDATA[
239-
// based on http://blog.davglass.com/files/yui/tab7/
240-
var url = location.href.split('#');
241-
if (url[1]) {
242-
url[1] = "#"+url[1];
243-
var tabs = tabView.get('tabs');
244-
for (var i = 0; i < tabs.length; i++) {
245-
if (url[1].indexOf(tabs[i].get('href')) == 0) {
246-
tabView.set('activeIndex', i);
247-
break;
248-
}
249-
}
250-
}
251-
//]]>
252-
</script>
253-
254-
{% endblock content_end %}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% extends "idrfc/doc_main.html" %}
2+
{% comment %}
3+
Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
4+
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions
8+
are met:
9+
10+
* Redistributions of source code must retain the above copyright
11+
notice, this list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above
14+
copyright notice, this list of conditions and the following
15+
disclaimer in the documentation and/or other materials provided
16+
with the distribution.
17+
18+
* Neither the name of the Nokia Corporation and/or its
19+
subsidiary(-ies) nor the names of its contributors may be used
20+
to endorse or promote products derived from this software
21+
without specific prior written permission.
22+
23+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
{% endcomment %}
35+
36+
{% load ietf_filters %}
37+
38+
{% block tab_content %}
39+
{% if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot %}
40+
{% with 1 as doc_ballot_edit_button %}
41+
{% with doc.ietf_process.iesg_ballot as ballot %}
42+
{% include "idrfc/doc_ballot.html" %}
43+
{% endwith %}
44+
{% endwith %}
45+
{% endif %}
46+
{% endblock tab_content %}
47+

0 commit comments

Comments
 (0)