Skip to content

Feedback #2

DTrejo opened this Issue Mar 6, 2012 · 8 comments

3 participants

DTrejo commented Mar 6, 2012

tldr; really liked what the tako example looked like, tried it out, couldn't figure out a good way to serve a 404 page, couldn't figure out how to have static files in sub-folders get served.

Hey Mikeal,
Some things that happened when I tried to use tako for my static site:

PUBLIC = path.join(__dirname, 'public')
  • sub-folders of /public are not correctly found & served by filed
  • if the file is not found, there is not a good way to serve a 404 page, e.g. public/404.html (I took a stab at writing this, but it doesn't feel very elegant)
app.notfound.html = path.join(PUBLIC, '404.html');

And in app.notfound:

@@ -437,10 +437,16 @@ Application.prototype.notfound = function (req, resp) {
   resp.setHeader('content-type', cc)
   if (cc === 'text/html') {
     body = '<html><body>Not Found</body></html>'
+    if (this.notfound.html) return filed(this.notfound.html).pipe(resp)
   } else if (cc === 'application/json') {
     body = JSON.stringify({status:404, reason:'not found', message:'not found'})
   } else {
     body = 'Not Found'
+    if (this.notfound.html) {
+      resp.setHeader('content-type', 'text/html')
+      console.log('fugg', this.notfound.html, resp.getHeader('content-type'))
+      return filed(this.notfound.html).pipe(resp);
+    }
mikeal commented Mar 6, 2012

I fucked up the docs app.route('/').files(PUBLIC) should be app.route('/*').files(PUBLIC)

mikeal commented Mar 6, 2012

i'll work on adding a notfound API, i'll need one pretty soon.

DTrejo commented Mar 6, 2012

thanks for the super fast response :)

DTrejo commented Mar 6, 2012

Also, super minor, but it would be great if tako.version returned the version number from the package.json.

Like this:

 module.exports = function (options) {
   return new Application(options)
+module.exports.version = require('./package.json').version
 exports.globalMiddles = {}

If it's easier, I can send a pull request.

dscape commented Mar 6, 2012

That will only work on 0.6+. readFileSync and JSON.parse work in 0.4+

DTrejo commented Mar 6, 2012

@mikeal Note that in order to get the index.html file to serve from '/', I had to add this:

mikeal commented Mar 6, 2012

@DTrejo that's a bug, we should fix that.

@dscape tako should only be expected to work on 0.6.

DTrejo commented Mar 28, 2012

Also would be cool to link to a "built with tako" wiki page from the readme.

Check out the code for the tako app I have "in production"
Note: some of it is a bit repetitive b/c of open issues, but try to ignore it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.