Class: Pageflow::FileImporter
- Inherits:
-
Object
- Object
- Pageflow::FileImporter
- 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
-
#authentication_provider ⇒ Object
Return authentication provider name e.g.
- #authentication_required(user) ⇒ Object
- #download_file(_credentials, _options) ⇒ Object
-
#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’ } ] }.
-
#logo_source ⇒ Object
returns the source for logo shown in the importer select view.
-
#name ⇒ Object
Override to return a string in snake_case.
-
#search(_credentials, _params) ⇒ Object
search method should return the search result according to the criteria given in params.
-
#translation_key ⇒ Object
Name to display in editor.
Instance Method Details
#authentication_provider ⇒ Object
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
54 55 56 |
# File 'lib/pageflow/file_importer.rb', line 54 def download_file(_credentials, ) 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'
}
]
}
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_source ⇒ Object
returns the source for logo shown in the importer select view
17 18 19 |
# File 'lib/pageflow/file_importer.rb', line 17 def logo_source raise(NotImplementedError, 'FileImporter subclass should define logo_source') end |
#name ⇒ Object
Override to return a string in snake_case.
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
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_key ⇒ Object
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 |