Merged in [16557] from pusateri@bangj.com:
Partially addresses issue #1926 still displaying markdown as text. Fixes #2704.
- Legacy-Id: 16576
Note: SVN reference [16557] has been migrated to Git commit f76c46bef0
This commit is contained in:
parent
5a1c35909a
commit
7039520557
|
@ -584,8 +584,11 @@ def document_main(request, name, rev=None):
|
||||||
if not url.endswith("/") and not url.endswith(extension):
|
if not url.endswith("/") and not url.endswith(extension):
|
||||||
url = urlbase + extension
|
url = urlbase + extension
|
||||||
if extension == ".txt":
|
if extension == ".txt":
|
||||||
content = doc.text_or_error() # pyflakes:ignore
|
content = doc.text_or_error()
|
||||||
t = "plain text"
|
t = "plain text"
|
||||||
|
elif extension == ".md":
|
||||||
|
content = doc.text_or_error()
|
||||||
|
t = "markdown"
|
||||||
other_types.append((t, url))
|
other_types.append((t, url))
|
||||||
|
|
||||||
return render(request, "doc/document_material.html",
|
return render(request, "doc/document_material.html",
|
||||||
|
|
|
@ -342,7 +342,7 @@ class FileUploadForm(forms.Form):
|
||||||
self.file_encoding = {}
|
self.file_encoding = {}
|
||||||
self.file_encoding[file.name] = encoding.replace('charset=','') if encoding else None
|
self.file_encoding[file.name] = encoding.replace('charset=','') if encoding else None
|
||||||
if self.mime_types:
|
if self.mime_types:
|
||||||
if mime_type != file.content_type:
|
if not file.content_type in settings.MEETING_VALID_UPLOAD_MIME_FOR_OBSERVED_MIME[mime_type]:
|
||||||
raise ValidationError('Upload Content-Type (%s) is different from the observed mime-type (%s)' % (file.content_type, 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 mime_type in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS:
|
||||||
if not ext in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS[mime_type]:
|
if not ext in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS[mime_type]:
|
||||||
|
|
|
@ -1840,8 +1840,9 @@ class MaterialsTests(TestCase):
|
||||||
self.assertNotIn('<section>', text)
|
self.assertNotIn('<section>', text)
|
||||||
self.assertIn('charset="utf-8"', text)
|
self.assertIn('charset="utf-8"', text)
|
||||||
|
|
||||||
|
# txt upload
|
||||||
test_file = BytesIO(b'This is some text for a test, with the word\nvirtual at the beginning of a line.')
|
test_file = BytesIO(b'This is some text for a test, with the word\nvirtual at the beginning of a line.')
|
||||||
test_file.name = "not_really.txt"
|
test_file.name = "some.txt"
|
||||||
r = self.client.post(url,dict(file=test_file,apply_to_all=False))
|
r = self.client.post(url,dict(file=test_file,apply_to_all=False))
|
||||||
self.assertEqual(r.status_code, 302)
|
self.assertEqual(r.status_code, 302)
|
||||||
doc = session.sessionpresentation_set.filter(document__type_id=doctype).first().document
|
doc = session.sessionpresentation_set.filter(document__type_id=doctype).first().document
|
||||||
|
@ -1853,7 +1854,7 @@ class MaterialsTests(TestCase):
|
||||||
q = PyQuery(r.content)
|
q = PyQuery(r.content)
|
||||||
self.assertIn('Revise', six.text_type(q("Title")))
|
self.assertIn('Revise', six.text_type(q("Title")))
|
||||||
test_file = BytesIO(b'this is some different text for a test')
|
test_file = BytesIO(b'this is some different text for a test')
|
||||||
test_file.name = "also_not_really.txt"
|
test_file.name = "also_some.txt"
|
||||||
r = self.client.post(url,dict(file=test_file,apply_to_all=True))
|
r = self.client.post(url,dict(file=test_file,apply_to_all=True))
|
||||||
self.assertEqual(r.status_code, 302)
|
self.assertEqual(r.status_code, 302)
|
||||||
doc = Document.objects.get(pk=doc.pk)
|
doc = Document.objects.get(pk=doc.pk)
|
||||||
|
|
|
@ -814,18 +814,24 @@ MEETING_VALID_UPLOAD_EXTENSIONS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
MEETING_VALID_UPLOAD_MIME_TYPES = {
|
MEETING_VALID_UPLOAD_MIME_TYPES = {
|
||||||
'agenda': ['text/plain', 'text/html', ],
|
'agenda': ['text/plain', 'text/html', 'text/markdown', ],
|
||||||
'minutes': ['text/plain', 'text/html', 'application/pdf', ],
|
'minutes': ['text/plain', 'text/html', 'application/pdf', 'text/markdown', ],
|
||||||
'slides': [],
|
'slides': [],
|
||||||
'bluesheets': ['application/pdf', 'text/plain', ],
|
'bluesheets': ['application/pdf', 'text/plain', ],
|
||||||
}
|
}
|
||||||
|
|
||||||
MEETING_VALID_MIME_TYPE_EXTENSIONS = {
|
MEETING_VALID_MIME_TYPE_EXTENSIONS = {
|
||||||
'text/plain': ['.txt', '.md', ],
|
'text/plain': ['.txt', '.md', ],
|
||||||
|
'text/markdown': ['.txt', '.md', ],
|
||||||
'text/html': ['.html', '.htm'],
|
'text/html': ['.html', '.htm'],
|
||||||
'application/pdf': ['.pdf'],
|
'application/pdf': ['.pdf'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEETING_VALID_UPLOAD_MIME_FOR_OBSERVED_MIME = {
|
||||||
|
'text/plain': ['text/plain', 'text/markdown', ],
|
||||||
|
'text/html': ['text/html', ],
|
||||||
|
'application/pdf': ['application/pdf', ],
|
||||||
|
}
|
||||||
|
|
||||||
INTERNET_DRAFT_DAYS_TO_EXPIRE = 185
|
INTERNET_DRAFT_DAYS_TO_EXPIRE = 185
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
{% with item.session.agenda as agenda %}
|
{% with item.session.agenda as agenda %}
|
||||||
{% if 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>
|
<h4>Agenda</h4>
|
||||||
<div class="frame" data-src="{{agenda.href}}"></div>
|
<div class="frame" data-src="{{agenda.href}}"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
{% with item.session.minutes as minutes %}
|
{% with item.session.minutes as minutes %}
|
||||||
{% if 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>
|
<h4>Minutes</h4>
|
||||||
<div class="frame2" data-src="{{minutes.href}}"></div>
|
<div class="frame2" data-src="{{minutes.href}}"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in a new issue