Skip to content

Commit

Permalink
Revert "Rework GSP encoding settings"
Browse files Browse the repository at this point in the history
This reverts commit 50a4b77.
  • Loading branch information
graemerocher committed Sep 3, 2015
1 parent 805b18e commit 1ad4d4d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.grails.gsp;

import grails.config.Config;
import grails.config.Settings;
import grails.core.GrailsApplication;
import grails.core.GrailsClass;
Expand Down Expand Up @@ -99,7 +98,7 @@ public class GroovyPagesTemplateEngine extends ResourceAwareTemplateEngine imple

private GrailsApplication grailsApplication;
private Map<String, Class<?>> cachedDomainsWithoutPackage;
private String gspEncoding = System.getProperty("file.encoding", "us-ascii");

private List<GroovyPageSourceDecorator> groovyPageSourceDecorators = new ArrayList();

static {
Expand Down Expand Up @@ -810,11 +809,14 @@ public void setBeanClassLoader(ClassLoader beanClassLoader) {
}
}

public void setGspEncoding(String gspEncoding) {
this.gspEncoding = gspEncoding;
}

public String getGspEncoding() {
return this.gspEncoding;
Map<?, ?> config = Holders.getFlatConfig();
if (config != null) {
Object gspEnc = config.get(GroovyPageParser.CONFIG_PROPERTY_GSP_ENCODING);
if ((gspEnc != null) && (gspEnc.toString().trim().length() > 0)) {
return gspEnc.toString();
}
}
return System.getProperty("file.encoding", "us-ascii");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package org.grails.gsp.compiler;

import grails.config.Config;
import grails.config.Settings;
import grails.io.IOUtils;
import grails.plugins.GrailsPluginInfo;
import grails.util.Environment;
Expand Down Expand Up @@ -129,7 +127,7 @@ public class GroovyPageParser implements Tokens {
"grails.util.GrailsUtil"
};
public static final String CONFIG_PROPERTY_DEFAULT_CODEC = "grails.views.default.codec";
public static final String CONFIG_PROPERTY_GSP_ENCODING = Settings.GSP_VIEW_ENCODING;
public static final String CONFIG_PROPERTY_GSP_ENCODING = "grails.views.gsp.encoding";
public static final String CONFIG_PROPERTY_GSP_KEEPGENERATED_DIR = "grails.views.gsp.keepgenerateddir";
public static final String CONFIG_PROPERTY_GSP_SITEMESH_PREPROCESS = "grails.views.gsp.sitemesh.preprocess";
public static final String CONFIG_PROPERTY_GSP_CODECS = "grails.views.gsp.codecs";
Expand Down Expand Up @@ -205,11 +203,13 @@ public GroovyPageParser(String name, String uri, String filename, String gspSour
}

public GroovyPageParser(String name, String uri, String filename, String gspSource, String expressionCodecName) throws IOException {
Config config = Holders.getConfig();
Map<?, ?> config = Holders.getFlatConfig();
if (config != null) {
setEnableSitemeshPreprocessing(
config.getProperty(GroovyPageParser.CONFIG_PROPERTY_GSP_SITEMESH_PREPROCESS, Boolean.class, true)
);
Object sitemeshPreprocessEnabled = config.get(GroovyPageParser.CONFIG_PROPERTY_GSP_SITEMESH_PREPROCESS);
if (sitemeshPreprocessEnabled != null) {
final boolean enableSitemeshPreprocessing = GrailsStringUtils.toBoolean(String.valueOf(sitemeshPreprocessEnabled).trim());
setEnableSitemeshPreprocessing(enableSitemeshPreprocessing);
}
}

GrailsPluginInfo pluginInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.grails.plugins.web
import grails.config.Config
import grails.config.Settings
import grails.core.GrailsClass
import grails.core.GrailsTagLibClass
import grails.gsp.PageRenderer
Expand All @@ -31,7 +30,6 @@ import org.grails.buffer.StreamCharBufferMetaUtils
import org.grails.core.artefact.TagLibArtefactHandler
import org.grails.gsp.GroovyPageResourceLoader
import org.grails.gsp.GroovyPagesTemplateEngine
import org.grails.gsp.compiler.GroovyPageParser
import org.grails.gsp.io.CachingGroovyPageStaticResourceLocator
import org.grails.gsp.jsp.TagLibraryResolverImpl
import org.grails.plugins.web.taglib.*
Expand Down Expand Up @@ -213,7 +211,6 @@ class GroovyPagesGrailsPlugin extends Plugin {
tagLibraryLookup = gspTagLibraryLookup
jspTagLibraryResolver = jspTagLibraryResolver
cacheResources = enableCacheResources
gspEncoding = config.getProperty(Settings.GSP_VIEW_ENCODING, System.getProperty("file.encoding", "us-ascii"))
}

spring.addAlias('groovyTemplateEngine', 'groovyPagesTemplateEngine')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public View call() throws Exception {
* @return prefix for cache key that contains current controller's context (currently plugin and namespace)
*/
protected String resolveCurrentControllerKeyPrefixes() {
String pluginContextPath;
String namespace;
String pluginContextPath = null;
String namespace = null;
GrailsWebRequest webRequest = GrailsWebRequest.lookup();
if(webRequest != null) {
namespace = webRequest.getControllerNamespace();
Expand Down

0 comments on commit 1ad4d4d

Please sign in to comment.