Skip to content

Commit c6264eb

Browse files
fix: remove cdn entirely and rely on Cloudflare
1 parent 06dbf8a commit c6264eb

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

assets/javascripts/app/config.coffee.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ app.config =
1212
sentry_dsn: '<%= App.sentry_dsn %>'
1313
version: <%= Time.now.to_i %>
1414
release: <%= Time.now.utc.httpdate.to_json %>
15-
mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'
15+
mathml_stylesheet: '/mathml.css'
1616
favicon_spritesheet: '<%= image_path('sprites/docs.png') %>'
1717
service_worker_path: '/service-worker.js'
1818
service_worker_enabled: <%= App.environment == :production || ENV['ENABLE_SERVICE_WORKER'] == 'true' %>

lib/app.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class App < Sinatra::Application
2020
set :root, Pathname.new(File.expand_path('../..', __FILE__))
2121
set :sprockets, Sprockets::Environment.new(root)
2222

23-
set :cdn_origin, ''
24-
2523
set :assets_prefix, 'assets'
2624
set :assets_path, File.join(public_folder, assets_prefix)
2725
set :assets_manifest_path, File.join(assets_path, 'manifest.json')
@@ -75,9 +73,8 @@ class App < Sinatra::Application
7573

7674
configure :production do
7775
set :static, false
78-
set :cdn_origin, 'https://cdn.devdocs.io'
7976
set :docs_origin, '//docs.devdocs.io'
80-
set :csp, "default-src 'self' *; script-src 'self' 'nonce-devdocs' https://cdn.devdocs.io https://www.google-analytics.com https://secure.gaug.es https://*.jquery.com; font-src 'none'; style-src 'self' 'unsafe-inline' *; img-src 'self' * data:;"
77+
set :csp, "default-src 'self' *; script-src 'self' 'nonce-devdocs' https://www.google-analytics.com https://secure.gaug.es https://*.jquery.com; font-src 'none'; style-src 'self' 'unsafe-inline' *; img-src 'self' * data:;"
8178

8279
use Rack::ConditionalGet
8380
use Rack::ETag
@@ -102,7 +99,6 @@ class App < Sinatra::Application
10299

103100
Sprockets::Helpers.configure do |config|
104101
config.digest = true
105-
config.asset_host = 'cdn.devdocs.io'
106102
config.manifest = Sprockets::Manifest.new(sprockets, assets_manifest_path)
107103
end
108104
end
@@ -202,7 +198,7 @@ def query_string_for_redirection
202198

203199
def service_worker_asset_urls
204200
@@service_worker_asset_urls ||= [
205-
javascript_path('application', asset_host: false),
201+
javascript_path('application'),
206202
stylesheet_path('application'),
207203
image_path('sprites/docs.png'),
208204
image_path('sprites/[email protected]'),

lib/tasks/docs.thor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class DocsCLI < Thor
198198
puts '[S3] Done syncing.'
199199

200200
# Upload packages to dl.devdocs.io (used by the "thor docs:download" command)
201+
# TODO(MIGRATION): replace this with an S3 bucket upload.
201202
puts '[MaxCDN] Begin uploading.'
202203
Net::SFTP.start('ftp.devdocs-dl.devdocs.netdna-cdn.com', ENV['DEVDOCS_DL_USERNAME'], password: ENV['DEVDOCS_DL_PASSWORD']) do |sftp|
203204
docs.each do |doc|

public/opensearch.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<Description>Search API documentation</Description>
55
<Tags>devdocs</Tags>
66
<Url type="text/html" method="get" template="https://devdocs.io/#q={searchTerms}"/>
7-
<Image height="16" width="16" type="image/vnd.microsoft.icon">https://cdn.devdocs.io/favicon.ico</Image>
8-
<Image height="64" width="64" type="image/x-icon">https://cdn.devdocs.io/images/icon-64.png</Image>
7+
<Image height="16" width="16" type="image/vnd.microsoft.icon">https://devdocs.io/favicon.ico</Image>
8+
<Image height="64" width="64" type="image/x-icon">https://devdocs.io/images/icon-64.png</Image>
99
<InputEncoding>UTF-8</InputEncoding>
1010
<moz:SearchForm>https://devdocs.io</moz:SearchForm>
1111
<Url type="application/opensearchdescription+xml" rel="self" template="https://devdocs.io/opensearch.xml"/>

views/index.erb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<meta property="og:description" content="Fast, offline, and free documentation browser for developers. Search 100+ docs in one web app including HTML, CSS, JavaScript, PHP, Ruby, Python, Go, C, C++, and many more.">
1010
<meta property="og:type" content="website">
1111
<meta property="og:url" content="<%= canonical_origin %>">
12-
<meta property="og:image" content="<%= App.cdn_origin %>/images/icon-320.png">
12+
<meta property="og:image" content="/images/icon-320.png">
1313
<meta name="apple-mobile-web-app-title" content="DevDocs">
1414
<meta name="apple-mobile-web-app-capable" content="yes">
1515
<meta name="apple-mobile-web-app-status-bar-style" content="black">
@@ -21,22 +21,22 @@
2121
<link rel="manifest" href="/manifest.json">
2222
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="DevDocs Search">
2323
<link rel="alternate" href="<%= canonical_origin %>/feed" title="DevDocs" type="application/atom+xml">
24-
<link rel="icon" type="image/x-icon" href="<%= App.cdn_origin %>/favicon.ico">
25-
<link rel="fluid-icon" href="<%= App.cdn_origin %>/images/fluid-icon.png" title="DevDocs">
26-
<link rel="apple-touch-icon" sizes="72x72" href="<%= App.cdn_origin %>/images/apple-icon-72.png">
27-
<link rel="apple-touch-icon" sizes="76x76" href="<%= App.cdn_origin %>/images/apple-icon-76.png">
28-
<link rel="apple-touch-icon" sizes="114x114" href="<%= App.cdn_origin %>/images/apple-icon-114.png">
29-
<link rel="apple-touch-icon" sizes="120x120" href="<%= App.cdn_origin %>/images/apple-icon-120.png">
30-
<link rel="apple-touch-icon" sizes="144x144" href="<%= App.cdn_origin %>/images/apple-icon-144.png">
31-
<link rel="apple-touch-icon" sizes="152x152" href="<%= App.cdn_origin %>/images/apple-icon-152.png">
32-
<link rel="apple-touch-icon" sizes="160x160" href="<%= App.cdn_origin %>/images/apple-icon-160.png">
33-
<link rel="mask-icon" href="<%= App.cdn_origin %>/images/webkit-mask-icon.svg" color="#398df0">
24+
<link rel="icon" type="image/x-icon" href="/favicon.ico">
25+
<link rel="fluid-icon" href="/images/fluid-icon.png" title="DevDocs">
26+
<link rel="apple-touch-icon" sizes="72x72" href="/images/apple-icon-72.png">
27+
<link rel="apple-touch-icon" sizes="76x76" href="/images/apple-icon-76.png">
28+
<link rel="apple-touch-icon" sizes="114x114" href="/images/apple-icon-114.png">
29+
<link rel="apple-touch-icon" sizes="120x120" href="/images/apple-icon-120.png">
30+
<link rel="apple-touch-icon" sizes="144x144" href="/images/apple-icon-144.png">
31+
<link rel="apple-touch-icon" sizes="152x152" href="/images/apple-icon-152.png">
32+
<link rel="apple-touch-icon" sizes="160x160" href="/images/apple-icon-160.png">
33+
<link rel="mask-icon" href="/images/webkit-mask-icon.svg" color="#398df0">
3434
<%= stylesheet_tag 'application' %>
3535
</head>
3636
<body>
3737
<noscript class="_fail">DevDocs requires JavaScript to run.</noscript>
3838
<%= erb :app -%>
39-
<%= javascript_tag 'application', asset_host: false %>
39+
<%= javascript_tag 'application' %>
4040
<%= javascript_tag 'docs' %><% unless App.production? %>
4141
<%= javascript_tag 'debug' %><% end %>
4242
</body>

views/other.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<% if doc_index_page? %><meta name="description" content="<%= @doc['name'] %> <%= @doc['release'] %> API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more."><% else %><meta name="robots" content="noindex"><% end %>
77
<meta name="format-detection" content="telephone=no">
88
<meta name="theme-color" content="#eee">
9-
<meta property="og:image" content="<%= App.cdn_origin %>/images/icon-320.png">
9+
<meta property="og:image" content="/images/icon-320.png">
1010
<title>DevDocs<%= " &mdash; #{@doc['full_name']} documentation" if doc_index_page? %></title>
1111
<link rel="canonical" href="<%= canonical_origin %><%= request.path %>">
1212
<link rel="manifest" href="/manifest.json">
13-
<link rel="icon" type="image/x-icon" href="<%= App.cdn_origin %>/favicon.ico">
13+
<link rel="icon" type="image/x-icon" href="/favicon.ico">
1414
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Search DevDocs">
1515
<%= stylesheet_tag 'application' %>
1616
</head>
1717
<body data-doc="<%= CGI::escape_html @doc.to_json %>">
1818
<noscript class="_fail">DevDocs requires JavaScript to run.</noscript>
1919
<%= erb :app -%>
20-
<%= javascript_tag 'application', asset_host: false %><% unless App.production? %>
20+
<%= javascript_tag 'application' %><% unless App.production? %>
2121
<%= javascript_tag 'debug' %><% end %>
2222
</body>
2323
</html>

0 commit comments

Comments
 (0)