Class: Pageflow::FileImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/file_importer.rb

Overview

Represents a template for file importer plugins File importer plugin should have one class FileImporter extending this FileImporter

Instance Method Summary collapse

Instance Method Details

#authentication_providerObject

Return authentication provider name e.g. :facebook



22
23
24
# File 'lib/pageflow/file_importer.rb', line 22

def authentication_provider
  nil
end

#authentication_required(user) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/pageflow/file_importer.rb', line 58

def authentication_required(user)
  if authentication_provider.present?
    token = AuthenticationToken.find_auth_token(user, authentication_provider)
    token.nil? || token.empty?
  else
    false
  end
end

#download_file(_credentials, _options) ⇒ Object

this method should return the data against the file mentioned in options the file data will be similar to what is return by get_files_meta_data method use file or file to download the file data.

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/pageflow/file_importer.rb', line 54

def download_file(_credentials, _options)
  raise(NotImplementedError, 'FileImporter subclass needs to define download_file method.')
end

#files_meta_data(_credentials, _params) ⇒ Object

this method returns the meta data of each selected file It should be of the format {

collection: 'collection_name',
files: [
  {
    name: file_name.png,
    id: file_id,
    rights: 'file rights',
    url_or_download_options: '',
    type: 'image/png'
  }
]

}

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/pageflow/file_importer.rb', line 47

def (_credentials, _params)
  raise(NotImplementedError, 'FileImporter subclass needs to define files_meta_data method.')
end

#logo_sourceObject

returns the source for logo shown in the importer select view

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/pageflow/file_importer.rb', line 17

def logo_source
  raise(NotImplementedError, 'FileImporter subclass should define logo_source')
end

#nameObject

Override to return a string in snake_case.

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/pageflow/file_importer.rb', line 12

def name
  raise(NotImplementedError, 'FileImporter subclass needs to define name method.')
end

#search(_credentials, _params) ⇒ Object

search method should return the search result according to the criteria given in params. If authenticaqtionn is required, then authentication data will be provided in credentials param

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/pageflow/file_importer.rb', line 29

def search(_credentials, _params)
  raise(NotImplementedError, 'FileImporter subclass needs to define search method.')
end

#translation_keyObject

Name to display in editor.



7
8
9
# File 'lib/pageflow/file_importer.rb', line 7

def translation_key
  "pageflow.editor.file_importers.#{name}.name"
end