Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
more tutorial tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhirsch committed Mar 18, 2013
1 parent 03e87e0 commit 5bcf9e5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fantastic-front-end-performance-3--connect-fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Let's walk through the process of adding ```connect-fonts``` to serve the Open S
var app = express.createServer(),
tpl = fs.readFileSync(__dirname, '/tpl.ejs', 'utf8');

3. Initialize the middleware.
3. Initialize the middleware:

// app.js continued
// add this app.use call:
Expand All @@ -111,7 +111,7 @@ The arguments to ```connect_fonts.setup()``` include:
* ```allow_origin```: the origin for which we serve fonts; ```connect-fonts``` uses this info to set the Access-Control-Allow-Origin header for browsers that need it (Firefox 3.5+, IE 9+)
* ```ua``` (optional): a parameter listing the user-agents to which we'll serve fonts. By default, ```connect-fonts``` uses UA sniffing to only serve browsers font formats they can parse, reducing CSS size. ```ua: 'all'``` overrides this to serve all fonts to all browsers.

4. Inside your route, pass the user's locale to the template
4. Inside your route, pass the user's locale to the template:

// app.js continued
app.get('/time', function(req, res) {
Expand All @@ -122,7 +122,7 @@ The arguments to ```connect_fonts.setup()``` include:
});
res.send(output);
});
5. Detect the user's preferred language. Mozilla Persona uses [i18n-abide](https://github.com/mozilla/i18n-abide), and [locale](https://github.com/jed/locale) is another swell option; both are available via npm. For the sake of keeping this example short, we'll just grab the first two chars from the [Accept-Language header](https://developer.mozilla.org/en-US/docs/HTTP/Content_negotiation#The_Accept-Language.3A_header).
5. Detect the user's preferred language:

// oversimplified locale detection
function detectLocale(req) {
Expand All @@ -131,6 +131,8 @@ The arguments to ```connect_fonts.setup()``` include:

app.listen(8765, '127.0.0.1');
// end of app.js
Mozilla Persona uses [i18n-abide](https://github.com/mozilla/i18n-abide), and [locale](https://github.com/jed/locale) is another swell option; both are available via npm. For the sake of keeping this example short, we'll just grab the first two chars from the [Accept-Language header](https://developer.mozilla.org/en-US/docs/HTTP/Content_negotiation#The_Accept-Language.3A_header).


### Template changes

Expand Down

0 comments on commit 5bcf9e5

Please sign in to comment.