Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 9e957d4e2c46a9042e1b4bcf9fcee686e3db5a71 @tj tj committed Aug 1, 2012
Showing with 2,781 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +1 −0 CNAME
  3. +19 −0 Makefile
  4. +26 −0 Readme.md
  5. +33 −0 api.jade
  6. +93 −0 app.js
  7. +25 −0 applications.html
  8. +14 −0 applications.jade
  9. +15 −0 community.html
  10. +14 −0 community.jade
  11. +59 −0 en/api/app-VERB.jade
  12. +34 −0 en/api/app-all.jade
  13. +40 −0 en/api/app-configure.jade
  14. +10 −0 en/api/app-disable.jade
  15. +13 −0 en/api/app-disabled.jade
  16. +10 −0 en/api/app-enable.jade
  17. +13 −0 en/api/app-enabled.jade
  18. +41 −0 en/api/app-engine.jade
  19. +13 −0 en/api/app-get.jade
  20. +37 −0 en/api/app-listen.jade
  21. +37 −0 en/api/app-locals.jade
  22. +73 −0 en/api/app-param.jade
  23. +16 −0 en/api/app-render.jade
  24. +31 −0 en/api/app-routes.jade
  25. +10 −0 en/api/app-set.jade
  26. +41 −0 en/api/app-settings.jade
  27. +16 −0 en/api/app.jade
  28. +15 −0 en/api/express.jade
  29. +68 −0 en/api/menu.jade
  30. +15 −0 en/api/req-accepted.jade
  31. +9 −0 en/api/req-acceptedCharsets.jade
  32. +9 −0 en/api/req-acceptedLanguages.jade
  33. +38 −0 en/api/req-accepts.jade
  34. +5 −0 en/api/req-acceptsCharset.jade
  35. +5 −0 en/api/req-acceptsLanguage.jade
  36. +20 −0 en/api/req-body.jade
  37. +12 −0 en/api/req-cookies.jade
  38. +10 −0 en/api/req-fresh.jade
  39. +17 −0 en/api/req-header.jade
  40. +10 −0 en/api/req-host.jade
  41. +10 −0 en/api/req-ip.jade
  42. +12 −0 en/api/req-ips.jade
  43. +22 −0 en/api/req-is.jade
  44. +30 −0 en/api/req-param.jade
  45. +23 −0 en/api/req-params.jade
  46. +10 −0 en/api/req-path.jade
  47. +14 −0 en/api/req-protocol.jade
  48. +21 −0 en/api/req-query.jade
  49. +8 −0 en/api/req-secure.jade
  50. +16 −0 en/api/req-signedCookies.jade
  51. +10 −0 en/api/req-stale.jade
  52. +10 −0 en/api/req-subdomains.jade
  53. +10 −0 en/api/req-xhr.jade
  54. +24 −0 en/api/req.jade
  55. +16 −0 en/api/res-attachment.jade
  56. +10 −0 en/api/res-charset.jade
  57. +9 −0 en/api/res-clearCookie.jade
  58. +26 −0 en/api/res-cookie.jade
  59. +28 −0 en/api/res-download.jade
  60. +56 −0 en/api/res-format.jade
  61. +8 −0 en/api/res-get.jade
  62. +14 −0 en/api/res-json.jade
  63. +19 −0 en/api/res-links.jade
  64. +18 −0 en/api/res-locals.jade
  65. +53 −0 en/api/res-redirect.jade
  66. +17 −0 en/api/res-render.jade
  67. +55 −0 en/api/res-send.jade
  68. +33 −0 en/api/res-sendfile.jade
  69. +16 −0 en/api/res-set.jade
  70. +8 −0 en/api/res-status.jade
  71. +14 −0 en/api/res-type.jade
  72. +17 −0 en/api/res.jade
  73. +86 −0 en/applications.jade
  74. +34 −0 en/community.jade
  75. +117 −0 en/faq.jade
  76. +76 −0 en/guide/executable.jade
  77. +2 −0 en/guide/index.jade
  78. +90 −0 en/guide/intro.jade
  79. +4 −0 en/guide/menu.jade
  80. +51 −0 faq.html
  81. +15 −0 faq.jade
  82. +111 −0 guide.html
  83. +19 −0 guide.jade
  84. BIN images/apps/logos/canadian-tire.png
  85. BIN images/apps/logos/clipboard.png
  86. BIN images/apps/logos/doodle-or-die.png
  87. BIN images/apps/logos/ebay.png
  88. BIN images/apps/logos/geeklist.png
  89. BIN images/apps/logos/klout.png
  90. BIN images/apps/logos/koding.png
  91. BIN images/apps/logos/learnboost.png
  92. BIN images/apps/logos/mcdonalds.png
  93. BIN images/apps/logos/mozilla.png
  94. BIN images/apps/logos/nerve.png
  95. BIN images/apps/logos/starbucks.png
  96. BIN images/apps/logos/storify.png
  97. BIN images/apps/logos/uber.png
  98. BIN images/apps/logos/yahoo.png
  99. BIN images/apps/screenshots/browserid.small.png
  100. BIN images/apps/screenshots/clipboard.small.png
  101. BIN images/apps/screenshots/geeklist.small.png
  102. BIN images/apps/screenshots/klout.small.png
  103. BIN images/apps/screenshots/learnboost.small.png
  104. BIN images/apps/screenshots/more.small.png
  105. BIN images/apps/screenshots/prismatic.small.png
  106. BIN images/apps/screenshots/storify.small.png
  107. BIN images/arrow.png
  108. BIN images/bg.png
  109. BIN images/github-small.png
  110. BIN images/github.png
  111. BIN images/hr.png
  112. BIN images/ios-bg.png
  113. BIN images/light-bg.png
  114. +17 −0 includes/app-logos.jade
  115. +7 −0 includes/footer.jade
  116. +5 −0 includes/head.jade
  117. +26 −0 includes/intro.jade
  118. +5 −0 includes/logo.jade
  119. +13 −0 includes/menu.jade
  120. +13 −0 includes/mixins.jade
  121. +19 −0 index.jade
  122. +8 −0 package.json
  123. +455 −0 style.css
@@ -0,0 +1,4 @@
+node_modules
+.DS_Store
+api.html
+index.html
1 CNAME
@@ -0,0 +1 @@
+expressjs.com
@@ -0,0 +1,19 @@
+
+JADE = ./node_modules/.bin/jade
+
+HTML = index.html \
+ api.html \
+ guide.html \
+ applications.html \
+ community.html \
+ faq.html
+
+docs: $(HTML)
+
+%.html: %.jade
+ $(JADE) --path $< < $< > $@
+
+clean:
+ rm -f *.html
+
+.PHONY: docs clean
@@ -0,0 +1,26 @@
+
+# ExpressJS.com
+
+ The site for Express.
+
+## Building
+
+Setup:
+
+```
+$ npm install -g serve
+$ npm install
+$ make
+$ serve . &
+$ open http://localhost:3000
+```
+
+then rebuild changes with:
+
+```
+$ make
+```
+
+## Contributing
+
+ - __dont__ edit the HTML directly, edit the _jade_.
@@ -0,0 +1,33 @@
+!!! 5
+html
+ head
+ title Express - api reference
+ include includes/head
+ body.inner
+ .bar
+ section#content
+ header
+ include includes/logo
+ active = '/api.html'
+ include includes/menu
+
+ include includes/mixins
+
+ include en/api/menu
+
+ #right
+ include en/api/express
+
+ h2 Application
+ a(name='application')
+ include en/api/app
+
+ h2 Request
+ a(name='request')
+ include en/api/req
+
+ h2 Response
+ a(name='response')
+ include en/api/res
+
+ include includes/footer
93 app.js
@@ -0,0 +1,93 @@
+
+o = $;
+
+// misc junk
+
+o(function(){
+ var width = window.innerWidth;
+ var height = window.innerHeight;
+ var doc = o(document);
+
+ // .onload
+ o('html').addClass('onload');
+
+ // top link
+ o('#top').click(function(e){
+ o('body').animate({ scrollTop: 0 }, 'fast');
+ e.preventDefault();
+ });
+
+ // scrolling links
+ var added;
+ doc.scroll(function(e){
+ if (doc.scrollTop() > 5) {
+ if (added) return;
+ added = true;
+ o('body').addClass('scroll');
+ } else {
+ o('body').removeClass('scroll');
+ added = false;
+ }
+ })
+
+ // highlight code
+ o('pre.js code').each(function(){
+ o(this).html(highlight(o(this).text()));
+ })
+})
+
+// active menu junk
+
+o(function(){
+ var prev;
+ var n = 0;
+
+ var headings = o('h3').map(function(i, el){
+ return {
+ top: o(el).offset().top,
+ id: el.id
+ }
+ });
+
+ function closest() {
+ var h;
+ var top = o(window).scrollTop();
+ var i = headings.length;
+ while (i--) {
+ h = headings[i];
+ if (top >= h.top) return h;
+ }
+ }
+
+ o(document).scroll(function(){
+ var h = closest();
+ if (!h) return;
+
+ if (prev) {
+ prev.removeClass('active');
+ prev.parent().parent().removeClass('active');
+ }
+
+ var a = o('a[href="#' + h.id + '"]');
+ a.addClass('active');
+ a.parent().parent().addClass('active');
+
+ prev = a;
+ })
+})
+
+/**
+ * Highlight the given `js`.
+ */
+
+function highlight(js) {
+ return js
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
+ .replace(/('.*?')/gm, '<span class="string">$1</span>')
+ .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
+ .replace(/(\d+)/gm, '<span class="number">$1</span>')
+ .replace(/\bnew *(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
+ .replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
+}
@@ -0,0 +1,25 @@
+<!DOCTYPE html><html><head><title>Express - applications</title><link rel="stylesheet" href="style.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;subset=latin,latin-ext"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script><script src="app.js"></script></head><body class="applications inner"><div class="bar"></div><section id="content"><header><section id="logo"><span class="express">express<em>3.0.0</em></span><span class="description">
+web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class=""> Guide</a><a href="/applications.html" class="active"> Applications</a><a href="/community.html" class=""> Community</a><a href="/faq.html" class=""> FAQ</a></nav><div id="x"></div><div id="y"></div></header><section class="application"><h2>LearnBoost</h2><p>LearnBoost provides a free, easy to use online
+online education suite including gradebook,
+lesson plans, attendance, reporting, and calendars
+among other tools.
+</p><div class="link">Visit <a href="https://www.learnboost.com/">LearnBoost</a></div><img src="/images/apps/screenshots/learnboost.small.png"></section><section class="application"><h2>Storify</h2><p>Create stories using social media. Turn what people post
+on social media into compelling stories. Collect the best photos, video,
+tweets and more to publish
+</p><div class="link">Visit <a href="http://storify.com/">Storify</a></div><img src="/images/apps/screenshots/storify.small.png"></section><section class="application"><h2>Geekli.st</h2><p>A place for geeks to share what they've done, who they did it with and
+connect with great companies and communities.
+</p><div class="link">Visit <a href="http://geekli.st">Geekli.st</a></div><img src="/images/apps/screenshots/geeklist.small.png"></section><section class="application"><h2>Klout</h2><p>Klout is the Standard for Influence. Join Klout to discover your
+influence and compare with others you may know.
+</p><div class="link">Visit <a href="http://klout.com">Klout</a></div><img src="/images/apps/screenshots/klout.small.png"></section><section class="application"><h2>Prismatic</h2><p>Prismatic learns from how you interact on social networks so that we
+can show you the most interesting content and conversation from your friends.
+</p><div class="link">Visit <a href="http://getprismatic.com/">Prismatic</a></div><img src="/images/apps/screenshots/prismatic.small.png"></section><section class="application"><h2>Clipboard</h2><p>Clipboard is a powerful tool allowing to save live clips
+of your interests on the web, not just static images,
+but fully-functional fragments of anything online.
+</p><div class="link">Visit <a href="http://clipboard.com/">Clipboard</a></div><img src="/images/apps/screenshots/clipboard.small.png"></section><section class="application"><h2>Persona</h2><p>Persona, or "BrowserID" is Mozilla's answer
+to a better identification system for your browser,
+this promising tool is definitely worth checking out.
+</p><div class="link">Visit <a href="https://login.persona.org/">Persona</a></div><img src="/images/apps/screenshots/browserid.small.png"></section><section class="application"><h2>and more!</h2><p>Shodan search reports that there are well over <strong>26,000</strong> Express applications
+in the wild, we can't possibly list them all here, but if you feel
+your application helps showcase the framework open an issue on
+the <a href="github.com/visionmedia/expressjs.com/issues">github repo</a>.
+</p><img src="/images/apps/screenshots/more.small.png"></section></section><a id="top" href="#"><img src="images/arrow.png"></a><footer><div id="footer-content">© 2012 TJ Holowaychuk. All rights reserved.</div></footer></body></html>
@@ -0,0 +1,14 @@
+!!! 5
+html
+ head
+ title Express - applications
+ include includes/head
+ body.applications.inner
+ .bar
+ section#content
+ header
+ include includes/logo
+ active = '/applications.html'
+ include includes/menu
+ include en/applications
+ include includes/footer
@@ -0,0 +1,15 @@
+<!DOCTYPE html><html><head><title>Express - community</title><link rel="stylesheet" href="style.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;subset=latin,latin-ext"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script><script src="app.js"></script></head><body class="community inner"><div class="bar"></div><section id="content"><header><section id="logo"><span class="express">express<em>3.0.0</em></span><span class="description">
+web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class=""> Guide</a><a href="/applications.html" class=""> Applications</a><a href="/community.html" class="active"> Community</a><a href="/faq.html" class=""> FAQ</a></nav><div id="x"></div><div id="y"></div></header><div id="boxes" class="clearfix"><section id="mailing-list"><h3>Mailing List</h3><p>Join over 1500 Express users or browse over 5000
+discussions in the <a href="https://groups.google.com/group/express-js">Google Group</a>.
+</p></section><section id="irc"><h3>IRC Channel</h3><p>Hundreds of developers idle in #express on freenode every day,
+if you have questions about the framework jump in for quick
+feedback.
+</p></section><section id="examples"><h3>Examples</h3><p>View dozens of Express application <a href="https://github.com/visionmedia/express/tree/master/examples">examples</a>
+in the github repository covering everything from API design and authentication
+to template engine integration.
+</p></section><section id="issues"><h3>Issues</h3><p>If you've come across what you think is a bug, or just want to make
+a feature request open a ticket in the <a href="https://github.com/visionmedia/express/issues">issue queue</a>.
+</p></section><section id="extending"><h3>Third Party</h3><p>Our vibrant community has created a large variety of extensions,
+<a href="https://github.com/senchalabs/connect/wiki">middleware</a>
+and higher level frameworks. Check them out in the
+<a href="https://github.com/visionmedia/express/wiki">wiki</a>.</p></section></div></section><a id="top" href="#"><img src="images/arrow.png"></a><footer><div id="footer-content">© 2012 TJ Holowaychuk. All rights reserved.</div></footer></body></html>
@@ -0,0 +1,14 @@
+!!! 5
+html
+ head
+ title Express - community
+ include includes/head
+ body.community.inner
+ .bar
+ section#content
+ header
+ include includes/logo
+ active = '/community.html'
+ include includes/menu
+ include en/community
+ include includes/footer
@@ -0,0 +1,59 @@
+section
+ h3(id='app.VERB') app.VERB(path, [callback...], callback)
+
+ p.
+ The <code>app.VERB()</code> methods provide the routing functionality
+ in Express, where <strong>VERB</strong> is one of the HTTP verbs, such
+ as <code>app.post()</code>. Multiple callbacks may be give, all are treated
+ equally, and behave just like middleware, with the one exception that
+ these callbacks may invoke <code>next('route')</code> to bypass the
+ remaining route callback(s). This mechanism can be used to perform pre-conditions
+ on a route then pass control to subsequent routes when there is no reason to proceed
+ with the route matched.
+
+ p.
+ The following snippet illustrates the most simple route definition possible. Express
+ translates the path strings to regular expressions, used internally to match incoming requests.
+ Query strings are <em>not</em> considered when peforming these matches, for example "GET /"
+ would match the following route, as would "GET /?name=tobi".
+
+ +js.
+ app.get('/', function(req, res){
+ res.send('hello world');
+ });
+
+ p.
+ Regular expressions may also be used, and can be useful
+ if you have very specific restraints, for example the following
+ would match "GET /commits/71dbb9c" as well as "GET /commits/71dbb9c..4c084f9".
+
+ +js.
+ app.get(/^\/commits\/(\d+)(?:\.\.(\d+))?$/, function(req, res){
+ var from = req.params[0];
+ var to = req.params[1] || 'HEAD';
+ res.send('commit range ' + from + '..' + to);
+ });
+
+ p.
+ Several callbacks may also be passed, useful for re-using middleware
+ that load resources, perform validations, etc.
+
+ +js.
+ app.get('/user/:id', user.load, function(){
+ // ...
+ })
+
+ p.
+ These callbacks may be passed within arrays as well, these arrays are
+ simply flattened when passed:
+
+ +js.
+ var middleware = [loadForum, loadThread];
+
+ app.get('/forum/:fid/thread/:tid', middleware, function(){
+ // ...
+ })
+
+ app.post('/forum/:fid/thread/:tid', middleware, function(){
+ // ...
+ })
@@ -0,0 +1,34 @@
+section
+ h3(id='app.all') app.all(path, [callback...], callback)
+
+ p.
+ This method functions just like the <code>app.VERB()</code> methods,
+ however it matches all HTTP verbs.
+
+ p.
+ This method is extremely useful for
+ mapping "global" logic for specific path prefixes or arbitrary matches.
+ For example if you placed the following route at the top of all other
+ route definitions, it would require that all routes from that point on
+ would require authentication, and automatically load a user. Keep in mind
+ that these callbacks do not have to act as end points, <code>loadUser</code>
+ can perform a task, then <code>next()</code> to continue matching subsequent
+ routes.
+
+ +js.
+ app.all('*', requireAuthentication, loadUser);
+
+ p.
+ Or the equivalent:
+
+ +js.
+ app.all('*', requireAuthentication)
+ app.all('*', loadUser);
+
+ p.
+ Another great example of this is white-listed "global" functionality. Here
+ the example is much like before, however only restricting paths prefixed with
+ "/api":
+
+ +js.
+ app.all('/api/*', requireAuthentication);
@@ -0,0 +1,40 @@
+section
+ h3(id='app.configure') app.configure([env], callback)
+
+ p.
+ Conditionally invoke <code>callback</code> when <code>env</code> matches <code>app.get('env')</code>,
+ aka <code>process.env.NODE_ENV</code>. This method remains for legacy reason, and is effectively
+ an <code>if</code> statement as illustrated in the following snippets. These functions are <em>not</em>
+ required in order to use <code>app.set()</code> and other configuration methods.
+
+ +js.
+ // all environments
+ app.configure(function(){
+ app.set('title', 'My Application');
+ })
+
+ // development only
+ app.configure('development', function(){
+ app.set('db uri', 'localhost/dev');
+ })
+
+ // production only
+ app.configure('production', function(){
+ app.set('db uri', 'n.n.n.n/prod');
+ })
+
+ Is effectively sugar for:
+
+ +js.
+ // all environments
+ app.set('title', 'My Application');
+
+ // development only
+ if ('development' == app.get('env')) {
+ app.set('db uri', 'localhost/dev');
+ }
+
+ // production only
+ if ('production' == app.get('env')) {
+ app.set('db uri', 'n.n.n.n/prod');
+ }
Oops, something went wrong.

0 comments on commit 9e957d4

Please sign in to comment.