diff --git a/src/main/java/cc/ryanc/halo/config/WebMvcAutoConfiguration.java b/src/main/java/cc/ryanc/halo/config/WebMvcAutoConfiguration.java index babf87d13..4bfa7698c 100644 --- a/src/main/java/cc/ryanc/halo/config/WebMvcAutoConfiguration.java +++ b/src/main/java/cc/ryanc/halo/config/WebMvcAutoConfiguration.java @@ -18,15 +18,14 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; -import org.springframework.web.servlet.i18n.SessionLocaleResolver; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; +import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; import java.util.List; -import java.util.Locale; /** *
@@ -99,4 +98,25 @@ public class WebMvcAutoConfiguration implements WebMvcConfigurer {
     public void addFormatters(FormatterRegistry registry) {
         registry.addConverterFactory(new StringToEnumConverterFactory());
     }
+
+    @Bean
+    public FreeMarkerConfigurer freemarkerConfig() {
+        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
+        configurer.setTemplateLoaderPaths("file:///" + System.getProperties().getProperty("user.home") + "/halo/templates/", "classpath:/templates/");
+        configurer.setDefaultEncoding("UTF-8");
+        return configurer;
+    }
+
+    @Override
+    public void configureViewResolvers(ViewResolverRegistry registry) {
+        FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
+        resolver.setAllowRequestOverride(false);
+        resolver.setCache(false);
+        resolver.setExposeRequestAttributes(false);
+        resolver.setExposeSessionAttributes(false);
+        resolver.setExposeSpringMacroHelpers(true);
+        resolver.setSuffix(".ftl");
+        resolver.setContentType("text/html; charset=UTF-8");
+        registry.viewResolver(resolver);
+    }
 }
diff --git a/src/main/java/cc/ryanc/halo/utils/ThemeUtils.java b/src/main/java/cc/ryanc/halo/utils/ThemeUtils.java
index e5d9f6f5e..2d6c95693 100644
--- a/src/main/java/cc/ryanc/halo/utils/ThemeUtils.java
+++ b/src/main/java/cc/ryanc/halo/utils/ThemeUtils.java
@@ -74,7 +74,6 @@ public class ThemeUtils {
                             theme.setHasUpdate(false);
                         }
                         theme.setProperties(getProperties(new File(themesBasePath,file.getName())));
-                        theme.setInternal(isInternal);
                         themes.add(theme);
                     }
                 }
diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml
index 79ee9de0d..ccd090a67 100755
--- a/src/main/resources/application-dev.yaml
+++ b/src/main/resources/application-dev.yaml
@@ -38,18 +38,6 @@ spring:
     hibernate:
       ddl-auto: update
     show-sql: true
-  freemarker:
-    allow-request-override: false
-    cache: false
-    check-template-location: true
-    charset: utf-8
-    content-type: text/html
-    expose-request-attributes: false
-    expose-session-attributes: false
-    expose-spring-macro-helpers: true
-    suffix: .ftl
-    settings:
-      auto_import: /spring.ftl as spring
   servlet:
     multipart:
       max-file-size: 10MB
diff --git a/src/main/resources/application-test.yaml b/src/main/resources/application-test.yaml
index 1aca56950..0cb5c3938 100755
--- a/src/main/resources/application-test.yaml
+++ b/src/main/resources/application-test.yaml
@@ -38,18 +38,6 @@ spring:
     hibernate:
       ddl-auto: update
     show-sql: true
-  freemarker:
-    allow-request-override: false
-    cache: false
-    check-template-location: true
-    charset: utf-8
-    content-type: text/html
-    expose-request-attributes: false
-    expose-session-attributes: false
-    expose-spring-macro-helpers: true
-    suffix: .ftl
-    settings:
-      auto_import: /spring.ftl as spring
   servlet:
     multipart:
       max-file-size: 10MB
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index eda72587c..c34abb3cc 100755
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -40,18 +40,6 @@ spring:
     hibernate:
       ddl-auto: update
     show-sql: false
-  freemarker:
-    allow-request-override: false
-    cache: false
-    check-template-location: true
-    charset: utf-8
-    content-type: text/html
-    expose-request-attributes: false
-    expose-session-attributes: false
-    expose-spring-macro-helpers: true
-    suffix: .ftl
-    settings:
-      auto_import: /spring.ftl as spring
   servlet:
     multipart:
       max-file-size: 10MB
diff --git a/src/main/resources/templates/themes/anatole/module/macro.ftl b/src/main/resources/templates/themes/anatole/module/macro.ftl
index 41e4744fb..a2b8af5b9 100644
--- a/src/main/resources/templates/themes/anatole/module/macro.ftl
+++ b/src/main/resources/templates/themes/anatole/module/macro.ftl
@@ -11,7 +11,7 @@
     
     
     
-    
+    
     
     
     <@verification>