Class: Lcms::Engine::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Lcms::Engine::ResourcesController
- Defined in:
- app/controllers/lcms/engine/resources_controller.rb
Instance Method Summary collapse
Instance Method Details
#generic ⇒ Object
35 36 37 38 39 40 |
# File 'app/controllers/lcms/engine/resources_controller.rb', line 35 def generic resource = Resource.find(params[:id]) return redirect_to lcms_engine.resource_path(resource) unless resource.generic? @resource = GenericPresenter.new(resource) end |
#media ⇒ Object
28 29 30 31 32 33 |
# File 'app/controllers/lcms/engine/resources_controller.rb', line 28 def media resource = Resource.find(params[:id]) return redirect_to lcms_engine.resource_path(resource) unless resource.media? @resource = MediaPresenter.new(resource) end |
#pdf_proxy ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/lcms/engine/resources_controller.rb', line 42 def pdf_proxy return head(:not_found) if (url = params[:url]).blank? uri = URI.parse(Addressable::URI.escape url) send_data uri.open.read, disposition: :inline, file_name: url.split('/').last rescue StandardError => e Rails.logger.warn "PDF-proxy failed! Url: #{url}, Error: #{e.}" head :bad_request end |
#related_instruction ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/lcms/engine/resources_controller.rb', line 22 def @resource = Resource.find params[:id] @related_instructions = render json: { instructions: @instructions } end |
#show ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/lcms/engine/resources_controller.rb', line 6 def show @resource = find_resource # redirect to document if resource has it (#161) return redirect_to dynamic_document_path(@resource.document) if @resource.document? # redirect grade and module to explore_curriculum (#122) return redirect_to lcms_engine.explore_curriculum_index_path(p: @resource.slug, e: 1) if grade_or_module? # redirect to the path with slug if we are using just the id return redirect_to lcms_engine.show_with_slug_path(@resource.slug), status: 301 if using_id? @related_instructions = @props = CurriculumMap.new(@resource).props end |