From a78d28f57118992f2fb9177e82001c4f8698722c Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Fri, 6 Nov 2015 19:09:50 -0800 Subject: [PATCH] Initial app structure --- .bowerrc | 3 ++ .gitignore | 10 +++++ app.yaml | 46 +++++++++++++++++++ app/docs/index.html | 9 ++++ app/elements/elements.html | 1 + app/index.html | 13 ++++++ app/js/app.js | 66 ++++++++++++++++++++++++++++ app/sass/site.scss | 11 +++++ app/test.html | 9 ++++ bower.json | 16 +++++++ gulpfile.js | 90 ++++++++++++++++++++++++++++++++++++++ humans.txt | 16 +++++++ index.yaml | 12 +++++ main.py | 76 ++++++++++++++++++++++++++++++++ package.json | 32 ++++++++++++++ templates/base.html | 45 +++++++++++++++++++ templates/footer.html | 3 ++ templates/header.html | 3 ++ 18 files changed, 461 insertions(+) create mode 100644 .bowerrc create mode 100644 .gitignore create mode 100644 app.yaml create mode 100644 app/docs/index.html create mode 100644 app/elements/elements.html create mode 100644 app/index.html create mode 100644 app/js/app.js create mode 100644 app/sass/site.scss create mode 100644 app/test.html create mode 100644 bower.json create mode 100644 gulpfile.js create mode 100644 humans.txt create mode 100644 index.yaml create mode 100644 main.py create mode 100644 package.json create mode 100644 templates/base.html create mode 100644 templates/footer.html create mode 100644 templates/header.html diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000000..5773025bf9 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "app/bower_components" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..48e6ed0ebb --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.DS_STORE + +# Generated files/folders +*.pyc +app/css/* +dist + +# Dev directories +bower_components +node_modules diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000000..3e57f5b0fe --- /dev/null +++ b/app.yaml @@ -0,0 +1,46 @@ +runtime: python27 +api_version: 1 +threadsafe: yes + +libraries: + - name: jinja2 + version: "2.6" + - name: webapp2 + version: "latest" + +handlers: + +- url: /bower_components + static_dir: app/bower_components + secure: always + +- url: /css + static_dir: app/css + secure: always + +- url: /elements + static_dir: app/elements + secure: always + +- url: /js + static_dir: app/js + secure: always + +- url: /humans.txt + static_files: humans.txt + upload: humans.txt + +- url: .* + script: main.app + secure: always + +skip_files: + - ^(.*/)?#.*#$ + - ^(.*/)?.*~$ + - ^(.*/)?.*\.py[co]$ + - ^(.*/)?.*\.md$ + - ^(.*/)?.*/RCS/.*$ + - ^(.*/)?\..*$ + - gulpfile.js + - app/bower_components/[^/]+/bower_components/.*$ + - app/bower_components/(.+/)+(test/|demo/|README|AUTHORS|CONTRIBUTING|PATENTS|Makefile) diff --git a/app/docs/index.html b/app/docs/index.html new file mode 100644 index 0000000000..4a20a54053 --- /dev/null +++ b/app/docs/index.html @@ -0,0 +1,9 @@ +{% extends "templates/base.html" %} + +{% block title %}page title{% endblock %} + +{% block content %} + +wow + +{% endblock %} diff --git a/app/elements/elements.html b/app/elements/elements.html new file mode 100644 index 0000000000..8d0b4c8d9c --- /dev/null +++ b/app/elements/elements.html @@ -0,0 +1 @@ + diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000000..49b76efbd8 --- /dev/null +++ b/app/index.html @@ -0,0 +1,13 @@ +{% extends "templates/base.html" %} + +{% block title %}page title{% endblock %} + +{% block content %} + +

{{{5+5}}}

+ + + +{% endblock %} diff --git a/app/js/app.js b/app/js/app.js new file mode 100644 index 0000000000..6a5a694eee --- /dev/null +++ b/app/js/app.js @@ -0,0 +1,66 @@ +/* + * @license + * Copyright (c) 2014 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(exports) { +'use strict'; + +// // Add permalinks to heading elements. +// function addPermalinkHeadings(opt_inDoc) { +// var doc = opt_inDoc || document; + +// var permalinkEl = doc.querySelector('.show-permalinks'); +// if (permalinkEl) { +// ['h2','h3','h4'].forEach(function(h, i) { +// Array.prototype.forEach.call( +// permalinkEl.querySelectorAll(h), addPermalink); +// }); +// } +// } + +// function prettyPrintPage(opt_inDoc) { +// var doc = opt_inDoc || document; +// Array.prototype.forEach.call(doc.querySelectorAll('pre'), function(pre, i) { +// pre.classList.add('prettyprint'); +// }); + +// exports.prettyPrint && prettyPrint(); +// } + +function downloadStarter() { + ga('send', 'event', 'button', 'download'); +} + +function recordSearch(term) { + ga('send', 'event', 'search', term); +} + +function recordPageview(opt_url) { + var url = opt_url || location.pathname + location.hash; + ga('send', 'pageview', url); + ga('devrelTracker.send', 'pageview', url); +} + +exports.recordPageview = recordPageview; +exports.recordSearch = recordSearch; +exports.downloadStarter = downloadStarter; + +// Analytics ----- +(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ +(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), +m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) +})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); + +ga('create', 'UA-39334307-1', 'auto', {'siteSpeedSampleRate': 50}); +ga('create', 'UA-49880327-9', 'auto', {'name': 'devrelTracker'}); +recordPageview(); + +console && console.log("%cWelcome to Polymer!\n%cweb components are the ", + "font-size:1.5em;color:#4558c9;", "color:#d61a7f;font-size:1em;"); +})(window); diff --git a/app/sass/site.scss b/app/sass/site.scss new file mode 100644 index 0000000000..3373369334 --- /dev/null +++ b/app/sass/site.scss @@ -0,0 +1,11 @@ +body { + $color: red; + color: $color; +} + +main { + border: 1px solid red; + display: flex; + align-items: center; +} + diff --git a/app/test.html b/app/test.html new file mode 100644 index 0000000000..2aeb4dc5ae --- /dev/null +++ b/app/test.html @@ -0,0 +1,9 @@ +{% extends "templates/base.html" %} + +{% block title %}page title{% endblock %} + +{% block content %} + +test + +{% endblock %} diff --git a/bower.json b/bower.json new file mode 100644 index 0000000000..6051955ab9 --- /dev/null +++ b/bower.json @@ -0,0 +1,16 @@ +{ + "name": "PolymerDocs", + "description": "Polymer documentation site", + "homepage": "https://www.polymer-project.org/", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "devDependencies": { + "iron-elements": "PolymerElements/iron-elements#^1.0.4", + "paper-elements": "PolymerElements/paper-elements#^1.0.5" + } +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..cd051ec27f --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,90 @@ +/* +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'; + +var gulp = require('gulp'); +var $ = require('gulp-load-plugins')(); +var merge = require('merge-stream'); +var del = require('del'); + +// Autoprefix and minify CSS +gulp.task('styles', ['clean'], function() { + var sassOpts = { + precision: 10, + outputStyle: 'expanded', + onError: console.error.bind(console, 'Sass error:') + }; + var autoprefixerOpts = ['last 2 versions', 'ios 8', 'Safari 8']; + + return gulp.src('app/sass/**/*.scss') + .pipe($.changed('dist/css')) + .pipe($.sass(sassOpts)) + .pipe($.autoprefixer(autoprefixerOpts)) + .pipe(gulp.dest('app/css')) // Save unminimized css to dev directory. + .pipe($.cssmin()) + .pipe(gulp.dest('dist/css')) +}); + +// Optimize Images +gulp.task('images', ['clean'], function () { + return gulp.src('app/images/**/*') + .pipe($.imagemin({ + progressive: true, + interlaced: true + })) + .pipe(gulp.dest('dist/images')); +}); + +// Minify html +gulp.task('html', ['clean'], function() { + gulp.src('app/index.html') + .pipe($.minifyHtml({ + quotes: true, + empty: true, + spare: true + })) + .pipe(gulp.dest('dist')); +}); + +// Vulcanize +gulp.task('vulcanize', ['clean'], function() { + return gulp.src('app/src/elements.html') + .pipe($.vulcanize({ + stripComments: true, + inlineCss: true, + inlineScripts: true + })) + .pipe(gulp.dest('dist/src')); +}); + +// Copy over polyfills +gulp.task('copy', ['clean'], function() { + var polyfills = gulp.src('app/bower_components/webcomponentsjs/webcomponents-lite.min.js') + .pipe(gulp.dest('dist/bower_components/webcomponentsjs')); + var router = gulp.src('app/bower_components/page/*.js') + .pipe(gulp.dest('dist/bower_components/page')); + var data = gulp.src('app/data/*.json') + .pipe(gulp.dest('dist/data')); + var CoC = gulp.src('app/code-of-conduct.html') + .pipe(gulp.dest('dist')); + var codelabs = gulp.src('app/codelabs.html') + .pipe(gulp.dest('dist')); + return merge(polyfills, router, data, CoC, codelabs); +}); + +gulp.task('watch', function() { + gulp.watch('app/sass/**/*.scss', ['styles']); +}); + +// Clean Output Directory +gulp.task('clean', del.bind(null, ['dist'])); + +// Default task, build dist dir +gulp.task('default', ['styles', 'images', 'html', 'vulcanize', 'copy']); diff --git a/humans.txt b/humans.txt new file mode 100644 index 0000000000..b627227d1e --- /dev/null +++ b/humans.txt @@ -0,0 +1,16 @@ +/* TEAM */ +Eric Bidelman, Polymer team - @ebidel +Addy Osmani, Polymer team +Rob Dodson, Polymer team +Arthur Evans, Polymer team + +/* THANKS */ +To everyone who has contributed to Polymer & its documentation! + +/* SITE */ +Standards: HTML5, CSS3, web components +Components: Polymer +Software: App Engine + + +Web Components are the bees knees. \ No newline at end of file diff --git a/index.yaml b/index.yaml new file mode 100644 index 0000000000..8e6046de97 --- /dev/null +++ b/index.yaml @@ -0,0 +1,12 @@ +indexes: + +# AUTOGENERATED + +# This index.yaml is automatically updated whenever the dev_appserver +# detects that a new type of query is run. If you want to manage the +# index.yaml file manually, remove the above marker line (the line +# saying "# AUTOGENERATED"). If you want to manage some indexes +# manually, move them above the marker line. The index.yaml file is +# automatically uploaded to the admin console when you next deploy +# your application using appcfg.py. + diff --git a/main.py b/main.py new file mode 100644 index 0000000000..46465a8edf --- /dev/null +++ b/main.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python + +# 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. + +__author__ = 'ericbidelman@chromium.org (Eric Bidelman)' + +#import sys +#sys.path.insert(0, 'lib') + +import logging +import os +import jinja2 +import webapp2 + +from google.appengine.api import memcache +from google.appengine.ext.webapp import template +# import http2push.http2push as http2push + +env = jinja2.Environment( + loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), + extensions=['jinja2.ext.autoescape'], + autoescape=True, + trim_blocks=True, + variable_start_string='{{{', + variable_end_string='}}}') +# env.filters.update({ +# 'is_list': lambda v: isinstance(v, list), +# }) + + +class Site(webapp2.RequestHandler): + + def get(self, path): + if not path: # / servers /index.html + path = 'index.html' + elif path.endswith('/'): # /docs/ serves /docs/index.html + path += 'index.html' + elif path.endswith('/index.html'): # Remove /index.html from URL. + path = path[:path.rfind('/') + 1] + # TODO: preserver URL parameters and hash. + return self.redirect('/' + path, permanent=True) + + try: + template = env.get_template('app/' + path) + except jinja2.exceptions.TemplateNotFound as e: + self.abort(404) + + data = { + # todo + } + + return self.response.write(template.render(data).encode('utf-8')) + + +def handle_404(request, response, exception): + logging.exception(exception) + response.write('Oops! I could swear this page was here!') + response.set_status(404) + +app = webapp2.WSGIApplication([ + ('/(.*)', Site) +], debug=True) + +app.error_handlers[404] = handle_404 diff --git a/package.json b/package.json new file mode 100644 index 0000000000..2d8e493edd --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "PolymerDocs", + "version": "1.0.0", + "private": true, + "description": "Polymer documentation site", + "engines": { + "node": ">=5.0.0" + }, + "scripts": { + "postinstall": "bower install" + }, + "repository": { + "type": "git", + "url": "https://github.com/Polymer/docs" + }, + "bugs": { + "url": "https://github.com/Polymer/docs/issues" + }, + "homepage": "https://www.polymer-project.org/1.0/", + "devDependencies": { + "del": "^2.0.2", + "gulp": "^3.9.0", + "gulp-autoprefixer": "^3.1.0", + "gulp-changed": "^1.3.0", + "gulp-crisper": "^1.0.0", + "gulp-cssmin": "^0.1.7", + "gulp-load-plugins": "^1.1.0", + "gulp-sass": "^2.1.0", + "gulp-vulcanize": "^6.0.1", + "merge-stream": "^1.0.0" + } +} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000000..084666892e --- /dev/null +++ b/templates/base.html @@ -0,0 +1,45 @@ + + + + + +{% block title %}{% endblock %} - Polymer Project + +{% block meta %}{% endblock %} + + + + +{% block css %}{% endblock %} + + + + + + +{% block imports %}{% endblock %} + + + +{% include "templates/header.html" %} + +
+ {% block content %}{% endblock %} +
+ +{% include "templates/footer.html" %} + + +{% block js %}{% endblock %} + + diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 0000000000..063fa826ee --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,3 @@ +
+ Footer stuff +
diff --git a/templates/header.html b/templates/header.html new file mode 100644 index 0000000000..bc74c91801 --- /dev/null +++ b/templates/header.html @@ -0,0 +1,3 @@ +
+ Header stuff +