History

Add /docs.json route redirecting to the most recent doc manifest on the CDN

cc @trollixx

Thibaut committed 11 years ago

Commit 0c15e191 parent de717512 files · +14 −2Browse files

Unified · Split

2 files
  1. lib/app.rb +6 −2
  2. test/app_test.rb +8 −0
lib/app.rb+6−2
@@ -17,7 +17,7 @@ class App < Sinatra::Application · 16 unmodified lines
17 set :assets_prefix, 'assets'17 set :assets_prefix, 'assets'
18 set :assets_path, -> { File.join(public_folder, assets_prefix) }18 set :assets_path, -> { File.join(public_folder, assets_prefix) }
19 set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') }19 set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') }
20 set :assets_compile, %w(*.png docs.js application.js application.css application-dark.css)20 set :assets_compile, %w(*.png docs.js docs.json application.js application.css application-dark.css)
21 21
22 require 'yajl/json_gem'22 require 'yajl/json_gem'
23 set :docs_prefix, 'docs'23 set :docs_prefix, 'docs'
@@ -64,7 +64,7 @@ class App < Sinatra::Application · 40 unmodified lines
64 use Rack::Deflater64 use Rack::Deflater
65 use Rack::Static,65 use Rack::Static,
66 root: 'public',66 root: 'public',
67 urls: %w(/assets /docs /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp),67 urls: %w(/assets /docs/ /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp),
68 header_rules: [68 header_rules: [
69 [:all, {'Cache-Control' => 'no-cache, max-age=0'}],69 [:all, {'Cache-Control' => 'no-cache, max-age=0'}],
70 ['/assets', {'Cache-Control' => 'public, max-age=604800'}],70 ['/assets', {'Cache-Control' => 'public, max-age=604800'}],
@@ -171,6 +171,10 @@ class App < Sinatra::Application · 100 unmodified lines
171 200171 200
172 end172 end
173 173
174 get '/docs.json' do
175 redirect asset_path('docs.json')
176 end
177
174 get '/s/maxcdn' do178 get '/s/maxcdn' do
175 redirect 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs'179 redirect 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs'
176 end180 end
test/app_test.rb+8−0
@@ -173,6 +173,14 @@ class AppTest < MiniTest::Spec · 172 unmodified lines
173 end173 end
174 end174 end
175 175
176 describe "/docs.json" do
177 it "returns to the asset path" do
178 get '/docs.json'
179 assert last_response.redirect?
180 assert_equal 'http://example.org/assets/docs.json', last_response['Location']
181 end
182 end
183
176 describe "/feed" do184 describe "/feed" do
177 it "returns an atom feed" do185 it "returns an atom feed" do
178 get '/feed'186 get '/feed'