History

Make hardcoded refs to devdocs.io and cdn.devdocs.io config vars

Thibaut Courouble committed 10 years ago

Commit d6823d81 parent 0cb57d54 files · +24 −17Browse files

Unified · Split

4 files
  1. assets/javascripts/app/config.coffee.erb +1 −1
  2. lib/app.rb +7 −0
  3. views/index.erb +13 −13
  4. views/other.erb +3 −3
assets/javascripts/app/config.coffee.erb+1−1
@@ -12,4 +12,4 @@ app.config = · 11 unmodified lines
1212 sentry_dsn: '<%= App.sentry_dsn %>'
1313 version: <%= Time.now.to_i %>
1414 release: <%= Time.now.utc.httpdate.to_json %>
15− mathml_stylesheet: 'https://cdn.devdocs.io/mathml.css'
15+ mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'
lib/app.rb+7−0
@@ -17,6 +17,8 @@ class App < Sinatra::Application · 16 unmodified lines
1717 set :root, Pathname.new(File.expand_path('../..', __FILE__))
1818 set :sprockets, Sprockets::Environment.new(root)
1919
20+ set :cdn_origin, ''
21+
2022 set :assets_prefix, 'assets'
2123 set :assets_path, -> { File.join(public_folder, assets_prefix) }
2224 set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') }
@@ -72,6 +74,7 @@ class App < Sinatra::Application · 49 unmodified lines
7274
7375 configure :production do
7476 set :static, false
77+ set :cdn_origin, 'https://cdn.devdocs.io'
7578 set :docs_host, '//docs.devdocs.io'
7679 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:;"
7780
@@ -106,6 +109,10 @@ class App < Sinatra::Application · 28 unmodified lines
106109 include Sinatra::Cookies
107110 include Sprockets::Helpers
108111
112+ def canonical_origin
113+ "http://#{request.host_with_port}"
114+ end
115+
109116 def browser
110117 @browser ||= Browser.new(request.user_agent)
111118 end
views/index.erb+13−13
@@ -7,25 +7,25 @@ · 6 unmodified lines
77 <meta property="og:title" content="DevDocs">
88 <meta property="og:description" content="DevDocs is an API documentation browser that combines 100+ docs in a single UI with offline mode, instant search, keyboard shortcuts, and more.">
99 <meta property="og:type" content="website">
10− <meta property="og:url" content="http://devdocs.io">
11− <meta property="og:image" content="https://cdn.devdocs.io/images/icon-128.png">
10+ <meta property="og:url" content="<%= canonical_origin %>">
11+ <meta property="og:image" content="<%= App.cdn_origin %>/images/icon-128.png">
1212 <meta name="apple-mobile-web-app-capable" content="yes">
1313 <meta name="apple-mobile-web-app-status-bar-style" content="black">
1414 <meta name="format-detection" content="telephone=no">
1515 <meta name="robots" content="noodp">
1616 <title>DevDocs API Documentation</title>
17− <link rel="canonical" href="http://devdocs.io">
17+ <link rel="canonical" href="<%= canonical_origin %>">
1818 <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="DevDocs Search">
19− <link rel="alternate" href="http://devdocs.io/feed" title="DevDocs" type="application/atom+xml">
20− <link rel="icon" type="image/x-icon" href="https://cdn.devdocs.io/favicon.ico">
21− <link rel="fluid-icon" href="https://cdn.devdocs.io/images/fluid-icon.png" title="DevDocs">
22− <link rel="apple-touch-icon" sizes="72x72" href="https://cdn.devdocs.io/images/apple-icon-72.png">
23− <link rel="apple-touch-icon" sizes="76x76" href="https://cdn.devdocs.io/images/apple-icon-76.png">
24− <link rel="apple-touch-icon" sizes="114x114" href="https://cdn.devdocs.io/images/apple-icon-114.png">
25− <link rel="apple-touch-icon" sizes="120x120" href="https://cdn.devdocs.io/images/apple-icon-120.png">
26− <link rel="apple-touch-icon" sizes="144x144" href="https://cdn.devdocs.io/images/apple-icon-144.png">
27− <link rel="apple-touch-icon" sizes="152x152" href="https://cdn.devdocs.io/images/apple-icon-152.png">
28− <link rel="apple-touch-icon" sizes="160x160" href="https://cdn.devdocs.io/images/apple-icon-160.png">
19+ <link rel="alternate" href="<%= canonical_origin %>/feed" title="DevDocs" type="application/atom+xml">
20+ <link rel="icon" type="image/x-icon" href="<%= App.cdn_origin %>/favicon.ico">
21+ <link rel="fluid-icon" href="<%= App.cdn_origin %>/images/fluid-icon.png" title="DevDocs">
22+ <link rel="apple-touch-icon" sizes="72x72" href="<%= App.cdn_origin %>/images/apple-icon-72.png">
23+ <link rel="apple-touch-icon" sizes="76x76" href="<%= App.cdn_origin %>/images/apple-icon-76.png">
24+ <link rel="apple-touch-icon" sizes="114x114" href="<%= App.cdn_origin %>/images/apple-icon-114.png">
25+ <link rel="apple-touch-icon" sizes="120x120" href="<%= App.cdn_origin %>/images/apple-icon-120.png">
26+ <link rel="apple-touch-icon" sizes="144x144" href="<%= App.cdn_origin %>/images/apple-icon-144.png">
27+ <link rel="apple-touch-icon" sizes="152x152" href="<%= App.cdn_origin %>/images/apple-icon-152.png">
28+ <link rel="apple-touch-icon" sizes="160x160" href="<%= App.cdn_origin %>/images/apple-icon-160.png">
2929 <link rel="stylesheet" href="<%= main_stylesheet_path %>" data-alt="<%= alternate_stylesheet_path %>">
3030 <%= javascript_tag 'application', asset_host: false %>
3131 <%= javascript_tag 'docs' %><% unless App.production? %>
views/other.erb+3−3
@@ -5,10 +5,10 @@ · 4 unmodified lines
55 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
66 <% if doc_index_page? %><meta name="description" content="<%= @doc['full_name'] %> API documentation with instant search, offline mode, keyboard shortcuts, mobile version, and more."><% else %><meta name="robots" content="noindex"><% end %>
77 <meta name="format-detection" content="telephone=no">
8− <meta property="og:image" content="https://cdn.devdocs.io/images/icon-128.png">
8+ <meta property="og:image" content="<%= App.cdn_origin %>/images/icon-128.png">
99 <title>DevDocs<%= " - #{@doc['full_name']} documentation" if doc_index_page? %></title>
10− <link rel="canonical" href="http://devdocs.io<%= request.path %>">
11− <link rel="icon" type="image/x-icon" href="https://cdn.devdocs.io/favicon.ico">
10+ <link rel="canonical" href="<%= canonical_origin %><%= request.path %>">
11+ <link rel="icon" type="image/x-icon" href="<%= App.cdn_origin %>/favicon.ico">
1212 <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Search DevDocs">
1313 <link rel="stylesheet" href="<%= main_stylesheet_path %>" data-alt="<%= alternate_stylesheet_path %>">
1414 <%= javascript_tag 'application', asset_host: false %><% unless App.production? %>