mirror of https://github.com/halo-dev/halo
feat: support set theme static source path type. (#535)
* feat: support set theme static source path type. * refactor: global_absolute_path_enabled property.pull/537/head
parent
474c2f369c
commit
6f6ed9ee07
|
@ -12,6 +12,7 @@ import run.halo.app.event.options.OptionUpdatedEvent;
|
||||||
import run.halo.app.event.theme.ThemeActivatedEvent;
|
import run.halo.app.event.theme.ThemeActivatedEvent;
|
||||||
import run.halo.app.event.user.UserUpdatedEvent;
|
import run.halo.app.event.user.UserUpdatedEvent;
|
||||||
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
||||||
|
import run.halo.app.model.properties.OtherProperties;
|
||||||
import run.halo.app.model.support.HaloConst;
|
import run.halo.app.model.support.HaloConst;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.ThemeService;
|
import run.halo.app.service.ThemeService;
|
||||||
|
@ -96,9 +97,14 @@ public class FreemarkerConfigAwareListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadThemeConfig() throws TemplateModelException {
|
private void loadThemeConfig() throws TemplateModelException {
|
||||||
|
|
||||||
|
// Get current activated theme.
|
||||||
ThemeProperty activatedTheme = themeService.getActivatedTheme();
|
ThemeProperty activatedTheme = themeService.getActivatedTheme();
|
||||||
|
|
||||||
|
Boolean enabledAbsolutePath = optionService.getByPropertyOrDefault(OtherProperties.GLOBAL_ABSOLUTE_PATH_ENABLED, Boolean.class, true);
|
||||||
|
|
||||||
configuration.setSharedVariable("theme", activatedTheme);
|
configuration.setSharedVariable("theme", activatedTheme);
|
||||||
configuration.setSharedVariable("static", optionService.getBlogBaseUrl() + "/" + activatedTheme.getFolderName());
|
configuration.setSharedVariable("static", (enabledAbsolutePath ? optionService.getBlogBaseUrl() : "") + "/" + activatedTheme.getFolderName());
|
||||||
configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
||||||
log.debug("Loaded theme and settings");
|
log.debug("Loaded theme and settings");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package run.halo.app.model.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global path type.
|
||||||
|
*
|
||||||
|
* @author ryanwang
|
||||||
|
* @date 2020-02-01
|
||||||
|
*/
|
||||||
|
public enum GlobalPathType implements ValueEnum<Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relative path.
|
||||||
|
*/
|
||||||
|
RELATIVE(0),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Absolute path.
|
||||||
|
*/
|
||||||
|
ABSOLUTE(1);
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
|
||||||
|
GlobalPathType(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,12 @@ public enum OtherProperties implements PropertyEnum {
|
||||||
/**
|
/**
|
||||||
* Statistics platform code,such as Google Analytics.
|
* Statistics platform code,such as Google Analytics.
|
||||||
*/
|
*/
|
||||||
STATISTICS_CODE("blog_statistics_code", String.class, "");
|
STATISTICS_CODE("blog_statistics_code", String.class, ""),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global absolute path enabled.
|
||||||
|
*/
|
||||||
|
GLOBAL_ABSOLUTE_PATH_ENABLED("global_absolute_path_enabled", Boolean.class, "true");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue