Skip to content

Commit 27a7770

Browse files
committed
/doc/rfcNNN/: include links to PDF/PS versions (if they exist); handle RFCs that are not available as .txt
- Legacy-Id: 2084
1 parent 0116d2a commit 27a7770

4 files changed

Lines changed: 43 additions & 6 deletions

File tree

ietf/idrfc/idrfc_wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ def in_ietf_process(self):
287287
return self.ietf_process != None
288288

289289
def file_types(self):
290-
# Not really correct, but the database doesn't
291-
# have this data for RFCs yet
292-
return [".txt"]
290+
types = self._rfcindex.file_formats
291+
types = types.replace("ascii","txt")
292+
return ["."+x for x in types.split(",")]
293293

294294
# TODO:
295295
# also/bcp_number/std_number/fyi_number

ietf/idrfc/testurl.list

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
200 /doc/rfc822/
3131
200 /doc/rfc822/_debug.data
3232

33+
# file formats
34+
200 /doc/rfc9/ # PDF only
35+
200 /doc/rfc2490/ # TXT+PDF+PS
36+
200 /doc/rfc500/ # not online
37+
3338
404 /doc/draft-no-such-draft/
3439
404 /doc/rfc4637/
3540

ietf/idrfc/views_doc.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ def document_main_rfc(request, rfc_number):
7777

7878
info = {}
7979
info['is_rfc'] = True
80-
(content1, content2) = _get_html(
81-
"rfc"+str(rfc_number)+",html",
82-
os.path.join(settings.RFC_PATH, "rfc"+str(rfc_number)+".txt"))
80+
info['has_pdf'] = (".pdf" in doc.file_types())
81+
info['has_txt'] = (".txt" in doc.file_types())
82+
info['has_ps'] = (".ps" in doc.file_types())
83+
if info['has_txt']:
84+
(content1, content2) = _get_html(
85+
"rfc"+str(rfc_number)+",html",
86+
os.path.join(settings.RFC_PATH, "rfc"+str(rfc_number)+".txt"))
87+
else:
88+
content1 = ""
89+
content2 = ""
8390

8491
history = _get_history(doc, None)
8592

ietf/templates/idrfc/doc_main_rfc.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,26 @@
6262

6363
{% endif %}
6464
<tr><td>Other versions:</td><td>
65+
{% if info.has_txt or info.has_ps or info.has_pdf %}
66+
{% if info.has_txt %}
6567
<a href="http://www.rfc-editor.org/rfc/rfc{{doc.rfc_number}}.txt">plain text</a>,
68+
{% endif %}
69+
{% if info.has_ps %}
70+
<a href="http://www.rfc-editor.org/rfc/rfc{{doc.rfc_number}}.ps">ps</a>,
71+
{% endif %}
72+
{% if info.has_pdf %}
73+
<a href="http://www.rfc-editor.org/rfc/rfc{{doc.rfc_number}}.pdf">pdf</a>,
74+
{% else %}
75+
{% if info.has_txt %}
6676
<a href="http://www.rfc-editor.org/rfc/pdfrfc/rfc{{doc.rfc_number}}.txt.pdf">pdf</a>,
77+
{% endif %}
78+
{% endif %}
79+
{% if info.has_txt %}
6780
<a href="http://tools.ietf.org/html/rfc{{doc.rfc_number}}">html</a>
81+
{% endif %}
82+
{% else %}
83+
(not online)
84+
{% endif %}
6885
</td></tr>
6986
{% endblock doc_metatable %}
7087

@@ -74,9 +91,17 @@
7491
{% endblock %}
7592

7693
{% block doc_text1 %}
94+
{% if info.has_txt %}
7795
<div class="markup_draft">
7896
{{ content1|safe }}
7997
</div>
98+
{% else %}
99+
{% if info.has_pdf or info.has_ps %}
100+
<p>This RFC is not available in plain text format.</p>
101+
{% else %}
102+
<p>This RFC is not currently available online.</p>
103+
{% endif %}
104+
{% endif %}
80105
{% endblock %}{# doc_text1 #}
81106

82107
{% block doc_text2 %}

0 commit comments

Comments
 (0)