Module: Gollum::Helpers

Included in:
Filter, Markup
Defined in:
lib/gollum-lib/helpers.rb

Instance Method Summary collapse

Instance Method Details

Take a link path and turn it into a string for display as link text. For example: ‘/opt/local/bin/ruby.ext’ -> ‘ruby’



17
18
19
20
# File 'lib/gollum-lib/helpers.rb', line 17

def path_to_link_text(str)
  return nil unless str
  ::File.basename(str, Page.valid_extension?(str) ? ::File.extname(str) : '')
end

#trim_leading_slashes(url) ⇒ Object

Replace url-encoded slashes (‘%2F’) with slashes Clean up double slashes



8
9
10
11
12
# File 'lib/gollum-lib/helpers.rb', line 8

def trim_leading_slashes(url)
  return nil if url.nil?
  url.gsub!('%2F', '/')
  Pathname.new(url).cleanpath.to_s
end