Commit d6c037de81096680db07397a44a0824355c703c8

Authored by Dmitriy Zaporozhets
1 parent 03770698

Dont render README with markup if format is not compatible

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/helpers/application_helper.rb
... ... @@ -217,4 +217,8 @@ module ApplicationHelper
217 217 haml_tag :script, "$('." + html_class + "').timeago().tooltip()"
218 218 end.html_safe
219 219 end
  220 +
  221 + def render_markup(file_name, file_content)
  222 + GitHub::Markup.render(file_name, file_content).html_safe
  223 + end
220 224 end
... ...
app/views/projects/blob/_text.html.haml
... ... @@ -4,7 +4,7 @@
4 4 = markdown(blob.data)
5 5 - elsif markup?(blob.name)
6 6 .file-content.wiki
7   - = raw GitHub::Markup.render(blob.name, blob.data)
  7 + = render_markup(blob.name, blob.data)
8 8 - else
9 9 .file-content.code
10 10 - unless blob.empty?
... ...
app/views/projects/tree/_readme.html.haml
... ... @@ -9,5 +9,5 @@
9 9 - elsif plain_text_readme?(readme.name)
10 10 %pre.clean
11 11 = readme.data
12   - - else
13   - = raw GitHub::Markup.render(readme.name, readme.data)
  12 + - elsif markup?(readme.name)
  13 + = render_markup(readme.name, readme.data)
... ...
app/views/snippets/_blob.html.haml
... ... @@ -15,7 +15,7 @@
15 15 = markdown(@snippet.data)
16 16 - elsif markup?(@snippet.file_name)
17 17 .file-content.wiki
18   - = raw GitHub::Markup.render(@snippet.file_name, @snippet.data)
  18 + = render_markup(@snippet.file_name, @snippet.data)
19 19 - else
20 20 .file-content.code
21 21 %div{class: user_color_scheme_class}
... ...