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_seed-0.1.1.pre9 lib/enju_seed/bookmark_url.rb
enju_bookmark-0.1.2.pre13 lib/enju_bookmark/bookmark_url.rb
enju_seed-0.1.1.pre8 lib/enju_seed/bookmark_url.rb
enju_seed-0.1.1.pre7 lib/enju_seed/bookmark_url.rb
enju_core-0.2.0.pre2 lib/enju_core/bookmark_url.rb
enju_core-0.1.1.pre6 lib/enju_core/bookmark_url.rb
enju_core-0.1.1.pre5 lib/enju_core/bookmark_url.rb
enju_core-0.2.0.pre1 lib/enju_core/bookmark_url.rb
enju_purchase_request-0.1.0.pre8 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2.pre12 lib/enju_bookmark/bookmark_url.rb
enju_purchase_request-0.1.0.pre7 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2.pre11 lib/enju_bookmark/bookmark_url.rb
enju_bookmark-0.1.2.pre10 lib/enju_bookmark/bookmark_url.rb
enju_bookmark-0.1.2.pre9 lib/enju_bookmark/bookmark_url.rb
enju_core-0.1.1.pre4 lib/enju_core/bookmark_url.rb
enju_purchase_request-0.1.0.pre6 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2.pre8 lib/enju_bookmark/bookmark_url.rb
enju_core-0.1.1.pre3 lib/enju_core/bookmark_url.rb
enju_purchase_request-0.1.0.pre5 lib/enju_purchase_request/bookmark_url.rb
enju_bookmark-0.1.2.pre7 lib/enju_bookmark/bookmark_url.rb