From f4882c305718203f206c54cb3c0b0d274d74f1c8 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 2 Aug 2016 18:48:27 +0200 Subject: [PATCH] Add powered by footer, set warn cookie using javascript, w3c validation --- README.rst | 1 + cas_server/default_settings.py | 2 + cas_server/static/cas_server/alert-version.js | 27 ------------- cas_server/static/cas_server/functions.js | 40 +++++++++++++++++++ cas_server/static/cas_server/styles.css | 21 +++++++++- cas_server/templates/cas_server/base.html | 35 +++++++++++----- cas_server/templates/cas_server/form.html | 2 +- cas_server/templates/cas_server/login.html | 17 +++++--- 8 files changed, 100 insertions(+), 45 deletions(-) delete mode 100644 cas_server/static/cas_server/alert-version.js create mode 100644 cas_server/static/cas_server/functions.js diff --git a/README.rst b/README.rst index ba461e0..e134387 100644 --- a/README.rst +++ b/README.rst @@ -206,6 +206,7 @@ Template settings templates. Set it to ``False`` to disable it. * ``CAS_FAVICON_URL``: URL to the favicon (shortcut icon) used by the default templates. Default is a key icon. Set it to ``False`` to disable it. +* ``CAS_SHOW_POWERED``: Set it to ``False`` to hide the powered by footer. The default is ``True``. * ``CAS_COMPONENT_URLS``: URLs to css and javascript external components. It is a dictionnary and it must have the five following keys: ``"bootstrap3_css"``, ``"bootstrap3_js"``, ``"html5shiv"``, ``"respond"``, ``"jquery"``. The default is:: diff --git a/cas_server/default_settings.py b/cas_server/default_settings.py index bfa6a54..8474d0b 100644 --- a/cas_server/default_settings.py +++ b/cas_server/default_settings.py @@ -20,6 +20,8 @@ from importlib import import_module CAS_LOGO_URL = static("cas_server/logo.png") #: URL to the favicon (shortcut icon) used by the default templates. Default is a key icon. CAS_FAVICON_URL = static("cas_server/favicon.ico") +#: Show the powered by footer if set to ``True`` +CAS_SHOW_POWERED = True #: URLs to css and javascript external components. CAS_COMPONENT_URLS = { "bootstrap3_css": "//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css", diff --git a/cas_server/static/cas_server/alert-version.js b/cas_server/static/cas_server/alert-version.js deleted file mode 100644 index 7b4fef5..0000000 --- a/cas_server/static/cas_server/alert-version.js +++ /dev/null @@ -1,27 +0,0 @@ -function alert_version(last_version){ - jQuery(function( $ ){ - $("#alert-version").click(function( e ){ - e.preventDefault(); - var date = new Date(); - date.setTime(date.getTime()+(10*365*24*60*60*1000)); - var expires = "; expires="+date.toGMTString(); - document.cookie = "cas-alert-version=" + last_version + expires + "; path=/"; - }); - - var nameEQ="cas-alert-version="; - var ca = document.cookie.split(";"); - var value; - for(var i=0;i < ca.length;i++) { - var c = ca[i]; - while(c.charAt(0) === " "){ - c = c.substring(1,c.length); - } - if(c.indexOf(nameEQ) === 0){ - value = c.substring(nameEQ.length,c.length); - } - } - if(value === last_version){ - $("#alert-version").parent().hide(); - } - }); -} diff --git a/cas_server/static/cas_server/functions.js b/cas_server/static/cas_server/functions.js new file mode 100644 index 0000000..560c4fa --- /dev/null +++ b/cas_server/static/cas_server/functions.js @@ -0,0 +1,40 @@ +function createCookie(name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name + "=" + value + expires + "; path=/"; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(";"); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==" "){ + c = c.substring(1,c.length); + } + if (c.indexOf(nameEQ) == 0){ + return c.substring(nameEQ.length,c.length); + } + } + return null; +} + +function eraseCookie(name) { + createCookie(name,"",-1); +} + +function alert_version(last_version){ + jQuery(function( $ ){ + $("#alert-version").click(function( e ){ + e.preventDefault(); + createCookie("cas-alert-version", last_version, 10*365) + }); + if(readCookie("cas-alert-version") === last_version){ + $("#alert-version").parent().hide(); + } + }); +} diff --git a/cas_server/static/cas_server/styles.css b/cas_server/static/cas_server/styles.css index 6d3524b..9ec8ec6 100644 --- a/cas_server/static/cas_server/styles.css +++ b/cas_server/static/cas_server/styles.css @@ -1,6 +1,9 @@ +html, body { + height: 100%; +} body { padding-top: 40px; - padding-bottom: 40px; + padding-bottom: 0px; background-color: #eee; } @@ -41,6 +44,22 @@ body { width:110px; } +/* Wrapper for page content to push down footer */ +#wrap { + min-height: 100%; + height: auto !important; + height: 100%; + /* Negative indent footer by it's height */ + margin: 0 auto -40px; +} +#footer { + height: 40px; + text-align: center; +} +#footer p { + padding-top: 10px; +} + @media screen and (max-width: 680px) { #app-name { margin: 0; diff --git a/cas_server/templates/cas_server/base.html b/cas_server/templates/cas_server/base.html index 87b9a6d..8a491ca 100644 --- a/cas_server/templates/cas_server/base.html +++ b/cas_server/templates/cas_server/base.html @@ -1,6 +1,4 @@ -{% load i18n %} -{% load staticfiles %} - +{% load i18n %}{% load staticfiles %} @@ -18,12 +16,13 @@ +
{% if auto_submit %}
{% endfor %} {% if auto_submit %}{% endif %} @@ -62,11 +61,25 @@
- - - {% if settings.CAS_NEW_VERSION_HTML_WARNING and upgrade_available %} - - - {% endif %} + +
+ {% if settings.CAS_SHOW_POWERED %} + + {% endif %} + + + + {% if settings.CAS_NEW_VERSION_HTML_WARNING and upgrade_available %} + + {% endif %} + {% block javascript %}{% endblock %} + diff --git a/cas_server/templates/cas_server/form.html b/cas_server/templates/cas_server/form.html index f189f6b..5571a7b 100644 --- a/cas_server/templates/cas_server/form.html +++ b/cas_server/templates/cas_server/form.html @@ -14,7 +14,7 @@ {% endif %}" {% endspaceless %}>{% spaceless %} {% if field|is_checkbox %} -
+
{% else %} {{field}} diff --git a/cas_server/templates/cas_server/login.html b/cas_server/templates/cas_server/login.html index d6adc64..ff98c03 100644 --- a/cas_server/templates/cas_server/login.html +++ b/cas_server/templates/cas_server/login.html @@ -14,10 +14,17 @@ {% if auto_submit %}{% endif %} -{% if auto_submit %} - -{% endif %} {% endblock %} +{% block javascript %}{% endblock %}