mirror of https://github.com/halo-dev/halo
Merge remote-tracking branch 'origin/v1' into v1
commit
ea761fa73f
|
@ -14,7 +14,7 @@ import run.halo.app.service.ThemeService;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme activated listener.
|
* Freemarker config aware listener.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-20
|
* @date 19-4-20
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class ThemeActivatedEvent extends ApplicationEvent {
|
||||||
private final ThemeProperty themeProperty;
|
private final ThemeProperty themeProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ApplicationEvent.
|
* Creates a new ApplicationEvent.
|
||||||
*
|
*
|
||||||
* @param source the object on which the event initially occurred (never {@code null})
|
* @param source the object on which the event initially occurred (never {@code null})
|
||||||
* @param themeProperty theme property must not be null
|
* @param themeProperty theme property must not be null
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package run.halo.app.listener;
|
package run.halo.app.listener;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import freemarker.template.TemplateModelException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
|
@ -36,12 +34,6 @@ import java.util.Map;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class StartedListener implements ApplicationListener<ApplicationStartedEvent> {
|
public class StartedListener implements ApplicationListener<ApplicationStartedEvent> {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private freemarker.template.Configuration configuration;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HaloProperties haloProperties;
|
private HaloProperties haloProperties;
|
||||||
|
|
||||||
|
@ -61,7 +53,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
public void onApplicationEvent(ApplicationStartedEvent event) {
|
public void onApplicationEvent(ApplicationStartedEvent event) {
|
||||||
// save halo version to database
|
// save halo version to database
|
||||||
this.cacheOwo();
|
this.cacheOwo();
|
||||||
// this.cacheActiveTheme();
|
|
||||||
this.printStartInfo();
|
this.printStartInfo();
|
||||||
this.initThemes();
|
this.initThemes();
|
||||||
|
|
||||||
|
@ -92,17 +83,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get active theme
|
|
||||||
*/
|
|
||||||
private void cacheActiveTheme() {
|
|
||||||
try {
|
|
||||||
configuration.setSharedVariable("theme", themeService.getActivatedTheme());
|
|
||||||
} catch (TemplateModelException e) {
|
|
||||||
log.error("", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printStartInfo() {
|
private void printStartInfo() {
|
||||||
String blogUrl = optionService.getBlogBaseUrl();
|
String blogUrl = optionService.getBlogBaseUrl();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue