Skip to content

Commit

Permalink
Update layout resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan committed Sep 5, 2023
1 parent 9ea68b7 commit 6af8d14
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
}
// Common data for the layout file.
// temporarily commented during unification
// layoutData.put("BASE_URL", layoutStoreURL.replace("${tenantDomain}", tenantRequestingPreferences));
layoutData.put("BASE_URL", "includes/layouts/" + layout);
if (brandingPreference != null) {
// First, check if Branding is enabled.
Expand Down Expand Up @@ -66,28 +65,33 @@
if (StringUtils.equals(temp, "custom")) {
String tempLayout = "";
String tempLayoutFileRelativePath = "";
String tempBaseURL = "";
// App-wise and tenant-wise custom layout resolving logic.
if (StringUtils.equals(preferenceResourceType, APP_PREFERENCE_RESOURCE_TYPE)) {
tempLayout = temp + "-" + tenantRequestingPreferences + "-" + applicationRequestingPreferences;
tempLayoutFileRelativePath = layoutStoreURL.replace("${tenantDomain}", tenantRequestingPreferences) + "/apps/" + applicationRequestingPreferences + "/body.ser";
tempBaseURL = layoutStoreURL.replace("${tenantDomain}", tenantRequestingPreferences) + "/apps/" + applicationRequestingPreferences;
}
if (config.getServletContext().getResource(tempLayoutFileRelativePath) == null || StringUtils.equals(preferenceResourceType, ORG_PREFERENCE_RESOURCE_TYPE)) {
tempLayout = temp + "-" + tenantRequestingPreferences;
tempLayoutFileRelativePath = layoutStoreURL.replace("${tenantDomain}", tenantRequestingPreferences) + "/body.ser";
tempBaseURL = layoutStoreURL.replace("${tenantDomain}", tenantRequestingPreferences);
}
if (config.getServletContext().getResource(tempLayoutFileRelativePath) != null) {
layout = tempLayout;
layoutFileRelativePath = tempLayoutFileRelativePath;
layoutData.put("BASE_URL", tempBaseURL);
}
} else {
// Pre-added layouts
String layoutFilePath = "includes/layouts/" + temp + "/body.ser";
if (config.getServletContext().getResource(layoutFilePath) != null) {
layout = temp;
layoutFileRelativePath = layoutFilePath;
layoutData.put("BASE_URL", "includes/layouts/" + temp);
// Get the related data to specific layouts.
if (brandingPreference.getJSONObject(LAYOUT_KEY).has(LAYOUT_ATTRIBUTE_SIDE_IMAGE_KEY)) {
Expand All @@ -110,4 +114,4 @@
}
}
}
%>
%>

0 comments on commit 6af8d14

Please sign in to comment.