Merge pull request #209 from henningpeters/master

add website trailing-slash redirects
This commit is contained in:
Matthew Honnibal 2015-12-16 11:29:17 +01:00
commit 976259010e

11
fabfile.py vendored
View File

@ -97,6 +97,17 @@ def web_publish(assets_path):
if not k.name.startswith('resources')]) if not k.name.startswith('resources')])
for root, dirnames, filenames in os.walk(site_path): for root, dirnames, filenames in os.walk(site_path):
for dirname in dirnames:
target = os.path.relpath(os.path.join(root, dirname), site_path)
source = os.path.join(target, 'index.html')
if os.path.exists(os.path.join(root, dirname, 'index.html')):
key = bucket.new_key(source)
key.set_redirect('//%s/%s' % (bucket.name, target))
print('adding redirect for %s' % target)
keys_left.remove(source)
for filename in filenames: for filename in filenames:
source = os.path.join(root, filename) source = os.path.join(root, filename)