diff --git a/ep19-go-offline/polymer-starter-kit/.editorconfig b/ep19-go-offline/polymer-starter-kit/.editorconfig new file mode 100644 index 0000000..c2cdfb8 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/ep19-go-offline/polymer-starter-kit/.gitattributes b/ep19-go-offline/polymer-starter-kit/.gitattributes new file mode 100644 index 0000000..2125666 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/ep19-go-offline/polymer-starter-kit/.gitignore b/ep19-go-offline/polymer-starter-kit/.gitignore new file mode 100644 index 0000000..fdb1b10 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/.gitignore @@ -0,0 +1,4 @@ +node_modules +dist +bower_components +.tmp diff --git a/ep19-go-offline/polymer-starter-kit/.jscsrc b/ep19-go-offline/polymer-starter-kit/.jscsrc new file mode 100644 index 0000000..880a269 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/.jscsrc @@ -0,0 +1,5 @@ +{ + "preset": "google", + "disallowSpacesInAnonymousFunctionExpression": null, + "excludeFiles": ["node_modules/**"] +} diff --git a/ep19-go-offline/polymer-starter-kit/.jshintrc b/ep19-go-offline/polymer-starter-kit/.jshintrc new file mode 100644 index 0000000..013f838 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/.jshintrc @@ -0,0 +1,24 @@ +{ + "node": true, + "browser": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "noarg": true, + "quotmark": "single", + "undef": true, + "unused": true, + "globals": { + "wrap": true, + "unwrap": true, + "Polymer": true, + "Platform": true, + "page": true, + "app": true + } +} diff --git a/ep19-go-offline/polymer-starter-kit/LICENSE.md b/ep19-go-offline/polymer-starter-kit/LICENSE.md new file mode 100644 index 0000000..bb3f440 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/LICENSE.md @@ -0,0 +1,19 @@ +# License + +Everything in this repo is BSD style license unless otherwise specified. + +Copyright (c) 2015 The Polymer Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. +* Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/ep19-go-offline/polymer-starter-kit/README.md b/ep19-go-offline/polymer-starter-kit/README.md new file mode 100644 index 0000000..9ea67c7 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/README.md @@ -0,0 +1,311 @@ +![](https://cloud.githubusercontent.com/assets/110953/7877439/6a69d03e-0590-11e5-9fac-c614246606de.png) +## Polymer Starter Kit + +> A starting point for building web applications with Polymer 1.0 + +### Included out of the box: + +* [Polymer](http://polymer-project.org), [Paper](https://elements.polymer-project.org/browse?package=paper-elements), [Iron](https://elements.polymer-project.org/browse?package=iron-elements) and [Neon](https://elements.polymer-project.org/browse?package=neon-elements) elements +* [Material Design](http://www.google.com/design/spec/material-design/introduction.html) layout +* Routing with [Page.js](https://visionmedia.github.io/page.js/) +* Unit testing with [Web Component Tester](https://github.com/Polymer/web-component-tester) +* Optional offline setup through [Platinum](https://elements.polymer-project.org/browse?package=platinum-elements) Service Worker elements +* End-to-end Build Tooling (including [Vulcanize](https://github.com/Polymer/vulcanize)) + +## Getting Started + +To take advantage of Polymer Starter Kit you need to: + +1. Get a copy of the code. +2. Install the dependencies if you don't already have them. +3. Modify the application to your liking. +4. Deploy your production code. + +### Get the code + +[Download](https://github.com/polymerelements/polymer-starter-kit/releases/latest) and extract Polymer Starter Kit to where you want to work. + +The standard version of Polymer Starter Kit comes with tools that are very handy when developing a Polymer app. If you'd like to get started without installing any new tools, see Polymer Starter Kit Light in the [Releases](https://github.com/polymerelements/polymer-starter-kit/releases/latest) page. + +### Install dependencies + +#### Quick-start (for experienced users) + +With Node.js installed, run the following one liner from the root of your Polymer Starter Kit download: + +```sh +npm install -g gulp bower && npm install && bower install +``` + +#### Prerequisites (for everyone) + +The full starter kit requires the following major dependencies: + +- Node.js, used to run JavaScript tools from the command line. +- npm, the node package manager, installed with Node.js and used to install Node.js packages. +- gulp, a Node.js-based build tool. +- bower, a Node.js-based package manager used to install front-end packages (like Polymer). + +**To install dependencies:** + +1) Check your Node.js version. + +```sh +node --version +``` + +The version should be at or above 0.12.x. + +2) If you don't have Node.js installed, or you have a lower version, go to [nodejs.org](https://nodejs.org) and click on the big green Install button. + +3) Install `gulp` and `bower` globally. + +```sh +npm install -g gulp bower +``` + +This lets you run `gulp` and `bower` from the command line. + +4) Install the starter kit's local `npm` and `bower` dependencies. + +```sh +cd polymer-starter-kit && npm install && bower install +``` + +This installs the element sets (Paper, Iron, Platinum) and tools the starter kit requires to build and serve apps. + +### Development workflow + +#### Serve / watch + +```sh +gulp serve +``` + +This outputs an IP address you can use to locally test and another that can be used on devices connected to your network. + +#### Run tests + +```sh +gulp test:local +``` + +This runs the unit tests defined in the `app/test` directory through [web-component-tester](https://github.com/Polymer/web-component-tester). + +#### Build & Vulcanize + +```sh +gulp +``` + +Build and optimize the current project, ready for deployment. This includes linting as well as vulcanization, image, script, stylesheet and HTML optimization and minification. + +## Application Theming + +Polymer 1.0 introduces a shim for CSS custom properties. We take advantage of this in `app/styles/app-theme.html` to provide theming for your application. You can also find our presets for Material Design breakpoints in this file. + +[Read more](https://www.polymer-project.org/1.0/docs/devguide/styling.html) about CSS custom properties. + +## Unit Testing + +Web apps built with Polymer Starter Kit come configured with support for [Web Component Tester](https://github.com/Polymer/web-component-tester) - Polymer's preferred tool for authoring and running unit tests. This makes testing your element based applications a pleasant experience. + +[Read more](https://github.com/Polymer/web-component-tester#html-suites) about using Web Component tester. + +## Dependency Management + +Polymer uses [Bower](http://bower.io) for package management. This makes it easy to keep your elements up to date and versioned. For tooling, we use npm to manage Node.js-based dependencies. + +## Service Worker + +Polymer Starter Kit offers an optional offline experience thanks to Service Worker and the [Platinum Service Worker elements](https://github.com/PolymerElements/platinum-sw). New to Service Worker? Read the following [introduction](http://www.html5rocks.com/en/tutorials/service-worker/introduction/) to understand how it works. + +Our optional offline setup should work well for relatively simple applications. For more complex apps, we recommend learning how Service Worker works so that you can make the most of the Platinum Service Worker element abstractions. + +### Enable Service Worker support? + +To enable Service Worker support for Polymer Starter Kit project use these 3 steps: + +1. Uncomment Service Worker code in index.html + ```HTML + + + ``` +2. Uncomment Service Worker code in elements.html + + ```HTML + + + ``` +3. Add 'precache' to the list in the 'default' gulp task like below. +[(gulpfile.js)](https://github.com/PolymerElements/polymer-starter-kit/blob/master/gulpfile.js) + + ```JavaScript + // Build Production Files, the Default Task + gulp.task('default', ['clean'], function (cb) { + runSequence( + ['copy', 'styles'], + 'elements', + ['jshint', 'images', 'fonts', 'html'], + 'vulcanize', 'precache', + cb); + }); + ``` + +#### Filing bugs in the right place + +If you experience an issue with Service Worker support in your application, check the origin of the issue and use the appropriate issue tracker: + +* [sw-toolbox](https://github.com/GoogleChrome/sw-toolbox/issues) +* [platinum-sw](https://github.com/PolymerElements/platinum-sw/issues) +* [platinum-push-notifications-manager](https://github.com/PolymerElements/push-notification-manager/) +* For all other issues, feel free to file them [here](https://github.com/polymerelements/polymer-starter-kit/issues). + +#### I get an error message about "Only secure origins are allowed" + +Service Workers are only available to "secure origins" (HTTPS sites, basically) in line with a policy to prefer secure origins for powerful new features. However http://localhost is also considered a secure origin, so if you can, developing on localhost is an easy way to avoid this error. For production, your site will need to support HTTPS. + +#### How do I debug Service Worker? + +If you need to debug the event listener wire-up use `chrome://serviceworker-internals`. + +#### What are those buttons on chrome://serviceworker-internals? + +This page shows your registered workers and provides some basic operations. + +* Unregister: Unregisters the worker. +* Start: Starts the worker. This would happen automatically when you navigate to a page in the worker's scope. +* Stop: Stops the worker. +* Sync: Dispatches a 'sync' event to the worker. If you don't handle this event, nothing will happen. +* Push: Dispatches a 'push' event to the worker. If you don't handle this event, nothing will happen. +* Inspect: Opens the worker in the Inspector. + +#### Development flow + +In order to guarantee that the latest version of your Service Worker script is being used, follow these instructions: + +* After you made changes to your service worker script, close all but one of the tabs pointing to your web application +* Hit shift-reload to bypass the service worker as to ensure that the remaining tab isn't under the control of a service worker +* Hit reload to let the newer version of the Service Worker control the page. + +If you find anything to still be stale, you can also try navigating to `chrome:serviceworker-internals` (in Chrome), finding the relevant Service Worker entry for your application and clicking 'Unregister' before refreshing your app. This will (of course) only clear it from the local development machine. If you have already deployed to production then further work will be necessary to remove it from your user's machines. + +#### Disable Service Worker support after you enabled it + +If for any reason you need to disable Service Worker support after previously enabling it, you can remove it from your Polymer Starter Kit project using these 4 steps: + +1. Remove references to the platinum-sw elements from your application [index](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/index.html). +2. Remove the two Platinum Service Worker elements (platinum-sw/..) in [app/elements/elements.html](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/elements/elements.html) +3. Remove 'precache' from the list in the 'default' gulp task ([gulpfile.js](https://github.com/PolymerElements/polymer-starter-kit/blob/master/gulpfile.js)) +4. Navigate to `chrome://serviceworker-internals` and unregister any Service Workers registered by Polymer Starter Kit for your app just in case there's a copy of it cached. + +## Yeoman support + +[generator-polymer](https://github.com/yeoman/generator-polymer/releases) now includes support for Polymer Starter Kit out of the box. + +## Frequently Asked Questions + +> Where do I customise my application theme? + +Theming can be achieved using [CSS Custom properties](https://www.polymer-project.org/1.0/docs/devguide/styling.html#xscope-styling-details) via [app/styles/app-theme.html](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/styles/app-theme.html). +You can also use `app/styles/main.css` for pure CSS stylesheets (e.g for global styles), however note that Custom properties will not work there under the shim. + +A [Polycast](https://www.youtube.com/watch?v=omASiF85JzI) is also available that walks through theming using Polymer 1.0. + +> Where do I configure routes in my application? + +This can be done via [`app/elements/routing.html`](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/elements/routing.html). We use Page.js for routing and new routes +can be defined in this import. We then toggle which `` page to display based on the [selected](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/index.html#L105) route. + +> Why are we using Page.js rather than a declarative router like ``? + +`` (in our opinion) is good, but lacks imperative hooks for getting full control +over the routing in your application. This is one place where a pure JS router shines. We may +at some point switch back to a declarative router when our hook requirements are tackled. That +said, it should be trivial to switch to `` or another declarative router in your +own local setup. + +> Where can I find the application layouts from your Google I/O 2015 talk? + +App layouts live in a separate repository called [app-layout-templates](https://github.com/PolymerElements/app-layout-templates). +You can select a template and copy over the relevant parts you would like to reuse to Polymer Starter Kit. + +You will probably need to change paths to where your Iron and Paper dependencies can be found to get everything working. +This can be done by adding them to the [`elements.html`](https://github.com/PolymerElements/polymer-starter-kit/blob/master/app/elements/elements.html) import. + +> Something has failed during installation. How do I fix this? + +Our most commonly reported issue is around system permissions for installing Node.js dependencies. +We recommend following the [fixing npm permissions](https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md) +guide to address any messages around administrator permissions being required. If you use `sudo` +to work around these issues, this guide may also be useful for avoiding that. + +If you run into an exception that mentions five optional dependencies failing (or an `EEXIST` error), you +may have run into an npm [bug](https://github.com/npm/npm/issues/6309). We recommend updating to npm 2.11.0+ +to work around this. You can do this by opening a Command Prompt/terminal and running `npm install npm@2.11.0 -g`. If you are on Windows, +Node.js (and npm) may have been installed into `C:\Program Files\`. Updating npm by running `npm install npm@2.11.0 -g` will install npm +into `%AppData%\npm`, but your system will still use the npm version. You can avoid this by deleting your older npm from `C:\Program Files\nodejs` +as described [here](https://github.com/npm/npm/issues/6309#issuecomment-67549380). + +If the issue is to do with a failure somewhere else, you might find that due to a network issue +a dependency failed to correctly install. We recommend running `npm cache clean` and deleting the `node_modules` directory followed by +`npm install` to see if this corrects the problem. If not, please check the [issue tracker](https://github.com/PolymerElements/polymer-starter-kit/issues) in case +there is a workaround or fix already posted. + + +> I'm having trouble getting Vulcanize to fully build my project on Windows. Help? + +Some Windows users have run into trouble with the `elements.vulcanized.html` file in their `dist` folder +not being correctly vulcanized. This can happen if your project is in a folder with a name containing a +space. You can work around this issue by ensuring your path doesn't contain one. + +There is also an [in-flight](https://github.com/PolymerElements/polymer-starter-kit/issues/62#issuecomment-108974016) issue +where some are finding they need to disable the `inlineCss` option in our configuration for Vulcanize +to correctly build. We are still investigating this, however for the time-being use the workaround if +you find your builds getting stuck here. + + +> How do I add new JavaScript files to Starter Kit so they're picked up by the build process? + +At the bottom of `app/index.html`, you will find a build block that can be used to include additional +scripts for your app. Build blocks are just normal script tags that are wrapped in a HTML +comment that indicates where to concatenate and minify their final contents to. + +Below, we've added in `script2.js` and `script3.js` to this block. The line +`` specifies that these scripts will be squashed into `scripts/app.js` +during a build. + +```html + + + + + +``` + +> I'm finding the installation/tooling here overwhelming. What should I do? + +Don't worry! We've got your covered. Polymer Starter Kit tries to offer everything you need to build and optimize your apps for production, which is why we include the tooling we do. We realise however that our tooling setup may not be for everyone. + +If you find that you just want the simplest setup possible, we recommend using Polymer Starter Kit light, which is available from the [Releases](https://github.com/PolymerElements/polymer-starter-kit/releases) page. This takes next to no time to setup. + +## Contributing + +Polymer Starter Kit is a new project and is an ongoing effort by the Web Component community. We welcome your bug reports, PRs for improvements, docs and anything you think would improve the experience for other Polymer developers. diff --git a/ep19-go-offline/polymer-starter-kit/app/elements/elements.html b/ep19-go-offline/polymer-starter-kit/app/elements/elements.html new file mode 100644 index 0000000..d870840 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/elements/elements.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/elements/my-greeting/my-greeting.html b/ep19-go-offline/polymer-starter-kit/app/elements/my-greeting/my-greeting.html new file mode 100644 index 0000000..f9105cc --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/elements/my-greeting/my-greeting.html @@ -0,0 +1,46 @@ + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/elements/my-list/my-list.html b/ep19-go-offline/polymer-starter-kit/app/elements/my-list/my-list.html new file mode 100644 index 0000000..a8e1d99 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/elements/my-list/my-list.html @@ -0,0 +1,49 @@ + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/elements/routing.html b/ep19-go-offline/polymer-starter-kit/app/elements/routing.html new file mode 100644 index 0000000..2f7d01c --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/elements/routing.html @@ -0,0 +1,41 @@ + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/favicon.ico b/ep19-go-offline/polymer-starter-kit/app/favicon.ico new file mode 100644 index 0000000..4887394 Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/favicon.ico differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/map.jpg b/ep19-go-offline/polymer-starter-kit/app/images/map.jpg new file mode 100644 index 0000000..1ab9ffb Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/map.jpg differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/touch/apple-touch-icon.png b/ep19-go-offline/polymer-starter-kit/app/images/touch/apple-touch-icon.png new file mode 100644 index 0000000..bacf318 Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/touch/apple-touch-icon.png differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/touch/chrome-touch-icon-192x192.png b/ep19-go-offline/polymer-starter-kit/app/images/touch/chrome-touch-icon-192x192.png new file mode 100644 index 0000000..6a5e101 Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/touch/chrome-touch-icon-192x192.png differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/touch/icon-128x128.png b/ep19-go-offline/polymer-starter-kit/app/images/touch/icon-128x128.png new file mode 100644 index 0000000..4364903 Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/touch/icon-128x128.png differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-icon-144x144.png b/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-icon-144x144.png new file mode 100644 index 0000000..cb9f44c Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-icon-144x144.png differ diff --git a/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-touch-icon-144x144-precomposed.png b/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-touch-icon-144x144-precomposed.png new file mode 100644 index 0000000..cb9f44c Binary files /dev/null and b/ep19-go-offline/polymer-starter-kit/app/images/touch/ms-touch-icon-144x144-precomposed.png differ diff --git a/ep19-go-offline/polymer-starter-kit/app/index.html b/ep19-go-offline/polymer-starter-kit/app/index.html new file mode 100644 index 0000000..9320827 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/index.html @@ -0,0 +1,199 @@ + + + + + + + + + + + Polymer Starter Kit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/manifest.json b/ep19-go-offline/polymer-starter-kit/app/manifest.json new file mode 100644 index 0000000..349050b --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/manifest.json @@ -0,0 +1,19 @@ +{ + "name": "Polymer Starter Kit", + "short_name": "Polymer Starter Kit", + "icons": [{ + "src": "images/touch/icon-128x128.png", + "sizes": "128x128" + }, { + "src": "images/touch/apple-touch-icon.png", + "sizes": "152x152" + }, { + "src": "images/touch/ms-touch-icon-144x144-precomposed.png", + "sizes": "144x144" + }, { + "src": "images/touch/chrome-touch-icon-192x192.png", + "sizes": "192x192" + }], + "start_url": "/#!/", + "display": "standalone" +} diff --git a/ep19-go-offline/polymer-starter-kit/app/precache.json b/ep19-go-offline/polymer-starter-kit/app/precache.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/precache.json @@ -0,0 +1 @@ +[] diff --git a/ep19-go-offline/polymer-starter-kit/app/robots.txt b/ep19-go-offline/polymer-starter-kit/app/robots.txt new file mode 100644 index 0000000..4d521f9 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/robots.txt @@ -0,0 +1,4 @@ +# robotstxt.org + +User-agent: * +Disallow: diff --git a/ep19-go-offline/polymer-starter-kit/app/scripts/app.js b/ep19-go-offline/polymer-starter-kit/app/scripts/app.js new file mode 100644 index 0000000..65be15d --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/scripts/app.js @@ -0,0 +1,54 @@ +/* +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +(function(document) { + 'use strict'; + + // Grab a reference to our auto-binding template + // and give it some initial binding values + // Learn more about auto-binding templates at http://goo.gl/Dx1u2g + var app = document.querySelector('#app'); + + app.displayInstalledToast = function() { + document.querySelector('#caching-complete').show(); + }; + + // Listen for template bound event to know when bindings + // have resolved and content has been stamped to the page + app.addEventListener('dom-change', function() { + console.log('Our app is ready to rock!'); + }); + + // See https://github.com/Polymer/polymer/issues/1381 + window.addEventListener('WebComponentsReady', function() { + // imports are loaded and elements have been registered + }); + + // Close drawer after menu item is selected if drawerPanel is narrow + app.onMenuSelect = function() { + var drawerPanel = document.querySelector('#paperDrawerPanel'); + if (drawerPanel.narrow) { + drawerPanel.closeDrawer(); + } + }; + + app.showMap = function() { + if (app.hasMap) { + return; + } + + var map = document.createElement('img'); + map.classList.add('map'); + map.src = 'images/map.jpg'; + map.alt = 'A map of our location'; + this.$.contactCard.appendChild(map); + app.hasMap = true; + }; + +})(document); diff --git a/ep19-go-offline/polymer-starter-kit/app/styles/app-theme.html b/ep19-go-offline/polymer-starter-kit/app/styles/app-theme.html new file mode 100644 index 0000000..95236d4 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/styles/app-theme.html @@ -0,0 +1,216 @@ + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/styles/main.css b/ep19-go-offline/polymer-starter-kit/app/styles/main.css new file mode 100644 index 0000000..7f91921 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/styles/main.css @@ -0,0 +1,22 @@ +/* +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +body { + background: #fafafa; + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; + color: #333; +} + +section[data-route="contact"] { + text-align: center; +} + +.map { + width: 100%; +} diff --git a/ep19-go-offline/polymer-starter-kit/app/sw-import.js b/ep19-go-offline/polymer-starter-kit/app/sw-import.js new file mode 100644 index 0000000..cb7fb1f --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/sw-import.js @@ -0,0 +1,10 @@ +/* +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +importScripts('bower_components/platinum-sw/service-worker.js'); diff --git a/ep19-go-offline/polymer-starter-kit/app/test/index.html b/ep19-go-offline/polymer-starter-kit/app/test/index.html new file mode 100644 index 0000000..6981750 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/test/index.html @@ -0,0 +1,32 @@ + + + + + + + + Elements Test Runner + + + + + + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/test/my-greeting-basic.html b/ep19-go-offline/polymer-starter-kit/app/test/my-greeting-basic.html new file mode 100644 index 0000000..eedfaf8 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/test/my-greeting-basic.html @@ -0,0 +1,53 @@ + + + + + + + my-greeting-basic + + + + + + + + + + + + + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/app/test/my-list-basic.html b/ep19-go-offline/polymer-starter-kit/app/test/my-list-basic.html new file mode 100644 index 0000000..a59dead --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/app/test/my-list-basic.html @@ -0,0 +1,68 @@ + + + + + + + my-list-basic + + + + + + + + + + + + + + + + + + + + + diff --git a/ep19-go-offline/polymer-starter-kit/bower.json b/ep19-go-offline/polymer-starter-kit/bower.json new file mode 100644 index 0000000..1cc5537 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/bower.json @@ -0,0 +1,15 @@ +{ + "name": "polymer-starter-kit", + "private": true, + "dependencies": { + "iron-elements": "PolymerElements/iron-elements#1.0.0", + "paper-elements": "PolymerElements/paper-elements#1.0.1", + "platinum-elements": "PolymerElements/platinum-elements#1.0.1", + "neon-elements": "PolymerElements/neon-elements#1.0.0", + "page": "visionmedia/page.js#~1.6.3" + }, + "devDependencies": { + "web-component-tester": "*", + "test-fixture": "PolymerElements/test-fixture#^1.0.0" + } +} diff --git a/ep19-go-offline/polymer-starter-kit/gulpfile.js b/ep19-go-offline/polymer-starter-kit/gulpfile.js new file mode 100644 index 0000000..3c8281a --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/gulpfile.js @@ -0,0 +1,252 @@ +/* +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +'use strict'; + +// Include Gulp & Tools We'll Use +var gulp = require('gulp'); +var $ = require('gulp-load-plugins')(); +var del = require('del'); +var runSequence = require('run-sequence'); +var browserSync = require('browser-sync'); +var reload = browserSync.reload; +var merge = require('merge-stream'); +var path = require('path'); +var fs = require('fs'); +var glob = require('glob'); +var historyApiFallback = require('connect-history-api-fallback'); + +var AUTOPREFIXER_BROWSERS = [ + 'ie >= 10', + 'ie_mob >= 10', + 'ff >= 30', + 'chrome >= 34', + 'safari >= 7', + 'opera >= 23', + 'ios >= 7', + 'android >= 4.4', + 'bb >= 10' +]; + +var styleTask = function (stylesPath, srcs) { + return gulp.src(srcs.map(function(src) { + return path.join('app', stylesPath, src); + })) + .pipe($.changed(stylesPath, {extension: '.css'})) + .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS)) + .pipe(gulp.dest('.tmp/' + stylesPath)) + .pipe($.if('*.css', $.cssmin())) + .pipe(gulp.dest('dist/' + stylesPath)) + .pipe($.size({title: stylesPath})); +}; + +// Compile and Automatically Prefix Stylesheets +gulp.task('styles', function () { + return styleTask('styles', ['**/*.css']); +}); + +gulp.task('elements', function () { + return styleTask('elements', ['**/*.css']); +}); + +// Lint JavaScript +gulp.task('jshint', function () { + return gulp.src([ + 'app/scripts/**/*.js', + 'app/elements/**/*.js', + 'app/elements/**/*.html' + ]) + .pipe(reload({stream: true, once: true})) + .pipe($.jshint.extract()) // Extract JS from .html files + .pipe($.jshint()) + .pipe($.jshint.reporter('jshint-stylish')) + .pipe($.if(!browserSync.active, $.jshint.reporter('fail'))); +}); + +// Optimize Images +gulp.task('images', function () { + return gulp.src('app/images/**/*') + .pipe($.cache($.imagemin({ + progressive: true, + interlaced: true + }))) + .pipe(gulp.dest('dist/images')) + .pipe($.size({title: 'images'})); +}); + +// Copy All Files At The Root Level (app) +gulp.task('copy', function () { + var app = gulp.src([ + 'app/*', + '!app/test', + '!app/precache.json' + ], { + dot: true + }).pipe(gulp.dest('dist')); + + var bower = gulp.src([ + 'bower_components/**/*' + ]).pipe(gulp.dest('dist/bower_components')); + + var elements = gulp.src(['app/elements/**/*.html']) + .pipe(gulp.dest('dist/elements')); + + var swBootstrap = gulp.src(['bower_components/platinum-sw/bootstrap/*.js']) + .pipe(gulp.dest('dist/elements/bootstrap')); + + var swToolbox = gulp.src(['bower_components/sw-toolbox/*.js']) + .pipe(gulp.dest('dist/sw-toolbox')); + + var vulcanized = gulp.src(['app/elements/elements.html']) + .pipe($.rename('elements.vulcanized.html')) + .pipe(gulp.dest('dist/elements')); + + return merge(app, bower, elements, vulcanized, swBootstrap, swToolbox) + .pipe($.size({title: 'copy'})); +}); + +// Copy Web Fonts To Dist +gulp.task('fonts', function () { + return gulp.src(['app/fonts/**']) + .pipe(gulp.dest('dist/fonts')) + .pipe($.size({title: 'fonts'})); +}); + +// Scan Your HTML For Assets & Optimize Them +gulp.task('html', function () { + var assets = $.useref.assets({searchPath: ['.tmp', 'app', 'dist']}); + + return gulp.src(['app/**/*.html', '!app/{elements,test}/**/*.html']) + // Replace path for vulcanized assets + .pipe($.if('*.html', $.replace('elements/elements.html', 'elements/elements.vulcanized.html'))) + .pipe(assets) + // Concatenate And Minify JavaScript + .pipe($.if('*.js', $.uglify({preserveComments: 'some'}))) + // Concatenate And Minify Styles + // In case you are still using useref build blocks + .pipe($.if('*.css', $.cssmin())) + .pipe(assets.restore()) + .pipe($.useref()) + // Minify Any HTML + .pipe($.if('*.html', $.minifyHtml({ + quotes: true, + empty: true, + spare: true + }))) + // Output Files + .pipe(gulp.dest('dist')) + .pipe($.size({title: 'html'})); +}); + +// Vulcanize imports +gulp.task('vulcanize', function () { + var DEST_DIR = 'dist/elements'; + + return gulp.src('dist/elements/elements.vulcanized.html') + .pipe($.vulcanize({ + dest: DEST_DIR, + strip: true, + inlineCss: true, + inlineScripts: true + })) + .pipe(gulp.dest(DEST_DIR)) + .pipe($.size({title: 'vulcanize'})); +}); + +// Generate a list of files that should be precached when serving from 'dist'. +// The list will be consumed by the element. +gulp.task('precache', function (callback) { + var dir = 'dist'; + + glob('{elements,scripts,styles}/**/*.*', {cwd: dir}, function(error, files) { + if (error) { + callback(error); + } else { + files.push('index.html', './', 'bower_components/webcomponentsjs/webcomponents-lite.min.js'); + var filePath = path.join(dir, 'precache.json'); + fs.writeFile(filePath, JSON.stringify(files), callback); + } + }); +}); + +// Clean Output Directory +gulp.task('clean', del.bind(null, ['.tmp', 'dist'])); + +// Watch Files For Changes & Reload +gulp.task('serve', ['styles', 'elements', 'images'], function () { + browserSync({ + notify: false, + logPrefix: 'PSK', + snippetOptions: { + rule: { + match: '', + fn: function (snippet) { + return snippet; + } + } + }, + // Run as an https by uncommenting 'https: true' + // Note: this uses an unsigned certificate which on first access + // will present a certificate warning in the browser. + // https: true, + server: { + baseDir: ['.tmp', 'app'], + middleware: [ historyApiFallback() ], + routes: { + '/bower_components': 'bower_components' + } + } + }); + + gulp.watch(['app/**/*.html'], reload); + gulp.watch(['app/styles/**/*.css'], ['styles', reload]); + gulp.watch(['app/elements/**/*.css'], ['elements', reload]); + gulp.watch(['app/{scripts,elements}/**/*.js'], ['jshint']); + gulp.watch(['app/images/**/*'], reload); +}); + +// Build and serve the output from the dist build +gulp.task('serve:dist', ['default'], function () { + browserSync({ + notify: false, + logPrefix: 'PSK', + snippetOptions: { + rule: { + match: '', + fn: function (snippet) { + return snippet; + } + } + }, + // Run as an https by uncommenting 'https: true' + // Note: this uses an unsigned certificate which on first access + // will present a certificate warning in the browser. + // https: true, + server: 'dist', + middleware: [ historyApiFallback() ] + }); +}); + +// Build Production Files, the Default Task +gulp.task('default', ['clean'], function (cb) { + runSequence( + ['copy', 'styles'], + 'elements', + ['jshint', 'images', 'fonts', 'html'], + 'vulcanize', 'precache', + cb); + // Note: add , 'precache' , after 'vulcanize', if your are going to use Service Worker +}); + +// Load tasks for web-component-tester +// Adds tasks for `gulp test:local` and `gulp test:remote` +require('web-component-tester').gulp.init(gulp); + +// Load custom tasks from the `tasks` directory +try { require('require-dir')('tasks'); } catch (err) {} diff --git a/ep19-go-offline/polymer-starter-kit/package.json b/ep19-go-offline/polymer-starter-kit/package.json new file mode 100644 index 0000000..3ae25e7 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/package.json @@ -0,0 +1,41 @@ +{ + "private": true, + "devDependencies": { + "array-uniq": "^1.0.2", + "browser-sync": "^2.7.7", + "connect-history-api-fallback": "^1.1.0", + "del": "^1.1.1", + "glob": "^5.0.6", + "gulp": "^3.8.5", + "gulp-autoprefixer": "^2.1.0", + "gulp-cache": "^0.2.8", + "gulp-changed": "^1.0.0", + "gulp-cssmin": "^0.1.7", + "gulp-flatten": "0.0.4", + "gulp-if": "^1.2.1", + "gulp-imagemin": "^2.2.1", + "gulp-jshint": "^1.6.3", + "gulp-load-plugins": "^0.10.0", + "gulp-minify-html": "^1.0.2", + "gulp-rename": "^1.2.0", + "gulp-replace": "^0.5.3", + "gulp-size": "^1.0.0", + "gulp-uglify": "^1.2.0", + "gulp-uncss": "^1.0.1", + "gulp-useref": "^1.1.2", + "gulp-vulcanize": "^6.0.0", + "jshint-stylish": "^2.0.0", + "merge-stream": "^0.1.7", + "opn": "^1.0.0", + "require-dir": "^0.3.0", + "run-sequence": "^1.0.2", + "vulcanize": ">= 1.4.2", + "web-component-tester": "^3.1.3" + }, + "scripts": { + "test": "gulp test:local" + }, + "engines": { + "node": ">=0.10.0" + } +} diff --git a/ep19-go-offline/polymer-starter-kit/wct.conf.json b/ep19-go-offline/polymer-starter-kit/wct.conf.json new file mode 100644 index 0000000..6278c68 --- /dev/null +++ b/ep19-go-offline/polymer-starter-kit/wct.conf.json @@ -0,0 +1,3 @@ +{ + "suites": ["app/test"] +}