From d6fab9883d275ac36a49e9ce84d085acc0d2b749 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 12 Aug 2018 16:35:58 +0200
Subject: [PATCH] Move assets to assets-dir + PSR-2

---
 modules/oauth/templates/registry.edit.tpl.php |  7 +-
 modules/oauth/templates/registry.edit.twig    | 14 +---
 modules/oauth/templates/registry.list.php     | 72 +++++++++----------
 modules/oauth/templates/registry.list.twig    |  2 +-
 modules/oauth/templates/registry.saved.php    |  1 -
 .../style.css => assets/css/oauth.css}        |  0
 modules/oauth/www/assets/js/oauth.js          |  3 +
 .../statistics/templates/statistics.tpl.php   |  4 +-
 modules/statistics/templates/statistics.twig  |  4 +-
 modules/statistics/templates/statmeta.tpl.php |  2 +-
 modules/statistics/templates/statmeta.twig    |  2 +-
 .../www/assets/{ => css}/statistics.css       |  0
 .../www/assets/{ => js}/statistics.js         |  0
 13 files changed, 49 insertions(+), 62 deletions(-)
 rename modules/oauth/www/{resources/style.css => assets/css/oauth.css} (100%)
 create mode 100644 modules/oauth/www/assets/js/oauth.js
 rename modules/statistics/www/assets/{ => css}/statistics.css (100%)
 rename modules/statistics/www/assets/{ => js}/statistics.js (100%)

diff --git a/modules/oauth/templates/registry.edit.tpl.php b/modules/oauth/templates/registry.edit.tpl.php
index 4c97f36f5..1e39b1ec7 100644
--- a/modules/oauth/templates/registry.edit.tpl.php
+++ b/modules/oauth/templates/registry.edit.tpl.php
@@ -10,12 +10,11 @@ $(document).ready(function() {
 
 $this->includeAtTemplateBase('includes/header.php');
 
+echo '<h1>OAuth Client</h1>';
 
-echo('<h1>OAuth Client</h1>');
+echo $this->data['form'];
 
-echo($this->data['form']);
-
-echo('<p style="float: right"><a href="registry.php">Return to entity listing <strong>without saving...</strong></a></p>');
+echo '<p style="float: right"><a href="registry.php">Return to entity listing <strong>without saving...</strong></a></p>';
 
 $this->includeAtTemplateBase('includes/footer.php');
 
diff --git a/modules/oauth/templates/registry.edit.twig b/modules/oauth/templates/registry.edit.twig
index baa44d4f9..ad9345d73 100644
--- a/modules/oauth/templates/registry.edit.twig
+++ b/modules/oauth/templates/registry.edit.twig
@@ -2,21 +2,11 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}resources/style.css" rel="stylesheet" />
+    <link href="{{ baseurlpath }}assets/css/oauth.css" rel="stylesheet">
 {% endblock %}
 
 {% block postload %}
-<script type="text/javascript">
-    $(document).ready(function() {
-	$("#tabdiv").tabs();
-        $('ul.tabset_tabs li').click(
-            function() {
-                $("html, body").animate({ scrollTop: 0 }, "slow");
-            }
-        )
-
-    });
-</script>
+    <script src="{{ baseurlpath}}assets/js/oauth.js"></script>
 {% endblock %}
 
 {% block content %}
diff --git a/modules/oauth/templates/registry.list.php b/modules/oauth/templates/registry.list.php
index 28d64e38e..f06912fe2 100644
--- a/modules/oauth/templates/registry.list.php
+++ b/modules/oauth/templates/registry.list.php
@@ -1,51 +1,47 @@
 <?php
 
-$this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE);
-$this->data['head']  = '<link rel="stylesheet" type="text/css" href="/' . $this->data['baseurlpath'] . 'module.php/oauth/resources/style.css" />' . "\n";
+$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);
+$this->data['head']  = '<link rel="stylesheet" type="text/css" href="/'.$this->data['baseurlpath'].'module.php/oauth/assets/oauth.css" />'."\n";
 $this->includeAtTemplateBase('includes/header.php');
 
-
-echo('<h1>OAuth Client Registry</h1>');
-
-echo('<p>Here you can register new OAuth Clients. You are successfully logged in as ' . htmlspecialchars($this->data['userid']) . '</p>');
-
-echo('<h2>Your clients</h2>');
-echo('<table class="metalist" style="width: 100%">');
-$i = 0; $rows = array('odd', 'even');
-foreach($this->data['entries']['mine'] AS $entryc ) {
-	$entry = $entryc['value'];
-	$i++; 
-	echo('<tr class="' . $rows[$i % 2] . '">
-		<td>' . htmlspecialchars($entry['name']) . '</td>
-		<td><tt>' . htmlspecialchars($entry['key']) . '</tt></td>
-		<td>
-			<a href="registry.edit.php?editkey=' . urlencode($entry['key']) . '">edit</a>
-			<a href="registry.php?delete=' . urlencode($entry['key']) . '">delete</a>
-		</td></tr>');
+echo '<h1>OAuth Client Registry</h1>';
+echo '<p>Here you can register new OAuth Clients. You are successfully logged in as '.htmlspecialchars($this->data['userid']).'</p>';
+
+echo '<h2>Your clients</h2>';
+echo '<table class="metalist" style="width: 100%">';
+$i = 0;
+$rows = array('odd', 'even');
+foreach ($this->data['entries']['mine'] as $entryc) {
+    $entry = $entryc['value'];
+    $i++; 
+    echo '<tr class="'.$rows[$i % 2].'"><td>'.
+        htmlspecialchars($entry['name']).'</td>	<td><tt>'.htmlspecialchars($entry['key']).
+        '</tt></td><td><a href="registry.edit.php?editkey='.urlencode($entry['key']).
+        '">edit</a><a href="registry.php?delete='.urlencode($entry['key']).'">delete</a></td></tr>';
 }
 if ($i == 0) {
-	echo('<tr><td colspan="3">No entries registered</td></tr>');
+    echo'<tr><td colspan="3">No entries registered</td></tr>';
 }
-echo('</table>');
-
-echo('<p><a href="registry.edit.php">Add new client</a></p>');
-
-echo('<h2>Other clients</h2>');
-echo('<table class="metalist" style="width: 100%">');
-$i = 0; $rows = array('odd', 'even');
-foreach($this->data['entries']['others'] AS $entryc ) {
-	$entry = $entryc['value'];
-	$i++; 
-	echo('<tr class="' . $rows[$i % 2] . '">
-		<td>' . htmlspecialchars($entry['name']) . '</td>
-		<td><tt>' . htmlspecialchars($entry['key']) . '</tt></td>
-		<td>' . (isset($entry['owner']) ? htmlspecialchars($entry['owner']) : 'No owner') . '
-		</td></tr>');
+echo '</table>';
+
+echo '<p><a href="registry.edit.php">Add new client</a></p>';
+
+echo '<h2>Other clients</h2>';
+echo '<table class="metalist" style="width: 100%">';
+$i = 0;
+$rows = array('odd', 'even');
+foreach ($this->data['entries']['others'] as $entryc) {
+    $entry = $entryc['value'];
+    $i++; 
+    echo '<tr class="'.$rows[$i % 2].'"><td>'.
+        htmlspecialchars($entry['name']).'</td><td><tt>'.htmlspecialchars($entry['key']).
+        '</tt></td><td>'.(isset($entry['owner']) ? htmlspecialchars($entry['owner']) : 'No owner').
+        '</td></tr>';
 }
 if ($i == 0) {
-	echo('<tr><td colspan="3">No entries registered</td></tr>');
+    echo '<tr><td colspan="3">No entries registered</td></tr>';
 }
-echo('</table>');
+echo '</table>';
 
 $this->includeAtTemplateBase('includes/footer.php');
 
diff --git a/modules/oauth/templates/registry.list.twig b/modules/oauth/templates/registry.list.twig
index e6ec234c6..c479cc202 100644
--- a/modules/oauth/templates/registry.list.twig
+++ b/modules/oauth/templates/registry.list.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}style.css" rel="stylesheet" />
+    <link href="{{ baseurlpath }}assets/css/oauth.css" rel="stylesheet" />
 {% endblock %}
 
 {% block content %}
diff --git a/modules/oauth/templates/registry.saved.php b/modules/oauth/templates/registry.saved.php
index 0ff62eb50..fe63bfafd 100644
--- a/modules/oauth/templates/registry.saved.php
+++ b/modules/oauth/templates/registry.saved.php
@@ -12,4 +12,3 @@ echo('<p><a href="registry.php">Go back to OAuth client listing</a></p>');
 
 
 $this->includeAtTemplateBase('includes/footer.php');
-
diff --git a/modules/oauth/www/resources/style.css b/modules/oauth/www/assets/css/oauth.css
similarity index 100%
rename from modules/oauth/www/resources/style.css
rename to modules/oauth/www/assets/css/oauth.css
diff --git a/modules/oauth/www/assets/js/oauth.js b/modules/oauth/www/assets/js/oauth.js
new file mode 100644
index 000000000..442c63eff
--- /dev/null
+++ b/modules/oauth/www/assets/js/oauth.js
@@ -0,0 +1,3 @@
+document.addEventListener('DOMContentLoaded', function () {
+    $("#tabdiv").tabs();
+});
diff --git a/modules/statistics/templates/statistics.tpl.php b/modules/statistics/templates/statistics.tpl.php
index 91cca8550..e1640b653 100644
--- a/modules/statistics/templates/statistics.tpl.php
+++ b/modules/statistics/templates/statistics.tpl.php
@@ -3,8 +3,8 @@ $this->data['header'] = 'SimpleSAMLphp Statistics';
 
 $this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);
 
-$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/assets/statistics.css") . '" />' . "\n";
-$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/assets/statistics.js") . '"></script>' . "\n";
+$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css") . '" />' . "\n";
+$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/assets/js/statistics.js") . '"></script>' . "\n";
 
 $this->includeAtTemplateBase('includes/header.php');
 
diff --git a/modules/statistics/templates/statistics.twig b/modules/statistics/templates/statistics.twig
index f3031f5c4..7fb375dfa 100644
--- a/modules/statistics/templates/statistics.twig
+++ b/modules/statistics/templates/statistics.twig
@@ -2,11 +2,11 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/statistics.css" rel="stylesheet" />
+    <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" />
 {% endblock %}
 
 {% block postload %}
-<script type="text/javascript" src="{{ baseurlpath }}assets/statistics.js"></script>
+<script type="text/javascript" src="{{ baseurlpath }}assets/js/statistics.js"></script>
 {% endblock %}
 
 {% block content %}
diff --git a/modules/statistics/templates/statmeta.tpl.php b/modules/statistics/templates/statmeta.tpl.php
index 9af5a032e..ddb72b4f5 100644
--- a/modules/statistics/templates/statmeta.tpl.php
+++ b/modules/statistics/templates/statmeta.tpl.php
@@ -1,6 +1,6 @@
 <?php
 $this->data['header'] = 'SimpleSAMLphp Statistics Metadata';
-$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/style.css") . '" />';
+$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css") . '" />';
 $this->includeAtTemplateBase('includes/header.php');
 
 echo '<table id="statmeta">' ;
diff --git a/modules/statistics/templates/statmeta.twig b/modules/statistics/templates/statmeta.twig
index dd2c475c5..09808e837 100644
--- a/modules/statistics/templates/statmeta.twig
+++ b/modules/statistics/templates/statmeta.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}style.css" rel="stylesheet" />
+    <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" />
 {% endblock %}
 
 {% block content %}
diff --git a/modules/statistics/www/assets/statistics.css b/modules/statistics/www/assets/css/statistics.css
similarity index 100%
rename from modules/statistics/www/assets/statistics.css
rename to modules/statistics/www/assets/css/statistics.css
diff --git a/modules/statistics/www/assets/statistics.js b/modules/statistics/www/assets/js/statistics.js
similarity index 100%
rename from modules/statistics/www/assets/statistics.js
rename to modules/statistics/www/assets/js/statistics.js
-- 
GitLab