Skip to content

Commit

Permalink
added support for windows projects, updated libs
Browse files Browse the repository at this point in the history
  • Loading branch information
n0nag0n committed Dec 13, 2023
1 parent 2129c81 commit ed20b06
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 59 deletions.
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/Config_Check_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

class Config_Check_Controller extends Base_Controller {
public function indexAction(\Base $fw): void {
$this->renderHtml('config_check/index.htm');
$this->renderHtml('config_check'.DIRECTORY_SEPARATOR.'index.htm');
}
}
10 changes: 5 additions & 5 deletions controllers/Controller_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
class Controller_Controller extends Base_Controller {
public function indexAction(\Base $fw): void {
$controllers = $this->getControllers();
$this->renderHtml('controllers/index.htm', [ 'controllers' => $controllers ]);
$this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'index.htm', [ 'controllers' => $controllers ]);
}

public function addAction(\Base $fw): void {
$this->renderHtml('controllers/add.htm');
$this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'add.htm');
}

public function create(\Base $fw, array $args = []): void {
Expand Down Expand Up @@ -50,15 +50,15 @@ public function detailsAction(\Base $fw, array $args = []): void {

$methods = $this->getControllerMethods($controller);
$methods = $this->getControllerEndpointMethods($controller);
$this->renderHtml('controllers/details.htm', [
$this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'details.htm', [
'controller_name' => $controller,
'methods' => $methods
]);
}

public function addEndpointAction(\Base $fw, array $args = []): void {
$controller = $args['controller'];
$this->renderHtml('controllers/add_endpoint.htm', [
$this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'add_endpoint.htm', [
'controller_name' => $controller
]);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ public function createControllerFile(string $controller_name): bool {
throw new \Exception('The controller already exists');
}

$contents = $this->fw->read(__DIR__.'/../templates/Controller.php');
$contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Controller.php');
$contents = str_replace([ '<?php', '#controller_name#' ], [ '#?php', $purified_controller_name ], $contents);
$contents = \Template::instance()->resolve($contents);
$write_result = $this->fw->write($full_path, str_replace('#?php', '<?php', $contents));
Expand Down
2 changes: 1 addition & 1 deletion controllers/Devtools_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function version(\Base $fw) {
}

public function cacheClear(\Base $fw) {
$fw->config(__DIR__.'/../config/webtools_config.ini', true);
$fw->config(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'webtools_config.ini', true);
$fw->set('DB', new \DB\Jig($fw->PROJECT_DATA_DIR, \DB\Jig::FORMAT_JSON ));

$Project_Config = new Project_Config($fw->DB);
Expand Down
2 changes: 1 addition & 1 deletion controllers/Index_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function index(\Base $fw): void {
$fw->reroute('/init-environment');
}

$this->renderHtml('index/index.htm');
$this->renderHtml('index'.DIRECTORY_SEPARATOR.'index.htm');
}

}
22 changes: 11 additions & 11 deletions controllers/Init_Environment_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Init_Environment_Controller extends Base_Controller {
protected array $temp;

public function indexAction(\Base $fw): void {
$this->renderHtml('init_environment/index.htm', [ 'PAGE_TITLE' => 'Initialize Environment' ]);
$this->renderHtml('init_environment'.DIRECTORY_SEPARATOR.'index.htm', [ 'PAGE_TITLE' => 'Initialize Environment' ]);
}

public function pageAction(\Base $fw, array $args = []): void {
Expand All @@ -21,42 +21,42 @@ public function pageAction(\Base $fw, array $args = []): void {

switch($page) {
case 'title':
$page_ui = 'init_environment/title.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'title.htm';
$page_title = 'Title';
break;

case 'directory-setup':
$page_ui = 'init_environment/directory_setup.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'directory_setup.htm';
$page_title = 'Directory Setup';
break;

case 'basic-config':
$page_ui = 'init_environment/basic_config.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'basic_config.htm';
$page_title = 'Basic Config';
break;

case 'choose-database':
$page_ui = 'init_environment/choose_database.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'choose_database.htm';
$page_title = 'Choose Database';
break;

case 'jig':
$page_ui = 'init_environment/jig.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'jig.htm';
$page_title = 'Jig';
break;

case 'sqlite':
$page_ui = 'init_environment/sqlite.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'sqlite.htm';
$page_title = 'SQLite';
break;

case 'mysql':
$page_ui = 'init_environment/mysql.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'mysql.htm';
$page_title = 'MySQL';
break;

case 'security':
$page_ui = 'init_environment/security.htm';
$page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'security.htm';
$page_title = 'Security';
break;

Expand Down Expand Up @@ -155,7 +155,7 @@ protected function createProjectDir(string $relative_path): bool {
protected function createProjectFile(string $relative_path, string $template_file_path): bool {
$file_path = $this->fw->PROJECT_BASE_DIR.$relative_path;
if(!empty($relative_path) && !file_exists($file_path)) {
$contents = $this->fw->read(__DIR__.'/../templates/'.$template_file_path);
$contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$template_file_path);
$contents = str_replace('<?php', '<test-php', $contents);

$parsed_contents = \Template::instance()->parse($contents);
Expand Down Expand Up @@ -186,7 +186,7 @@ protected function createControllerFileOld(string $relative_path): bool {
if(!file_exists($this->fw->PROJECT_BASE_DIR.$relative_path)) {
$controller_filename = basename($this->fw->PROJECT_BASE_DIR.$relative_path);
$controller_name = explode('.', $controller_filename)[0];
$contents = $this->fw->read(__DIR__.'/../templates/Controller.php');
$contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Controller.php');
$contents = str_replace([ '<?php', '#controller_name#' ], [ '#?php', $controller_name ], $contents);
$contents = \Template::instance()->resolve($contents);
$this->fw->write($this->fw->PROJECT_BASE_DIR.$relative_path, str_replace('#?php', '<?php', $contents));
Expand Down
21 changes: 11 additions & 10 deletions controllers/Manage_Composer_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
class Manage_Composer_Controller extends Base_Controller {
public function indexAction(\Base $fw): void {
foreach([
__DIR__.'/../vendor/', // if running this project only locally as if you forked this project
__DIR__.'/../../../', // if finding this from within a project
getenv('HOME').'/.config/composer/vendor/', // if composer installed globally,
__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR, // if running this project only locally as if you forked this project
__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR, // if finding this from within a project
getenv('HOME').DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'composer'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR, // if composer installed globally,

] as $dir_path) {
$final_path = $dir_path.'net-tools/composer-interface/src/autoload.php';
$final_path = $dir_path.'net-tools'.DIRECTORY_SEPARATOR.'composer-interface'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'autoload.php';
if(file_exists($final_path) === true) {
require($final_path);
break;
}
}

$root = rtrim($fw->PROJECT_BASE_DIR, '/');
$root = rtrim($fw->PROJECT_BASE_DIR, DIRECTORY_SEPARATOR);
$ret = '';
try
{
Expand All @@ -34,7 +34,8 @@ public function indexAction(\Base $fw): void {
'/usr/bin/',
'~/',
$fw->PROJECT_BASE_DIR,
'.'
'.',
'C:\ProgramData\ComposerSetup\bin'
];
$composer_bin_location = '';
foreach([ 'composer', 'composer.phar' ] as $composer_app_name) {
Expand Down Expand Up @@ -84,8 +85,8 @@ public function indexAction(\Base $fw): void {

error_reporting(E_ALL);

if(file_exists($root . '/composer.json')) {
$composer_file_contents = file_get_contents($root . '/composer.json');
if(file_exists($root . DIRECTORY_SEPARATOR . 'composer.json')) {
$composer_file_contents = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json');
} else {
$composer_file_contents = "No composer.json file detected; you MUST install composer by hitting the SETUP link below.>";
}
Expand All @@ -94,9 +95,9 @@ public function indexAction(\Base $fw): void {
$params = [
'command_return' => $ret,
'composer_file_contents' => $composer_file_contents,
'composer_file_path' => $root.'/composer.json'
'composer_file_path' => $root.DIRECTORY_SEPARATOR.'composer.json'
];

$this->renderHtml('manage_composer/index.htm', $params);
$this->renderHtml('manage_composer'.DIRECTORY_SEPARATOR.'index.htm', $params);
}
}
6 changes: 3 additions & 3 deletions controllers/Model_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
class Model_Controller extends Base_Controller {
public function indexAction(\Base $fw): void {
$models = $this->getModels();
$this->renderHtml('models/index.htm', [ 'models' => $models ]);
$this->renderHtml('models'.DIRECTORY_SEPARATOR.'index.htm', [ 'models' => $models ]);
}

public function addAction(\Base $fw): void {
$this->renderHtml('models/add.htm');
$this->renderHtml('models'.DIRECTORY_SEPARATOR.'add.htm');
}

public function create(\Base $fw, array $args = []): void {
Expand Down Expand Up @@ -54,7 +54,7 @@ public function createModelFile(string $model_name, string $table_name): bool {
throw new \Exception('The model already exists');
}

$contents = $this->fw->read(__DIR__.'/../templates/Model.php');
$contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Model.php');
$contents = str_replace([ '<?php', '#model_name#', '#table_name#' ], [ '#?php', $purified_model_name, $table_name ], $contents);
$contents = \Template::instance()->resolve($contents);
$write_result = $this->fw->write($full_path, str_replace('#?php', '<?php', $contents));
Expand Down
2 changes: 1 addition & 1 deletion controllers/Plugin_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function indexAction(\Base $fw): void {
],
];
ksort($projects['projects']);
$this->renderHtml('plugins/index.htm', $projects);
$this->renderHtml('plugins'.DIRECTORY_SEPARATOR.'index.htm', $projects);
}

public static function hasPackageInstalled(string $package_name): bool {
Expand Down
4 changes: 2 additions & 2 deletions controllers/Route_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(\Base $fw) {

public function indexAction(\Base $fw): void {
$routes = $this->getRoutes();
$this->renderHtml('routes/index.htm', [ 'routes' => $routes ]);
$this->renderHtml('routes'.DIRECTORY_SEPARATOR.'index.htm', [ 'routes' => $routes ]);
}

public function addAction(\Base $fw): void {
Expand All @@ -25,7 +25,7 @@ public function addAction(\Base $fw): void {
foreach($controllers as &$controller) {
$controller['endpoints'] = $Controller_Controller->getControllerEndpointMethods($controller['base_name']);
}
$this->renderHtml('routes/add.htm', [
$this->renderHtml('routes'.DIRECTORY_SEPARATOR.'add.htm', [
'controllers' => $controllers
]);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$fw = Base::instance();

// Define some constants you may need
define('PROJECT_DEVTOOLS_DATA_DIR', PROJECT_ROOT_DIR.'.fatfree-devtools/');
define('PROJECT_DEVTOOLS_DATA_DIR', PROJECT_ROOT_DIR.'.fatfree-devtools'.DIRECTORY_SEPARATOR);

// This will hold the config settings necessary for your routes, variables, connection settings, etc.
$fw->config(PROJECT_ROOT_DIR.'{{ @cnf_config }}main_config.ini', true);
Expand Down
10 changes: 5 additions & 5 deletions templates/config.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[globals]

; Various config options
AUTOLOAD = "../{{ @cnf_controller }}; ../{{ @cnf_model }}; ../{{ @cnf_utils }}; ../{{ @cnf_task }}; {{ @cnf_autoload ? '../'.@cnf_autoload : '' }}"
AUTOLOAD = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_controller }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_model }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_utils }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_task }}; {{ @cnf_autoload ? '..'.DIRECTORY_SEPARATOR.@cnf_autoload : '' }}"
CACHE = {{ @cnf_cache }}
DEBUG = {{ @cnf_debug }}
ENCODING = {{ @cnf_encoding }}
ESCAPE = {{ @cnf_escape ? 'true' : 'false' }}
HALT = {{ @cnf_halt ? 'true' : 'false' }}
HIGHLIGHT = {{ @cnf_highlight ? 'true' : 'false' }}
UI = "../{{ @cnf_ui }}"
LOGS = "../{{ @cnf_log }}"
TEMP = "../{{ @cnf_temp }}"
UPLOADS = "../{{ @cnf_uploads }}"
UI = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_ui }}"
LOGS = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_log }}"
TEMP = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_temp }}"
UPLOADS = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_uploads }}"
; Removing the 'Fat-Free Framework' reference for security reasons
PACKAGE = ""
<check if="{{ !empty(@cnf_mysql_name) }}">
Expand Down
4 changes: 2 additions & 2 deletions templates/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

DEFINE("PROJECT_ROOT_DIR", __DIR__.'/../');
require(__DIR__.'/../{{ @cnf_config }}bootstrap.php');
DEFINE("PROJECT_ROOT_DIR", __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR);
require(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'{{ @cnf_config }}bootstrap.php');

$fw->run();
6 changes: 3 additions & 3 deletions templates/main_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
; Don't edit this file directly! Edit one of the files below!
;
; Main config for variables, connection information, etc.
../{{ @cnf_config }}{{ @cnf_general_config }} = false
..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_general_config }} = false

; Routes for all your URL endpoints
../{{ @cnf_config }}{{ @cnf_routes }} = false
..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_routes }} = false

; Routes for all your CLI scripts
../{{ @cnf_config }}{{ @cnf_cli_routes }} = false
..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_cli_routes }} = false
2 changes: 1 addition & 1 deletion utils/ComposerInterfaceAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function php_shell($script) {
// path to php binary
$phpbin = $this->_config->composer_phpbin;

// path to composer home ; will be set in the shell environment. We recommand defining a home value
// path to composer home ; will be set in the shell environment. We recommend defining a home value
// in the parent folder of the project, allowing sharing data between projects
if ( $this->_config->composer_home ) {
$home = $this->_config->composer_home;
Expand Down

0 comments on commit ed20b06

Please sign in to comment.