Skip to content

Commit

Permalink
Merge pull request #577 from PAWECOGmbH/staging
Browse files Browse the repository at this point in the history
Staging to Production
  • Loading branch information
ptruessel authored Dec 6, 2024
2 parents e55ae25 + 6f2ea6c commit b7ec347
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 20 deletions.
3 changes: 3 additions & 0 deletions www/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
// Load layout setting struct and save it into the application scope
application.layoutStruct = application.objLayout.layoutSetting(application.systemSettingStruct.settingLayout);

// Load JS and CSS path
application.assetFiles = application.objCoreUtil.getAssets(variables.activeTheme);

ownApplicationStart();

return true;
Expand Down
86 changes: 86 additions & 0 deletions www/frontend/core/com/coreutility.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,91 @@
component displayname="coreutility" output="false" {

/**
* Returns the paths to the CSS and JS files, including versions if available, preferring minified files.
*/
public struct function getAssets(required string theme) {

local.result = {};
local.systemPath = expandPath("frontend/" & arguments.theme & "/");
local.wwwPath = application.mainURL & "/frontend/" & arguments.theme & "/";

// Standard CSS file
local.cssFile = local.wwwPath & "css/styles.css";

// Standard JS file
local.jsFile = local.wwwPath & "js/scripts.js";


// CSS handling
if (fileExists(local.systemPath & "css/styles.min.css")) {

// Minimized CSS file
local.cssFile = local.wwwPath & "css/styles.min.css";

// JSON file with the current version for the CSS
local.cssVFile = local.systemPath & "css/version.json";

if (fileExists(local.cssVFile)) {

// Read the JSON file
local.jsonFile = fileRead(local.cssVFile);

if (isJSON(local.jsonFile)) {

// Extract the version number and append it to the css
local.jsonContent = deserializeJSON(local.jsonFile);
if (structKeyExists(local.jsonContent, "version")) {
local.cssVersion = local.jsonContent.version;
local.cssFile = local.cssFile & "?v=" & local.cssVersion;
}

}

}

}

local.result["css"] = local.cssFile;


// JS handling
if (fileExists(local.systemPath & "js/scripts.min.js")) {

// Minimized JS file
local.jsFile = local.wwwPath & "js/scripts.min.js";

// JSON file with the current version for the CSS
local.jsVFile = local.systemPath & "js/version.json";

if (fileExists(local.jsVFile)) {

// Read the JSON file
local.jsonFile = fileRead(local.jsVFile);

if (isJSON(local.jsonFile)) {

// Extract the version number and append it to the js
local.jsonContent = deserializeJSON(local.jsonFile);
if (structKeyExists(local.jsonContent, "version")) {
local.jsVersion = local.jsonContent.version;
local.jsFile = local.jsFile & "?v=" & local.jsVersion;
}

}

}

}

local.result["js"] = local.jsFile;

return local.result;

}




/**
* Prepares session data for the registration form and initializes default values if needed.
*/
Expand Down
6 changes: 1 addition & 5 deletions www/frontend/custom_theme/css/css-include.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
<cfoutput>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<cfif fileExists("/frontend/#application.activeTheme#/css/styles-min.css")>
<link rel="stylesheet" type="text/css" href="/frontend/#application.activeTheme#/css/styles-min.css?v=123456789" />
<cfelse>
<link rel="stylesheet" type="text/css" href="/frontend/#application.activeTheme#/css/styles.css" />
</cfif>
<link rel="stylesheet" type="text/css" href="#application.assetFiles.css#" />
</cfoutput>
6 changes: 1 addition & 5 deletions www/frontend/custom_theme/js/js-include.cfm
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

<cfoutput>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<cfif fileExists("/frontend/#application.activeTheme#/js/scripts-min.js")>
<script src="/frontend/#application.activeTheme#/js/scripts-min.js?v=1.0.0"></script>
<cfelse>
<script src="/frontend/#application.activeTheme#/js/scripts.js"></script>
</cfif>
<script src="#application.assetFiles.js#"></script>
</cfoutput>
6 changes: 1 addition & 5 deletions www/frontend/default_theme/css/css-include.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
<cfoutput>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<cfif fileExists("/frontend/#application.activeTheme#/css/styles-min.css")>
<link rel="stylesheet" type="text/css" href="/frontend/#application.activeTheme#/css/styles-min.css?v=123456789" />
<cfelse>
<link rel="stylesheet" type="text/css" href="/frontend/#application.activeTheme#/css/styles.css" />
</cfif>
<link rel="stylesheet" type="text/css" href="#application.assetFiles.css#" />
</cfoutput>
6 changes: 1 addition & 5 deletions www/frontend/default_theme/js/js-include.cfm
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

<cfoutput>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<cfif fileExists("/frontend/#application.activeTheme#/js/scripts-min.js")>
<script src="/frontend/#application.activeTheme#/js/scripts-min.js?v=1.0.0"></script>
<cfelse>
<script src="/frontend/#application.activeTheme#/js/scripts.js"></script>
</cfif>
<script src="#application.assetFiles.js#"></script>
</cfoutput>

0 comments on commit b7ec347

Please sign in to comment.