mirror of https://github.com/halo-dev/halo
Update anatole theme.
parent
77196780ee
commit
81ba6e3c5f
|
@ -9,6 +9,8 @@ import run.halo.app.model.freemarker.method.RecentCommentsMethod;
|
|||
import run.halo.app.model.freemarker.method.RecentPostsMethod;
|
||||
import run.halo.app.model.freemarker.tag.*;
|
||||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.service.ThemeService;
|
||||
import run.halo.app.service.ThemeSettingService;
|
||||
import run.halo.app.service.UserService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@ -32,6 +34,12 @@ public class FreeMarkerAutoConfiguration {
|
|||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private ThemeService themeService;
|
||||
|
||||
@Autowired
|
||||
private ThemeSettingService themeSettingService;
|
||||
|
||||
@Autowired
|
||||
private PostTagDirective postTagDirective;
|
||||
|
||||
|
@ -67,6 +75,7 @@ public class FreeMarkerAutoConfiguration {
|
|||
try {
|
||||
configuration.setSharedVariable("options", optionsService.listOptions());
|
||||
configuration.setSharedVariable("user", userService.getCurrentUser().orElse(null));
|
||||
configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
||||
//Freemarker custom tags
|
||||
configuration.setSharedVariable("categoryTag", categoryTagDirective);
|
||||
configuration.setSharedVariable("commentTag", commentTagDirective);
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
|||
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
||||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.service.ThemeService;
|
||||
import run.halo.app.service.ThemeSettingService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -29,12 +30,16 @@ public class FreemarkerConfigAwareListener {
|
|||
|
||||
private final ThemeService themeService;
|
||||
|
||||
private final ThemeSettingService themeSettingService;
|
||||
|
||||
public FreemarkerConfigAwareListener(OptionService optionService,
|
||||
Configuration configuration,
|
||||
ThemeService themeService) {
|
||||
ThemeService themeService,
|
||||
ThemeSettingService themeSettingService) {
|
||||
this.optionService = optionService;
|
||||
this.configuration = configuration;
|
||||
this.themeService = themeService;
|
||||
this.themeSettingService = themeSettingService;
|
||||
}
|
||||
|
||||
@Async
|
||||
|
@ -59,6 +64,8 @@ public class FreemarkerConfigAwareListener {
|
|||
Map<String, String> options = optionService.listOptions();
|
||||
log.debug("Set shared variable options: [{}]", options);
|
||||
configuration.setSharedVariable("options", options);
|
||||
log.debug("Set shared variable theme settings: [{}]", options);
|
||||
configuration.setSharedVariable("setting",themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
||||
} catch (TemplateModelException e) {
|
||||
log.warn("Failed to configure freemarker", e);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import run.halo.app.exception.ServiceException;
|
||||
import run.halo.app.handler.theme.config.support.Group;
|
||||
import run.halo.app.handler.theme.config.support.Item;
|
||||
import run.halo.app.model.entity.ThemeSetting;
|
||||
|
@ -31,11 +34,15 @@ public class ThemeSettingServiceImpl extends AbstractCrudService<ThemeSetting, I
|
|||
|
||||
private final ThemeService themeService;
|
||||
|
||||
private final Configuration configuration;
|
||||
|
||||
public ThemeSettingServiceImpl(ThemeSettingRepository themeSettingRepository,
|
||||
ThemeService themeService) {
|
||||
ThemeService themeService,
|
||||
Configuration configuration) {
|
||||
super(themeSettingRepository);
|
||||
this.themeSettingRepository = themeSettingRepository;
|
||||
this.themeService = themeService;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,6 +101,12 @@ public class ThemeSettingServiceImpl extends AbstractCrudService<ThemeSetting, I
|
|||
|
||||
// Save the settings
|
||||
settings.forEach((key, value) -> save(key, value.toString(), themeId));
|
||||
|
||||
try {
|
||||
configuration.setSharedVariable("settings", listAsMapBy(themeService.getActivatedThemeId()));
|
||||
} catch (TemplateModelException e) {
|
||||
throw new ServiceException("Save theme settings error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
<link href="/anatole/source/css/style.min.css" type="text/css" rel="stylesheet" />
|
||||
<link rel="alternate" type="application/rss+xml" title="atom 1.0" href="/feed.xml">
|
||||
<style>
|
||||
<#if (options.anatole_style_post_title_lower!'true') == "false">
|
||||
<#if !(settings.post_title_uppper!true)>
|
||||
.post .post-title h3 {
|
||||
text-transform: none;
|
||||
}
|
||||
</#if>
|
||||
<#if (options.anatole_style_blog_title_lower!'true') == "false">
|
||||
<#if !(settings.blog_title_uppper!true)>
|
||||
.sidebar .logo-title .title h3 {
|
||||
text-transform: none;
|
||||
}
|
||||
|
@ -37,12 +37,12 @@
|
|||
background-color: #eee;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: ${options.anatole_style_scrollbar!'#3798e8'};
|
||||
background-color: ${settings.scrollbar!'#3798e8'};
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: #eee;
|
||||
}
|
||||
${options.anatole_style_self!}
|
||||
${settings.custom!}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</li>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<img src="${options.anatole_style_right_icon!'/anatole/source/images/logo.png'}" />
|
||||
<img src="${settings.icon!'/anatole/source/images/logo.png'}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<div class="sidebar animated fadeInDown">
|
||||
<div class="logo-title">
|
||||
<div class="title">
|
||||
<img src="${options.blog_logo!'/anatole/source/images/logo@2x.png'}" style="width:127px;<#if (options.anatole_style_avatar_circle!'false')=='true'>border-radius:50%</#if>" />
|
||||
<img src="${options.blog_logo!'/anatole/source/images/logo@2x.png'}" style="width:127px;<#if settings.avatar_circle!false>border-radius:50%</#if>" />
|
||||
<h3 title="">
|
||||
<a href="${options.blog_url!}">${options.blog_title!'ANATOLE'}</a>
|
||||
<a href="${options.blog_url!}">${options.blog_title!'Anatole'}</a>
|
||||
</h3>
|
||||
<div class="description">
|
||||
<#if (options.anatole_style_hitokoto!'false')=="true">
|
||||
<#if settings.hitokoto!false>
|
||||
<p id="yiyan">获取中...</p>
|
||||
<#else >
|
||||
<p>${user.description!'A other Halo theme'}</p>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<ul class="social-links">
|
||||
|
||||
<#if (options.theme_anatole_sns_rss!'true')=='true'>
|
||||
<#if settings.rss!true>
|
||||
<li>
|
||||
<a target="_blank" href="${options.blog_url!}/atom.xml">
|
||||
<i class="fa fa-rss"></i>
|
||||
|
@ -8,73 +8,73 @@
|
|||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_twitter??>
|
||||
<#if settings.twitter??>
|
||||
<li>
|
||||
<a target="_blank" href="https://twitter.com/${options.theme_anatole_sns_twitter}">
|
||||
<a target="_blank" href="https://twitter.com/${settings.twitter}">
|
||||
<i class="fa fa-twitter"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_facebook??>
|
||||
<#if settings.facebook??>
|
||||
<li>
|
||||
<a target="_blank" href="https://www.facebook.com/${options.theme_anatole_sns_facebook}">
|
||||
<a target="_blank" href="https://www.facebook.com/${settings.facebook}">
|
||||
<i class="fa fa-facebook"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_instagram??>
|
||||
<#if settings.instagram??>
|
||||
<li>
|
||||
<a target="_blank" href="https://www.instagram.com/${options.theme_anatole_sns_instagram}">
|
||||
<a target="_blank" href="https://www.instagram.com/${settings.instagram}">
|
||||
<i class="fa fa-instagram"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_dribbble??>
|
||||
<#if settings.dribbble??>
|
||||
<li>
|
||||
<a target="_blank" href="https://dribbble.com/${options.theme_anatole_sns_dribbble}">
|
||||
<a target="_blank" href="https://dribbble.com/${settings.dribbble}">
|
||||
<i class="fa fa-dribbble"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_weibo??>
|
||||
<#if settings.weibo??>
|
||||
<li>
|
||||
<a target="_blank" href="https://weibo.com/${options.theme_anatole_sns_weibo}">
|
||||
<a target="_blank" href="https://weibo.com/${settings.weibo}">
|
||||
<i class="fa fa-weibo"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_qq??>
|
||||
<#if settings.qq??>
|
||||
<li>
|
||||
<a target="_blank" href="tencent://message/?uin=${options.theme_anatole_sns_qq}&Site=&Menu=yes">
|
||||
<a target="_blank" href="tencent://message/?uin=${settings.qq}&Site=&Menu=yes">
|
||||
<i class="fa fa-qq"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_telegram??>
|
||||
<#if settings.telegram??>
|
||||
<li>
|
||||
<a target="_blank" href="https://t.me/${options.theme_anatole_sns_telegram}">
|
||||
<a target="_blank" href="https://t.me/${settings.telegram}">
|
||||
<i class="fa fa-telegram"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_email??>
|
||||
<#if settings.email??>
|
||||
<li>
|
||||
<a target="_blank" href="mailto:${options.theme_anatole_sns_email}">
|
||||
<a target="_blank" href="mailto:${settings.email}">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</a>
|
||||
</li>
|
||||
</#if>
|
||||
|
||||
<#if options.theme_anatole_sns_github??>
|
||||
<#if settings.github??>
|
||||
<li>
|
||||
<a target="_blank" href="https://github.com/${options.theme_anatole_sns_github}">
|
||||
<a target="_blank" href="https://github.com/${settings.github}">
|
||||
<i class="fa fa-github"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue