Sha256: b94bfb95d8c021bd4455c57eff0dc513fef1a5b581307ed4088bbe2c95e4e44b

Contents?: true

Size: 771 Bytes

Versions: 22

Compression:

Stored size: 771 Bytes

Contents

module PublishMyData
  module ResourcesHelper

    # uses eager loaded data to get the uri or label for a term
    def resource_uri_or_label(resource, term)

      if term.try(:uri?) # if it's a RDF::URI it will respond to uri? with true
        res = resource.get_related_resource(term, PublishMyData::Resource)
        if res
          link_to((res.label || res.uri.to_s), resource_path_from_uri(res.uri))
        else
          link_to term.to_s, resource_path_from_uri(term)
        end
      else
        term.to_s
      end
    end

    def resource_path_from_uri(uri)
      resource = Resource.new(uri)
      if resource.in_domain?(request.host)
        uri.to_s
      else
        publish_my_data.show_resource_path(:uri => uri.to_s)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
publish_my_data-0.0.32 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.31 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.30 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.29 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.28 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.27 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.26 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.25 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.24 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.23 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.22 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.21 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.20 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.19 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.18 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.17 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.16 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.15 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.14 app/helpers/publish_my_data/resources_helper.rb
publish_my_data-0.0.13 app/helpers/publish_my_data/resources_helper.rb