Add: bitshift/assets.py -add module that contains functions to be called from inside the templates/ Jinja HTML files -- currently contains tag(), which generates an HTML asset tag based on a filename. bitshift/config.py -add Flask configuration module. static/(sass/main.sass, css/main.css) -create isolated directory for SASS files; compiled CSS files will be stored in static/css. static/css/_mixins.sass -add SASS partial to contain mixins (globally relevant to the project's styling). templates/layout.html -add various metadata.tags/v1.0
@@ -1,10 +1,18 @@ | |||||
""" | |||||
Module to contain all the project's Flask server plumbing. | |||||
""" | |||||
from flask import Flask | from flask import Flask | ||||
from flask import render_template | |||||
from flask import render_template, session | |||||
from bitshift import * | |||||
app = Flask(__name__) | app = Flask(__name__) | ||||
app.config.from_object("bitshift.config") | |||||
env = app.jinja_env | |||||
app.jinja_env.line_statement_prefix = "=" | |||||
app_env = app.jinja_env | |||||
app_env.line_statement_prefix = "=" | |||||
app_env.globals.update(assets = assets) | |||||
@app.route("/") | @app.route("/") | ||||
def index(): | def index(): | ||||
@@ -0,0 +1 @@ | |||||
__all__ = ["config", "assets"] |
@@ -0,0 +1,22 @@ | |||||
""" | |||||
Module contains helper functions to be used inside the project's Jinja | |||||
templates. | |||||
""" | |||||
from flask import Markup | |||||
ASSET_HTML_TEMPLATES = { | |||||
'css': "<link rel='stylesheet' type='text/css' href='/static/css/%s'>", | |||||
'js': "<script src='/static/js/%s'></script>" | |||||
} | |||||
def tag(filename): | |||||
""" | |||||
Return HTML tag for asset named filename. | |||||
Return either a <script> or <link> tag to the file named filename, | |||||
based on its extension. | |||||
""" | |||||
file_ext = filename.split(".")[-1] | |||||
return Markup(ASSET_HTML_TEMPLATES[file_ext] % filename) |
@@ -0,0 +1,6 @@ | |||||
""" | |||||
Module to contain definitions of all Flask variables required by the app module. | |||||
""" | |||||
DEBUG = True | |||||
SECRET_KEY = "\x89\x87\x9a9\xab{\xda\xfe.28\xb4\x18\x01\x95]]\xd2\xeaen\xe0Ot" |
@@ -1,2 +1,4 @@ | |||||
/* Global project stylesheet. | |||||
*/ | |||||
p { | p { | ||||
font-size: 1.5em; } | font-size: 1.5em; } |
@@ -1,2 +0,0 @@ | |||||
p | |||||
font-size: 1.5em |
@@ -0,0 +1,11 @@ | |||||
/* | |||||
Partial to contain all globally-applicable mixins | |||||
*/ | |||||
// add vendor prefixes for the property $property with value $value | |||||
@mixin vendor($property, $value) | |||||
-webkit-#{$property}: $value | |||||
-moz-#{$property}: $value | |||||
-ms-#{$property}: $value | |||||
-o-#{$property}: $value | |||||
#{$property}: $value |
@@ -0,0 +1,7 @@ | |||||
/* | |||||
Global project stylesheet. | |||||
*/ | |||||
// placeholder | |||||
p | |||||
font-size: 1.5em |
@@ -1,4 +1,6 @@ | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<!-- Global layout template, to be inherited by other project HTML files. --> | |||||
<html> | <html> | ||||
<head> | <head> | ||||
<title> | <title> | ||||
@@ -6,9 +8,16 @@ | |||||
= endblock | = endblock | ||||
</title> | </title> | ||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> | |||||
<meta name="description" content="bitshift is an online code snippet | |||||
exchange."/> | |||||
<meta name="keywords" content="code snippet exchange golf programming | |||||
software community"/> | |||||
<meta name="author" content="Benjamin Attal Ben Kurtovic Severyn Kozak"/> | |||||
{{ assets.tag("main.css") }} | |||||
= block head | = block head | ||||
<link rel="stylesheet" type="text/css" | |||||
href={{ url_for('static', filename='css/main.css') }}> | |||||
= endblock | = endblock | ||||
</head> | </head> | ||||
<body> | <body> | ||||