Skip to content

Commit 0f1c823

Browse files
committed
Now that the timeline stuff seems stable, show it for all document types.
- Legacy-Id: 10555
1 parent b6e02b1 commit 0f1c823

10 files changed

Lines changed: 85 additions & 54 deletions

.editorconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ indent_style = space
1111
indent_size = 4
1212
end_of_line = lf
1313
charset = utf-8
14-
trim_trailing_whitespace = true
15-
insert_final_newline = true
14+
# to avoid tripping Henrik's commit hook:
15+
trim_trailing_whitespace = false
16+
insert_final_newline = false

ietf/doc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
url(r'^(?P<name>[A-Za-z0-9._+-]+)/ballot/(?P<ballot_id>[0-9]+)/emailposition/$', views_ballot.send_ballot_comment, name='doc_send_ballot_comment'),
6666
url(r'^(?P<name>[A-Za-z0-9._+-]+)/ballot/(?P<ballot_id>[0-9]+)/$', views_doc.document_ballot, name="doc_ballot"),
6767
url(r'^(?P<name>[A-Za-z0-9._+-]+)/ballot/$', views_doc.document_ballot, name="doc_ballot"),
68-
(r'^(?P<name>[A-Za-z0-9._+-]+)/doc.json$', views_doc.document_json),
68+
(r'^(?P<name>[A-Za-z0-9._+-]+)/(?:(?P<rev>[0-9-]+)/)?doc.json$', views_doc.document_json),
6969
(r'^(?P<name>[A-Za-z0-9._+-]+)/ballotpopup/(?P<ballot_id>[0-9]+)/$', views_doc.ballot_popup),
7070

7171
url(r'^(?P<name>[A-Za-z0-9._+-]+)/email-aliases/$', RedirectView.as_view(pattern_name='doc_email', permanent=False),name='doc_specific_email_aliases'),

ietf/doc/views_doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def ballot_popup(request, name, ballot_id):
878878
context_instance=RequestContext(request))
879879

880880

881-
def document_json(request, name):
881+
def document_json(request, name, rev=None):
882882
doc = get_object_or_404(Document, docalias__name=name)
883883

884884
def extract_name(s):

ietf/static/ietf/css/ietf.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,31 @@ h1 small .pull-right { margin-top: 10.5px; }
426426
*/
427427
form.navbar-form input.form-control.input-sm { width: 141px; }
428428

429+
430+
431+
/* Styles for d3.js graphical SVG timelines */
432+
#timeline { font-size: small; }
433+
434+
#timeline .axis path, #timeline .axis line {
435+
fill: none;
436+
stroke: black;
437+
}
438+
439+
#timeline .axis.y path, #timeline .axis.y line { stroke: none; }
440+
441+
#timeline .axis.x text { dominant-baseline: central; }
442+
443+
#timeline .bar text {
444+
fill: white;
445+
dominant-baseline: central;
446+
}
447+
448+
/* like label-success */
449+
#timeline .bar:nth-child(odd) rect { fill: #5CB85C; }
450+
451+
/* like label-primary */
452+
#timeline .bar:nth-child(even) rect { fill: #337AB7; }
453+
454+
/* like label-warning */
455+
#timeline .gradient.left { stop-color: #F0AD4E; }
456+
#timeline .gradient.right { stop-color: white; }

ietf/static/ietf/js/document_timeline.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var width;
1010

1111
function offset(d, i) {
1212
// increase the y offset if the document name changed in this revision
13-
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("rfc"))
13+
if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$"))
1414
bar_y += bar_height;
1515
return "translate(" + x_scale(d.published) + ", " + bar_y + ")";
1616
}
@@ -59,8 +59,7 @@ function update_timeline() {
5959

6060

6161
function draw_timeline() {
62-
bar_height = parseFloat($("body").css('line-height'));
63-
// bar_height = 20;
62+
bar_height = parseFloat($("body").css("line-height"));
6463

6564
var div = $("#timeline");
6665
if (div.is(":empty"))
@@ -70,12 +69,16 @@ function draw_timeline() {
7069
var gradient = chart.append("defs")
7170
.append("linearGradient")
7271
.attr("id", "gradient");
73-
gradient.append('stop')
74-
.attr('class', 'stop-left')
75-
.attr('offset', '0');
76-
gradient.append('stop')
77-
.attr('class', 'stop-right')
78-
.attr('offset', '1');
72+
gradient.append("stop")
73+
.attr({
74+
class: "gradient left",
75+
offset: 0
76+
});
77+
gradient.append("stop")
78+
.attr({
79+
class: "gradient right",
80+
offset: 1
81+
});
7982

8083
var y_labels = data
8184
.map(function(elem) { return elem.name; })
@@ -121,6 +124,10 @@ function draw_timeline() {
121124
})
122125
.text(function(d) { return d.rev; });
123126

127+
// since the gradient is defined inside the SVG, we need to set the CSS
128+
// style here, so the relative URL works
129+
$("#timeline .bar:nth-last-child(2) rect").css("fill", "url(#gradient)");
130+
124131
var y_scale = d3.scale.ordinal()
125132
.domain(y_labels)
126133
.rangePoints([0, bar_y]);
@@ -150,22 +157,24 @@ function draw_timeline() {
150157
d3.select(".x.axis").each(function() {
151158
x_label_height = this.getBBox().height;
152159
});
153-
chart.attr('height', bar_y + x_label_height);
160+
chart.attr("height", bar_y + x_label_height);
154161
}
155162

156163

157164
d3.json("doc.json", function(error, json) {
158-
if (error) return; // console.warn(error);
165+
if (error) return;
159166
data = json["rev_history"];
160167

161-
// make js dates out of publication dates
162-
data.forEach(function(d) { d.published = new Date(d.published); });
168+
if (data.length) {
169+
// make js dates out of publication dates
170+
data.forEach(function(d) { d.published = new Date(d.published); });
163171

164-
// add pseudo entry 185 days after last revision (when the ID will expire)
165-
var pseudo = new Date(data[data.length - 1].published.getTime() +
166-
1000*60*60*24*185);
167-
data.push({ name: "", rev: "", published: pseudo});
168-
draw_timeline();
172+
// add pseudo entry 185 days after last rev (when the ID will expire)
173+
var pseudo = new Date(data[data.length - 1].published.getTime() +
174+
1000*60*60*24*185);
175+
data.push({ name: "", rev: "", published: pseudo});
176+
draw_timeline();
177+
}
169178
});
170179

171180

ietf/templates/doc/document_charter.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{{ top|safe }}
1616

1717
{% include "doc/revisions_list.html" %}
18+
<div id="timeline"></div>
1819

1920
<table class="table table-condensed">
2021
<thead id="message-row">
@@ -210,3 +211,7 @@ <h2>Proposed milestones</h2>
210211

211212
{% endblock %}
212213

214+
{% block js %}
215+
<script src="{% static 'd3/d3.min.js' %}"></script>
216+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
217+
{% endblock %}

ietf/templates/doc/document_conflict_review.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{{ top|safe }}
1212

1313
{% include "doc/revisions_list.html" %}
14+
<div id="timeline"></div>
1415

1516
<table class="table table-condensed">
1617
<thead id="message-row">
@@ -137,6 +138,10 @@ <h2>Conflict review<br><small>{{ conflictdoc.name }}-{{ conflictdoc.rev }}</smal
137138
<p></p>
138139
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
139140
{% endif %}
140-
141141
{% endblock %}
142142

143+
144+
{% block js %}
145+
<script src="{% static 'd3/d3.min.js' %}"></script>
146+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
147+
{% endblock %}

ietf/templates/doc/document_draft.html

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,6 @@
1111

1212
{% block morecss %}
1313
.inline { display: inline; }
14-
15-
#timeline { font-size: small; }
16-
17-
#timeline .axis path, #timeline .axis line {
18-
fill: none;
19-
stroke: black;
20-
}
21-
22-
#timeline .axis.y path, #timeline .axis.y line { stroke: none; }
23-
24-
#timeline .axis.x text { dominant-baseline: central; }
25-
26-
#timeline .bar text {
27-
fill: white;
28-
dominant-baseline: central;
29-
}
30-
31-
{% comment %} like label-success {% endcomment %}
32-
#timeline .bar:nth-child(odd) rect { fill: #5CB85C; }
33-
34-
{% comment %} like label-primary {% endcomment %}
35-
#timeline .bar:nth-child(even) rect { fill: #337AB7; }
36-
37-
{% comment %} like label-warning {% endcomment %}
38-
.stop-left { stop-color: #F0AD4E; }
39-
.stop-right { stop-color: white; }
40-
#timeline .bar:nth-last-child(4) rect { fill: url(#gradient); }
4114
{% endblock %}
4215

4316
{% block title %}
@@ -520,10 +493,8 @@ <h4>Authors</h4>
520493
</div>
521494
</div>
522495
{% endif %}
523-
524496
{% endblock %}
525497

526-
527498
{% block js %}
528499
<script src="{% static 'd3/d3.min.js' %}"></script>
529500
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>

ietf/templates/doc/document_material.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "base.html" %}
22
{# Copyright The IETF Trust 2015, All Rights Reserved #}
33
{% load origin %}
4-
4+
{% load staticfiles %}
55
{% load ietf_filters %}
66

77
{% block title %}{{ doc.title }}{% endblock %}
@@ -11,6 +11,7 @@
1111
{{ top|safe }}
1212

1313
{% include "doc/revisions_list.html" %}
14+
<div id="timeline"></div>
1415

1516
<table class="table table-condensed">
1617
<thead id="message-row">
@@ -125,5 +126,10 @@ <h2>{% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }}<br><small
125126
<p class="download-instead"><a href="{{ other_types.0.1 }}">Download as {{ other_types.0.0.upper }}</a></p>
126127
{% endif %}
127128
{% endif %}
129+
{% endblock %}
130+
128131

132+
{% block js %}
133+
<script src="{% static 'd3/d3.min.js' %}"></script>
134+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
129135
{% endblock %}

ietf/templates/doc/document_status_change.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "base.html" %}
22
{# Copyright The IETF Trust 2015, All Rights Reserved #}
33
{% load origin %}
4-
4+
{% load staticfiles %}
55
{% load ietf_filters %}
66

77
{% block title %}{{ doc.title }}{% endblock %}
@@ -11,6 +11,7 @@
1111
{{ top|safe }}
1212

1313
{% include "doc/revisions_list.html" %}
14+
<div id="timeline"></div>
1415

1516
<table class="table table-condensed">
1617
<thead id="message-row">
@@ -153,3 +154,8 @@
153154

154155
{% endblock %}
155156

157+
158+
{% block js %}
159+
<script src="{% static 'd3/d3.min.js' %}"></script>
160+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
161+
{% endblock %}

0 commit comments

Comments
 (0)