Browse Source

Merge branch 'master' into develop

Conflicts:
	app.py
tags/v1.0^2
Severyn Kozak 10 years ago
parent
commit
6ff65c0906
10 changed files with 107 additions and 2 deletions
  1. +3
    -0
      .gitignore
  2. +17
    -2
      app.py
  3. +1
    -0
      bitshift/__init__.py
  4. +22
    -0
      bitshift/assets.py
  5. +6
    -0
      bitshift/config.py
  6. +4
    -0
      static/css/main.css
  7. +11
    -0
      static/sass/_mixins.sass
  8. +7
    -0
      static/sass/main.sass
  9. +9
    -0
      templates/index.html
  10. +27
    -0
      templates/layout.html

+ 3
- 0
.gitignore View File

@@ -1,3 +1,6 @@
.sass-cache

# github premade rules
*.py[cod]

# C extensions


+ 17
- 2
app.py View File

@@ -1,7 +1,22 @@
"""
Module to contain all the project's Flask server plumbing.
"""

from flask import Flask
from flask import render_template, session

from bitshift import *

app = Flask(__name__)
app.secret_key = "\x03#\xa8\xf3!\xddHd\x11\x8dx\xd9mR\xb2\xfb\x89LH^\x05\xe7\xc6F"
app.config.from_object("bitshift.config")

app_env = app.jinja_env
app_env.line_statement_prefix = "="
app_env.globals.update(assets = assets)

@app.route("/")
def index():
return render_template("index.html")

if __name__ == "__main__":
app.run(debug=True)
app.run()

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

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

@@ -0,0 +1,4 @@
/* Global project stylesheet.
*/
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

+ 9
- 0
templates/index.html View File

@@ -0,0 +1,9 @@
= extends "layout.html"

= block title
Home
= endblock

= block body
<p>Hello, world.</p>
= endblock

+ 27
- 0
templates/layout.html View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<!-- Global layout template, to be inherited by other project HTML files. -->

<html>
<head>
<title>
= block title
= endblock
</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
= endblock
</head>
<body>
= block body
= endblock
</body>
</html>

Loading…
Cancel
Save