binaryage / drydrop

Deploy static sites to App Engine by pushing to GitHub
http://drydrop.binaryage.com
Other
224 stars 32 forks source link

Question: how to make index.html the default in all directories? #3

Open zzamboni opened 14 years ago

zzamboni commented 14 years ago

Hi,

Is there a forum of some other place to ask questions like this?

First of all, drydrop is very very useful! I'm using it to migrate my static web sites to GAE and get rid of a rented dedicated server.

Second, I know this is more of a GAE question, but I thought you may have encountered it - how to make index.html the default file for all directories? I tried the following:

- url: /(.+)/
  static_files: \1/index.html
  upload: /.*

But this resulted in a syntax error. I would like if possible to avoid having to add handlers for all my directories.

Thanks a lot.

darwin commented 14 years ago

I don't have answer for this, because I don't remember it. I've used google's code which existed in their app engine SDK at some point.

I did quick scan of this document: http://code.google.com/appengine/docs/python/config/appconfig.html

According to that document regexps should work and I don't see any mistake in your site.yaml. Maybe they updated their code and this document... or there is some bug on my side :-/

darwin commented 14 years ago

And yes, this is the best place for asking questions. I don't have time to open and maintain separate support forum for drydrop.

zzamboni commented 14 years ago

Thanks for all the support!

zzamboni commented 14 years ago

I'm toying a bit with the code, trying to make it an option for drydrop to automatically search for index.html in directories instead of trying to fetch the directory itself. My current algorithm is this: if query returns with 404 and the requested filename does not have an extension (to avoid trying this on every single file not found), then append "/index.html" and try again.

This seems to work fine for most cases, but I think it would be best to just test if the requested file is a directory, and then append /index.html to it from the start. However, not being very familiar with GAE, I don't know if this is possible.

Thanks for any ideas! I will push a patch to my branch when I'm happier with the code, in case you want to take a look at it.

darwin commented 14 years ago

if you fork I'll look at it for sure.

your approach is more like a hack, so I cannot promise I'll include it into official drydrop. in drydrop I'd like to see working those regexps from appconfig.html docs.

zzamboni commented 14 years ago

I actually think using regexes to identify directories is more of a hack, because there is no way to reliably do it (unless you assume a slash is ALWAYS included at the end of a directory request, but this is not the case). If there is a way to detect if a requested resource is a directory, and only then append /index.html to it, then it would be the same mechanism that a regular web server uses.

I haven't had a chance to look more at the code, but I'll do in the next few days and send you a patch.

yoav-zibin commented 11 years ago

You can use github api to see what is a directory, e.g, https://api.github.com/repos/phonegap/phonegap-start/contents/www vs https://api.github.com/repos/phonegap/phonegap-start/contents/www/index.html