Skip to content

Commit

Permalink
New installer.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirix committed Mar 22, 2015
1 parent 3804d8f commit ce80ac3
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 0 deletions.
26 changes: 26 additions & 0 deletions install/index.php
@@ -0,0 +1,26 @@
<?php
/*!
* Traq
* Copyright (C) 2009-2015 Jack Polgar
* Copyright (C) 2012-2015 Traq.io
* https://github.com/nirix
* https://traq.io
*
* This file is part of Traq.
*
* Traq is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 only.
*
* Traq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Traq. If not, see <http://www.gnu.org/licenses/>.
*/

require dirname(__DIR__) . '/vendor/autoload.php';
use Traq\Installer\Kernel;
(new Kernel)->run();
52 changes: 52 additions & 0 deletions src/Installer/Controllers/AppController.php
@@ -0,0 +1,52 @@
<?php
/*!
* Traq
* Copyright (C) 2009-2015 Jack Polgar
* Copyright (C) 2012-2015 Traq.io
* https://github.com/nirix
* https://traq.io
*
* This file is part of Traq.
*
* Traq is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 only.
*
* Traq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Traq. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Traq\Installer\Controllers;

use Avalon\Http\Controller;

/**
* @author Jack P.
* @since 4.0.0
*/
class AppController extends Controller
{
public function __construct()
{
parent::__construct();

$this->set("installStep", function($routeName) {
return $this->request->basePath("index.php") . $this->generateUrl($routeName);
});
}

/**
* Set page title.
*
* @param string $title
*/
protected function title($title)
{
$this->set("stepTitle", $title);
}
}
45 changes: 45 additions & 0 deletions src/Installer/Controllers/Checks.php
@@ -0,0 +1,45 @@
<?php
/*!
* Traq
* Copyright (C) 2009-2015 Jack Polgar
* Copyright (C) 2012-2015 Traq.io
* https://github.com/nirix
* https://traq.io
*
* This file is part of Traq.
*
* Traq is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 only.
*
* Traq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Traq. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Traq\Installer\Controllers;

/**
* @author Jack P.
* @since 4.0.0
*/
class Checks extends AppController
{
/**
* License agreement page.
*/
public function licenseAgreementAction()
{
$this->title("License Agreement");

// Get license
$license = file_get_contents(dirname(dirname(dirname(__DIR__))) . '/COPYING');
$this->set("license", $license);

return $this->render("license_agreement.phtml");
}
}
52 changes: 52 additions & 0 deletions src/Installer/Kernel.php
@@ -0,0 +1,52 @@
<?php
/*!
* Traq
* Copyright (C) 2009-2015 Jack Polgar
* Copyright (C) 2012-2015 Traq.io
* https://github.com/nirix
* https://traq.io
*
* This file is part of Traq.
*
* Traq is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 only.
*
* Traq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Traq. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Traq\Installer;

use Exception;
use Avalon\AppKernel;

/**
* Traq installation kernel.
*
* @package Traq\Installer
*/
class Kernel extends AppKernel
{
public function __construct()
{
parent::__construct();

class_alias("Avalon\\Http\\Request", "Request");
class_alias("Avalon\\Helpers\\HTML", "HTML");
}

/**
* Loads the applications configuration.
*/
protected function loadConfiguration()
{
// We don't need the configuration during installation.
return false;
}
}
28 changes: 28 additions & 0 deletions src/Installer/config/routes.php
@@ -0,0 +1,28 @@
<?php
/*!
* Traq
* Copyright (C) 2009-2015 Jack Polgar
* Copyright (C) 2012-2015 Traq.io
* https://github.com/nirix
* https://traq.io
*
* This file is part of Traq.
*
* Traq is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 only.
*
* Traq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Traq. If not, see <http://www.gnu.org/licenses/>.
*/

use Avalon\Routing\Router;

Router::map(function($r) {
$r->root("Traq\\Installer\\Controllers\\Checks::licenseAgreement");
});
30 changes: 30 additions & 0 deletions src/Installer/views/layouts/default.phtml
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Traq Installation - <?=$stepTitle?></title>
<link rel="stylesheet" type="text/css" href="<?=dirname(Request::basePath())?>/assets/css/traq.css">
<style type="text/css">
.license {
font-family: monospace;
max-height: 400px;
overflow: auto;
}
</style>
</head>
<body>
<header id="header" class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<span class="navbar-brand">Traq Installation</span>
</div>
<div class="navbar-collapse collapse">
<p class="navbar-text">
<?=$stepTitle?>
</p>
</div>
</div>
</header>
<?=$content?>
</body>
</html>
16 changes: 16 additions & 0 deletions src/Installer/views/license_agreement.phtml
@@ -0,0 +1,16 @@
<div class="container">
<h1 class="page-title">License Agreement</h1>

<form action="<?=$installStep("step1")?>" method="post">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<pre class="license"><?=htmlentities($license)?></pre>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<button class="btn btn-block btn-primary">Accept</button>
</div>
</div>
</form>
</div>

0 comments on commit ce80ac3

Please sign in to comment.