Merge pull request #660 from simonista/fix-github-links

Fix for embedding code from github
This commit is contained in:
bootstraponline
2013-03-19 17:25:36 -07:00
3 changed files with 21 additions and 19 deletions
+10 -10
View File
@@ -462,23 +462,23 @@ module Gollum
# Acceptable formats:
# ```language:local-file.ext```
# ```language:/abs/other-file.ext```
# ```language:gollum/gollum/master/somefile.txt```
# ```language:github:gollum/gollum/master/somefile.txt```
#
#########################################################################
def extract_gitcode data
data.gsub /^[ \t]*``` ?([^:\n\r]+):([^`\n\r]+)```/ do
data.gsub /^[ \t]*``` ?([^:\n\r]+):(?:(github:))?([^`\n\r]+)```/ do
contents = ''
# Use empty string if $2 is nil.
uri = $2 || ''
uri = $3 || ''
# Detect local file.
if uri[0..6] != 'gollum/'
if file = self.find_file(uri, @wiki.ref)
contents = file.raw_data
else
# How do we communicate a render error?
next "File not found: #{Rack::Utils::escape_html(uri)}"
end
if $2.nil?
if file = self.find_file(uri, @wiki.ref)
contents = file.raw_data
else
# How do we communicate a render error?
next "File not found: #{Rack::Utils::escape_html(uri)}"
end
else
contents = Gollum::Gitcode.new(uri).contents
end