mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 04:15:17 +00:00
First version of the build system
This commit is contained in:
69
system/config/build.config.php
Normal file
69
system/config/build.config.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP build config for the website
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
class Build {
|
||||
|
||||
/**
|
||||
* Site URL
|
||||
*/
|
||||
const SITE_URL = "http://devweb.local/comunic/v2/output/";
|
||||
|
||||
/**
|
||||
* Site production mode
|
||||
*/
|
||||
const PROD_MODE = TRUE;
|
||||
|
||||
/**
|
||||
* Path to assets (relative to the build folder)
|
||||
*/
|
||||
const PATH_ASSETS = "assets/";
|
||||
|
||||
/**
|
||||
* Path to assets (URL)
|
||||
*/
|
||||
const ASSETS_URL = "http://devweb.local/comunic/v2/output/assets/";
|
||||
|
||||
/**
|
||||
* Third party CSS files
|
||||
*/
|
||||
const THIRD_PARTY_CSS = "third_party_css.css";
|
||||
|
||||
/**
|
||||
* Third party Javascript files
|
||||
*/
|
||||
const THIRD_PARTY_JS = "third_party.js";
|
||||
|
||||
/**
|
||||
* Third party Javascript files (bundle)
|
||||
*/
|
||||
const THIRD_PARTY_BUNDLE_JS = "third_party.bundle.js";
|
||||
|
||||
/**
|
||||
* Application CSS files
|
||||
*/
|
||||
const APP_CSS = "app.css";
|
||||
|
||||
/**
|
||||
* Application JS files
|
||||
*/
|
||||
const APP_JS = "app.js";
|
||||
|
||||
/**
|
||||
* Application JS files (bundles)
|
||||
*/
|
||||
const APP_BUNDLE_JS = "app.bundle.js";
|
||||
|
||||
/**
|
||||
* Language settings
|
||||
*/
|
||||
const DEFAULT_LANGUAGE = "en";
|
||||
|
||||
/**
|
||||
* Templates settings
|
||||
*/
|
||||
const TEMPLATES_PATH = "templates/";
|
||||
}
|
@ -18,7 +18,12 @@ class Dev {
|
||||
const PROD_MODE = false;
|
||||
|
||||
/**
|
||||
* Path to assets
|
||||
* Path to assets (relative to the base project)
|
||||
*/
|
||||
const PATH_ASSETS = "assets/";
|
||||
|
||||
/**
|
||||
* URL to assets
|
||||
*/
|
||||
const ASSETS_URL = "http://devweb.local/comunic/v2/assets/";
|
||||
|
||||
@ -30,6 +35,7 @@ class Dev {
|
||||
"3rdparty/adminLTE/bootstrap/css/bootstrap.min.css",
|
||||
"3rdparty/adminLTE/plugins/font-awesome/css/font-awesome.min.css",
|
||||
"3rdparty/adminLTE/plugins/ionicons/css/ionicons.min.css",
|
||||
"3rdparty/adminLTE/plugins/googleFonts/css.css",
|
||||
|
||||
//iCheck
|
||||
"3rdparty/adminLTE/plugins/iCheck/square/blue.css",
|
||||
|
@ -16,10 +16,10 @@ require_once __DIR__."/config/global.config.php";
|
||||
* @param string $config The configuration to use to load a page
|
||||
* @return string Generated source page
|
||||
*/
|
||||
function load_page(string $config) : string{
|
||||
function load_page(string $config) : string {
|
||||
|
||||
//Load configuration
|
||||
require __DIR__."/config/".$config.".config.php";
|
||||
load_config($config);
|
||||
$conf = new $config();
|
||||
|
||||
//Load page template
|
||||
@ -32,14 +32,31 @@ function load_page(string $config) : string{
|
||||
$source = str_replace("{js_config}", get_javascript_config($conf), $source);
|
||||
|
||||
//Update assets inclusion
|
||||
$source = str_replace("{THIRD_PARTY_CSS}", src_inc_list_css($conf::ASSETS_URL, $conf::THIRD_PARTY_CSS), $source);
|
||||
$source = str_replace("{APP_CSS}", src_inc_list_css($conf::ASSETS_URL, $conf::APP_CSS), $source);
|
||||
$source = str_replace("{THIRD_PARTY_JS}", src_inc_list_js($conf::ASSETS_URL, $conf::THIRD_PARTY_JS), $source);
|
||||
$source = str_replace("{APP_JS}", src_inc_list_js($conf::ASSETS_URL, $conf::APP_JS), $source);
|
||||
if(is_array($conf::THIRD_PARTY_CSS)){
|
||||
$source = str_replace("{THIRD_PARTY_CSS}", src_inc_list_css($conf::ASSETS_URL, $conf::THIRD_PARTY_CSS), $source);
|
||||
$source = str_replace("{APP_CSS}", src_inc_list_css($conf::ASSETS_URL, $conf::APP_CSS), $source);
|
||||
$source = str_replace("{THIRD_PARTY_JS}", src_inc_list_js($conf::ASSETS_URL, $conf::THIRD_PARTY_JS), $source);
|
||||
$source = str_replace("{APP_JS}", src_inc_list_js($conf::ASSETS_URL, $conf::APP_JS), $source);
|
||||
}
|
||||
else {
|
||||
$source = str_replace("{THIRD_PARTY_CSS}", src_inc_css($conf::ASSETS_URL.$conf::THIRD_PARTY_CSS), $source);
|
||||
$source = str_replace("{APP_CSS}", src_inc_css($conf::ASSETS_URL.$conf::APP_CSS), $source);
|
||||
$source = str_replace("{THIRD_PARTY_JS}", src_inc_js($conf::ASSETS_URL.$conf::THIRD_PARTY_JS), $source);
|
||||
$source = str_replace("{APP_JS}", src_inc_js($conf::ASSETS_URL.$conf::APP_JS), $source);
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a configuration
|
||||
*
|
||||
* @param string $name The name of the configuration to load
|
||||
*/
|
||||
function load_config(string $config){
|
||||
require_once __DIR__."/config/".$config.".config.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get javascript configuration
|
||||
*
|
||||
@ -74,8 +91,8 @@ function get_javascript_config($config) : string {
|
||||
//Default language
|
||||
defaultLanguage: '".$config::DEFAULT_LANGUAGE."',
|
||||
|
||||
//LanguagesPath
|
||||
languagesPath: '".$config::ASSETS_URL.$config::LANGUAGE_PATH."',
|
||||
"/*LanguagesPath
|
||||
"languagesPath: '".$config::ASSETS_URL.$config::LANGUAGE_PATH."', */."
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user