Class: Tasks::Sources::NewSourceController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/sources/new_source_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#citation_paramObject (protected)



26
27
28
29
30
31
32
# File 'app/controllers/tasks/sources/new_source_controller.rb', line 26

def citation_param
  begin
    params.require(:citation)
  rescue ActionController::ParameterMissing
    nil
  end
end

#crossref_previewObject

GET /sources/new_source/crossref_preview.json



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/tasks/sources/new_source_controller.rb', line 8

def crossref_preview
  if citation_param.blank?
    render json: :invalid_request
  else
    @source = Vendor::Serrano.new_from_citation(citation: citation_param)
    @source ||= Source::Bibtex.new
    render '/sources/show'
  end
rescue Vendor::Serrano::CrossrefBibtexParseError => e
  render json: {
    error: 'Crossref returned BibTeX that could not be parsed.',
    doi: e.doi,
    bibtex: e.bibtex
  }, status: :unprocessable_content
end

#indexObject



4
5
# File 'app/controllers/tasks/sources/new_source_controller.rb', line 4

def index
end