Skip to content

Commit

Permalink
Merge pull request #2 from inceptphp/0.1
Browse files Browse the repository at this point in the history
0.1
  • Loading branch information
cblanquera authored May 14, 2021
2 parents b92a58c + 7532cd9 commit f368edb
Show file tree
Hide file tree
Showing 36 changed files with 517 additions and 246 deletions.
33 changes: 28 additions & 5 deletions admin/AdminPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ public function error(
return;
}

//if there's already content
if ($response->hasContent()) {
return;
}

//get the path
$path = $request->getPath('string');
//if not an admin path
if ($path !== '/admin' && strpos($path, '/admin/') !== 0) {
return;
}

$debug = strpos($path, '/admin/spa/') === false ? 'page': 'spa';

//if it was a call for an actual file
if (preg_match('/\.[a-zA-Z0-9]{1,4}$/', $path)) {
return;
Expand All @@ -114,7 +121,7 @@ public function error(
$type = $response->getHeaders('Content-Type');
if (strpos($type, 'html') === false) {
//don't make it pretty
return $this->errorDebug($request, $response, $error);
return $this->errorDebug($request, $response, $error, $debug);
}

//get the code
Expand All @@ -135,7 +142,7 @@ public function error(
|| $code !== 500
) {
//don't make it pretty
return $this->errorDebug($request, $response, $error);
return $this->errorDebug($request, $response, $error, $debug);
}

//okay make it pretty...
Expand Down Expand Up @@ -290,14 +297,16 @@ protected function errorEmail(
*
* @param *RequestInterface $request
* @param *ResponseInterface $response
* @param *Throwable $error
* @param *Throwable $error
* @param *string $mode
*
* @return bool
*/
protected function errorDebug(
RequestInterface $request,
ResponseInterface $response,
Throwable $error
Throwable $error,
string $mode = 'page'
) {
//load some packages
$host = $this->handler->package('host');
Expand Down Expand Up @@ -435,19 +444,33 @@ protected function errorDebug(
$data['stack'][] = $trace;
}

$handlebars->registerHelper('plus', function($x, $y) {
return $x + $y;
});

$handlebars->registerHelper('nolines', function($string) {
$string = preg_replace('/\s+/is', ' ', $string);
$string = str_replace('Array ( ', 'Array(', $string);
return str_replace(' ', ' ', $string);
});

//set the template root
$template = __DIR__ . '/template';

$body = $handlebars
->setTemplateFolder($template)
->renderFromFolder('error', $data);
->renderFromFolder('debug/' . $mode, $data);

//set content
$response
->set('page', 'title', $language->translate('Oops...'))
->set('page', 'class', 'page-error')
->setContent($body);

if ($mode === 'spa') {
return;
}

//render page
$this->render($request, $response, 'blank');
return true;
Expand Down
57 changes: 28 additions & 29 deletions admin/assets/script/_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,44 +1342,43 @@
* Code Editor - Ace
*/
$(window).on('code-editor-init', function(e, target) {
$.require.load(
'components/ace-editor-builds/src/ace.js',
function() {
target = $(target);
$.require.load('components/ace-editor-builds/src/ace.js', function() {
target = $(target);

var mode = target.attr('data-mode');
var width = target.attr('data-height') || 0;
var height = target.attr('data-height') || 500;
var mode = target.attr('data-mode');
var width = target.attr('data-height') || 0;
var height = target.attr('data-height') || 500;

var container = $('<section>')
.addClass('form-control')
.addClass('code-editor-container');
var container = $('<section>')
.addClass('form-control')
.addClass('code-editor-container');

if(width) {
container.width(width);
}
if(width) {
container.width(width);
}

if(height) {
container.height(height);
}
if(height) {
container.height(height);
}

target.after(container);
target.after(container);

var editor = ace.edit(container[0]);
var editor = ace.edit(container[0]);

if(mode) {
// set mode
editor.getSession().setMode('ace/mode/' + mode);
}
if(mode) {
// set mode
editor.getSession().setMode('ace/mode/' + mode);
}

// set editor default value
editor.setValue(target.val());
// set editor default value
editor.setValue(target.val());

target.closest('form').submit(function() {
target.val(editor.getValue());
});
}
);
target.closest('form').submit(function() {
target.val(editor.getValue());
});

target.hide();
});
});

/**
Expand Down
11 changes: 10 additions & 1 deletion admin/assets/style/_form.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
.form-mobile .form-group-textarea,
.form-mobile .form-group-markdown,
.form-mobile .form-group-wysiwyg,
.form-mobile .form-group-image,
.form-mobile .form-group-file,
.form-mobile .form-group-imagelist,
.form-mobile .form-group-filelist,
.form-mobile .form-group-fieldset,
.form-mobile .form-group.no-flex {
border-width: 0;
Expand All @@ -24,6 +28,10 @@
.form-mobile .form-group-textarea .control-label,
.form-mobile .form-group-markdown .control-label,
.form-mobile .form-group-wysiwyg .control-label,
.form-mobile .form-group-image .control-label,
.form-mobile .form-group-file .control-label,
.form-mobile .form-group-imagelist .control-label,
.form-mobile .form-group-filelist .control-label,
.form-mobile .form-group-fieldset .control-label,
.form-mobile .form-group.no-flex .control-label {
margin-bottom: 5px;
Expand Down Expand Up @@ -231,7 +239,8 @@
width: 100% !important;
}

.form-mobile .select2-container--default .select2-selection--single, .form-mobile .select2-container--default .select2-selection--multiple {
.form-mobile .select2-container--default .select2-selection--single,
.form-mobile .select2-container--default .select2-selection--multiple {
border-width: 0 !important;
}

Expand Down
7 changes: 7 additions & 0 deletions admin/assets/style/_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@
margin-top: -3px;
}

.layout-panel .panel-sidebar-left .nav {
display: block;
height: 100%;
overflow: auto;
width: 100%;
}

.layout-panel .panel-sidebar-left .nav-link .nav-right {
color: #FFFFFF;
float: right;
Expand Down
12 changes: 12 additions & 0 deletions admin/assets/style/_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,15 @@ a:visited {
.form-mobile .ace-tm .ace_gutter-active-line {
background-color: #000000;
}

.form-mobile .ace-tm .ace_meta.ace_tag {
color: #F43A80;
}

.form-mobile .ace-tm .ace_cursor {
color: #929AAD;
}

.form-mobile .ace_content {
background-color: #000000;
}
2 changes: 1 addition & 1 deletion admin/controller/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@

//----------------------------//
// 2. Process Data
$template = dirname(__DIR__) . '/template/fieldset';
$template = dirname(__DIR__) . '/template/schema';
if (is_dir($response->get('page', 'template_root'))) {
$template = $response->get('page', 'template_root');
}
Expand Down
Loading

0 comments on commit f368edb

Please sign in to comment.