diff --git a/bitshift/assets.py b/bitshift/assets.py index 2b0145f..c7b7c11 100644 --- a/bitshift/assets.py +++ b/bitshift/assets.py @@ -2,6 +2,8 @@ :synopsis: Helper functions for use inside the project's Jinja templates. """ +import re + from flask import Markup ASSET_HTML_TEMPLATES = { @@ -24,3 +26,21 @@ def tag(filename): file_ext = filename.split(".")[-1] return Markup(ASSET_HTML_TEMPLATES[file_ext] % filename) + +def syntax_highlight(msg): + """ + Inserts HTML `` elements into a string, for symbol/word styling. + + Args: + msg : (str) A message. + """ + + msg.replace("<", "&;lt") + msg.replace(">", "&;gt") + + font_size = 16.0 / len(msg) + msg = re.sub('([!()"%])', '\\1', msg) + msg = re.sub('([:.;,])', '\\1', msg) + msg = msg.replace("404", '404') + return "%s" % ( + font_size, msg) diff --git a/static/sass/error404.sass b/static/sass/error404.sass index f002aac..6afb76e 100644 --- a/static/sass/error404.sass +++ b/static/sass/error404.sass @@ -9,15 +9,11 @@ div#message text-align: center span - &#error-num - font-size: 170% - vertical-align: middle - - &.c1 - color: $baseColor1 + &.light + color: $baseColor3 - &.c2 + &.dark color: $baseColor2 - &.c3 - color: $baseColor3 + &.red + color: $baseColor1 diff --git a/templates/error404.html b/templates/error404.html index dad4920..0e258b3 100644 --- a/templates/error404.html +++ b/templates/error404.html @@ -6,9 +6,17 @@ = block body
- puts("404"); + {{ assets.syntax_highlight([ + 'puts("404");', + 'printf("%d\n", 404);', + 'puts 404', + 'System.out.println("404")', + 'print 404', + 'console.log("404")', + 'echo 404', + 'std::cout << "404\\n"', + '(println "404")', + 'say "404!";' + ] | random) | safe }}
= endblock