kwin commented on code in PR #610:
URL: 
https://github.com/apache/maven-doxia-sitetools/pull/610#discussion_r2842061934


##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -931,6 +939,51 @@ private static void copyFileFromResource(String name, File 
destFile) throws IOEx
         }
     }
 
+    private boolean isResourceRelevant(String name, Context velocityContext, 
Map<String, String> resourceConditions) {
+        if (resourceConditions == null || 
!resourceConditions.containsKey(name)) {
+            LOGGER.debug("No condition for resource: {}", name);
+        } else {
+            String condition = resourceConditions.get(name);
+            LOGGER.debug("Evaluating condition for resource: {} with 
condition: {}", name, condition);
+            StringWriter writer = new StringWriter();
+            Velocity.evaluate(velocityContext, writer, 
"conditional-resource-evaluation", condition);
+            String result = writer.toString().trim();
+            LOGGER.debug("Condition evaluation result: {}", result);
+            if (!Boolean.parseBoolean(result)) {
+                LOGGER.debug("Excluding resource: {}", name);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private Map<String, String> createResourceConditionsMap(SkinModel 
skinModel) {
+        if (skinModel == null) {
+            LOGGER.debug("No skin model provided, so no resource conditions 
will be applied.");
+            return Collections.emptyMap();
+        }
+        Map<String, String> resourceConditions = new HashMap<>();
+        for (ResourceCondition resource : skinModel.getResourceConditions()) {
+            if (resource.getVtlCondition() != null
+                    && !resource.getVtlCondition().isEmpty()) {
+                for (String resourceName : resource.getResourceNames()) {
+                    if (resourceConditions.containsKey(resourceName)) {
+                        LOGGER.warn(
+                                "Multiple conditions found for resource '{}'. 
Only the first one will be used.",
+                                resourceName);
+                        continue;
+                    }
+                    LOGGER.debug(
+                            "Adding condition for resource: {} with condition: 
{}",

Review Comment:
   Done in 
https://github.com/apache/maven-doxia-sitetools/pull/610/commits/3496db9b0f1238d03f1e656e44d60feb1114184a.



##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -931,6 +939,51 @@ private static void copyFileFromResource(String name, File 
destFile) throws IOEx
         }
     }
 
+    private boolean isResourceRelevant(String name, Context velocityContext, 
Map<String, String> resourceConditions) {
+        if (resourceConditions == null || 
!resourceConditions.containsKey(name)) {
+            LOGGER.debug("No condition for resource: {}", name);
+        } else {
+            String condition = resourceConditions.get(name);
+            LOGGER.debug("Evaluating condition for resource: {} with 
condition: {}", name, condition);
+            StringWriter writer = new StringWriter();
+            Velocity.evaluate(velocityContext, writer, 
"conditional-resource-evaluation", condition);
+            String result = writer.toString().trim();
+            LOGGER.debug("Condition evaluation result: {}", result);
+            if (!Boolean.parseBoolean(result)) {
+                LOGGER.debug("Excluding resource: {}", name);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private Map<String, String> createResourceConditionsMap(SkinModel 
skinModel) {
+        if (skinModel == null) {
+            LOGGER.debug("No skin model provided, so no resource conditions 
will be applied.");
+            return Collections.emptyMap();
+        }
+        Map<String, String> resourceConditions = new HashMap<>();
+        for (ResourceCondition resource : skinModel.getResourceConditions()) {
+            if (resource.getVtlCondition() != null
+                    && !resource.getVtlCondition().isEmpty()) {
+                for (String resourceName : resource.getResourceNames()) {
+                    if (resourceConditions.containsKey(resourceName)) {
+                        LOGGER.warn(
+                                "Multiple conditions found for resource '{}'. 
Only the first one will be used.",
+                                resourceName);
+                        continue;
+                    }
+                    LOGGER.debug(
+                            "Adding condition for resource: {} with condition: 
{}",

Review Comment:
   Done in 
https://github.com/apache/maven-doxia-sitetools/pull/610/commits/3496db9b0f1238d03f1e656e44d60feb1114184a.



##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -931,6 +939,51 @@ private static void copyFileFromResource(String name, File 
destFile) throws IOEx
         }
     }
 
+    private boolean isResourceRelevant(String name, Context velocityContext, 
Map<String, String> resourceConditions) {
+        if (resourceConditions == null || 
!resourceConditions.containsKey(name)) {
+            LOGGER.debug("No condition for resource: {}", name);
+        } else {
+            String condition = resourceConditions.get(name);
+            LOGGER.debug("Evaluating condition for resource: {} with 
condition: {}", name, condition);

Review Comment:
   Done in 
https://github.com/apache/maven-doxia-sitetools/pull/610/commits/3496db9b0f1238d03f1e656e44d60feb1114184a.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to