Skip to content

Commit 88c9f84

Browse files
committed
Summary: Facelift material document page
- Legacy-Id: 8937
1 parent 7561ce4 commit 88c9f84

4 files changed

Lines changed: 93 additions & 102 deletions

File tree

ietf/doc/templatetags/ietf_filters.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,11 @@ def format_snippet(text, trunc_words=25):
463463
return mark_safe(u'<div class="snippet">%s<button class="btn btn-xs btn-default show-all"><span class="fa fa-caret-down"></span></button></div><div class="hidden full">%s</div>' % (snippet, full))
464464
return full
465465

466-
@register.filter
467-
def format_editable_snippet(text,link):
468-
full = mark_safe(keep_spacing(collapsebr(linebreaksbr(urlize(sanitize_html(text))))))
469-
snippet = truncatewords_html(full, 25)
470-
if snippet != full:
471-
return mark_safe(u'<div class="snippet">%s<span class="show-all">[show all]</span></div><div style="display:none" class="full">%s' % (format_editable(snippet,link),format_editable(full,link)) )
472-
else:
473-
return format_editable(full,link)
474-
475-
@register.filter
476-
def format_editable(text,link):
477-
return mark_safe(u'<a class="editlink" href="%s">%s</a>' % (link,text))
466+
@register.simple_tag
467+
def doc_edit_button(url_name, *args, **kwargs):
468+
"""Given URL name/args/kwargs, looks up the URL just like "url" tag and returns a properly formatted button for the document material tables."""
469+
from django.core.urlresolvers import reverse as urlreverse
470+
return mark_safe(u'<a class="btn btn-default btn-xs" href="%s">Edit</a>' % (urlreverse(url_name, args=args, kwargs=kwargs)))
478471

479472
@register.filter
480473
def textify(text):

ietf/templates/doc/charter/change_title.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
{% block content %}
88
<h1>{{ title }}</h1>
99

10-
<form role="form" class="change-title" method="post">{% csrf_token %}
10+
<form role="form" class="change-title" method="post">
11+
{% csrf_token %}
12+
1113
{% bootstrap_form form %}
1214

1315
{% buttons %}

ietf/templates/doc/document_charter.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
</th>
2929
<td class="edit"></td>
3030
<td>
31-
{{ group.name }} {{ group.type.name }}
32-
<a href="{{ group.about_url }}">({{ group.acronym }})</a> {{ group.type.name }}
31+
{{ group.name }} {{ group.type.name }}
32+
<a href="{{ group.about_url }}">({{ group.acronym }})</a>
3333

3434
{% if snapshot %}
3535
<span class="label label-warning">Snapshot</span>
@@ -40,9 +40,9 @@
4040
<tr>
4141
<th>Title</th>
4242
<td class="edit">
43-
{% if not snapshot and can_manage %}
44-
<a class="btn btn-default btn-xs pull-right" href="{% url "charter_change_title" name=doc.name %}">Edit</a>
45-
{% endif %}
43+
{% if not snapshot and can_manage %}
44+
{% doc_edit_button "charter_change_title" name=doc.name %}
45+
{% endif %}
4646
</td>
4747
<td>{{ doc.title }}</td>
4848
</tr>
@@ -57,11 +57,11 @@
5757
<th><a href="/doc/help/state/charter/">Charter state</a></th>
5858
<td class="edit">
5959
{% if not snapshot and can_manage %}
60-
<a class="btn btn-default btn-xs pull-right" title="{{ doc.get_state.desc }}" href="{% url "charter_change_state" name=doc.name %}">Edit</a>
61-
{% endif %}
60+
{% doc_edit_button "charter_change_state" name=doc.name %}
61+
{% endif %}
6262
</td>
6363
<td>
64-
{{ doc.get_state.name }}
64+
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
6565

6666
{% if chartering == "initial" %}
6767
<span class="label label-info">Initial chartering</span>
@@ -77,8 +77,8 @@
7777
<th>Telechat date</th>
7878
<td class="edit">
7979
{% if can_manage %}
80-
<a class="btn btn-default btn-xs pull-right" href="{% url "charter_telechat_date" name=doc.name %}">Edit</a>
81-
{% endif %}
80+
{% doc_edit_button "charter_telechat_date" name=doc.name %}
81+
{% endif %}
8282
</td>
8383
<td>
8484
{% if not telechat %}
@@ -97,8 +97,8 @@
9797
<th>Responsible AD</th>
9898
<td class="edit">
9999
{% if can_manage %}
100-
<a class="btn btn-default btn-xs pull-right" href="{% url "charter_edit_ad" name=doc.name %}">Edit</a>
101-
{% endif %}
100+
{% doc_edit_button "charter_edit_ad" name=doc.name %}
101+
{% endif %}
102102
</td>
103103
<td>
104104
{{ doc.ad|default:"(None)" }}
@@ -109,7 +109,7 @@
109109
<th>Send notices to</th>
110110
<td class="edit">
111111
{% if can_manage %}
112-
<a class="btn btn-default btn-xs pull-right" href="{% url "charter_edit_notify" name=doc.name %}">Edit</a>
112+
{% doc_edit_button "charter_edit_notify" name=doc.name %}
113113
{% endif %}
114114
</td>
115115
<td>
Lines changed: 72 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
1-
{% extends "base.html" %}
1+
{% extends "ietf.html" %}
22

33
{% load ietf_filters %}
44

5-
{% block title %}{{ doc.canonical_name }}-{{ doc.rev }}{% endblock %}
6-
7-
{% block pagehead %}
8-
<link rel="stylesheet" type="text/css" href="/css/doc.css"></link>
9-
{% endblock %}
5+
{% block title %}{{ doc.title }}{% endblock %}
106

117
{% block content %}
128
{{ top|safe }}
139

1410
{% include "doc/revisions_list.html" %}
1511

16-
<div class="ietf-box metabox">
17-
<div>
18-
{% if snapshot %}Snapshot of{% endif %} {% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }} for <a href="{{ doc.group.about_url }}">{{ doc.group.acronym }}</a> group
19-
</div>
20-
21-
<table id="metatable" width="100%">
12+
<table class="table table-condensed table-striped">
13+
<tr>
14+
<th>{% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }}</th>
15+
<td class="edit"></td>
16+
<td>
17+
{{ doc.group.name }}
18+
<a href="{{ doc.group.about_url }}">({{ doc.group.acronym }})</a> {{ doc.group.type.name }}
19+
20+
{% if snapshot %}
21+
<span class="label label-warning">Snapshot</span>
22+
{% endif %}
23+
</td>
24+
</tr>
25+
26+
<tr>
27+
<th>Title</th>
28+
<td class="edit">
29+
{% if not snapshot and can_manage_material %}
30+
{% doc_edit_button "material_edit" name=doc.name action="title" %}
31+
{% endif %}
32+
</td>
33+
<td>{{ doc.title }}</td>
34+
</tr>
35+
36+
{% if doc.abstract %}
2237
<tr>
23-
<td>Title:</td>
24-
<td>
38+
<th>Abstract</th>
39+
<td class="edit">
2540
{% if not snapshot and can_manage_material %}
26-
{% url "material_edit" name=doc.name action="title" as editurl %}
27-
{{ doc.title | format_editable:editurl }}
28-
{% else %}
29-
{{ doc.title }}
41+
{% doc_edit_button "material_edit" name=doc.name action="abstract" %}
3042
{% endif %}
3143
</td>
44+
<td>{{ doc.abstract|format_snippet }}</td>
3245
</tr>
46+
{% endif %}
3347

34-
{% if doc.abstract %}
35-
<tr>
36-
<td>Abstract:</td>
37-
<td>
38-
{% if not snapshot and can_manage_material %}
39-
{% url "material_edit" name=doc.name action="abstract" as editurl %}
40-
{{ doc.abstract | format_editable_snippet:editurl }}
41-
{% else %}
42-
{{ doc.abstract | format_snippet }}
43-
{% endif %}
44-
</td>
45-
</tr>
46-
{% endif %}
48+
<tr>
49+
<th>State</th>
50+
<td class="edit">
51+
{% if not snapshot and can_manage_material %}
52+
{% doc_edit_button "material_edit" name=doc.name action="state" %}
53+
{% endif %}
54+
</td>
55+
<td>{{ doc.get_state.name }}</td>
56+
</tr>
4757

58+
{% if other_types %}
4859
<tr>
49-
<td>State:</td>
50-
<td>
51-
{% if not snapshot and can_manage_material %}
52-
{% url "material_edit" name=doc.name action="state" as editurl %}
53-
{{ doc.get_state.name | format_editable:editurl }}
54-
{% else %}
55-
{{ doc.get_state.name }}
56-
{% endif %}
57-
</td>
58-
</tr>
59-
60-
{% if other_types %}
61-
<tr>
62-
<td>Other versions:</td>
60+
<th>Other versions</th>
61+
<td class="edit"></td>
6362
<td>
6463
{% for t, url in other_types %}
6564
<a href="{{ url }}">{{ t }}</a>{% if not forloop.last %},{% endif %}
6665
{% endfor %}
6766
</td>
6867
</tr>
69-
{% endif %}
68+
{% endif %}
7069

71-
{% if presentations or can_manage_material %}
70+
{% if presentations or can_manage_material %}
7271
<tr>
73-
<td>On Agenda:</td>
72+
<th>On Agenda</th>
73+
<td class="edit">
74+
{% if not snapshot and can_manage_material %}
75+
{% doc_edit_button "material_presentations" name=doc.name %}
76+
{% endif %}
77+
</td>
78+
7479
<td>
75-
<a {% if not snapshot and can_manage_material %} class="editlink" href="{% url "material_presentations" name=doc.name %}"{%endif%}>
76-
{% if presentations %}
77-
{% for pres in presentations %}{{pres.session.short_name}} at {{pres.session.meeting}} {% if pres.rev != doc.rev %}(version -{{pres.rev}}){% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
78-
{% else %}
79-
None
80-
{% endif %}
81-
</a>
82-
</td>
80+
{% if presentations %}
81+
{% for pres in presentations %}{{ pres.session.short_name }} at {{ pres.session.meeting }} {% if pres.rev != doc.rev %}(version -{{ pres.rev }}){% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
82+
{% else %}
83+
None
84+
{% endif %}
85+
</td>
8386
</tr>
84-
{% endif %}
87+
{% endif %}
8588

86-
<tr>
87-
<td>Last updated:</td>
88-
<td>{{ doc.time|date:"Y-m-d" }}</td>
89-
</tr>
89+
<tr>
90+
<th>Last updated</th>
91+
<td class="edit"></td>
92+
<td>{{ doc.time|date:"Y-m-d" }}</td>
93+
</tr>
94+
</table>
9095

91-
{% if not snapshot and can_manage_material %}
92-
<tr><td colspan="2">
93-
<a class="button" href="{% url "material_edit" name=doc.name action="revise" %}">Upload New Revision</a>
94-
</td><tr/>
95-
{% endif %}
96+
<p class="buttonlist">
97+
{% if not snapshot and can_manage_material %}
98+
<a class="btn btn-default" href="{% url "material_edit" name=doc.name action="revise" %}">Upload New Revision</a>
99+
{% endif %}
100+
</p>
96101

97-
</table>
98-
</div>
102+
<h2>{% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }}<br><small>{{ doc.name }}</small></h2>
99103

100104
{% if doc.rev and content != None %}
101-
<h3>{{ doc.title }}</h3>
102-
103-
<div class="markup_draft">
104105
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
105-
</div>
106106
{% else %}
107107
<p>Not available as plain text.</p>
108108

@@ -112,7 +112,3 @@ <h3>{{ doc.title }}</h3>
112112
{% endif %}
113113

114114
{% endblock %}
115-
116-
{% block content_end %}
117-
<script src="/js/snippet.js" type="text/javascript"></script>
118-
{% endblock %}

0 commit comments

Comments
 (0)