mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-12 08:16:33 +02:00
handle README file
This commit is contained in:
@@ -102,7 +102,7 @@ class Anonymous_Github:
|
|||||||
return ""
|
return ""
|
||||||
if file.size > 1000000:
|
if file.size > 1000000:
|
||||||
return Markup("The file %s is too big to be anonymized (beyond 1MB, Github limit)" % (file.name))
|
return Markup("The file %s is too big to be anonymized (beyond 1MB, Github limit)" % (file.name))
|
||||||
if ".md" in file.name:
|
if ".md" in file.name or file.name == file.name.upper() or "changelog" == file.name.lower():
|
||||||
return Markup("<div class='markdown-body'>%s</div>" % remove_terms(
|
return Markup("<div class='markdown-body'>%s</div>" % remove_terms(
|
||||||
self.github.render_markdown(file.decoded_content.decode('utf-8')).decode('utf-8'),
|
self.github.render_markdown(file.decoded_content.decode('utf-8')).decode('utf-8'),
|
||||||
repository_configuration))
|
repository_configuration))
|
||||||
@@ -197,7 +197,7 @@ class Anonymous_Github:
|
|||||||
content_type = 'text/plain; charset=utf-8'
|
content_type = 'text/plain; charset=utf-8'
|
||||||
if ".html" in file_name:
|
if ".html" in file_name:
|
||||||
content_type = 'text/html; charset=utf-8'
|
content_type = 'text/html; charset=utf-8'
|
||||||
if ".md" in file_name:
|
if ".md" in file_name or file.name == file.name.upper():
|
||||||
content_type = 'text/html; charset=utf-8'
|
content_type = 'text/html; charset=utf-8'
|
||||||
if ".jpg" in file_name \
|
if ".jpg" in file_name \
|
||||||
or ".png" in file_name \
|
or ".png" in file_name \
|
||||||
@@ -312,7 +312,7 @@ class Anonymous_Github:
|
|||||||
if type(current_file) is not github.ContentFile.ContentFile:
|
if type(current_file) is not github.ContentFile.ContentFile:
|
||||||
files = g_repo.get_git_tree(g_commit.sha)
|
files = g_repo.get_git_tree(g_commit.sha)
|
||||||
for f in current_file:
|
for f in current_file:
|
||||||
if f.name.lower() == "readme.md" or f.name.lower() == "index.html":
|
if f.name.lower() == "readme" or f.name.lower() == "index.html":
|
||||||
current_file = f
|
current_file = f
|
||||||
break
|
break
|
||||||
elif current_file.type == 'file':
|
elif current_file.type == 'file':
|
||||||
@@ -376,7 +376,6 @@ class Anonymous_Github:
|
|||||||
|
|
||||||
content = get_content(current_file, files, clean_path, repository_configuration, g_repo)
|
content = get_content(current_file, files, clean_path, repository_configuration, g_repo)
|
||||||
content_type = get_type_content(current_file.name, clean_path, repository_configuration, g_repo)
|
content_type = get_type_content(current_file.name, clean_path, repository_configuration, g_repo)
|
||||||
|
|
||||||
return content, {'Content-Type': content_type}
|
return content, {'Content-Type': content_type}
|
||||||
|
|
||||||
@application.route('/', methods=['GET'])
|
@application.route('/', methods=['GET'])
|
||||||
|
|||||||
Reference in New Issue
Block a user