From 1a97bb0690eda9bd953eae1bcfdb13f922431b8c Mon Sep 17 00:00:00 2001 From: Keanu Lee Date: Mon, 2 Oct 2017 10:37:33 -0700 Subject: [PATCH 1/4] Remove server-specific stuff; consistency with Shop --- README.md | 20 ++++---------------- app.yaml | 35 ----------------------------------- main.py | 31 ------------------------------- polymer.json | 8 ++++---- sw-precache-config.js | 15 ++++++++++++--- 5 files changed, 20 insertions(+), 89 deletions(-) delete mode 100755 app.yaml delete mode 100644 main.py diff --git a/README.md b/README.md index e120eb79..19e96b6c 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,7 @@ Install [polymer-cli](https://github.com/Polymer/polymer-cli): npm install -g polymer-cli -### Google App Engine SDK - -Install [Google App Engine SDK](https://cloud.google.com/appengine/downloads) - -## Setup +### Setup git clone https://github.com/polymer/news.git cd news @@ -20,7 +16,7 @@ Install [Google App Engine SDK](https://cloud.google.com/appengine/downloads) ## Start the development server - dev_appserver.py . + polymer serve ## Build @@ -28,14 +24,6 @@ Install [Google App Engine SDK](https://cloud.google.com/appengine/downloads) ## Test the build -This command serves the `es5-bundled` build version of the app: - - dev_appserver.py build/es5-bundled - -This command serves the `es6-unbundled` build version of the app: - - dev_appserver.py build/es6-unbundled - -## Deploy to Google App Engine +Use `polymer serve` to serve a specific build preset of the app. For example: - gcloud app deploy build/es6-unbundled/app.yaml --project [YOUR_PROJECT_ID] + polymer serve build/es5-bundled diff --git a/app.yaml b/app.yaml deleted file mode 100755 index 0443ec01..00000000 --- a/app.yaml +++ /dev/null @@ -1,35 +0,0 @@ -runtime: python27 -api_version: 1 -threadsafe: true - -handlers: -- url: /bower_components - static_dir: bower_components - secure: always - -- url: /data - static_dir: data - secure: always - application_readable: true - -- url: /images - static_dir: images - secure: always - -- url: /src - static_dir: src - secure: always - -- url: /service-worker.js - static_files: service-worker.js - upload: service-worker.js - secure: always - -- url: /manifest.json - static_files: manifest.json - upload: manifest.json - secure: always - -- url: /.* - script: main.app - secure: always diff --git a/main.py b/main.py deleted file mode 100644 index 4b39b1fb..00000000 --- a/main.py +++ /dev/null @@ -1,31 +0,0 @@ -import webapp2 -import re - -class MainPage(webapp2.RequestHandler): - def get(self, **kwargs): - self.response.out.write(open('index.html').read()) - -class ArticlePage(webapp2.RequestHandler): - def get(self, **kwargs): - bots = '|'.join([ - 'Googlebot', - 'bingbot', - 'msnbot', - 'facebookexternalhit', - 'Facebot', - 'Twitterbot', - 'Google-Structured-Data-Testing-Tool' - ]) - if re.search(bots, self.request.headers.get('User-Agent'), re.I): - self.response.out.write(open('data/articles/' + kwargs['article_id'] + '.html').read()) - else: - self.response.out.write(open('index.html').read()) - -app = webapp2.WSGIApplication([ - webapp2.Route('/', handler=MainPage), - webapp2.Route('/index.html', handler=MainPage), - webapp2.Route('//', handler=MainPage), - webapp2.Route('///', handler=MainPage), - webapp2.Route('///', handler=ArticlePage), - webapp2.Route('////', handler=ArticlePage), - ], debug=True) diff --git a/polymer.json b/polymer.json index 8ef3675c..d77e23b3 100644 --- a/polymer.json +++ b/polymer.json @@ -10,12 +10,9 @@ "sources": [ "src/**/*", "images/**/*", - "data/**/*", - "bower.json" + "data/**/*" ], "extraDependencies": [ - "app.yaml", - "main.py", "manifest.json", "bower_components/webcomponentsjs/*" ], @@ -28,6 +25,9 @@ }, { "preset": "es6-unbundled" + }, + { + "preset": "es6-bundled" } ] } diff --git a/sw-precache-config.js b/sw-precache-config.js index b1d4f57e..f3259868 100644 --- a/sw-precache-config.js +++ b/sw-precache-config.js @@ -1,10 +1,19 @@ module.exports = { staticFileGlobs: [ - '/manifest.json', - '/bower_components/webcomponentsjs/*.js', - '/images/*' + 'manifest.json', + 'bower_components/webcomponentsjs/webcomponents-loader.js', + 'images/*' ], runtimeCaching: [ + { + urlPattern: /\/bower_components\/webcomponentsjs\/.*.js/, + handler: 'fastest', + options: { + cache: { + name: 'webcomponentsjs-polyfills-cache' + } + } + }, { urlPattern: /.*\.(png|jpg|gif|svg)/i, handler: 'fastest', From 887009a2bc0017ed51db3e3f9f667ba5738ec1ff Mon Sep 17 00:00:00 2001 From: Keanu Lee Date: Mon, 2 Oct 2017 11:01:48 -0700 Subject: [PATCH 2/4] relative paths; const --- index.html | 9 +++++---- src/news-app.html | 2 +- src/news-article.html | 10 +++++----- src/news-data.html | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 70d61f97..6954019d 100644 --- a/index.html +++ b/index.html @@ -12,13 +12,14 @@ + NEWS - + - +