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

cc @trollixx
pull/185/head
Thibaut 10 years ago
parent de71751bad
commit 0c15e192e2

@ -17,7 +17,7 @@ class App < Sinatra::Application
set :assets_prefix, 'assets' set :assets_prefix, 'assets'
set :assets_path, -> { File.join(public_folder, assets_prefix) } set :assets_path, -> { File.join(public_folder, assets_prefix) }
set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') } set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') }
set :assets_compile, %w(*.png docs.js application.js application.css application-dark.css) set :assets_compile, %w(*.png docs.js docs.json application.js application.css application-dark.css)
require 'yajl/json_gem' require 'yajl/json_gem'
set :docs_prefix, 'docs' set :docs_prefix, 'docs'
@ -64,7 +64,7 @@ class App < Sinatra::Application
use Rack::Deflater use Rack::Deflater
use Rack::Static, use Rack::Static,
root: 'public', root: 'public',
urls: %w(/assets /docs /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp), urls: %w(/assets /docs/ /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp),
header_rules: [ header_rules: [
[:all, {'Cache-Control' => 'no-cache, max-age=0'}], [:all, {'Cache-Control' => 'no-cache, max-age=0'}],
['/assets', {'Cache-Control' => 'public, max-age=604800'}], ['/assets', {'Cache-Control' => 'public, max-age=604800'}],
@ -171,6 +171,10 @@ class App < Sinatra::Application
200 200
end end
get '/docs.json' do
redirect asset_path('docs.json')
end
get '/s/maxcdn' do get '/s/maxcdn' do
redirect 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs' redirect 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs'
end end

@ -173,6 +173,14 @@ class AppTest < MiniTest::Spec
end end
end end
describe "/docs.json" do
it "returns to the asset path" do
get '/docs.json'
assert last_response.redirect?
assert_equal 'http://example.org/assets/docs.json', last_response['Location']
end
end
describe "/feed" do describe "/feed" do
it "returns an atom feed" do it "returns an atom feed" do
get '/feed' get '/feed'

Loading…
Cancel
Save