Fixing PHPCI so that it'll work in a subdirectory.
This commit is contained in:
parent
b9415316d4
commit
f256db237b
|
@ -18,6 +18,15 @@ use b8\Registry;
|
|||
*/
|
||||
class Application extends b8\Application
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (isset($_SERVER['REDIRECT_PATH_INFO'])) {
|
||||
$_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_PATH_INFO'];
|
||||
}
|
||||
|
||||
return parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming web request.
|
||||
*/
|
||||
|
|
|
@ -81,7 +81,7 @@ class BuildController extends b8\Controller
|
|||
|
||||
$build = $this->_buildStore->save($build);
|
||||
|
||||
header('Location: /build/view/' . $build->getId());
|
||||
header('Location: '.PHPCI_URL.'build/view/' . $build->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ class BuildController extends b8\Controller
|
|||
$build = $this->_buildStore->getById($buildId);
|
||||
$this->_buildStore->delete($build);
|
||||
|
||||
header('Location: /project/view/' . $build->getProjectId());
|
||||
header('Location: '.PHPCI_URL.'project/view/' . $build->getProjectId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,7 +61,7 @@ class ProjectController extends b8\Controller
|
|||
|
||||
$build = $this->_buildStore->save($build);
|
||||
|
||||
header('Location: /build/view/' . $build->getId());
|
||||
header('Location: '.PHPCI_URL.'build/view/' . $build->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ class ProjectController extends b8\Controller
|
|||
$project = $this->_projectStore->getById($projectId);
|
||||
$this->_projectStore->delete($project);
|
||||
|
||||
header('Location: /');
|
||||
header('Location: '.PHPCI_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,7 +164,7 @@ class ProjectController extends b8\Controller
|
|||
|
||||
$project = $this->_projectStore->save($project);
|
||||
|
||||
header('Location: /project/view/' . $project->getId());
|
||||
header('Location: '.PHPCI_URL.'project/view/' . $project->getId());
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class ProjectController extends b8\Controller
|
|||
if ($resp['success']) {
|
||||
parse_str($resp['body'], $resp);
|
||||
$_SESSION['github_token'] = $resp['access_token'];
|
||||
header('Location: /project/add');
|
||||
header('Location: '.PHPCI_URL.'project/add');
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ class ProjectController extends b8\Controller
|
|||
$project->setValues($values);
|
||||
$project = $this->_projectStore->save($project);
|
||||
|
||||
header('Location: /project/view/' . $project->getId());
|
||||
header('Location: '.PHPCI_URL.'project/view/' . $project->getId());
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ class ProjectController extends b8\Controller
|
|||
{
|
||||
$form = new Form();
|
||||
$form->setMethod('POST');
|
||||
$form->setAction('/project/' . $type);
|
||||
$form->setAction(PHPCI_URL.'project/' . $type);
|
||||
$form->addField(new Form\Element\Csrf('csrf'));
|
||||
$form->addField(new Form\Element\Hidden('token'));
|
||||
$form->addField(new Form\Element\Hidden('pubkey'));
|
||||
|
|
|
@ -34,7 +34,7 @@ class SessionController extends b8\Controller
|
|||
|
||||
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
||||
$_SESSION['user_id'] = $user->getId();
|
||||
header('Location: /');
|
||||
header('Location: ' . PHPCI_URL);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class SessionController extends b8\Controller
|
|||
{
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
header('Location: /');
|
||||
header('Location: ' . PHPCI_URL);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class UserController extends b8\Controller
|
|||
|
||||
$user = $this->_userStore->save($user);
|
||||
|
||||
header('Location: /user');
|
||||
header('Location: '.PHPCI_URL.'user');
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class UserController extends b8\Controller
|
|||
$user->setValues($values);
|
||||
$user = $this->_userStore->save($user);
|
||||
|
||||
header('Location: /user');
|
||||
header('Location: '.PHPCI_URL.'user');
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class UserController extends b8\Controller
|
|||
$user = $this->_userStore->getById($userId);
|
||||
$this->_userStore->delete($user);
|
||||
|
||||
header('Location: /user');
|
||||
header('Location: '.PHPCI_URL.'user');
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
<div class="span3">
|
||||
<div class="well" style="padding: 8px 0">
|
||||
<ul class="nav nav-list">
|
||||
<li><a href="/"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="/project/view/<?php print $build->getProject()->getId(); ?>"><i class="icon-folder-open"></i> <?php print $build->getProject()->getTitle(); ?></a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>project/view/<?php print $build->getProject()->getId(); ?>"><i class="icon-folder-open"></i> <?php print $build->getProject()->getTitle(); ?></a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="nav-header">Options</li>
|
||||
<li><a href="/build/rebuild/<?php print $build->getId(); ?>"><i class="icon-cog"></i> Rebuild</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>build/rebuild/<?php print $build->getId(); ?>"><i class="icon-cog"></i> Rebuild</a></li>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<li><a href="javascript:confirmDelete('/build/delete/<?php print $build->getId(); ?>')"><i class="icon-trash"></i> Delete Build</a></li>
|
||||
<li><a href="javascript:confirmDelete('<?= PHPCI_URL ?>build/delete/<?php print $build->getId(); ?>')"><i class="icon-trash"></i> Delete Build</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -69,7 +69,7 @@
|
|||
<?php if($build->getStatus() == 0 || $build->getStatus() == 1 || true): ?>
|
||||
setInterval(function()
|
||||
{
|
||||
$.getJSON('/build/data/<?php print $build->getId(); ?>', updateBuildView);
|
||||
$.getJSON('<?= PHPCI_URL ?>build/data/<?php print $build->getId(); ?>', updateBuildView);
|
||||
}, 10000);
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
|
@ -31,20 +31,20 @@ switch($build->getStatus())
|
|||
}
|
||||
?>
|
||||
<tr class="<?php print $cls; ?>">
|
||||
<td><a href="/build/view/<?php print $build->getId(); ?>">#<?php print str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
|
||||
<td><a href="/project/view/<?php print $build->getProjectId(); ?>"><?php print $build->getProject()->getTitle(); ?></a></td>
|
||||
<td><a href="<?= PHPCI_URL ?>build/view/<?php print $build->getId(); ?>">#<?php print str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
|
||||
<td><a href="<?= PHPCI_URL ?>project/view/<?php print $build->getProjectId(); ?>"><?php print $build->getProject()->getTitle(); ?></a></td>
|
||||
<td><a href="<?php print $build->getCommitLink(); ?>"><?php print $build->getCommitId(); ?></a></td>
|
||||
<td><a href="<?php print $build->getBranchLink(); ?>"><?php print $build->getBranch(); ?></a></td>
|
||||
<td><?php print $status; ?></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a class="btn" href="/build/view/<?php print $build->getId(); ?>">View</a>
|
||||
<a class="btn" href="<?= PHPCI_URL ?>build/view/<?php print $build->getId(); ?>">View</a>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:confirmDelete('/build/delete/<?php print $build->getId(); ?>');">Delete Build</a></li>
|
||||
<li><a href="javascript:confirmDelete('<?= PHPCI_URL ?>build/delete/<?php print $build->getId(); ?>');">Delete Build</a></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<div class="span3">
|
||||
<div class="well" style="padding: 8px 0">
|
||||
<ul class="nav nav-list">
|
||||
<li><a href="/"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="/user"><i class="icon-user"></i> Users</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>user"><i class="icon-user"></i> Users</a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="nav-header">Projects</li>
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
}
|
||||
}
|
||||
?>
|
||||
<li><a href="/project/view/<?php print $project->getId(); ?>"><i class="<?= $status; ?>"></i> <?php print $project->getTitle(); ?></a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>project/view/<?php print $project->getId(); ?>"><i class="<?= $status; ?>"></i> <?php print $project->getTitle(); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -61,6 +61,6 @@
|
|||
<script>
|
||||
setInterval(function()
|
||||
{
|
||||
$('#latest-builds').load('/index/latest');
|
||||
$('#latest-builds').load('<?= PHPCI_URL ?>index/latest');
|
||||
}, 10000);
|
||||
</script>
|
|
@ -7,24 +7,24 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900,300italic' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/phpci.css">
|
||||
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/phpci.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script src="/assets/js/bootstrap.min.js"></script>
|
||||
<script src="/assets/js/phpci.js"></script>
|
||||
<script src="<?= PHPCI_URL ?>assets/js/bootstrap.min.js"></script>
|
||||
<script src="<?= PHPCI_URL ?>assets/js/phpci.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="/">PHPCI <span class="badge badge-important" style="position: relative; top: -3px; margin-left: 10px">1.0 Alpha</span></a>
|
||||
<a class="brand" href="<?= PHPCI_URL ?>">PHPCI <span class="badge badge-important" style="position: relative; top: -3px; margin-left: 10px">1.0 Alpha</span></a>
|
||||
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="/session/logout">Log out</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>session/logout">Log out</a></li>
|
||||
</ul>
|
||||
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<a class="pull-right btn" href="/project/add">Add Project</a>
|
||||
<a class="pull-right btn" href="<?= PHPCI_URL ?>project/add">Add Project</a>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css">
|
||||
<!-- link rel="stylesheet" type="text/css" href="/assets/css/cms.css" -->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/bootstrap.min.css">
|
||||
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
|
||||
<script src="/assets/js/bootstrap.min.js"></script>
|
||||
<script src="<?= PHPCI_URL ?>assets/js/bootstrap.min.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
<div class="span3">
|
||||
<div class="well" style="padding: 8px 0">
|
||||
<ul class="nav nav-list">
|
||||
<li><a href="/"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="/project/view/<?php print $project->getId(); ?>"><i class="icon-folder-open"></i> <?php print $project->getTitle(); ?></a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>project/view/<?php print $project->getId(); ?>"><i class="icon-folder-open"></i> <?php print $project->getTitle(); ?></a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="nav-header">Options</li>
|
||||
<li><a href="/project/build/<?php print $project->getId(); ?>"><i class="icon-cog"></i> Build Now</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>project/build/<?php print $project->getId(); ?>"><i class="icon-cog"></i> Build Now</a></li>
|
||||
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<li><a href="/project/edit/<?php print $project->getId(); ?>"><i class="icon-edit"></i> Edit Project</a></li>
|
||||
<li><a href="javascript:confirmDelete('/project/delete/<?php print $project->getId(); ?>')"><i class="icon-trash"></i> Delete Project</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>project/edit/<?php print $project->getId(); ?>"><i class="icon-edit"></i> Edit Project</a></li>
|
||||
<li><a href="javascript:confirmDelete('<?= PHPCI_URL ?>project/delete/<?php print $project->getId(); ?>')"><i class="icon-trash"></i> Delete Project</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -61,14 +61,14 @@
|
|||
$pages = ceil($total / 10);
|
||||
$pages = $pages == 0 ? 1 : $pages;
|
||||
|
||||
print '<li class="'.($page == 1 ? 'disabled' : '').'"><a href="/project/view/'.$project->getId().'?p='.($page == 1 ? '1' : $page - 1).'">«</a></li>';
|
||||
print '<li class="'.($page == 1 ? 'disabled' : '').'"><a href="<?= PHPCI_URL ?>project/view/'.$project->getId().'?p='.($page == 1 ? '1' : $page - 1).'">«</a></li>';
|
||||
|
||||
for($i = 1; $i <= $pages; $i++)
|
||||
{
|
||||
print '<li><a href="/project/view/' . $project->getId() . '?p=' . $i . '">' . $i . '</a></li>';
|
||||
print '<li><a href="<?= PHPCI_URL ?>project/view/' . $project->getId() . '?p=' . $i . '">' . $i . '</a></li>';
|
||||
}
|
||||
|
||||
print '<li class="'.($page == $pages ? 'disabled' : '').'"><a href="/project/view/'.$project->getId().'?p='.($page == $pages ? $pages : $page + 1).'">»</a></li>';
|
||||
print '<li class="'.($page == $pages ? 'disabled' : '').'"><a href="<?= PHPCI_URL ?>project/view/'.$project->getId().'?p='.($page == $pages ? $pages : $page + 1).'">»</a></li>';
|
||||
|
||||
print '</ul></div>';
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
|||
<script>
|
||||
setInterval(function()
|
||||
{
|
||||
$('#latest-builds').load('/project/builds/<?php print $project->getId(); ?>');
|
||||
$('#latest-builds').load('<?= PHPCI_URL ?>project/builds/<?php print $project->getId(); ?>');
|
||||
}, 10000);
|
||||
</script>
|
||||
<?php endif; ?>
|
|
@ -6,10 +6,10 @@
|
|||
<div class="span3">
|
||||
<div class="well" style="padding: 8px 0">
|
||||
<ul class="nav nav-list">
|
||||
<li><a href="/"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="/user"><i class="icon-user"></i> Users</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>"><i class="icon-home"></i> Dashboard</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>user"><i class="icon-user"></i> Users</a></li>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<li><a href="/user/add"><i class="icon-plus-sign"></i> Add User</a></li>
|
||||
<li><a href="<?= PHPCI_URL ?>user/add"><i class="icon-plus-sign"></i> Add User</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -41,18 +41,18 @@
|
|||
}
|
||||
?>
|
||||
<tr class="<?php print $cls; ?>">
|
||||
<td><a href="/user/edit/<?php print $user->getId(); ?>"><?php print $user->getEmail(); ?></a></td>
|
||||
<td><a href="<?= PHPCI_URL ?>user/edit/<?php print $user->getId(); ?>"><?php print $user->getEmail(); ?></a></td>
|
||||
<td><?php print $user->getName(); ?></td>
|
||||
<td><?php print $status; ?></td>
|
||||
<td>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<div class="btn-group">
|
||||
<a class="btn" href="/user/edit/<?php print $user->getId(); ?>">Edit</a>
|
||||
<a class="btn" href="<?= PHPCI_URL ?>user/edit/<?php print $user->getId(); ?>">Edit</a>
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:confirmDelete('/user/delete/<?php print $user->getId(); ?>');">Delete User</a></li>
|
||||
<li><a href="javascript:confirmDelete('<?= PHPCI_URL ?>user/delete/<?php print $user->getId(); ?>');">Delete User</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -47,9 +47,10 @@ _**Please be aware that this is a brand new project, in an alpha state, so there
|
|||
**Apache Example**:
|
||||
|
||||
RewriteEngine On
|
||||
RewriteBase /path-to-phpci
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . index.php [L]
|
||||
RewriteRule (.*)? index.php [L,E=PATH_INFO:/$1]
|
||||
|
||||
**Nginx Example**:
|
||||
|
||||
|
|
|
@ -38,6 +38,11 @@ require_once(APPLICATION_PATH . 'vendor/autoload.php');
|
|||
// Load configuration if present:
|
||||
if (file_exists(APPLICATION_PATH . 'config.php')) {
|
||||
require(APPLICATION_PATH . 'config.php');
|
||||
|
||||
// Define our PHPCI_URL, if not already defined:
|
||||
if (!defined('PHPCI_URL')) {
|
||||
define('PHPCI_URL', $registry->get('install_url', '') . '/');
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the registry:
|
||||
|
|
Loading…
Reference in a new issue