From d6823d823a7480d1cea3d8ff22f46aa7fef72de1 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 16 Oct 2016 10:33:27 -0400 Subject: [PATCH] Make hardcoded refs to devdocs.io and cdn.devdocs.io config vars --- assets/javascripts/app/config.coffee.erb | 2 +- lib/app.rb | 7 +++++++ views/index.erb | 26 ++++++++++++------------ views/other.erb | 6 +++--- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/assets/javascripts/app/config.coffee.erb b/assets/javascripts/app/config.coffee.erb index 56ac3512..e54a1b73 100644 --- a/assets/javascripts/app/config.coffee.erb +++ b/assets/javascripts/app/config.coffee.erb @@ -12,4 +12,4 @@ app.config = sentry_dsn: '<%= App.sentry_dsn %>' version: <%= Time.now.to_i %> release: <%= Time.now.utc.httpdate.to_json %> - mathml_stylesheet: 'https://cdn.devdocs.io/mathml.css' + mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css' diff --git a/lib/app.rb b/lib/app.rb index d8394d6c..7b1b5c9f 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -17,6 +17,8 @@ class App < Sinatra::Application set :root, Pathname.new(File.expand_path('../..', __FILE__)) set :sprockets, Sprockets::Environment.new(root) + set :cdn_origin, '' + set :assets_prefix, 'assets' set :assets_path, -> { File.join(public_folder, assets_prefix) } set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') } @@ -72,6 +74,7 @@ class App < Sinatra::Application configure :production do set :static, false + set :cdn_origin, 'https://cdn.devdocs.io' set :docs_host, '//docs.devdocs.io' set :csp, "default-src 'self' *; script-src 'self' 'nonce-devdocs' http://cdn.devdocs.io https://cdn.devdocs.io https://www.google-analytics.com https://secure.gaug.es http://*.jquery.com https://*.jquery.com; font-src data:; style-src 'self' 'unsafe-inline' *; img-src 'self' * data:;" @@ -106,6 +109,10 @@ class App < Sinatra::Application include Sinatra::Cookies include Sprockets::Helpers + def canonical_origin + "http://#{request.host_with_port}" + end + def browser @browser ||= Browser.new(request.user_agent) end diff --git a/views/index.erb b/views/index.erb index 30fd75cb..53cdc96c 100644 --- a/views/index.erb +++ b/views/index.erb @@ -7,25 +7,25 @@ - - + + DevDocs API Documentation - + - - - - - - - - - - + + + + + + + + + + <%= javascript_tag 'application', asset_host: false %> <%= javascript_tag 'docs' %><% unless App.production? %> diff --git a/views/other.erb b/views/other.erb index 4c8df481..91110284 100644 --- a/views/other.erb +++ b/views/other.erb @@ -5,10 +5,10 @@ <% if doc_index_page? %><% else %><% end %> - + DevDocs<%= " - #{@doc['full_name']} documentation" if doc_index_page? %> - - + + <%= javascript_tag 'application', asset_host: false %><% unless App.production? %>