Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from Polymer/one-dot-merge
Browse files Browse the repository at this point in the history
Redirect legacy URLs.
  • Loading branch information
robdodson committed May 28, 2015
2 parents 2285101 + 0149479 commit 3ba014c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ kramdown:
# Site globals used throughout docs.
project_title: Polymer
project_status: 'Dev preview'
latest_version: 0.5.6
default_version: 1.0 # default version the docs should serve
# TODO: add version global for new, 1.0 docs.
latest_version: 0.5.6 # version global used in 0.5 docs.
default_version: 1.0 # default homepage version the docs should serve
legacy_version: 0.5 # version for legacy versionless URLs

versions:
'0.5': 'dev preview'
Expand Down
17 changes: 13 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@ def get_default_polymer_version():
default_version = config.get('default_version')
memcache.add('default_version', default_version, namespace=current_app_version)

return default_version
legacy_version = memcache.get('legacy_version', namespace=current_app_version)
if legacy_version is None:
legacy_version = config.get('legacy_version')
memcache.add('legacy_version', legacy_version, namespace=current_app_version)

return (default_version, legacy_version)


class VersionHandler(webapp2.RequestHandler):

def get(self, version=None):
version_dir = get_default_polymer_version()
version_dir, legacy_version_dir = get_default_polymer_version()
if self.request.path.startswith('/latest'):
path = self.request.path.replace('/latest', '/%s' % version_dir)
return self.redirect('%s' % path)

return self.redirect('/%s%s' % (version_dir, self.request.path))
# redirect raw path to new version
if self.request.path == '/':
return self.redirect('/%s/' % (version_dir))

# redirect unversioned legacy URLs
return self.redirect('/%s%s' % (legacy_version_dir, self.request.path))

class ObsoleteVersionHandler(webapp2.RequestHandler):

Expand Down

0 comments on commit 3ba014c

Please sign in to comment.