Navigation Menu

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

Commit

Permalink
Initial app structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Nov 7, 2015
0 parents commit a78d28f
Show file tree
Hide file tree
Showing 18 changed files with 461 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
@@ -0,0 +1,3 @@
{
"directory": "app/bower_components"
}
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
.DS_STORE

# Generated files/folders
*.pyc
app/css/*
dist

# Dev directories
bower_components
node_modules
46 changes: 46 additions & 0 deletions 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)
9 changes: 9 additions & 0 deletions app/docs/index.html
@@ -0,0 +1,9 @@
{% extends "templates/base.html" %}

{% block title %}page title{% endblock %}

{% block content %}

wow

{% endblock %}
1 change: 1 addition & 0 deletions app/elements/elements.html
@@ -0,0 +1 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
13 changes: 13 additions & 0 deletions app/index.html
@@ -0,0 +1,13 @@
{% extends "templates/base.html" %}

{% block title %}page title{% endblock %}

{% block content %}

<p>{{{5+5}}}</p>

<template id="t" is="dom-bind">
dom bind (<span>{{test}}</span>)
</template>

{% endblock %}
66 changes: 66 additions & 0 deletions 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 <bees-knees>",
"font-size:1.5em;color:#4558c9;", "color:#d61a7f;font-size:1em;");
})(window);
11 changes: 11 additions & 0 deletions app/sass/site.scss
@@ -0,0 +1,11 @@
body {
$color: red;
color: $color;
}

main {
border: 1px solid red;
display: flex;
align-items: center;
}

9 changes: 9 additions & 0 deletions app/test.html
@@ -0,0 +1,9 @@
{% extends "templates/base.html" %}

{% block title %}page title{% endblock %}

{% block content %}

test

{% endblock %}
16 changes: 16 additions & 0 deletions 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"
}
}
90 changes: 90 additions & 0 deletions 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']);
16 changes: 16 additions & 0 deletions 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.
12 changes: 12 additions & 0 deletions 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.

76 changes: 76 additions & 0 deletions 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

0 comments on commit a78d28f

Please sign in to comment.