Sha256: 5315dad8df2de1370b295c5f1fa83e26cda7cc06ba8f9b51241135cd18654bbd

Contents?: true

Size: 896 Bytes

Versions: 21

Compression:

Stored size: 896 Bytes

Contents

# ~*~ encoding: utf-8 ~*~
module Precious
  module Helpers
    # Extract the path string that Gollum::Wiki expects
    def extract_path(file_path)
      return nil if file_path.nil?
      last_slash = file_path.rindex("/")
      if last_slash
        file_path[0, last_slash]
      end
    end

    # Extract the 'page' name from the file_path
    def extract_name(file_path)
      ::File.basename(file_path)
    end

    def sanitize_empty_params(param)
      [nil,''].include?(param) ? nil : CGI.unescape(param)
    end

    # Remove all slashes from the start of string.
    # Remove all double slashes
    def clean_url url
      return url if url.nil?
      url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
    end

    def trim_leading_slash url
      return url if url.nil?
      url.gsub!('%2F','/')
      return '/' + url.gsub(/^\/+/,'') if url[0,1] == '/'
      url
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gollum-2.4.11 lib/gollum/frontend/helpers.rb
gollum-2.4.10 lib/gollum/frontend/helpers.rb
gollum-2.4.9 lib/gollum/frontend/helpers.rb
gollum-2.4.8 lib/gollum/frontend/helpers.rb
gollum-2.4.7 lib/gollum/frontend/helpers.rb
gollum-2.4.6 lib/gollum/frontend/helpers.rb
gollum-2.4.5 lib/gollum/frontend/helpers.rb
gollum-2.4.4 lib/gollum/frontend/helpers.rb
gollum-2.4.3 lib/gollum/frontend/helpers.rb
gollum-2.4.2 lib/gollum/frontend/helpers.rb
gollum-2.4.1 lib/gollum/frontend/helpers.rb
gollum-2.4.0 lib/gollum/frontend/helpers.rb
gollum-2.3.12 lib/gollum/frontend/helpers.rb
gollum-2.3.11 lib/gollum/frontend/helpers.rb
gollum-2.3.10 lib/gollum/frontend/helpers.rb
gollum-2.3.9 lib/gollum/frontend/helpers.rb
gollum-2.3.8 lib/gollum/frontend/helpers.rb
gollum-2.3.7 lib/gollum/frontend/helpers.rb
gollum-2.3.6 lib/gollum/frontend/helpers.rb
gollum-2.3.5 lib/gollum/frontend/helpers.rb