Skip to content

Commit

Permalink
Merge pull request #301 from rainboyan/sitemesh_2_6
Browse files Browse the repository at this point in the history
Upgrade to SiteMesh 2.6.0-M1

Closes gh-299
  • Loading branch information
rainboyan authored Jun 11, 2024
2 parents 0560b5a + ab16621 commit f0cef1f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 473 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2023 the original author or authors.
* Copyright 2014-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,16 @@
*/
package org.grails.web.servlet.view;

import java.util.Collections;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Map;

import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletContext;

import com.opensymphony.module.sitemesh.Config;
import com.opensymphony.module.sitemesh.Factory;
import com.opensymphony.module.sitemesh.factory.DefaultFactory;
import com.opensymphony.sitemesh.ContentProcessor;
import com.opensymphony.sitemesh.compatability.PageParser2ContentProcessor;
import org.springframework.beans.factory.DisposableBean;
Expand All @@ -36,7 +38,6 @@
import grails.core.support.GrailsApplicationAware;

import org.grails.web.sitemesh.FactoryHolder;
import org.grails.web.sitemesh.Grails5535Factory;
import org.grails.web.sitemesh.GroovyPageLayoutFinder;
import org.grails.web.sitemesh.SitemeshLayoutView;

Expand Down Expand Up @@ -80,38 +81,33 @@ public void init() {

protected Factory loadSitemeshConfig() {
FilterConfig filterConfig = new FilterConfig() {
private final Map<String, String> customConfig =
Collections.singletonMap("configFile",
"classpath:org/grails/web/sitemesh/sitemesh-default.xml");

@Override
public ServletContext getServletContext() {
return servletContext;
}

@Override
public Enumeration<String> getInitParameterNames() {
return new Enumeration<String>() {
@Override
public boolean hasMoreElements() {
return false;
}

@Override
public String nextElement() {
throw new NoSuchElementException();
}
};
return Collections.enumeration(this.customConfig.keySet());
}

@Override
public String getInitParameter(String name) {
return null;
return this.customConfig.get(name);
}

@Override
public String getFilterName() {
return null;
}
};

Config config = new Config(filterConfig);
Grails5535Factory sitemeshFactory = new Grails5535Factory(config);
DefaultFactory sitemeshFactory = new DefaultFactory(config);
if (servletContext != null) {
servletContext.setAttribute(FACTORY_SERVLET_CONTEXT_ATTRIBUTE, sitemeshFactory);
}
Expand Down
2 changes: 1 addition & 1 deletion grace-web-sitemesh/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api libs.jakarta.servlet
api project(":grace-sitemesh")
api libs.sitemesh
api project(":grace-web-common")

testImplementation libs.spring.test
Expand Down
Loading

0 comments on commit f0cef1f

Please sign in to comment.