Skip to content

Commit

Permalink
0.5 dir structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Feb 19, 2015
1 parent b6e5fbd commit cb39a21
Show file tree
Hide file tree
Showing 144 changed files with 80 additions and 8 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 14 additions & 2 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: polymer-project
version: 0-5-4-take3
version: zerodoteight
runtime: python27
api_version: 1
threadsafe: yes
Expand Down Expand Up @@ -67,7 +67,7 @@ handlers:
upload: components/polymer/polymer\.js
http_headers:
Access-Control-Allow-Origin: "*"

- url: /polymer(\.min)?\.js\.map
static_files: components/polymer/polymer.js.map
upload: components/polymer/polymer\.js\.map
Expand All @@ -77,6 +77,18 @@ handlers:
# Redirects
# This needs to appear above the block below, otherwise anything with a trailing
# slash will fail to redirect

# /0.5/docs/start/getting-the-code.html
- url: /(.+)?/docs/
static_files: _site/\1/docs
upload: _site/(.+)?/docs/
http_headers:
Access-Control-Allow-Origin: "*"

# No version goes through redirect to latest version.
- url: /docs/.*
script: main.app

- url: /apps/.*
script: main.app

Expand Down
72 changes: 66 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,69 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import logging
import os
import re
import webapp2
import yaml

from google.appengine.api import app_identity
from google.appengine.api import memcache
from webapp2_extras.routes import RedirectRoute

app = webapp2.WSGIApplication([
RedirectRoute('/apps/topeka/', name='topeka', redirect_to='http://polymer-topeka.appspot.com/', strict_slash=True),
RedirectRoute('/apps/designer/', name='designer', redirect_to='http://polymer-designer.appspot.com/', strict_slash=True),
RedirectRoute('/tools/designer/', name='designer', redirect_to='http://polymer-designer.appspot.com/', strict_slash=True),
RedirectRoute('/apps/polymer-tutorial/finished/', name='tutorial', redirect_to='http://polymer-tut.appspot.com/', strict_slash=True)
], debug=False)

def get_dirs(root='.'):
a = re.compile(r'^\d.\d(\.\d)?$')
return [x for x in os.listdir(root) if os.path.isdir(x) and a.match(x)]

def get_latest_polymer_version_dir():
current_app_version = os.environ['CURRENT_VERSION_ID'].split('.')[0]

latest_version = memcache.get('latest_version', namespace=current_app_version)
if latest_version is None:
f = open('_config.yml', 'r')
config = yaml.load(f)

latest_version = config.get('latest_version')
memcache.add('latest_version', latest_version, namespace=current_app_version)

dirs = get_dirs(root='.')
# ['0.5', '0.6', '1.0.1'] -> max(['05', '06', '101']) -> '101' -> '1.0.1'
latest = '.'.join(max([x.replace('.', '') for x in dirs]))

return latest


class VersionHandler(webapp2.RequestHandler):

def get(self, version=None):
version_dir = get_latest_polymer_version_dir()
self.response.write('serve %s docs' % version_dir)


routes = [
RedirectRoute('/apps/topeka/', name='topeka',
redirect_to='https://polymer-topeka.appspot.com/', strict_slash=True),
RedirectRoute('/apps/designer/', name='designer',
redirect_to='https://polymer-designer.appspot.com/', strict_slash=True),
RedirectRoute('/tools/designer/', name='designer',
redirect_to='https://polymer-designer.appspot.com/', strict_slash=True),
RedirectRoute('/apps/polymer-tutorial/finished/', name='tutorial',
redirect_to='https://polymer-tut.appspot.com/', strict_slash=True),
('/docs/.*', VersionHandler),
]

app = webapp2.WSGIApplication(routes=routes, debug=False)

0 comments on commit cb39a21

Please sign in to comment.