Sha256: 73286ecac5922c595084882e7dd9d9a14489ce0c7929dc113ed9a066f3507e54

Contents?: true

Size: 985 Bytes

Versions: 110

Compression:

Stored size: 985 Bytes

Contents

module BookmarkUrl
  def my_host?
    url = ::Addressable::URI.parse(self)
    unless url.host
      raise ::Addressable::URI::InvalidURIError
    end
    config_url = ::Addressable::URI.parse(LibraryGroup.site_config.url)
    if url.host == config_url.host and url.port == config_url.port and ['http', 'https'].include?(url.scheme)
      true
    else
      false
    end
  end

  def bookmarkable?
    if self.my_host?
      url = ::Addressable::URI.parse(self)
      path = url.path.split("/").reverse
      if path[1] == "manifestations" and Manifestation.where(:id => path[0]).first
        true
      else
        false
      end
    else
      true
    end
  rescue ::Addressable::URI::InvalidURIError
    false
  end

  def bookmarkable_id
    if self.my_host?
      path = ::Addressable::URI.parse(self).path.split("/").reverse
      unless path[1] == "manifestations"
        nil
      else
        path[0]
      end
    end
  end
end

class String
  include BookmarkUrl
end

Version data entries

110 entries across 110 versions & 5 rubygems

Version Path
enju_purchase_request-0.3.2 lib/enju_purchase_request/bookmark_url.rb
enju_purchase_request-0.3.1 lib/enju_purchase_request/bookmark_url.rb
enju_purchase_request-0.3.0.beta.1 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.2.2 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.2.1 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.2.1 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.2.0 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.2.0 lib/enju_bookmark/bookmark_url.rb
enju_bookmark-0.2.0.beta.5 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.2.0.beta.2 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.2.0.beta.3 lib/enju_bookmark/bookmark_url.rb
enju_bookmark-0.2.0.beta.2 lib/enju_bookmark/bookmark_url.rb
enju_bookmark-0.2.0.beta.1 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.1.1 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.3 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.1.0 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.1.0.pre15 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2.pre23 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.1.0.pre14 lib/enju_purchase_request/bookmark_url.rb