diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..e2a371d1a42a69b6cc345b90cf2e1168b8a24495 --- /dev/null +++ b/app/controllers/api/application_controller.rb @@ -0,0 +1,7 @@ +class Api::ApplicationController < ApplicationController + layout false + skip_before_action :authenticate_user! + + def index + end +end diff --git a/app/controllers/api/lheo_controller.rb b/app/controllers/api/lheo_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..5e788e8f75c1492838f662ead3b40bfcdd7966c2 --- /dev/null +++ b/app/controllers/api/lheo_controller.rb @@ -0,0 +1,5 @@ +class Api::LheoController < Api::ApplicationController + def index + @programs = current_university.education_programs + end +end diff --git a/app/views/api/application/index.html.erb b/app/views/api/application/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/api/lheo/index.xml.erb b/app/views/api/lheo/index.xml.erb new file mode 100644 index 0000000000000000000000000000000000000000..2e445347736e7288bfefe322542fdc07fbedfe97 --- /dev/null +++ b/app/views/api/lheo/index.xml.erb @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<lheo xmlns="http://lheo.gouv.fr/2.3"> + <offres> + <% @programs.each do |program| %> + <formation> + <intitule-formation><![CDATA[<%= program.name %>]]></intitule-formation> + </formation> + <% end %> + </offres> +</lheo> diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc1899682b01c3a6d9673faf746e235fb64fc4d2..1ce3a81f7e1d1cae513859231bea011311b7add5 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,3 +2,4 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf +Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml ) diff --git a/config/routes.rb b/config/routes.rb index 7bf2ee0b0c0d5c65699cb0a2059c705454874c5b..c6a0a9514d727e96014985a16e4bce7dc81dd2bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,6 +30,7 @@ Rails.application.routes.draw do end draw 'extranet' + draw 'api' get '/media/:signed_id/:filename_with_transformations' => 'media#show', as: :medium diff --git a/config/routes/api.rb b/config/routes/api.rb new file mode 100644 index 0000000000000000000000000000000000000000..729a8fb933db5f40589bce3eed59258fe42d7acf --- /dev/null +++ b/config/routes/api.rb @@ -0,0 +1,4 @@ +namespace :api do + get 'lheo' => 'lheo#index', defaults: { format: :xml } + root to: 'application#index' +end