Class: Lcms::Engine::Admin::SketchCompilersController

Inherits:
AdminController show all
Includes:
GoogleCredentials
Defined in:
app/controllers/lcms/engine/admin/sketch_compilers_controller.rb

Constant Summary

Constants inherited from AdminController

AdminController::RE_GOOGLE_FOLDER

Instance Method Summary collapse

Methods inherited from AdminController

settings

Methods included from PathHelper

#dynamic_document_path, #dynamic_material_path, #dynamic_path

Instance Method Details

#compileObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/lcms/engine/admin/sketch_compilers_controller.rb', line 11

def compile
  response = SketchCompiler
               .new(current_user.id, request.remote_ip, params[:version])
               .compile(params[:url], params[:foundational_url])

  if response.success?
    url = DocumentExporter::Gdoc::Base.url_for JSON.parse(response.body)['id']
    redirect_back fallback_location: new_admin_sketch_compiler_path, notice: t('.success', url: url)
  else
    redirect_back fallback_location: new_admin_sketch_compiler_path, alert: t('.compile_error')
  end
end

#newObject



24
25
26
27
# File 'app/controllers/lcms/engine/admin/sketch_compilers_controller.rb', line 24

def new
  head :bad_request unless google_credentials.present?
  @version = params[:version].presence || 'v1'
end