Sha256: 12f1cef7b6f2e5d4bb47c4c4b70208dff20d9bc23a11a98f7f93295bb06ce300

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

module Sufia
  class GenericFilePresenter
    include Hydra::Presenter
    self.model_class = ::GenericFile
    # Terms is the list of fields displayed by app/views/generic_files/_show_descriptions.html.erb
    self.terms = [:resource_type, :title, :creator, :contributor, :description, :tag, :rights,
       :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url]

    # Depositor and permissions are not displayed in app/views/generic_files/_show_descriptions.html.erb
    # so don't include them in `terms'.
    delegate :depositor, :permissions, to: :model

    def tweeter
      user = ::User.find_by_user_key(model.depositor)
      if user.try(:twitter_handle).present?
        "@#{user.twitter_handle}"
      else
        I18n.translate('sufia.product_twitter_handle')
      end
    end

    # Add a schema.org itemtype
    def itemtype
      # Look up the first non-empty resource type value in a hash from the config
      Sufia.config.resource_types_to_schema[resource_type.to_a.reject { |type| type.empty? }.first] || 'http://schema.org/CreativeWork'
    rescue
      'http://schema.org/CreativeWork'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sufia-6.2.0 app/presenters/sufia/generic_file_presenter.rb
sufia-6.1.0 app/presenters/sufia/generic_file_presenter.rb
sufia-6.0.0 app/presenters/sufia/generic_file_presenter.rb
sufia-6.0.0.rc4 app/presenters/sufia/generic_file_presenter.rb
sufia-6.0.0.rc3 app/presenters/sufia/generic_file_presenter.rb