Skip to content

Commit

Permalink
2.0 (#29)
Browse files Browse the repository at this point in the history
* initial upgrade

* use a div

* page navigation title

* panel header uses flex

* don't overflow wrapped hero bar
  • Loading branch information
TomK committed Feb 8, 2019
1 parent 925256d commit b4de8b6
Show file tree
Hide file tree
Showing 46 changed files with 296 additions and 430 deletions.
12 changes: 9 additions & 3 deletions assets_src/assets/css/GlobalElements/Panels.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.panel[class~="f-panel"] > [class*="f-panel-heading"] {
display: flex;
padding: 10px 15px;
font-size: inherit;
align-items: center;
}

/*
Expand All @@ -12,12 +14,16 @@ Remove margin-bottom from last direct child of panel-body

/**/
.panel[class~="f-panel"][class~="panel-plain"] {
padding: 0;
border: none;
box-shadow: none;
padding: 0;
border: none;
box-shadow: none;
background-color: transparent;
}

.panel[class~="f-panel"][class~="panel-default"] {
background-color: #fff;
}

.f-panel-heading-text {
flex-grow: 1;
}
1 change: 1 addition & 0 deletions assets_src/assets/css/PageElements/HeroItemBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
padding: 0 32px;
color: #FFFFFF;
flex-wrap: wrap;
overflow: hidden;
}

.f-hero-item-bar > div {
Expand Down
5 changes: 1 addition & 4 deletions assets_src/assets/css/PageElements/PageNavigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
margin-bottom: 15px;
}

.f-page-navigation > .panel-heading h2 {
.f-page-navigation > .f-page-navigation-title {
font-size: 14px;
}

.f-page-navigation > .panel-heading {
background: 0 0;
border: none;
border-bottom: 1px solid #d8d8d8;
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
"email": "brooke@bajb.net"
}
],
"minimum-stability": "dev",
"require": {
"packaged/dispatch": "~1.6",
"packaged/glimpse": "^0.8||^1.0||^2.0",
"packaged/dispatch": "^2.0",
"packaged/glimpse": "^2.0",
"nesbot/carbon": "~1.22",
"illuminate/contracts": "~5.5",
"fortifi/fontawesome": "^3.0"
},
"require-dev": {
"cubex/framework": "~2.6",
"stack/builder": "~1.0",
"packaged/helpers": "~1.16||^2.0"
"cubex/framework": "dev-docblock",
"packaged/docblock": "^1.0",
"phpunit/phpunit": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
35 changes: 2 additions & 33 deletions cubex
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
#!/usr/bin/env php
<?php
/**
* Cubex Console Application
*/
//Defining PHP_START will allow cubex to add an execution time header
define('PHP_START', microtime(true));

//These values are set for support within HHVM
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
defined('STDERR') or define('STDERR', fopen('php://stderr', 'w'));

//Include the composer autoloader
require_once __DIR__ . '/vendor/autoload.php';

//Create an instance of cubex, with the bin root defined
$app = new \Cubex\Cubex(__DIR__ . DIRECTORY_SEPARATOR . 'public/');

//Boot Cubex
$app->boot();

//Create a request object
$request = \Cubex\Http\Request::createConsoleRequest();
$app->instance('request', $request);

//Create a new console application
$console = \Cubex\Console\Console::withCubex($app);

//Execute the command and retrieve the exit code
$exit = $console->run();

$app->shutdown();

exit($exit);
$loader = require_once('vendor/autoload.php');
exit((new Cubex\Cubex(__DIR__, $loader))->cli());
73 changes: 35 additions & 38 deletions example_src/Controllers/ExampleController.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
<?php
namespace Fortifi\UiExample\Controllers;

use Cubex\Http\Response;
use Cubex\View\LayoutController;
use Cubex\Controller\Controller;
use Fortifi\Ui\ContentElements\QueryBuilder\QueryBuilderDataType as QBDT;
use Fortifi\Ui\ContentElements\QueryBuilder\QueryBuilderDefinition as QBD;
use Fortifi\Ui\ContentElements\QueryBuilder\QueryBuilderDefinitions;
use Fortifi\Ui\ProjectSupport\FortifiUiLayout;
use Fortifi\UiExample\Layouts\ExampleLayout;
use Packaged\Glimpse\Tags\Div;
use Packaged\Helpers\Arrays;
use Packaged\Helpers\Objects;
use Packaged\Http\Responses\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

class ExampleController extends LayoutController
class ExampleController extends Controller
{
protected $_views = [];

protected function _init()
public function getRoutes()
{
yield self::route('querybuilder/definition', 'qbDefinition');
yield self::route('querybuilder/policy', 'qbPolicyData');
yield self::route('querybuilder/browsers', 'qbBrowsers');
yield self::route('querybuilder/sids', 'qbSids');

yield self::route('dropdowns/content', 'dropContent');

yield self::route('{page}', 'default');
yield self::route('', 'default');
}

public function getDefault()
{
$views = glob(dirname(__DIR__) . '/Views/*View.php');
foreach($views as $view)
Expand All @@ -26,43 +39,27 @@ protected function _init()
continue;
}
$key = strtolower(substr($view, 0, -8));
$obj = Objects::create('Fortifi\\UiExample\\Views\\' . substr($view, 0, -4), []);
$objClass = '\\Fortifi\\UiExample\\Views\\' . substr($view, 0, -4);
$obj = $objClass::i();
$this->_views[$key] = $obj;
}
$layout = new FortifiUiLayout($this);
$layout->setData('views', $this->_views);
$this->setLayout($layout);
}

public function defaultAction($page = null)
{
$layout = new ExampleLayout();
$layout->views = $this->_views;
$page = $this->getContext()->routeData()->get('page');
if(isset($this->_views[$page]))
{
return $this->_views[$page];
$layout->content = $this->_views[$page]->render();
}
return 'Page Unavailable';
}

public function getRoutes()
{
return [
'querybuilder/definition' => 'qbDefinition',
'querybuilder/policy' => 'qbPolicyData',
'querybuilder/browsers' => 'qbBrowsers',
'querybuilder/sids' => 'qbSids',

'dropdowns/content' => 'dropContent',

':page' => 'defaultAction',
];
return $layout;
}

public function dropContent()
public function getDropContent()
{
return Div::create('this is a dropdown loaded by ajax');
}

public function qbDefinition()
public function getQbDefinition()
{
$definitions = new QueryBuilderDefinitions();

Expand Down Expand Up @@ -115,7 +112,7 @@ public function qbDefinition()
'Sub ID',
QBDT::STRING
);
$sidDefinition->setValues($this->qbSids());
$sidDefinition->setValues($this->getQbSids());
$sidDefinition->setStrict(false);
$sidDefinition->setComparators(
[
Expand Down Expand Up @@ -170,7 +167,7 @@ public function qbDefinition()
return new Response(json_encode($definitions->forOutput()));
}

public function qbPolicyData()
public function getQbPolicyData()
{
$policy = [
[
Expand All @@ -191,12 +188,12 @@ public function qbPolicyData()
'sid' => ['12'],
['key' => 'aaa', 'comparator' => QBD::COMPARATOR_EQUALS, 'value' => 'test3'],
];
return $policy;
return JsonResponse::create($policy);
}

public function qbBrowsers()
public function getQbBrowsers()
{
$query = $this->_getRequest()->query->get('search');
$query = $this->getRequest()->query->get('search');
$values = [
['value' => '', 'text' => 'No Browser'],
['value' => 'chrome', 'text' => 'Chrome'],
Expand All @@ -218,7 +215,7 @@ function ($var) use ($query) {
);
}

public function qbSids()
public function getQbSids()
{
$values = [
['value' => 'malware15IT', 'text' => 'malware15IT'],
Expand All @@ -230,7 +227,7 @@ public function qbSids()
['value' => 'spyware16', 'text' => 'spyware16'],
];

$query = $this->_getRequest()->query->get('search');
$query = $this->getRequest()->query->get('search');
if($query)
{
return array_filter(
Expand Down
17 changes: 11 additions & 6 deletions example_src/ExampleUi.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<?php
namespace Fortifi\UiExample;

use Cubex\Kernel\CubexKernel;
use Cubex\Controller\Controller;
use Fortifi\Ui\Ui;
use Fortifi\UiExample\Controllers\ExampleController;
use Packaged\Dispatch\AssetManager;
use Packaged\Dispatch\ResourceManager;

class ExampleUi extends CubexKernel
class ExampleUi extends Controller
{
public function getRoutes()
{
return 'default';
}

public function __construct()
{
Ui::boot(AssetManager::aliasType('root'));
AssetManager::aliasType('esrc')->requireCss('css/theme');
Ui::boot(ResourceManager::alias('root'));
ResourceManager::alias('esrc')->requireCss('css/theme.css');
}

public function defaultAction()
public function getDefault()
{
return new ExampleController();
}
Expand Down
10 changes: 10 additions & 0 deletions example_src/Layouts/ExampleLayout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Fortifi\UiExample\Layouts;

use Cubex\Ui\UiElement;

class ExampleLayout extends UiElement
{
public $views;
public $content;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php
/**
* @var $this \Cubex\View\Layout
* @var $this ExampleLayout
*/

use Fortifi\UiExample\Layouts\ExampleLayout;
use Packaged\Dispatch\Dispatch;

$r = Dispatch::instance()->store();
?>
<!DOCTYPE html>
<!--[if lt IE 7]>
Expand All @@ -17,24 +22,23 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="fragment" content="!">
<title><?= $this->getData('title', 'Fortifi UI Examples'); ?></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= \Packaged\Dispatch\AssetManager::generateHtmlIncludes(\Packaged\Dispatch\AssetManager::TYPE_CSS); ?>
<?= $r->generateHtmlIncludes($r::TYPE_CSS); ?>
</head>
<body>
<div id="title-bar">
<h1>Fortifi UI</h1>
<ul class="title-bar-nav">
<?php foreach($this->getData('views') as $uri => $obj) { ?>
<?php foreach($this->views as $uri => $obj) { ?>
<li><a href="/<?= $uri; ?>"><?= $obj->getDisplayName(); ?></a></li>
<?php } ?>
</ul>
</div>

<div id="wrapper">
<?= $this->content(); ?>
<?= $this->content; ?>
</div>
<?= \Packaged\Dispatch\AssetManager::generateHtmlIncludes(\Packaged\Dispatch\AssetManager::TYPE_JS); ?>
<?= $r->generateHtmlIncludes($r::TYPE_JS); ?>
</body>
</html>
Loading

0 comments on commit b4de8b6

Please sign in to comment.