Skip to content

Commit

Permalink
Partially addresses issue #1926 still displaying markdown as text. Fixes
Browse files Browse the repository at this point in the history
 #2704. Commit ready for merge.

 - Legacy-Id: 16557
  • Loading branch information
pusateri committed Jul 20, 2019
1 parent c3ffd09 commit f76c46b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ietf/doc/views_doc.py
Expand Up @@ -586,6 +586,9 @@ def document_main(request, name, rev=None):
if extension == ".txt":
content = doc.text_or_error() # pyflakes:ignore
t = "plain text"
elif extension == ".md":
content = doc.text_or_error() # pyflakes:ignore
t = "markdown"
other_types.append((t, url))

return render(request, "doc/document_material.html",
Expand Down
2 changes: 1 addition & 1 deletion ietf/meeting/forms.py
Expand Up @@ -342,7 +342,7 @@ def clean_file(self):
self.file_encoding = {}
self.file_encoding[file.name] = encoding.replace('charset=','') if encoding else None
if self.mime_types:
if mime_type != file.content_type:
if mime_type != file.content_type and not file.content_type in settings.MEETING_VALID_MAGIC_MIME_TYPES[mime_type]:
raise ValidationError('Upload Content-Type (%s) is different from the observed mime-type (%s)' % (file.content_type, mime_type))
if mime_type in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS:
if not ext in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS[mime_type]:
Expand Down
10 changes: 8 additions & 2 deletions ietf/settings.py
Expand Up @@ -814,18 +814,24 @@ def skip_unreadable_post(record):
}

MEETING_VALID_UPLOAD_MIME_TYPES = {
'agenda': ['text/plain', 'text/html', ],
'minutes': ['text/plain', 'text/html', 'application/pdf', ],
'agenda': ['text/plain', 'text/html', 'text/markdown', ],
'minutes': ['text/plain', 'text/html', 'application/pdf', 'text/markdown', ],
'slides': [],
'bluesheets': ['application/pdf', 'text/plain', ],
}

MEETING_VALID_MIME_TYPE_EXTENSIONS = {
'text/plain': ['.txt', '.md', ],
'text/markdown': ['.txt', '.md', ],
'text/html': ['.html', '.htm'],
'application/pdf': ['.pdf'],
}

MEETING_VALID_MAGIC_MIME_TYPES = {
'text/plain': ['text/plain', 'text/markdown', ],
'text/html': ['text/html', ],
'application/pdf': ['application/pdf', ],
}

INTERNET_DRAFT_DAYS_TO_EXPIRE = 185

Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/meeting/session_agenda_include.html
Expand Up @@ -16,7 +16,7 @@ <h4 class="modal-title" id="label-{{item.slug}}">
<div class="modal-body">
{% with item.session.agenda as agenda %}
{% if agenda %}
{% if agenda.file_extension == "txt" or agenda.file_extension == "html" or agenda.file_extension == "htm" %}
{% if agenda.file_extension == "txt" or agenda.file_extension == "md" or agenda.file_extension == "html" or agenda.file_extension == "htm" %}
<h4>Agenda</h4>
<div class="frame" data-src="{{agenda.href}}"></div>
{% else %}
Expand All @@ -41,7 +41,7 @@ <h4>Slides</h4>

{% with item.session.minutes as minutes %}
{% if minutes %}
{% if minutes.file_extension == "txt" or minutes.file_extension == "html" or minutes.file_extension == "htm" %}
{% if minutes.file_extension == "txt" or minutes.file_extension == "md" or minutes.file_extension == "html" or minutes.file_extension == "htm" %}
<h4>Minutes</h4>
<div class="frame2" data-src="{{minutes.href}}"></div>
{% else %}
Expand Down

0 comments on commit f76c46b

Please sign in to comment.