fixed caching issues, reworked error pages

This commit is contained in:
checktheroads 2019-05-14 12:58:56 -07:00
parent d86f1bf6f4
commit e488f54a8f
12 changed files with 113 additions and 115 deletions

View file

@ -309,6 +309,14 @@ class brand:
else:
return t["color_bg"]
def color_danger():
list = []
for t in branding:
if len(t["color_danger"]) == 0:
return "#ff3860"
else:
return t["color_danger"]
def logo_path():
list = []
for t in branding:

View file

@ -25,12 +25,12 @@ subtitle = ""
enable_footer = true
enable_credit = true
color_bg = ""
color_danger = ""
color_btn_submit = ""
color_tag_loctitle = ""
color_tag_cmdtitle = ""
color_tag_cmd = ""
color_tag_loc = ""
color_hero = ""
color_progressbar = ""
logo_path = ""
logo_width = ""

View file

@ -141,26 +141,28 @@ def lg():
cache_value = execute.execute(lg_data)
value_output = cache_value[0]
value_code = cache_value[1]
value_entry = cache_value[0:2]
value_params = cache_value[2:]
logger.info(f"No cache match for: {cache_key}")
# If it doesn't, create a cache entry
try:
cache.set(cache_key, value_output)
cache.set(cache_key, value_entry)
logger.info(f"Added cache entry: {value_params}")
except:
raise RuntimeError("Unable to add output to cache.", 415, *value_params)
# If 200, return output
response = cache.get(cache_key)
if value_code == 200:
return Response(cache.get(cache_key), value_code)
return Response(response[0], response[1])
# If 400 error, return error message and code
elif value_code in [405, 415]:
return Response(cache.get(cache_key), value_code)
return Response(response[0], response[1])
# If it does, return the cached entry
else:
logger.info(f"Cache match for: {cache_key}, returning cached entry...")
response = cache.get(cache_key)
try:
return Response(cache.get(cache_key))
return Response(response[0], response[1])
except:
raise
# Upon exception, render generic error

View file

@ -34,7 +34,7 @@ class html:
elif t == "415":
template = env.get_template("templates/415.html")
elif t == "test":
template = env.get_template("templates/429.html")
template = env.get_template("templates/415.html")
return template.render(
# General
primary_asn=configuration.gen.primary_asn(),
@ -53,6 +53,7 @@ class html:
subtitle=configuration.brand.subtitle(),
title_mode=configuration.brand.title_mode(),
color_bg=configuration.brand.color_bg(),
color_danger=configuration.brand.color_danger(),
color_btn_submit=configuration.brand.color_btn_submit(),
color_progressbar=configuration.brand.color_progressbar(),
color_tag_loctitle=configuration.brand.color_tag_loctitle(),
@ -100,6 +101,7 @@ class css:
color_tag_cmd=configuration.brand.color_tag_cmd(),
color_tag_loc=configuration.brand.color_tag_loc(),
color_bg=configuration.brand.color_bg(),
color_danger=configuration.brand.color_danger(),
primary_font_url=configuration.brand.primary_font_url(),
primary_font_name=configuration.brand.primary_font_name(),
mono_font_url=configuration.brand.mono_font_url(),

View file

@ -1,29 +1,28 @@
{% extends "templates/base.html" %}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
{% block content %}
<section class="hero is-danger is-fullheight is-clipped">
<div class="hero-head">
<nav class="navbar">
<body class="has-background-danger">
<section class="section">
<nav class="navbar has-background-danger">
<div class="container">
<div class="navbar-brand">
</div>
</div>
</nav>
<div class="container has-text-centered">
</div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
</section>
<section>
<div class="container has-text-centered">
<h1 class="title is-size-1">
{{ text_415_title }}
@ -31,22 +30,13 @@
<h2 class="subtitle is-size-3">
{{ text_415_subtitle }}
</h2>
<a href="/" class="button is-medium is-rounded is-inverted is-danger is-outlined">{{ text_415_button }}</a>
</div>
<div class="hero-body">
</div>
{% if enable_footer == true %}
<div class="hero-foot">
<div class="container">
<div class="content is-small has-text-centered">
{{ footer_content }}
</div>
</div>
</div>
<br>
{% endif %}
<a href="/" class="button is-medium is-rounded is-inverted is-danger is-outlined">Home</a>
</div>
</section>
{% endblock %}
</body>
{% endblock %}
{% if enable_footer == true %}
{% include "templates/footer.html" %}
{% endif %}
</html>

View file

@ -1,28 +1,28 @@
{% extends "templates/base.html" %}
<!DOCTYPE html>
<html>
<head>
</head>
{% block content %}
<body>
<section class="hero is-danger is-fullheight is-clipped">
<div class="hero-head">
<nav class="navbar">
<body class="has-background-danger">
<section class="section">
<nav class="navbar has-background-danger">
<div class="container">
<div class="navbar-brand">
</div>
</div>
</nav>
<div class="container has-text-centered">
</div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
</section>
<section>
<div class="container has-text-centered">
<h1 class="title is-size-1">
{{ text_limiter_title }}
@ -30,22 +30,13 @@
<h2 class="subtitle is-size-3">
{{ text_limiter_subtitle }}
</h2>
<br>
<a href="/" class="button is-medium is-rounded is-inverted is-danger is-outlined">Try Again</a>
</div>
<div class="hero-body">
</div>
{% if enable_footer == true %}
<div class="hero-foot">
<div class="container">
<div class="content is-small has-text-centered">
{{ footer_content }}
</div>
</div>
</div>
<br>
{% endif %}
</section>
</body>
{% endblock %}
{% if enable_footer == true %}
{% include "templates/footer.html" %}
{% endif %}
</html>

View file

@ -1 +1 @@
<p>Powered by <a href="https://github.com/checktheroads/hyperglass">Hyperglass</a>. Source code licensed <a href="https://github.com/checktheroads/hyperglass/blob/master/LICENSE">BSD 3-Clause Clear.</a</p>
<p>Powered by <a href="https://github.com/checktheroads/hyperglass">Hyperglass</a>. Source code licensed <a href="https://github.com/checktheroads/hyperglass/blob/master/LICENSE">BSD 3-Clause Clear.</a></p>

View file

@ -7,6 +7,6 @@
<div class="content is-small has-text-centered">
{% include "templates/credit.html" %}
</div>
{% endif %}
</div>
</footer>
{% endif %}

View file

@ -9,7 +9,8 @@ $family-monospace: "{{ mono_font_name }}", monospace;
/* Color Changes */
$body-background-color: {{ color_bg }};
$footer-background-color: $body-background-color;
$footer-background-color: transparent;
$danger: {{ color_danger }};
/* Custom Colors */
$lg-btn-submit: {{ color_btn_submit }};

View file

@ -764,13 +764,13 @@ a.has-text-warning:hover, a.has-text-warning:focus {
background-color: #ffdd57 !important; }
.has-text-danger {
color: #ff3860 !important; }
color: #000000 !important; }
a.has-text-danger:hover, a.has-text-danger:focus {
color: #ff0537 !important; }
color: black !important; }
.has-background-danger {
background-color: #ff3860 !important; }
background-color: #000000 !important; }
.has-text-black-bis {
color: #121212 !important; }
@ -1793,30 +1793,30 @@ a.box:active {
box-shadow: none;
color: rgba(0, 0, 0, 0.7); }
.button.is-danger {
background-color: #ff3860;
background-color: #000000;
border-color: transparent;
color: #fff; }
.button.is-danger:hover, .button.is-danger.is-hovered {
background-color: #ff2b56;
background-color: black;
border-color: transparent;
color: #fff; }
.button.is-danger:focus, .button.is-danger.is-focused {
border-color: transparent;
color: #fff; }
.button.is-danger:focus:not(:active), .button.is-danger.is-focused:not(:active) {
box-shadow: 0 0 0 0.125em rgba(255, 56, 96, 0.25); }
box-shadow: 0 0 0 0.125em rgba(0, 0, 0, 0.25); }
.button.is-danger:active, .button.is-danger.is-active {
background-color: #ff1f4b;
background-color: black;
border-color: transparent;
color: #fff; }
.button.is-danger[disabled],
fieldset[disabled] .button.is-danger {
background-color: #ff3860;
background-color: #000000;
border-color: transparent;
box-shadow: none; }
.button.is-danger.is-inverted {
background-color: #fff;
color: #ff3860; }
color: #000000; }
.button.is-danger.is-inverted:hover {
background-color: #f2f2f2; }
.button.is-danger.is-inverted[disabled],
@ -1824,32 +1824,32 @@ a.box:active {
background-color: #fff;
border-color: transparent;
box-shadow: none;
color: #ff3860; }
color: #000000; }
.button.is-danger.is-loading::after {
border-color: transparent transparent #fff #fff !important; }
.button.is-danger.is-outlined {
background-color: transparent;
border-color: #ff3860;
color: #ff3860; }
border-color: #000000;
color: #000000; }
.button.is-danger.is-outlined:hover, .button.is-danger.is-outlined:focus {
background-color: #ff3860;
border-color: #ff3860;
background-color: #000000;
border-color: #000000;
color: #fff; }
.button.is-danger.is-outlined.is-loading::after {
border-color: transparent transparent #ff3860 #ff3860 !important; }
border-color: transparent transparent #000000 #000000 !important; }
.button.is-danger.is-outlined[disabled],
fieldset[disabled] .button.is-danger.is-outlined {
background-color: transparent;
border-color: #ff3860;
border-color: #000000;
box-shadow: none;
color: #ff3860; }
color: #000000; }
.button.is-danger.is-inverted.is-outlined {
background-color: transparent;
border-color: #fff;
color: #fff; }
.button.is-danger.is-inverted.is-outlined:hover, .button.is-danger.is-inverted.is-outlined:focus {
background-color: #fff;
color: #ff3860; }
color: #000000; }
.button.is-danger.is-inverted.is-outlined[disabled],
fieldset[disabled] .button.is-danger.is-inverted.is-outlined {
background-color: transparent;
@ -2255,13 +2255,13 @@ a.box:active {
box-shadow: 0 0 0 0.125em rgba(255, 221, 87, 0.25); }
.input.is-danger,
.textarea.is-danger {
border-color: #ff3860; }
border-color: #000000; }
.input.is-danger:focus, .input.is-danger.is-focused, .input.is-danger:active, .input.is-danger.is-active,
.textarea.is-danger:focus,
.textarea.is-danger.is-focused,
.textarea.is-danger:active,
.textarea.is-danger.is-active {
box-shadow: 0 0 0 0.125em rgba(255, 56, 96, 0.25); }
box-shadow: 0 0 0 0.125em rgba(0, 0, 0, 0.25); }
.input.is-small,
.textarea.is-small {
border-radius: 2px;
@ -2471,13 +2471,13 @@ a.box:active {
.select.is-warning select:focus, .select.is-warning select.is-focused, .select.is-warning select:active, .select.is-warning select.is-active {
box-shadow: 0 0 0 0.125em rgba(255, 221, 87, 0.25); }
.select.is-danger:not(:hover)::after {
border-color: #ff3860; }
border-color: #000000; }
.select.is-danger select {
border-color: #ff3860; }
border-color: #000000; }
.select.is-danger select:hover, .select.is-danger select.is-hovered {
border-color: #ff1f4b; }
border-color: black; }
.select.is-danger select:focus, .select.is-danger select.is-focused, .select.is-danger select:active, .select.is-danger select.is-active {
box-shadow: 0 0 0 0.125em rgba(255, 56, 96, 0.25); }
box-shadow: 0 0 0 0.125em rgba(0, 0, 0, 0.25); }
.select.is-small {
border-radius: 2px;
font-size: 0.75rem; }
@ -2654,19 +2654,19 @@ a.box:active {
border-color: transparent;
color: rgba(0, 0, 0, 0.7); }
.file.is-danger .file-cta {
background-color: #ff3860;
background-color: #000000;
border-color: transparent;
color: #fff; }
.file.is-danger:hover .file-cta, .file.is-danger.is-hovered .file-cta {
background-color: #ff2b56;
background-color: black;
border-color: transparent;
color: #fff; }
.file.is-danger:focus .file-cta, .file.is-danger.is-focused .file-cta {
border-color: transparent;
box-shadow: 0 0 0.5em rgba(255, 56, 96, 0.25);
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.25);
color: #fff; }
.file.is-danger:active .file-cta, .file.is-danger.is-active .file-cta {
background-color: #ff1f4b;
background-color: black;
border-color: transparent;
color: #fff; }
.file.is-small {
@ -2826,7 +2826,7 @@ a.box:active {
.help.is-warning {
color: #ffdd57; }
.help.is-danger {
color: #ff3860; }
color: #000000; }
.field:not(:last-child) {
margin-bottom: 0.75rem; }
@ -3157,7 +3157,7 @@ a.box:active {
background-color: #ffdd57;
color: rgba(0, 0, 0, 0.7); }
.notification.is-danger {
background-color: #ff3860;
background-color: #000000;
color: #fff; }
.progress {
@ -3266,13 +3266,13 @@ a.box:active {
.progress.is-warning:indeterminate {
background-image: linear-gradient(to right, #ffdd57 30%, #dbdbdb 30%); }
.progress.is-danger::-webkit-progress-value {
background-color: #ff3860; }
background-color: #000000; }
.progress.is-danger::-moz-progress-bar {
background-color: #ff3860; }
background-color: #000000; }
.progress.is-danger::-ms-fill {
background-color: #ff3860; }
background-color: #000000; }
.progress.is-danger:indeterminate {
background-image: linear-gradient(to right, #ff3860 30%, #dbdbdb 30%); }
background-image: linear-gradient(to right, #000000 30%, #dbdbdb 30%); }
.progress.is-small {
height: 0.75rem; }
.progress.is-medium {
@ -3342,8 +3342,8 @@ a.box:active {
color: rgba(0, 0, 0, 0.7); }
.table td.is-danger,
.table th.is-danger {
background-color: #ff3860;
border-color: #ff3860;
background-color: #000000;
border-color: #000000;
color: #fff; }
.table td.is-narrow,
.table th.is-narrow {
@ -3504,7 +3504,7 @@ a.box:active {
background-color: #ffdd57;
color: rgba(0, 0, 0, 0.7); }
.tag:not(body).is-danger {
background-color: #ff3860;
background-color: #000000;
color: #fff; }
.tag:not(body).is-normal {
font-size: 0.75rem; }
@ -4092,13 +4092,13 @@ a.list-item {
border-color: #ffdd57;
color: #3b3108; }
.message.is-danger {
background-color: #fff5f7; }
background-color: #fafafa; }
.message.is-danger .message-header {
background-color: #ff3860;
background-color: #000000;
color: #fff; }
.message.is-danger .message-body {
border-color: #ff3860;
color: #cd0930; }
border-color: #000000;
color: black; }
.message-header {
align-items: center;
@ -4579,7 +4579,7 @@ a.list-item {
background-color: #ffdd57;
color: rgba(0, 0, 0, 0.7); } }
.navbar.is-danger {
background-color: #ff3860;
background-color: #000000;
color: #fff; }
.navbar.is-danger .navbar-brand > .navbar-item,
.navbar.is-danger .navbar-brand .navbar-link {
@ -4587,7 +4587,7 @@ a.list-item {
.navbar.is-danger .navbar-brand > a.navbar-item:hover, .navbar.is-danger .navbar-brand > a.navbar-item.is-active,
.navbar.is-danger .navbar-brand .navbar-link:hover,
.navbar.is-danger .navbar-brand .navbar-link.is-active {
background-color: #ff1f4b;
background-color: black;
color: #fff; }
.navbar.is-danger .navbar-brand .navbar-link::after {
border-color: #fff; }
@ -4606,17 +4606,17 @@ a.list-item {
.navbar.is-danger .navbar-end > a.navbar-item.is-active,
.navbar.is-danger .navbar-end .navbar-link:hover,
.navbar.is-danger .navbar-end .navbar-link.is-active {
background-color: #ff1f4b;
background-color: black;
color: #fff; }
.navbar.is-danger .navbar-start .navbar-link::after,
.navbar.is-danger .navbar-end .navbar-link::after {
border-color: #fff; }
.navbar.is-danger .navbar-item.has-dropdown:hover .navbar-link,
.navbar.is-danger .navbar-item.has-dropdown.is-active .navbar-link {
background-color: #ff1f4b;
background-color: black;
color: #fff; }
.navbar.is-danger .navbar-dropdown a.navbar-item.is-active {
background-color: #ff3860;
background-color: #000000;
color: #fff; } }
.navbar > .container {
align-items: stretch;
@ -6816,7 +6816,7 @@ label.panel-block {
.hero.is-warning.is-bold .navbar-menu {
background-image: linear-gradient(141deg, #ffaf24 0%, #ffdd57 71%, #fffa70 100%); } }
.hero.is-danger {
background-color: #ff3860;
background-color: #000000;
color: #fff; }
.hero.is-danger a:not(.button):not(.dropdown-item):not(.tag),
.hero.is-danger strong {
@ -6830,14 +6830,14 @@ label.panel-block {
color: #fff; }
@media screen and (max-width: 1087px) {
.hero.is-danger .navbar-menu {
background-color: #ff3860; } }
background-color: #000000; } }
.hero.is-danger .navbar-item,
.hero.is-danger .navbar-link {
color: rgba(255, 255, 255, 0.7); }
.hero.is-danger a.navbar-item:hover, .hero.is-danger a.navbar-item.is-active,
.hero.is-danger .navbar-link:hover,
.hero.is-danger .navbar-link.is-active {
background-color: #ff1f4b;
background-color: black;
color: #fff; }
.hero.is-danger .tabs a {
color: #fff;
@ -6853,12 +6853,12 @@ label.panel-block {
.hero.is-danger .tabs.is-boxed li.is-active a, .hero.is-danger .tabs.is-boxed li.is-active a:hover, .hero.is-danger .tabs.is-toggle li.is-active a, .hero.is-danger .tabs.is-toggle li.is-active a:hover {
background-color: #fff;
border-color: #fff;
color: #ff3860; }
color: #000000; }
.hero.is-danger.is-bold {
background-image: linear-gradient(141deg, #ff0561 0%, #ff3860 71%, #ff5257 100%); }
background-image: linear-gradient(141deg, black 0%, #000000 71%, #0d0d0d 100%); }
@media screen and (max-width: 768px) {
.hero.is-danger.is-bold .navbar-menu {
background-image: linear-gradient(141deg, #ff0561 0%, #ff3860 71%, #ff5257 100%); } }
background-image: linear-gradient(141deg, black 0%, #000000 71%, #0d0d0d 100%); } }
.hero.is-small .hero-body {
padding-bottom: 1.5rem;
padding-top: 1.5rem; }
@ -6929,7 +6929,7 @@ label.panel-block {
padding: 18rem 1.5rem; } }
.footer {
background-color: #fbfffe;
background-color: transparent;
padding: 3rem 1.5rem 3rem; }
/* Looking Glass Imports */
@ -6942,7 +6942,7 @@ label.panel-block {
#lg-title, #lg-subtitle {
color: rgba(0, 0, 0, 0.7); }
.is-danger #lg-title, .is-danger #lg-subtitle {
.has-background-danger p, a, .title, .subtitle {
color: #fff; }
.navbar-menu, .navbar-brand, .navbar-tabs {

View file

@ -9,7 +9,10 @@
#lg-title, #lg-subtitle
color: findColorInvert($body-background-color)
.is-danger #lg-title, .is-danger #lg-subtitle
// .danger-text
// color: findColorInvert($danger)
.has-background-danger p, a, .title, .subtitle
color: findColorInvert($danger)
.navbar-menu, .navbar-brand, .navbar-tabs

View file

@ -9,7 +9,8 @@ $family-monospace: "Fira Mono", monospace;
/* Color Changes */
$body-background-color: #fbfffe;
$footer-background-color: $body-background-color;
$footer-background-color: transparent;
$danger: #000000;
/* Custom Colors */
$lg-btn-submit: #40798c;