Skip to content

Commit

Permalink
Removed leading / from resources and use only the last part of the re…
Browse files Browse the repository at this point in the history
…quest uri for routing.
  • Loading branch information
thirsch committed Nov 9, 2013
1 parent 1bb1d8d commit 2bef0c0
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/public/.htaccess

4 changes: 3 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
/**
* Setup routing
*/
switch(trim($_SERVER['REQUEST_URI'], '/')) {

$request = explode('/', $_SERVER['REQUEST_URI']);
switch(end($request)) {
case 'configuration':
ob_start();
require __DIR__ . '/template/configuration.phtml';
Expand Down
6 changes: 6 additions & 0 deletions public/.htaccess.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=favicon.ico
RewriteRule ^ /index.php [L]

4 changes: 2 additions & 2 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

if ($(td).hasClass('active')) {
$(td).removeClass('active');
td.querySelector('img').src = '/style/toggle-expand.png';
td.querySelector('img').src = 'style/toggle-expand.png';
td.querySelector('img').setAttribute('alt', '+');
var rows = document.querySelectorAll('.script');
for (var i = 0, l = rows.length; i < l; i++) {
Expand All @@ -120,7 +120,7 @@
}
} else {
$(td).addClass('active');
td.querySelector('img').src = '/style/toggle-collapse.png';
td.querySelector('img').src = 'style/toggle-collapse.png';
td.querySelector('img').setAttribute('alt', '-');
var rows = document.querySelectorAll('.script');
for (var i = 0, l = rows.length; i < l; i++) {
Expand Down
4 changes: 2 additions & 2 deletions template/cached.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ foreach($status->getCachedScripts() as $data) {
<?php $i = 0; ?>
<?php foreach ($directories as $directory => $scripts) { ?>
<tr class="<?= $classCycler->next(); ?>">
<td colspan="6" class="directory" data-directoryid="<?= ++$i; ?>"><img src="/style/toggle-expand.png" alt="+"><?= $directory . sprintf($translator->translate('scripts.directory.script_count'), count($scripts)); ?></td>
<td colspan="6" class="directory" data-directoryid="<?= ++$i; ?>"><img src="style/toggle-expand.png" alt="+"><?= $directory . sprintf($translator->translate('scripts.directory.script_count'), count($scripts)); ?></td>
</tr>
<tr class="script heading" data-directoryid="<?= $i; ?>">
<th class="full_path"><?= $translator->translate('scripts.full_path'); ?></th>
Expand All @@ -38,7 +38,7 @@ foreach($status->getCachedScripts() as $data) {
<td class="last_used_timestamp"><?= $script['last_used_timestamp']; ?></td>
<td class="timestamp"><?= $script['timestamp']; ?></td>
<td class="invalidate">
<form action="/invalidate" method="post">
<form action="invalidate" method="post">
<input type="hidden" name="csrfToken" value="<?= $csrfToken->get(); ?>">
<input type="hidden" name="key" value="<?= $script['full_path']; ?>">
<input type="submit" name="submit" value="<?= $translator->translate('script.invalidate'); ?>">
Expand Down
2 changes: 1 addition & 1 deletion template/configuration.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $classCycler = new OpCacheGUI\Presentation\ClassCycler(['odd', 'even']);
<tr class="<?= $classCycler->next(); ?>">
<th><?= $translator->translate('config.' . $key); ?></th>
<?php if (in_array($key, ['opcache.enable', 'opcache.enable_cli', 'opcache.use_cwd', 'opcache.validate_timestamps', 'opcache.inherited_hack', 'opcache.dups_fix', 'opcache.revalidate_path', 'opcache.save_comments', 'opcache.load_comments', 'opcache.fast_shutdown', 'opcache.enable_file_override'])) { ?>
<th><img src="/style/bullet-<?= $directiveItem ? 'green' : 'red'; ?>-icon.png"></th>
<th><img src="style/bullet-<?= $directiveItem ? 'green' : 'red'; ?>-icon.png"></th>
<?php } else { ?>
<th><?= $directiveItem; ?></th>
<?php } ?>
Expand Down
20 changes: 10 additions & 10 deletions template/page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<head>
<title>OpCacheGUI 1.0</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/style/style.css">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="style/style.css">
<link rel="shortcut icon" href="favicon.ico">
<script>'article aside footer header nav section time'.replace(/\w+/g,function(n){document.createElement(n)})</script>
</head>
<body>
<header>
<div class="content">
<h1><a href="/">PHP <?= phpversion(); ?> OpCache x</a></h1>
<h1><a href="">PHP <?= phpversion(); ?> OpCache x</a></h1>
<nav>
<ul>
<li<?= $active == 'status' ? ' class="active"' : null ?>><a href="/"><?= $translator->translate('menu.status'); ?></a></li>
<li<?= $active == 'config' ? ' class="active"' : null ?>><a href="/configuration"><?= $translator->translate('menu.config'); ?></a></li>
<li<?= $active == 'cached' ? ' class="active"' : null ?>><a href="/cached-scripts"><?= $translator->translate('menu.scripts'); ?></a></li>
<li<?= $active == 'graphs' ? ' class="active"' : null ?>><a href="/graphs"><?= $translator->translate('menu.graphs'); ?></a></li>
<li<?= $active == 'status' ? ' class="active"' : null ?>><a href="status"><?= $translator->translate('menu.status'); ?></a></li>
<li<?= $active == 'config' ? ' class="active"' : null ?>><a href="configuration"><?= $translator->translate('menu.config'); ?></a></li>
<li<?= $active == 'cached' ? ' class="active"' : null ?>><a href="cached-scripts"><?= $translator->translate('menu.scripts'); ?></a></li>
<li<?= $active == 'graphs' ? ' class="active"' : null ?>><a href="graphs"><?= $translator->translate('menu.graphs'); ?></a></li>
</ul>
</nav>
</div>
Expand All @@ -33,8 +33,8 @@
<li>Maintained by <a href="https://github.com/PeeHaa" target="_blank">Pieter Hordijk</a></li>
</ul>
</footer>
<script src="/js/Chart.js"></script>
<script src="/js/DomHandler.js"></script>
<script src="/js/main.js"></script>
<script src="js/Chart.js"></script>
<script src="js/DomHandler.js"></script>
<script src="js/main.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions template/status.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $classCycler = new OpCacheGUI\Presentation\ClassCycler(['odd', 'even']);
<article class="cols-3 first">
<h2>
<?= $translator->translate('status.title'); ?>
<form action="/reset" method="post" id="reset" data-confirmation="<?= $translator->translate('confirmation.reset'); ?>" data-yes="<?= $translator->translate('confirmation.yes'); ?>" data-no="<?= $translator->translate('confirmation.no'); ?>">
<form action="reset" method="post" id="reset" data-confirmation="<?= $translator->translate('confirmation.reset'); ?>" data-yes="<?= $translator->translate('confirmation.yes'); ?>" data-no="<?= $translator->translate('confirmation.no'); ?>">
<input type="hidden" name="csrfToken" value="<?= $csrfToken->get(); ?>">
<input type="submit" name="submit" value="<?= $translator->translate('reset.submit'); ?>">
</form>
Expand All @@ -15,7 +15,7 @@ $classCycler = new OpCacheGUI\Presentation\ClassCycler(['odd', 'even']);
<?php foreach ($status->getStatusInfo() as $key => $statusItem) { ?>
<tr class="<?= $classCycler->next(); ?>">
<th><?= $translator->translate('status.' . $key); ?></th>
<td><img src="/style/bullet-<?= $statusItem ? 'green' : 'red'; ?>-icon.png"></td>
<td><img src="style/bullet-<?= $statusItem ? 'green' : 'red'; ?>-icon.png"></td>
</tr>
<?php } ?>
</table>
Expand Down

0 comments on commit 2bef0c0

Please sign in to comment.