From 0f1c823a6ef6bec839b2dd66f90379a28a134b88 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 9 Dec 2015 16:54:53 +0000 Subject: [PATCH] Now that the timeline stuff seems stable, show it for all document types. - Legacy-Id: 10555 --- .editorconfig | 5 ++- ietf/doc/urls.py | 2 +- ietf/doc/views_doc.py | 2 +- ietf/static/ietf/css/ietf.css | 28 ++++++++++++ ietf/static/ietf/js/document_timeline.js | 45 +++++++++++-------- ietf/templates/doc/document_charter.html | 5 +++ .../doc/document_conflict_review.html | 7 ++- ietf/templates/doc/document_draft.html | 29 ------------ ietf/templates/doc/document_material.html | 10 ++++- .../templates/doc/document_status_change.html | 8 +++- 10 files changed, 86 insertions(+), 55 deletions(-) diff --git a/.editorconfig b/.editorconfig index ae5bbcda4..63bf7a66d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,6 @@ indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true +# to avoid tripping Henrik's commit hook: +trim_trailing_whitespace = false +insert_final_newline = false diff --git a/ietf/doc/urls.py b/ietf/doc/urls.py index ae29d42c2..140b27253 100644 --- a/ietf/doc/urls.py +++ b/ietf/doc/urls.py @@ -65,7 +65,7 @@ urlpatterns = patterns('', url(r'^(?P[A-Za-z0-9._+-]+)/ballot/(?P[0-9]+)/emailposition/$', views_ballot.send_ballot_comment, name='doc_send_ballot_comment'), url(r'^(?P[A-Za-z0-9._+-]+)/ballot/(?P[0-9]+)/$', views_doc.document_ballot, name="doc_ballot"), url(r'^(?P[A-Za-z0-9._+-]+)/ballot/$', views_doc.document_ballot, name="doc_ballot"), - (r'^(?P[A-Za-z0-9._+-]+)/doc.json$', views_doc.document_json), + (r'^(?P[A-Za-z0-9._+-]+)/(?:(?P[0-9-]+)/)?doc.json$', views_doc.document_json), (r'^(?P[A-Za-z0-9._+-]+)/ballotpopup/(?P[0-9]+)/$', views_doc.ballot_popup), url(r'^(?P[A-Za-z0-9._+-]+)/email-aliases/$', RedirectView.as_view(pattern_name='doc_email', permanent=False),name='doc_specific_email_aliases'), diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 3564a3e57..9a6f1cb74 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -878,7 +878,7 @@ def ballot_popup(request, name, ballot_id): context_instance=RequestContext(request)) -def document_json(request, name): +def document_json(request, name, rev=None): doc = get_object_or_404(Document, docalias__name=name) def extract_name(s): diff --git a/ietf/static/ietf/css/ietf.css b/ietf/static/ietf/css/ietf.css index a1700fc63..df38e0769 100644 --- a/ietf/static/ietf/css/ietf.css +++ b/ietf/static/ietf/css/ietf.css @@ -426,3 +426,31 @@ h1 small .pull-right { margin-top: 10.5px; } */ form.navbar-form input.form-control.input-sm { width: 141px; } + + +/* Styles for d3.js graphical SVG timelines */ +#timeline { font-size: small; } + +#timeline .axis path, #timeline .axis line { + fill: none; + stroke: black; +} + +#timeline .axis.y path, #timeline .axis.y line { stroke: none; } + +#timeline .axis.x text { dominant-baseline: central; } + +#timeline .bar text { + fill: white; + dominant-baseline: central; +} + +/* like label-success */ +#timeline .bar:nth-child(odd) rect { fill: #5CB85C; } + +/* like label-primary */ +#timeline .bar:nth-child(even) rect { fill: #337AB7; } + +/* like label-warning */ +#timeline .gradient.left { stop-color: #F0AD4E; } +#timeline .gradient.right { stop-color: white; } diff --git a/ietf/static/ietf/js/document_timeline.js b/ietf/static/ietf/js/document_timeline.js index 2b42b7597..47efd2895 100644 --- a/ietf/static/ietf/js/document_timeline.js +++ b/ietf/static/ietf/js/document_timeline.js @@ -10,7 +10,7 @@ var width; function offset(d, i) { // increase the y offset if the document name changed in this revision - if (i > 0 && data[i - 1].name !== d.name || d.rev.match("rfc")) + if (i > 0 && data[i - 1].name !== d.name || d.rev.match("^rfc\d+$")) bar_y += bar_height; return "translate(" + x_scale(d.published) + ", " + bar_y + ")"; } @@ -59,8 +59,7 @@ function update_timeline() { function draw_timeline() { - bar_height = parseFloat($("body").css('line-height')); - // bar_height = 20; + bar_height = parseFloat($("body").css("line-height")); var div = $("#timeline"); if (div.is(":empty")) @@ -70,12 +69,16 @@ function draw_timeline() { var gradient = chart.append("defs") .append("linearGradient") .attr("id", "gradient"); - gradient.append('stop') - .attr('class', 'stop-left') - .attr('offset', '0'); - gradient.append('stop') - .attr('class', 'stop-right') - .attr('offset', '1'); + gradient.append("stop") + .attr({ + class: "gradient left", + offset: 0 + }); + gradient.append("stop") + .attr({ + class: "gradient right", + offset: 1 + }); var y_labels = data .map(function(elem) { return elem.name; }) @@ -121,6 +124,10 @@ function draw_timeline() { }) .text(function(d) { return d.rev; }); + // since the gradient is defined inside the SVG, we need to set the CSS + // style here, so the relative URL works + $("#timeline .bar:nth-last-child(2) rect").css("fill", "url(#gradient)"); + var y_scale = d3.scale.ordinal() .domain(y_labels) .rangePoints([0, bar_y]); @@ -150,22 +157,24 @@ function draw_timeline() { d3.select(".x.axis").each(function() { x_label_height = this.getBBox().height; }); - chart.attr('height', bar_y + x_label_height); + chart.attr("height", bar_y + x_label_height); } d3.json("doc.json", function(error, json) { - if (error) return; // console.warn(error); + if (error) return; data = json["rev_history"]; - // make js dates out of publication dates - data.forEach(function(d) { d.published = new Date(d.published); }); + if (data.length) { + // make js dates out of publication dates + data.forEach(function(d) { d.published = new Date(d.published); }); - // add pseudo entry 185 days after last revision (when the ID will expire) - var pseudo = new Date(data[data.length - 1].published.getTime() + - 1000*60*60*24*185); - data.push({ name: "", rev: "", published: pseudo}); - draw_timeline(); + // add pseudo entry 185 days after last rev (when the ID will expire) + var pseudo = new Date(data[data.length - 1].published.getTime() + + 1000*60*60*24*185); + data.push({ name: "", rev: "", published: pseudo}); + draw_timeline(); + } }); diff --git a/ietf/templates/doc/document_charter.html b/ietf/templates/doc/document_charter.html index 5d67b41db..a1cce09d5 100644 --- a/ietf/templates/doc/document_charter.html +++ b/ietf/templates/doc/document_charter.html @@ -15,6 +15,7 @@ {{ top|safe }} {% include "doc/revisions_list.html" %} +
@@ -210,3 +211,7 @@ {% endblock %} +{% block js %} + + +{% endblock %} diff --git a/ietf/templates/doc/document_conflict_review.html b/ietf/templates/doc/document_conflict_review.html index e0544c702..38c25c2d3 100644 --- a/ietf/templates/doc/document_conflict_review.html +++ b/ietf/templates/doc/document_conflict_review.html @@ -11,6 +11,7 @@ {{ top|safe }} {% include "doc/revisions_list.html" %} +
@@ -137,6 +138,10 @@

{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }} {% endif %} - {% endblock %} + +{% block js %} + + +{% endblock %} diff --git a/ietf/templates/doc/document_draft.html b/ietf/templates/doc/document_draft.html index 6af87a31e..7188cb557 100644 --- a/ietf/templates/doc/document_draft.html +++ b/ietf/templates/doc/document_draft.html @@ -11,33 +11,6 @@ {% block morecss %} .inline { display: inline; } - -#timeline { font-size: small; } - -#timeline .axis path, #timeline .axis line { - fill: none; - stroke: black; -} - -#timeline .axis.y path, #timeline .axis.y line { stroke: none; } - -#timeline .axis.x text { dominant-baseline: central; } - -#timeline .bar text { - fill: white; - dominant-baseline: central; -} - -{% comment %} like label-success {% endcomment %} -#timeline .bar:nth-child(odd) rect { fill: #5CB85C; } - -{% comment %} like label-primary {% endcomment %} -#timeline .bar:nth-child(even) rect { fill: #337AB7; } - -{% comment %} like label-warning {% endcomment %} -.stop-left { stop-color: #F0AD4E; } -.stop-right { stop-color: white; } -#timeline .bar:nth-last-child(4) rect { fill: url(#gradient); } {% endblock %} {% block title %} @@ -520,10 +493,8 @@ {% endif %} - {% endblock %} - {% block js %} diff --git a/ietf/templates/doc/document_material.html b/ietf/templates/doc/document_material.html index a3a6269b5..6956ac3b0 100644 --- a/ietf/templates/doc/document_material.html +++ b/ietf/templates/doc/document_material.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {# Copyright The IETF Trust 2015, All Rights Reserved #} {% load origin %} - +{% load staticfiles %} {% load ietf_filters %} {% block title %}{{ doc.title }}{% endblock %} @@ -11,6 +11,7 @@ {{ top|safe }} {% include "doc/revisions_list.html" %} +
@@ -125,5 +126,10 @@

Download as {{ other_types.0.0.upper }}

{% endif %} {% endif %} - +{% endblock %} + + +{% block js %} + + {% endblock %} diff --git a/ietf/templates/doc/document_status_change.html b/ietf/templates/doc/document_status_change.html index d6542332a..5ea14afdf 100644 --- a/ietf/templates/doc/document_status_change.html +++ b/ietf/templates/doc/document_status_change.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {# Copyright The IETF Trust 2015, All Rights Reserved #} {% load origin %} - +{% load staticfiles %} {% load ietf_filters %} {% block title %}{{ doc.title }}{% endblock %} @@ -11,6 +11,7 @@ {{ top|safe }} {% include "doc/revisions_list.html" %} +
@@ -153,3 +154,8 @@ {% endblock %} + +{% block js %} + + +{% endblock %}