Last active
December 28, 2015 12:59
-
-
Save alexbaldwin/7504857 to your computer and use it in GitHub Desktop.
When using Middleman http://middlemanapp.com and HF&J http://typography.com together, the production checks fail. Use this Rack middleware to fix it. Code via @croaky.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'lib/rack_typography' | |
use Rack::Typography |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class Typography | |
# When switching to a new webfont, Hoefler Frere-Jones' typography.com runs | |
# an HTTP GET confirmation step against our font directory to see if we've | |
# installed it correctly. Because the directory returns 404 by default, | |
# we're unable to confirm the step. This middleware returns 200 OK for all | |
# possible /fonts/[:digits] routes that H&FJ may generate so that the | |
# confirmation step will pass. | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if env['REQUEST_PATH'] =~ /^\/fonts\/\d+$/ | |
[200, { 'Content-Type' => 'text/html' }, ['']] | |
else | |
@app.call(env) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment