diff --git a/app/controllers/concerns/apps_validator.rb b/app/controllers/concerns/apps_validator.rb index e9480fce..669e1284 100644 --- a/app/controllers/concerns/apps_validator.rb +++ b/app/controllers/concerns/apps_validator.rb @@ -58,19 +58,19 @@ def lti_app_url(name) end def lti_icon(app_name) - return "http://#{request.host_with_port}#{Rails.configuration.assets.prefix}/icon.svg" if app_name == 'default' - begin app = lti_app(app_name) uri = URI.parse(app['redirect_uri'].sub('https', 'http')) site = "#{uri.scheme}://#{uri.host}#{uri.port != 80 ? ":#{uri.port}" : ''}/" path = uri.path.split('/') - path_base = "#{(path[0].chomp(' ') == '' ? path[1] : path[0]).gsub('/', '')}/" + path_base = "#{(path[0].chomp(' ') == '' ? path[1] : path[0]).gsub('/', '')}/#{app_name}" + relative_url_root = Rails.configuration.relative_url_root + path_base = relative_url_root[0] == '/' ? relative_url_root[1..] : relative_url_root if app_name == 'default' rescue StandardError # TODO: handle exception logger.error("App #{app_name} is not registered.") return end - "#{site}#{"#{path_base}#{app_name}/assets/icon.svg"}" + "#{site}#{"#{path_base}/assets/icon.svg"}" end end diff --git a/app/controllers/concerns/deep_link_service.rb b/app/controllers/concerns/deep_link_service.rb index 07dec346..bafc9c93 100644 --- a/app/controllers/concerns/deep_link_service.rb +++ b/app/controllers/concerns/deep_link_service.rb @@ -20,11 +20,17 @@ module DeepLinkService include ActiveSupport::Concern # custom_params are passed as a hash of {'key': 'value'} objects. - def deep_link_resource(url, title, custom_params = {}) + def deep_link_resource(url, title, text, icon, custom_params = {}) { 'type' => 'ltiResourceLink', - 'title' => title, 'url' => url, + 'title' => title, + 'text' => text, + 'icon' => { + "url": icon, + "width": 100, + "height": 100, + }, 'presentation' => { 'documentTarget' => 'window', }, diff --git a/app/controllers/concerns/dynamic_registration_service.rb b/app/controllers/concerns/dynamic_registration_service.rb index 7e33b30a..7d10ab18 100644 --- a/app/controllers/concerns/dynamic_registration_service.rb +++ b/app/controllers/concerns/dynamic_registration_service.rb @@ -45,7 +45,7 @@ def client_registration_request_body(key_token) deep_link_request_launch_url(protocol: 'https'),], "client_name": t("apps.#{tool}.title"), "jwks_uri": jwks_uri, - # "logo_uri": 'https://client.example.org/logo.png', + "logo_uri": secure_url(lti_icon(params[:app])), # "policy_uri": 'https://client.example.org/privacy', # "policy_uri#ja": 'https://client.example.org/privacy?lang=ja', # "tos_uri": 'https://client.example.org/tos', diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 198f4d84..2c41cb64 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -170,7 +170,7 @@ def deep_link # Remove the default tool unless working in development mode. apps -= ['default'] unless Rails.configuration.developer_mode_enabled apps.each do |app| - resource = deep_link_resource(openid_launch_url, "My #{app.singularize}", { 'broker_app': app }) + resource = deep_link_resource(openid_launch_url, "My #{app.singularize}", '', secure_url(lti_icon(app)), { 'broker_app': app }) deep_link_jwt_message = deep_link_jwt_response(lti_registration_params(@jwt_body['iss']), @jwt_header, @jwt_body, [resource]) @apps << { app_name: app, deep_link_jwt_message: deep_link_jwt_message } end diff --git a/config/environments/production.rb b/config/environments/production.rb index cbbbb191..6fbf9853 100755 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -49,7 +49,7 @@ # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + config.assets.compile = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = 'http://assets.example.com' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e9731dae..1f139c59 100755 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -28,3 +28,5 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) + +Rails.application.config.assets.prefix = '/assets'