Sha256: 78ad6a66a3494821dc0af8058cfd221463a0157319ba60963b265b8be5e801f3

Contents?: true

Size: 649 Bytes

Versions: 22

Compression:

Stored size: 649 Bytes

Contents

# ~*~ encoding: utf-8 ~*~

module Gollum
  module Helpers
    
    # If url starts with a leading slash, trim down its number of leading slashes to 1. Else, return url unchanged.
    def trim_leading_slashes(url)
      return nil if url.nil?
      url.gsub!('%2F', '/')
      return '/' + url.gsub(/^\/+/, '') if url[0, 1] == '/'
      url
    end
    
    # Take a link path and turn it into a string for display as link text.
    # For example:
    # '/opt/local/bin/ruby.ext' -> 'ruby'
    def path_to_link_text(str)
      return nil unless str
      ::File.basename(str, Page.valid_extension?(str) ? ::File.extname(str) : '')
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
gollum-lib-5.2.4-java lib/gollum-lib/helpers.rb
gollum-lib-5.2.4 lib/gollum-lib/helpers.rb
gollum-lib-5.2.3-java lib/gollum-lib/helpers.rb
gollum-lib-5.2.3 lib/gollum-lib/helpers.rb
gollum-lib-5.2.2-java lib/gollum-lib/helpers.rb
gollum-lib-5.2.2 lib/gollum-lib/helpers.rb
gollum-lib-5.2.1-java lib/gollum-lib/helpers.rb
gollum-lib-5.2.1 lib/gollum-lib/helpers.rb
gollum-lib-5.2-java lib/gollum-lib/helpers.rb
gollum-lib-5.2 lib/gollum-lib/helpers.rb
gollum-lib-5.1.3-java lib/gollum-lib/helpers.rb
gollum-lib-5.1.3 lib/gollum-lib/helpers.rb
gollum-lib-5.1.2-java lib/gollum-lib/helpers.rb
gollum-lib-5.1.2 lib/gollum-lib/helpers.rb
gollum-lib-5.1.1-java lib/gollum-lib/helpers.rb
gollum-lib-5.1.1 lib/gollum-lib/helpers.rb
gollum-lib-5.1-java lib/gollum-lib/helpers.rb
gollum-lib-5.1 lib/gollum-lib/helpers.rb
gollum-lib-5.0.6-java lib/gollum-lib/helpers.rb
gollum-lib-5.0.6 lib/gollum-lib/helpers.rb