parent
b78fd0c130
commit
52c521ffe8
4 changed files with 28 additions and 8 deletions
|
@ -24,4 +24,14 @@ module TreeHelper
|
||||||
content.name
|
content.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Determines if a given filename is compatible with GitHub::Markup.
|
||||||
|
#
|
||||||
|
# filename - Filename string to check
|
||||||
|
#
|
||||||
|
# Returns boolean
|
||||||
|
def markup?(filename)
|
||||||
|
filename.end_with?(*%w(.mdown .md .markdown .textile .rdoc .org .creole
|
||||||
|
.mediawiki .rst .asciidoc .pod))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,11 +43,7 @@
|
||||||
%i.icon-file
|
%i.icon-file
|
||||||
= content.name
|
= content.name
|
||||||
.file_content.wiki
|
.file_content.wiki
|
||||||
- if content.name =~ /\.(md|markdown)$/i
|
= raw GitHub::Markup.render(content.name, content.data)
|
||||||
= preserve do
|
|
||||||
= markdown(content.data)
|
|
||||||
- else
|
|
||||||
= simple_format(content.data)
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
= link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small"
|
= link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small"
|
||||||
= link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small"
|
= link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small"
|
||||||
- if file.text?
|
- if file.text?
|
||||||
- if name =~ /\.(md|markdown)$/i
|
- if markup?(name)
|
||||||
.file_content.wiki
|
.file_content.wiki
|
||||||
= preserve do
|
= raw GitHub::Markup.render(name, file.data)
|
||||||
= markdown(file.data)
|
|
||||||
- else
|
- else
|
||||||
.file_content.code
|
.file_content.code
|
||||||
- unless file.empty?
|
- unless file.empty?
|
||||||
|
|
15
spec/helpers/tree_helper_spec.rb
Normal file
15
spec/helpers/tree_helper_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe TreeHelper do
|
||||||
|
describe '#markup?' do
|
||||||
|
%w(mdown md markdown textile rdoc org creole mediawiki rst asciidoc pod).each do |type|
|
||||||
|
it "returns true for #{type} files" do
|
||||||
|
markup?("README.#{type}").should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false when given a non-markup filename" do
|
||||||
|
markup?('README.rb').should_not be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue