Skip to content

Commit 7039520

Browse files
committed
Merged in [16557] from pusateri@bangj.com:
Partially addresses issue ietf-tools#1926 still displaying markdown as text. Fixes ietf-tools#2704. - Legacy-Id: 16576 Note: SVN reference [16557] has been migrated to Git commit f76c46b
1 parent 5a1c359 commit 7039520

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

ietf/doc/views_doc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,11 @@ def document_main(request, name, rev=None):
584584
if not url.endswith("/") and not url.endswith(extension):
585585
url = urlbase + extension
586586
if extension == ".txt":
587-
content = doc.text_or_error() # pyflakes:ignore
587+
content = doc.text_or_error()
588588
t = "plain text"
589+
elif extension == ".md":
590+
content = doc.text_or_error()
591+
t = "markdown"
589592
other_types.append((t, url))
590593

591594
return render(request, "doc/document_material.html",

ietf/meeting/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def clean_file(self):
342342
self.file_encoding = {}
343343
self.file_encoding[file.name] = encoding.replace('charset=','') if encoding else None
344344
if self.mime_types:
345-
if mime_type != file.content_type:
345+
if not file.content_type in settings.MEETING_VALID_UPLOAD_MIME_FOR_OBSERVED_MIME[mime_type]:
346346
raise ValidationError('Upload Content-Type (%s) is different from the observed mime-type (%s)' % (file.content_type, mime_type))
347347
if mime_type in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS:
348348
if not ext in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS[mime_type]:

ietf/meeting/tests_views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,8 +1840,9 @@ def test_upload_minutes_agenda(self):
18401840
self.assertNotIn('<section>', text)
18411841
self.assertIn('charset="utf-8"', text)
18421842

1843+
# txt upload
18431844
test_file = BytesIO(b'This is some text for a test, with the word\nvirtual at the beginning of a line.')
1844-
test_file.name = "not_really.txt"
1845+
test_file.name = "some.txt"
18451846
r = self.client.post(url,dict(file=test_file,apply_to_all=False))
18461847
self.assertEqual(r.status_code, 302)
18471848
doc = session.sessionpresentation_set.filter(document__type_id=doctype).first().document
@@ -1853,7 +1854,7 @@ def test_upload_minutes_agenda(self):
18531854
q = PyQuery(r.content)
18541855
self.assertIn('Revise', six.text_type(q("Title")))
18551856
test_file = BytesIO(b'this is some different text for a test')
1856-
test_file.name = "also_not_really.txt"
1857+
test_file.name = "also_some.txt"
18571858
r = self.client.post(url,dict(file=test_file,apply_to_all=True))
18581859
self.assertEqual(r.status_code, 302)
18591860
doc = Document.objects.get(pk=doc.pk)

ietf/settings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,18 +814,24 @@ def skip_unreadable_post(record):
814814
}
815815

816816
MEETING_VALID_UPLOAD_MIME_TYPES = {
817-
'agenda': ['text/plain', 'text/html', ],
818-
'minutes': ['text/plain', 'text/html', 'application/pdf', ],
817+
'agenda': ['text/plain', 'text/html', 'text/markdown', ],
818+
'minutes': ['text/plain', 'text/html', 'application/pdf', 'text/markdown', ],
819819
'slides': [],
820820
'bluesheets': ['application/pdf', 'text/plain', ],
821821
}
822822

823823
MEETING_VALID_MIME_TYPE_EXTENSIONS = {
824824
'text/plain': ['.txt', '.md', ],
825+
'text/markdown': ['.txt', '.md', ],
825826
'text/html': ['.html', '.htm'],
826827
'application/pdf': ['.pdf'],
827828
}
828829

830+
MEETING_VALID_UPLOAD_MIME_FOR_OBSERVED_MIME = {
831+
'text/plain': ['text/plain', 'text/markdown', ],
832+
'text/html': ['text/html', ],
833+
'application/pdf': ['application/pdf', ],
834+
}
829835

830836
INTERNET_DRAFT_DAYS_TO_EXPIRE = 185
831837

ietf/templates/meeting/session_agenda_include.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h4 class="modal-title" id="label-{{item.slug}}">
1616
<div class="modal-body">
1717
{% with item.session.agenda as agenda %}
1818
{% if agenda %}
19-
{% if agenda.file_extension == "txt" or agenda.file_extension == "html" or agenda.file_extension == "htm" %}
19+
{% if agenda.file_extension == "txt" or agenda.file_extension == "md" or agenda.file_extension == "html" or agenda.file_extension == "htm" %}
2020
<h4>Agenda</h4>
2121
<div class="frame" data-src="{{agenda.href}}"></div>
2222
{% else %}
@@ -41,7 +41,7 @@ <h4>Slides</h4>
4141

4242
{% with item.session.minutes as minutes %}
4343
{% if minutes %}
44-
{% if minutes.file_extension == "txt" or minutes.file_extension == "html" or minutes.file_extension == "htm" %}
44+
{% if minutes.file_extension == "txt" or minutes.file_extension == "md" or minutes.file_extension == "html" or minutes.file_extension == "htm" %}
4545
<h4>Minutes</h4>
4646
<div class="frame2" data-src="{{minutes.href}}"></div>
4747
{% else %}

0 commit comments

Comments
 (0)