From 41c8cab1429170ccd540caadbc15ef5144ee462c Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 12 Aug 2018 10:03:14 +0200
Subject: [PATCH] Move assets to assets-dir and inline JS to separate file (&
 PSR2)

---
 modules/authX509/templates/X509warning.twig     |  6 ++----
 modules/authYubiKey/templates/yubikeylogin.twig | 16 ++++++----------
 modules/consent/templates/consentform.twig      |  4 ++--
 modules/core/templates/short_sso_interval.twig  |  2 +-
 modules/discopower/templates/disco.twig         | 14 +++++++-------
 modules/expirycheck/templates/about2expire.twig |  4 ++--
 modules/multiauth/templates/selectsource.twig   |  8 ++------
 modules/preprodwarning/templates/warning.twig   |  5 ++---
 8 files changed, 24 insertions(+), 35 deletions(-)

diff --git a/modules/authX509/templates/X509warning.twig b/modules/authX509/templates/X509warning.twig
index 59a65f64f..b75f7c370 100644
--- a/modules/authX509/templates/X509warning.twig
+++ b/modules/authX509/templates/X509warning.twig
@@ -1,5 +1,3 @@
-{% set autofocus = 'proceedbutton' %}
-
 {% extends "base.twig" %}
 
 {% block content %}
@@ -8,7 +6,7 @@
 <form action="{{ target | escape }}">
 
     {% for name, value in data -%}
-    <input type="hidden" name="{{ name }}" value="{{ value }}" />
+    <input type="hidden" name="{{ name }}" value="{{ value }}">
     {%- endfor %}
 
     <p>{% trans %}Your certificate will expire in {{ daysleft }} days.{% endtrans %}</p>
@@ -19,7 +17,7 @@
     <p>{% trans 'Please renew your certificate in time.' %}</p>
     {% endif -%}
 
-    <p><input type="submit" name="proceed" id="proceedbutton" value="{% trans 'Proceed' %}" /></p>
+    <p><input type="submit" name="proceed" id="proceedbutton" value="{% trans 'Proceed' %}" autofocus></p>
 
 </form>
 
diff --git a/modules/authYubiKey/templates/yubikeylogin.twig b/modules/authYubiKey/templates/yubikeylogin.twig
index 774a9e9e2..d329c0303 100644
--- a/modules/authYubiKey/templates/yubikeylogin.twig
+++ b/modules/authYubiKey/templates/yubikeylogin.twig
@@ -2,32 +2,28 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/yubikey.css" />
-{% endblock %}
-
-{% block postload %}
-    <script src="{{ baseurlpath }}assets/js/autofocus.js"></script>
+    <link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/yubikey.css">
 {% endblock %}
 
 {% block content %}
     {% if errorCode != null %}
     <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5">
-        <img src="{{ baseurlpath }}resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px;" alt="" />
+        <img src="{{ baseurlpath }}resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px;" alt="">
         <h2>{{ '{login:error_header}'|trans }}</h2>
         <p><span style="text-decoration: bold;">{{ errorTitle }}</p>
         <p>{{ errorDesc }}</p>
     </div>
     {% endif %}
 
-    <img style="float: right" src="{{ logoUrl }}" alt="" />
-    <img style="clear: right; float: right" src="{{ devicepicUrl }}" alt="YubiKey" />
+    <img style="float: right" src="{{ logoUrl }}" alt="">
+    <img style="clear: right; float: right" src="{{ devicepicUrl }}" alt="YubiKey">
 
     <h2>{{ '{authYubiKey:yubikey:header}'|trans }}</h2>
     <form action="?" method="post" name="f">
         <p>{{ '{authYubiKey:yubikey:intro}'|trans }}</p>
-        <p><input id="otp" type="text" tabindex="2" name="otp" /></p>
+        <p><input id="otp" type="text" tabindex="2" name="otp" autofocus></p>
     {% for key, value in stateParams %}
-        <input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}"/>
+        <input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}">
     {% endfor %}
     </form>
 {% endblock %}
diff --git a/modules/consent/templates/consentform.twig b/modules/consent/templates/consentform.twig
index c980f147b..1889a84c6 100644
--- a/modules/consent/templates/consentform.twig
+++ b/modules/consent/templates/consentform.twig
@@ -19,12 +19,12 @@
     {% endif %}
 
     <input type="hidden" name="StateId" value="{{ stateId }}" />
-    <button type="submit" name="yes" class="btn" id="yesbutton">{{ '{consent:consent:yes}'|trans }}</button>
+    <button type="submit" name="yes" class="btn" id="yesbutton"{%- if autofocus == 'yesbutton'%} autofocus{% endif %-}>{{ '{consent:consent:yes}'|trans }}</button>
 </form>
 
 <form id="consent_no" action="{{ noTarget }}">
     <input type="hidden" name="StateId" value="{{ stateId }}" />
-    <button type="submit" class="btn" name="no" id="nobutton">{{ '{consent:consent:no}'|trans }}</button>
+    <button type="submit" class="btn" name="no" id="nobutton"{%- if autofocus == 'nobutton'%} autofocus{% endif %-}>{{ '{consent:consent:no}'|trans }}</button>
 </form>
 
 {% if sppp != false %}
diff --git a/modules/core/templates/short_sso_interval.twig b/modules/core/templates/short_sso_interval.twig
index 91288cd9f..c8b08934a 100644
--- a/modules/core/templates/short_sso_interval.twig
+++ b/modules/core/templates/short_sso_interval.twig
@@ -11,6 +11,6 @@
         <div class="trackidtext">
             <p>{{ '{errors:report_trackid}'|trans }}<span class="trackid">{{ trackId }}</span></p>
         </div>
-        <input type="submit" name="continue" id="contbutton" value="'{core:short_sso_interval:retry}'|trans|escape('html') }}" />
+        <input type="submit" name="continue" id="contbutton" value="'{core:short_sso_interval:retry}'|trans|escape('html') }}" autofocus />
     </form>
 {% endblock %}
diff --git a/modules/discopower/templates/disco.twig b/modules/discopower/templates/disco.twig
index 3a65afff1..e9c892d3f 100644
--- a/modules/discopower/templates/disco.twig
+++ b/modules/discopower/templates/disco.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/css/style.css" rel="stylesheet" type="text/css" media="screen" />
+    <link href="{{ baseurlpath }}assets/css/style.css" rel="stylesheet" type="text/css" media="screen">
 {% endblock %}
 {% block postload %}
     <script type="text/javascript" src="{{ baseurlpath }}assets/js/jquery.livesearch.js"></script>
@@ -15,11 +15,11 @@
     <div class="favourite">{{ '{disco:previous_auth}'|trans }}
         <strong>{{ faventry.translated|escape('html') }}</strong>
         <form id="idpselectform" method="get" action="{{ urlpattern }}">
-            <input type="hidden" name="entityID" value="{{ entityID|escape('html') }}" />
-            <input type="hidden" name="return" value="{{ return|escape('html') }}" />
-            <input type="hidden" name="returnIDParam" value="{{ returnIDParam|escape('html') }}" />
-            <input type="hidden" name="idpentityid" value="{{ faventry.entityid|escape('html') }}" />
-            <input type="submit" name="formsubmit" id="favouritesubmit" value="{{ '{disco:login_at}'|trans }} {{ faventry.translated|escape('html') }}" /> 
+            <input type="hidden" name="entityID" value="{{ entityID|escape('html') }}">
+            <input type="hidden" name="return" value="{{ return|escape('html') }}">
+            <input type="hidden" name="returnIDParam" value="{{ returnIDParam|escape('html') }}">
+            <input type="hidden" name="idpentityid" value="{{ faventry.entityid|escape('html') }}">
+            <input type="submit" name="formsubmit" id="favouritesubmit" value="{{ '{disco:login_at}'|trans }} {{ faventry.translated|escape('html') }}" autofocus> 
 	</form>
     </div>
     {% endif %}
@@ -51,7 +51,7 @@
           <div class="inlinesearch">
               <p>Incremental search...</p>
               <form id="idpselectform" method="get">
-                  <input class="inlinesearch" type="text" value="" name="query_{{ tab }}" id="query_{{ tab }}" />
+                  <input class="inlinesearch" type="text" value="" name="query_{{ tab }}" id="query_{{ tab }}">
               </form>
           </div>
           <div class="metalist" id="list_{{ tab }}">
diff --git a/modules/expirycheck/templates/about2expire.twig b/modules/expirycheck/templates/about2expire.twig
index c60788051..1e1d5d427 100644
--- a/modules/expirycheck/templates/about2expire.twig
+++ b/modules/expirycheck/templates/about2expire.twig
@@ -4,10 +4,10 @@
 {% block content %}
     <form style="display: inline; margin: 0px; padding: 0px" action="{{ yesTarget|escape('html') }}">
         {% for name, value in yesData %}
-        <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}" />
+        <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}">
         {% endfor %}
         <h3>{{ warning }}</h3>
         <p>{{ '{expirycheck:expwarning:expiry_date_text}'|trans }} {{ expireOnDate }}</p>
-        <input type="submit" name="yes" id="yesbutton" value="{{ '{expirycheck:expwarning:btn_continue}'|trans }}" />
+        <input type="submit" name="yes" id="yesbutton" value="{{ '{expirycheck:expwarning:btn_continue}'|trans }}" autofocus>
     </form>
 {% endblock %}
diff --git a/modules/multiauth/templates/selectsource.twig b/modules/multiauth/templates/selectsource.twig
index d308d457a..67483d11f 100644
--- a/modules/multiauth/templates/selectsource.twig
+++ b/modules/multiauth/templates/selectsource.twig
@@ -6,17 +6,13 @@
     <p>{{ '{multiauth:multiauth:select_source_text}'| trans }}</p>
 
     <form action="{{ selfUrl|escape('html') }}" method="get">
-        <input type="hidden" name="AuthState" value="{{ authstate|escape('html') }} " />
+        <input type="hidden" name="AuthState" value="{{ authstate|escape('html') }} ">
         <ul>
         {% for key, source in sources %}
             {% set name = ('src-' ~ source.source64) %}
             {% set button = ('button-' ~ source.source) %}
 	    <li class="{{ source.css_class|escape('html') }} authsource">
-            {% if source.source == preferred %}
-                <input type="submit" name="{{ name|escape('html') }}" autofocus="autofocus" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" />
-            {% else %}
-                <input type="submit" name="{{ name|escape('html') }}" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" />
-            {% endif %}
+            <input type="submit" name="{{ name|escape('html') }}" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}"{%- source.source == preferred %} autofocus{% endif -%}>
             {% if source.help %}
               <p>{{ source.help|escape('html') }}</p>
             {% endif %}
diff --git a/modules/preprodwarning/templates/warning.twig b/modules/preprodwarning/templates/warning.twig
index 9a86ffb69..838dd072b 100644
--- a/modules/preprodwarning/templates/warning.twig
+++ b/modules/preprodwarning/templates/warning.twig
@@ -7,11 +7,10 @@
 
         <p>{% trans %}You are now accessing a pre-production system. This authentication setup is for testing and pre-production verification only. If someone sent you a link that pointed you here, and you are not <i>a tester</i> you probably got the wrong link, and should <b>not be here</b>.{% endtrans %}</p><br />
 {% for name,value in yesData %}
-        <input type="hidden" name="{{ name }}" value="{{ value }}" />
+        <input type="hidden" name="{{ name }}" value="{{ value }}">
 {% endfor %}
 <p>
-        <input type="submit" name="yes" class="pure-button pure-button-red" value="{{'Yes, I know I am accessing a pre-production system'|trans}}" />
-
+        <input type="submit" name="yes" class="pure-button pure-button-red" value="{{'Yes, I know I am accessing a pre-production system'|trans}}" autofocus>
 </p>
 
 </form>
-- 
GitLab