Skip to content
Snippets Groups Projects
Unverified Commit 1bf3e157 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Properly render plain readme

parent 3cdd6847
No related branches found
No related tags found
No related merge requests found
Loading
@@ -17,6 +17,14 @@ pre {
Loading
@@ -17,6 +17,14 @@ pre {
background: #333; background: #333;
color: $background-color; color: $background-color;
} }
&.plain-readme {
background: none;
border: none;
padding: 0;
margin: 0;
font-size: 14px;
}
} }
   
.monospace { .monospace {
Loading
Loading
Loading
@@ -213,6 +213,10 @@ module ApplicationHelper
Loading
@@ -213,6 +213,10 @@ module ApplicationHelper
Haml::Helpers.preserve(markdown(file_content)) Haml::Helpers.preserve(markdown(file_content))
elsif asciidoc?(file_name) elsif asciidoc?(file_name)
asciidoc(file_content) asciidoc(file_content)
elsif plain?(file_name)
content_tag :pre, class: 'plain-readme' do
file_content
end
else else
GitHub::Markup.render(file_name, file_content). GitHub::Markup.render(file_name, file_content).
force_encoding(file_content.encoding).html_safe force_encoding(file_content.encoding).html_safe
Loading
@@ -221,6 +225,10 @@ module ApplicationHelper
Loading
@@ -221,6 +225,10 @@ module ApplicationHelper
simple_format(file_content) simple_format(file_content)
end end
   
def plain?(filename)
Gitlab::MarkupHelper.plain?(filename)
end
def markup?(filename) def markup?(filename)
Gitlab::MarkupHelper.markup?(filename) Gitlab::MarkupHelper.markup?(filename)
end end
Loading
Loading
Loading
@@ -33,6 +33,16 @@ module Gitlab
Loading
@@ -33,6 +33,16 @@ module Gitlab
filename.downcase.end_with?(*%w(.adoc .ad .asciidoc)) filename.downcase.end_with?(*%w(.adoc .ad .asciidoc))
end end
   
# Public: Determines if the given filename is plain text.
#
# filename - Filename string to check
#
# Returns boolean
def plain?(filename)
filename.downcase.end_with?('.txt') ||
filename.downcase == 'readme'
end
def previewable?(filename) def previewable?(filename)
markup?(filename) markup?(filename)
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment