Skip to content

Commit

Permalink
Remove SiteMesh 2 (grails#13492)
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole authored Apr 30, 2024
1 parent 60c9c4c commit 34bba33
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ import org.grails.web.servlet.mvc.GrailsWebRequest
import org.grails.web.servlet.mvc.exceptions.ControllerExecutionException
import org.grails.web.servlet.view.CompositeViewResolver
import org.grails.web.servlet.view.GroovyPageView
import org.grails.web.sitemesh.GrailsLayoutView
import org.grails.web.sitemesh.GroovyPageLayoutFinder
import org.grails.web.util.GrailsApplicationAttributes
import org.springframework.beans.factory.NoSuchBeanDefinitionException
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.http.HttpStatus
Expand Down Expand Up @@ -69,15 +67,8 @@ trait ResponseRenderer extends WebAttributes {


private MimeUtility mimeUtility
private GroovyPageLayoutFinder groovyPageLayoutFinder
private GrailsPluginManager pluginManager

@Generated
@Autowired(required = false)
void setGroovyPageLayoutFinder(GroovyPageLayoutFinder groovyPageLayoutFinder) {
this.groovyPageLayoutFinder = groovyPageLayoutFinder
}

@Generated
@Autowired(required = false)
@Qualifier("grailsMimeUtility")
Expand Down Expand Up @@ -307,17 +298,9 @@ trait ResponseRenderer extends WebAttributes {

boolean renderWithLayout = (explicitSiteMeshLayout || webRequest.getCurrentRequest().getAttribute(GroovyPageLayoutFinder.LAYOUT_ATTRIBUTE))
// if automatic decoration occurred unwrap, since this is a partial
if(view instanceof GrailsLayoutView) {
view = ((GrailsLayoutView)view).getInnerView()
}

if(renderWithLayout && groovyPageLayoutFinder) {
if (renderWithLayout) {
applySiteMeshLayout webRequest.currentRequest, false, explicitSiteMeshLayout
try {
view = new GrailsLayoutView(groovyPageLayoutFinder, view)
} catch (NoSuchBeanDefinitionException e) {
// ignore
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.grails.web.servlet.mvc

import grails.testing.web.controllers.ControllerUnitTest
import org.grails.web.sitemesh.GroovyPageLayoutFinder
import spock.lang.Specification
import grails.artefact.Artefact
import org.grails.web.sitemesh.GrailsLayoutDecoratorMapper
import org.grails.buffer.FastStringWriter

class RenderDynamicMethodTests extends Specification implements ControllerUnitTest<RenderDynamicMethodTestController> {
Expand All @@ -15,7 +15,7 @@ class RenderDynamicMethodTests extends Specification implements ControllerUnitTe
then:
response.contentType == response.contentType
response.contentAsString == response.contentAsString
request.getAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE) == "bar"
request.getAttribute(GroovyPageLayoutFinder.LAYOUT_ATTRIBUTE) == "bar"
}

void testRenderView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ grails.converters.encoding="UTF-8"
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true

// enable GSP preprocessing: replace head -> g:captureHead, title -> g:captureTitle, meta -> g:captureMeta, body -> g:captureBody
grails.views.gsp.sitemesh.preprocess = true

// set per-environment serverURL stem for creating absolute links
environments {
production {
Expand All @@ -60,7 +57,6 @@ log4j = {

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import grails.web.mapping.UrlMappingsHolder;
import org.grails.web.util.GrailsApplicationAttributes;
import org.grails.web.servlet.mvc.exceptions.GrailsMVCException;
import org.grails.web.sitemesh.GrailsContentBufferingResponse;
import org.grails.web.util.WebUtils;
import org.codehaus.groovy.runtime.InvokerInvocationException;
import org.springframework.beans.BeanUtils;
Expand Down Expand Up @@ -192,10 +191,6 @@ protected ModelAndView resolveViewOrForward(Exception ex, UrlMappingsHolder urlM
else if (info != null && info.getControllerName() != null) {
String uri = determineUri(request);
if (!response.isCommitted()) {
if(response instanceof GrailsContentBufferingResponse) {
// clear the output from sitemesh before rendering error page
((GrailsContentBufferingResponse)response).deactivateSitemesh();
}
forwardRequest(info, request, response, mv, uri);
// return an empty ModelAndView since the error handler has been processed
return new ModelAndView();
Expand Down
5 changes: 0 additions & 5 deletions grails-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ dependencies {
exclude group:'org.grails', module:'grails-encoder'
exclude group:'org.grails', module:'grails-web-common'
}
compileOnly "org.grails:grails-web-sitemesh:$gspVersion", {
exclude group:'org.grails', module:'grails-core'
exclude group:'org.grails', module:'grails-encoder'
exclude group:'org.grails', module:'grails-web-common'
}
}

0 comments on commit 34bba33

Please sign in to comment.