Skip to content

Commit

Permalink
Tuned
Browse files Browse the repository at this point in the history
  • Loading branch information
energy-coresky committed Jan 18, 2024
1 parent b6d00f5 commit 899ea5d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"require": {
"php": ">=7.4.0"
},
"bin": [
"sky"
],
"bin": ["sky"],
"authors": [
{
"name": "Energy",
Expand Down
2 changes: 1 addition & 1 deletion sky.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SKY implements PARADISE
const ERR_DETECT = 1;
const ERR_SHOW = 3;
const ERR_SUPPRESSED = 4;
const CORE = '0.529 2024-01-15T12:28:54+02:00 energy';
const CORE = '0.531 2024-01-18T20:29:41+02:00 energy';

public $tracing = '';
public $error_prod = '';
Expand Down
7 changes: 4 additions & 3 deletions w2/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static function lint(string $in, $is_file = true) : bool {
}

static function yml(string $in, $is_file = true) {
self::$dir = $is_file ? dirname(realpath($in)) : '???';
self::$dir = $is_file ? str_replace('\\', '/', dirname(realpath($in))) : '???';
defined('DEV') && (self::$dev = DEV);
$yml = new Boot;
$yml->at = [$is_file ? $in : false, 0];
Expand Down Expand Up @@ -294,7 +294,8 @@ static function wares($fn, &$ctrl, &$class) {
$ymls = [];
foreach (require $fn as $ware => $ary) {
unset($yml);
$cfg = self::cfg($yml, ($path = $ary['path']) . "/config.yaml");
$path = str_replace('\\', '/', realpath($ary['path']));
$cfg = self::cfg($yml, "$path/config.yaml");
$plan = $cfg['plans'];
if ($ary['type'] ?? false)
$plan['app']['type'] = 'pr-dev';
Expand All @@ -316,7 +317,7 @@ static function wares($fn, &$ctrl, &$class) {
$app['cfg'] = $cfg;
if ($yml)
$ymls[$ware] = $yml;
SKY::$plans[$ware] = ['app' => ['path' => realpath($path)] + $plan['app']] + $plan;
SKY::$plans[$ware] = ['app' => ['path' => $path] + $plan['app']] + $plan;
}
return $ymls;
}
Expand Down
6 changes: 3 additions & 3 deletions w2/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ function __construct($argv = [], $found = []) {
$this->__call("c_$argv[1]", array_slice($argv, 2));
}

static function dd_h($dd, $name) {
if ('core' === $name) {
static function dd_h($dd, $name, $ware) {
if ('core' == $name && 'main' == $ware) {
require DIR_S . '/w2/mvc.php';
Plan::app_r('mvc/common_c.php');
}
common_c::dd_h($dd, $name);
common_c::dd_h($dd, $name, $ware);
}

function __call($name, $args) {
Expand Down
20 changes: 10 additions & 10 deletions w2/dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ static function gate(&$p, &$in, $ware) {
$msrc = Plan::app_mq([$ware, "mvc/$class.php"]);
if ('main' != $ware) {
trace($ware, 'WARE');
} elseif ($x && ($_m = Plan::app_mq("mvc/c_$in.php"))) {
} elseif ($x && ($_m = Plan::app_mq("mvc/c_$in.php"))) { # added new Controller
$msrc = $_m;
$p[$in] = 'main'; # added new Controller
$p[$in] = 'main';
$class = "c_$in";
Plan::cache_d('sky_plan.php');
} elseif (!$msrc) {
} elseif (!$msrc) { # Controller deleted
if ('default_c' == $class)
throw new Error('Controller `main::default_c` is mandatory');
unset($p[$in]); # Controller deleted
unset($p[$in]);
$msrc = Plan::app_m('mvc/' . ($class = 'default_c') . '.php');
Plan::cache_d('sky_plan.php');
}
$mdst = Plan::gate_mq("$ware-$class.php");
if ($drop = $mdst && $msrc > $mdst)
Plan::gate_d("$ware-$class.php"); # delete before recompile
return ['data' => ['recompile' => !$mdst || $drop]];
return (object)['data' => ['recompile' => !$mdst || $drop]];
}

static function init() {
Expand Down Expand Up @@ -272,7 +272,7 @@ function j_attach() {
'opt' => $class ? (new $class) : false,
'classes' => Globals::def($dir),
'name' => $name,
'dir' => str_replace('\\', '/', $dir),
'dir' => $dir,
'flags' => $flags,
'md' => $doc,
];
Expand All @@ -282,7 +282,7 @@ function j_attach() {
return $this->error('Must select at least one class');
}
$wares[$name] = [
'path' => str_replace('\\', '/', $dir),
'path' => $dir,
'class' => $cls,
'tune' => $_POST['tune'] ?? '',
];
Expand Down Expand Up @@ -347,7 +347,7 @@ function c_ware() {
'class' => $wares[$name]['class'],
'cnt' => count($wares[$name]['class']),
'desc' => $this->desc($path = Plan::_obj([$name])->path),
'path' => str_replace('\\', '/', $path),
'path' => $path,
];
},
'e_dir' => function ($row) use (&$dir) {
Expand All @@ -361,7 +361,7 @@ function c_ware() {
return [
'name' => ucfirst($ware),
'type' => $conf['app']['type'],
'path' => str_replace('\\', '/', $path),
'path' => $path,
'desc' => $this->desc($path),
];
},
Expand Down Expand Up @@ -421,7 +421,7 @@ function j_readme() {
$html = is_file($fn = "$dir/README.md") ? Display::md(file_get_contents($fn)) : '';
if (is_file($fn = "$dir/LICENSE"))
$html .= Display::bash(file_get_contents($fn));
return ['html' => $html, 'dir' => str_replace('\\', '/', $dir)];
return ['html' => $html, 'dir' => $dir];
}

function j_inet() {
Expand Down
4 changes: 2 additions & 2 deletions w2/mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static function user_h(&$lg = null) {
return new USER;
}

static function dd_h($dd, $name = '') {
static function dd_h($dd, $name = 'core', $ware = 'main') {
$dd->init();
}

Expand Down Expand Up @@ -486,7 +486,7 @@ private function gate(&$class, &$a, &$g) {
}
return $p[$in] ?? ($x = 'main');
};
$vars = DEV ? (object)DEV::gate($p, $in, $ware) : false;
$vars = DEV ? DEV::gate($p, $in, $ware) : false;
Plan::$view = Plan::$ware = $ware = $ware($x);
$class = $x ? (MVC::$tpl = 'default') . '_c' : 'c_' . (MVC::$tpl = $in);
$x or is_string($in = $this->_1) or $in = '*';
Expand Down
6 changes: 3 additions & 3 deletions w2/plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ static function echoHead($plus = '') {
}

static function echoTail($plus = '') {
if (self::$tail[2])
if (self::$tail[2] ?? false)
$plus .= css(self::$tail[2]); # css
if (self::$tail[1])
if (self::$tail[1] ?? false)
$plus .= js(self::$tail[1]); # js
echo $plus . implode('', self::$tail[0]); # raw
echo $plus . implode('', self::$tail[0] ?? []); # raw
HEAVEN::tail_t();
}

Expand Down
2 changes: 1 addition & 1 deletion w2/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static function open($name = 'core', $ware = false, $p2 = false) {
$dd->cname = $name;
SQL::$connections[$ware][$name] = $dd;
unset($cfg['dsn']);
call_user_func(SQL::$dd_h, $dd, $name);
call_user_func(SQL::$dd_h, $dd, $name, $ware);
}
return $p2 || !SQL::$dd ? (SQL::$dd = $dd) : $dd;
}
Expand Down

0 comments on commit 899ea5d

Please sign in to comment.