start of gae site

This commit is contained in:
Lindsey Heagy
2016-05-30 22:01:15 -07:00
parent 9fbdaaf0a5
commit 01e19e4227
5 changed files with 197 additions and 1 deletions
+95
View File
@@ -0,0 +1,95 @@
# application: simpegdocs
# version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
# favicon
- url: /images/logo-block\.ico
static_files: /images/logo-block.ico
upload: /images/logo-block\.ico
# all css
- url: /(.*\.css)
mime_type: text/css
static_files: _build/html/\1
upload: _build/html/(.*\.css)
# webfonts
- url: /(.*\.(eot|svg|ttf|woff|woff2|otf))
static_files: _build/html/\1
upload: _build/html/(.*\.(eot|svg|ttf|woff|woff2|otf))
# javascript
- url: /(.*\.js)
mime_type: text/javascript
static_files: _build/html/\1
upload: _build/html/(.*\.js)
# plain text source
- url: /(.*\.txt)
mime_type: text/plain
static_files: _build/html/\1
upload: _build/html/(.*\.txt)
# images
- url: /_images/(.*\.(gif|png|jpg|ico))
static_files: _build/html/_images/\1
upload: _build/html/_images/(.*\.(gif|png|jpg|ico))
# redirect en/latest traffic
- url: /en/latest/(.*\.html)
script: simpegdocs.app
# raw html
- url: /(.*\.html)
mime_type: text/html
static_files: _build/html/\1
upload: _build/html/(.*\.html)
# serve index files
- url: /(.+)/
static_files: _build/html/\1/index.html
upload: _build/html/(.+)/index.html
- url: /(.+)
static_files: _build/html/\1/index.html
upload: _build/html/(.+)/index.html
- url: /
static_files: _build/html/index.html
upload: _build/html/index.html
- url: .*
script: simpegdocs.app
# Recommended file skipping declaration from the GAE tutorials
skip_files:
- ^(.*/)?app\.yaml
- ^(.*/)?app\.yml
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?tests$
- ^(.*/)?test$
- ^test/(.*/)?
- ^COPYING.LESSER
- ^README\..*
- \.gitignore
- ^\.git/.*
- \.*\.lint$
- ^(.*/)?.*\.doctree$
libraries:
- name: webapp2
version: "2.5.2"
- name: PIL
version: "1.1.7"
- name: numpy
version: "latest"
- name: jinja2
version: "latest"
+1 -1
View File
@@ -124,7 +124,7 @@ except Exception, e:
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
html_favicon = './images/logo-block.ico'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+11
View File
@@ -0,0 +1,11 @@
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.
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env python
#
# Copyright 2007 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 cgi
import datetime
import webapp2
import logging
from google.appengine.ext import ndb
from google.appengine.api import users
from google.appengine.api import mail
from google.appengine.api import urlfetch
import os
import jinja2
import urllib, hashlib
import json
TEMPLATEFOLDER = '_build/html/'
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__).split('/')[:-1])),
extensions=['jinja2.ext.autoescape'],
autoescape=False)
def setTemplate(self, template_values, templateFile, _templateFolder=TEMPLATEFOLDER):
# add Defaults
template_values['_templateFolder'] = _templateFolder
template_values['_year'] = str(datetime.datetime.now().year)
path = os.path.normpath(_templateFolder+templateFile)
template = JINJA_ENVIRONMENT.get_template(path)
resp = self.response.write(template.render(template_values))
# if resp is None:
# self.redirect('/error.html', permanent=True)
class Images(webapp2.RequestHandler):
def get(self):
self.redirect('/'+self.request.path)
class Redirect(webapp2.RequestHandler):
def get(self):
path = str(self.request.path).split(os.path.sep)[3:]
self.redirect(('/%s'%os.path.sep.join(path)), permanent=True)
class MainPage(webapp2.RequestHandler):
def get(self):
setTemplate(self, {"indexPage":True}, 'index.html')
# class Error(webapp2.RequestHandler):
# def get(self):
# setTemplate(self, {}, 'error.html', _templateFolder='_templates/')
# # self.redirect('/error.html', permanent=True)
from webapp2 import Route, RedirectHandler
# pointers = [
# Route('/en/latest/.*', RedirectHandler, defaults={'_uri': '/.*'}),
# # Route('/en/latest', RedirectHandler, defaults={'_uri': '/en/latest/'}),
# Route('/en/latest/', RedirectHandler, defaults={'_uri': '/'}),
#
# ('/.*', MainPage),
# ('/', MainPage),
# ('', MainPage),
# ('/_images/.*', Images),
# ]
app = webapp2.WSGIApplication([
('/_images/.*', Images),
('/en/latest/.*',Redirect),
('/', MainPage),
# ('/.*', Error),
], debug=True)
# app.error_handlers[404] = Error