Permalink
Browse files

Merge pull request #1 from poundifdef/bobby

New template
  • Loading branch information...
aaronsw committed Sep 2, 2012
2 parents bf88803 + 6482497 commit 275617d5651921fd0ec87c2cc1fb0ab890cc7be6
Showing with 47 additions and 0 deletions.
  1. +5 −0 app.py
  2. +5 −0 config.py
  3. +11 −0 hacking.txt
  4. BIN static/bobby/bobby.jpg
  5. +22 −0 templates/bobby/index.html
  6. +4 −0 templates/index.html
View
5 app.py
@@ -1,12 +1,17 @@
+from config import TEMPLATES
import os
from flask import Flask, request, make_response, render_template
+from jinja2.exceptions import TemplateNotFound
app = Flask(__name__)
app.config['DEBUG'] = bool(os.environ.get('DEBUG'))
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
+ if path in TEMPLATES:
+ return render_template(path + '/index.html', path=path)
+
return render_template("index.html")
if __name__ == "__main__":
View
@@ -0,0 +1,5 @@
+# List of templates - custom URLs, really - which this site supports
+
+TEMPLATES = [
+ 'bobby',
+]
View
@@ -0,0 +1,11 @@
+To add a new template (new_template_name):
+
+1. Add a folder with that template's name to the templates/ directory
+ (templates/new_template_name)
+
+2. If necessary, add static files to static/new_template_name/ To reference
+ URLs for static files in the jinja template, use the macro
+ {{ url(name_of_static_resource) }} which is defined in the default
+ index.html file.
+
+3. Add the name of that template to the TEMPLATES variable in config.py
View
Binary file not shown.
View
@@ -0,0 +1,22 @@
+{% import "/index.html" as macros with context %}
+
+<html>
+<body>
+
+<a href="http://bobbymcferrin.com/images/press/BOBBYMCFERRIN07smile.jpg">
+<img src="{{ macros.url('bobby.jpg') }}">
+</a>
+
+Comments are closed but don't worry!
+
+<br /><br />
+
+&lt;br&gt;
+br&gt;
+
+<br /><br />
+
+<iframe width="560" height="315" src="http://www.youtube.com/embed/ne6tB2KiZuk?rel=0" frameborder="0" allowfullscreen></iframe>
+
+</body>
+</html>
View
@@ -1,3 +1,7 @@
+{% macro url(file) %}
+{{ url_for('static', filename=path + '/' + file) }}
+{% endmacro%}
+
<a href="https://github.com/aaronsw/commentsareclosed"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<h1 style="text-align: center">Sorry to disappoint you, but comments are closed.</h1>

0 comments on commit 275617d

Please sign in to comment.