Merge branch 'plain-readme' into 'master'

Properly render plain readme

## Before

![Screenshot_2015-07-09_11.38.16](https://gitlab.com/gitlab-org/gitlab-ce/uploads/ba53ad380060eba368aed4ecc71ff4da/Screenshot_2015-07-09_11.38.16.png)

## After

![Screenshot_2015-07-09_11.37.38](https://gitlab.com/gitlab-org/gitlab-ce/uploads/b154c5464c3f89d3ed7a0e7157ee6c58/Screenshot_2015-07-09_11.37.38.png)

cc @rspeicher

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !945
This commit is contained in:
Dmitriy Zaporozhets
2015-07-09 09:54:31 +00:00
3 changed files with 26 additions and 0 deletions
@@ -17,6 +17,14 @@ pre {
background: #333;
color: $background-color;
}
&.plain-readme {
background: none;
border: none;
padding: 0;
margin: 0;
font-size: 14px;
}
}
.monospace {
+8
View File
@@ -213,6 +213,10 @@ module ApplicationHelper
Haml::Helpers.preserve(markdown(file_content))
elsif asciidoc?(file_name)
asciidoc(file_content)
elsif plain?(file_name)
content_tag :pre, class: 'plain-readme' do
file_content
end
else
GitHub::Markup.render(file_name, file_content).
force_encoding(file_content.encoding).html_safe
@@ -221,6 +225,10 @@ module ApplicationHelper
simple_format(file_content)
end
def plain?(filename)
Gitlab::MarkupHelper.plain?(filename)
end
def markup?(filename)
Gitlab::MarkupHelper.markup?(filename)
end
+10
View File
@@ -33,6 +33,16 @@ module Gitlab
filename.downcase.end_with?(*%w(.adoc .ad .asciidoc))
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)
markup?(filename)
end