From 26a20687dbaab4d50699df5949692a43c8530b2e Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Thu, 12 Jun 2014 22:23:12 -0400 Subject: [PATCH 1/3] Add Google Analytics, authentication file. Add: static/js/main.js -Add a global javascript file, with bitshift's Google Analytics snippet. static/google10335120a3066831.html -Add our Google "Administrator Console" authentication. --- static/google10335120a3066831.html | 1 + static/js/main.js | 6 ++++++ templates/layout.html | 1 + 3 files changed, 8 insertions(+) create mode 100644 static/google10335120a3066831.html create mode 100644 static/js/main.js diff --git a/static/google10335120a3066831.html b/static/google10335120a3066831.html new file mode 100644 index 0000000..6eccd36 --- /dev/null +++ b/static/google10335120a3066831.html @@ -0,0 +1 @@ +google-site-verification: google10335120a3066831.html \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..d5b9feb --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,6 @@ +(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ +(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), +m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) +})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); +ga('create', 'UA-51910807-1', 'bitshift.it'); +ga('send', 'pageview'); diff --git a/templates/layout.html b/templates/layout.html index d85be6f..f40c43e 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -18,6 +18,7 @@ {{ assets.tag("main.css") }} + {{ assets.tag("main.js") }} = block head = endblock From cd1c9a2ec1fe0213464f48777694764431522814 Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Thu, 12 Jun 2014 22:41:55 -0400 Subject: [PATCH 2/3] Remove hard-coded file routes. Add: app.py -Remove hard-coded routes for files in the application's "root" (`static/`) directory; redefined Flask's `static_url_path` accordingly. Files can now be directly accessed by URL. bitshift/assets.py -Remove the `static/` prepended to all resource paths. --- app.py | 8 +------- bitshift/assets.py | 4 ++-- static/{img => }/favicon.ico | Bin templates/layout.html | 1 - 4 files changed, 3 insertions(+), 10 deletions(-) rename static/{img => }/favicon.ico (100%) diff --git a/app.py b/app.py index cf64f91..cd09cb5 100644 --- a/app.py +++ b/app.py @@ -12,7 +12,7 @@ from bitshift.database import Database from bitshift.languages import LANGS from bitshift.query import parse_query, QueryParseException -app = Flask(__name__) +app = Flask(__name__, static_folder="static", static_url_path="") app.config.from_object("bitshift.config") app.jinja_env.globals.update(year=datetime.datetime.now().year) @@ -56,11 +56,5 @@ def about(): def developers(): return render_template("developers.html") -@app.route("/robots.txt") -@app.route("/sitemap.xml") -@app.route("/favicon.ico") -def static_from_root(): - return flask.send_from_directory(app.static_folder, request.path[1:]) - if __name__ == "__main__": app.run(debug=True) diff --git a/bitshift/assets.py b/bitshift/assets.py index b4f597b..2b0145f 100644 --- a/bitshift/assets.py +++ b/bitshift/assets.py @@ -5,8 +5,8 @@ from flask import Markup ASSET_HTML_TEMPLATES = { - 'css': "", - 'js': "" + 'css': "", + 'js': "" } def tag(filename): diff --git a/static/img/favicon.ico b/static/favicon.ico similarity index 100% rename from static/img/favicon.ico rename to static/favicon.ico diff --git a/templates/layout.html b/templates/layout.html index f40c43e..ebdcdba 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -16,7 +16,6 @@ - {{ assets.tag("main.css") }} {{ assets.tag("main.js") }} From 064dde5792a6cdcb4acc971e94ee3482f6077757 Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Thu, 12 Jun 2014 23:09:49 -0400 Subject: [PATCH 3/3] Add 404 page. Minor footer-style mod. Add: app.py, templates/error404.html, static/sass/error404.sass -Add Flask 404 handler and styled 404 page. --- app.py | 4 ++++ static/sass/error404.sass | 23 +++++++++++++++++++++++ static/sass/main.sass | 2 ++ templates/error404.html | 14 ++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 static/sass/error404.sass create mode 100644 templates/error404.html diff --git a/app.py b/app.py index cd09cb5..3e470fd 100644 --- a/app.py +++ b/app.py @@ -56,5 +56,9 @@ def about(): def developers(): return render_template("developers.html") +@app.errorhandler(404) +def error404(error): + return render_template("error404.html"), 404 + if __name__ == "__main__": app.run(debug=True) diff --git a/static/sass/error404.sass b/static/sass/error404.sass new file mode 100644 index 0000000..f002aac --- /dev/null +++ b/static/sass/error404.sass @@ -0,0 +1,23 @@ +@import variables + +div#message + color: $baseColor1 + font-family: monospace + font-size: 700% + font-weight: normal + margin-top: 8% + text-align: center + + span + &#error-num + font-size: 170% + vertical-align: middle + + &.c1 + color: $baseColor1 + + &.c2 + color: $baseColor2 + + &.c3 + color: $baseColor3 diff --git a/static/sass/main.sass b/static/sass/main.sass index 4474ee0..e987f0c 100644 --- a/static/sass/main.sass +++ b/static/sass/main.sass @@ -35,10 +35,12 @@ div#container background-color: $baseColor1 bottom: -30px height: 60px + padding-bottom: 5px padding-top: 15px position: fixed text-align: center width: 100% + z-index: 100 &:hover @include delay(0s) diff --git a/templates/error404.html b/templates/error404.html new file mode 100644 index 0000000..dad4920 --- /dev/null +++ b/templates/error404.html @@ -0,0 +1,14 @@ += extends "layout.html" + += block head + {{ assets.tag("error404.css") }} += endblock + += block body +
+ puts("404"); +
+= endblock