diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-09 12:36:09 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-09 12:36:09 +0300 |
commit | 1bf3e1578abf41d937a2bf8e2512e0174ed0a4b4 (patch) | |
tree | 73d781b23380cac46a1d7e643e5b1e235b769474 | |
parent | 3cdd68475f80c43371610c981b41cd3dc87e3300 (diff) |
Properly render plain readme
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/assets/stylesheets/generic/typography.scss | 8 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/markup_helper.rb | 10 |
3 files changed, 26 insertions, 0 deletions
diff --git a/app/assets/stylesheets/generic/typography.scss b/app/assets/stylesheets/generic/typography.scss index 66767cb13cb..2db4213159a 100644 --- a/app/assets/stylesheets/generic/typography.scss +++ b/app/assets/stylesheets/generic/typography.scss @@ -17,6 +17,14 @@ pre { background: #333; color: $background-color; } + + &.plain-readme { + background: none; + border: none; + padding: 0; + margin: 0; + font-size: 14px; + } } .monospace { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0b46db4b1c3..a803b66c502 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/lib/gitlab/markup_helper.rb b/lib/gitlab/markup_helper.rb index f99be969d3e..b1991e2e285 100644 --- a/lib/gitlab/markup_helper.rb +++ b/lib/gitlab/markup_helper.rb @@ -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 |