Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging to Production #577

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/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/[email protected]/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/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/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/[email protected]/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>