Browse Source

Add assets/config module, SASS files, templates.

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
Severyn Kozak 10 years ago
parent
commit
f24d2a6be2
9 changed files with 71 additions and 7 deletions
  1. +11
    -3
      app.py
  2. +1
    -0
      bitshift/__init__.py
  3. +22
    -0
      bitshift/assets.py
  4. +6
    -0
      bitshift/config.py
  5. +2
    -0
      static/css/main.css
  6. +0
    -2
      static/css/main.sass
  7. +11
    -0
      static/sass/_mixins.sass
  8. +7
    -0
      static/sass/main.sass
  9. +11
    -2
      templates/layout.html

+ 11
- 3
app.py View File

@@ -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():


+ 1
- 0
bitshift/__init__.py View File

@@ -0,0 +1 @@
__all__ = ["config", "assets"]

+ 22
- 0
bitshift/assets.py View File

@@ -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)

+ 6
- 0
bitshift/config.py View File

@@ -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"

+ 2
- 0
static/css/main.css View File

@@ -1,2 +1,4 @@
/* Global project stylesheet.
*/
p { p {
font-size: 1.5em; } font-size: 1.5em; }

+ 0
- 2
static/css/main.sass View File

@@ -1,2 +0,0 @@
p
font-size: 1.5em

+ 11
- 0
static/sass/_mixins.sass View File

@@ -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

+ 7
- 0
static/sass/main.sass View File

@@ -0,0 +1,7 @@
/*
Global project stylesheet.
*/

// placeholder
p
font-size: 1.5em

+ 11
- 2
templates/layout.html View File

@@ -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>


Loading…
Cancel
Save