mirror of https://github.com/halo-dev/halo
feat: support custom post password template. (#1236)
parent
042e72f224
commit
8bb416db1a
|
@ -75,7 +75,10 @@ public class PostModel {
|
|||
|
||||
if (post.getStatus().equals(PostStatus.INTIMATE) && StringUtils.isEmpty(token)) {
|
||||
model.addAttribute("slug", post.getSlug());
|
||||
return "common/template/post_password";
|
||||
if (themeService.templateExists(HaloConst.POST_PASSWORD_TEMPLATE + HaloConst.SUFFIX_FTL)) {
|
||||
return themeService.render(HaloConst.POST_PASSWORD_TEMPLATE);
|
||||
}
|
||||
return "common/template/" + HaloConst.POST_PASSWORD_TEMPLATE;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
|
|
|
@ -46,11 +46,6 @@ public class HaloConst {
|
|||
*/
|
||||
public final static String HALO_DATA_EXPORT_PREFIX = "halo-data-export-";
|
||||
|
||||
/**
|
||||
* Static pages pack prefix.
|
||||
*/
|
||||
public final static String STATIC_PAGE_PACK_PREFIX = "static-pages-";
|
||||
|
||||
/**
|
||||
* Default theme name.
|
||||
*/
|
||||
|
@ -65,6 +60,11 @@ public class HaloConst {
|
|||
* Path separator.
|
||||
*/
|
||||
public static final String FILE_SEPARATOR = File.separator;
|
||||
|
||||
/**
|
||||
* Post password template name.
|
||||
*/
|
||||
public static final String POST_PASSWORD_TEMPLATE = "post_password";
|
||||
/**
|
||||
* Suffix of freemarker template file
|
||||
*/
|
||||
|
|
|
@ -165,6 +165,7 @@ public class ThemeServiceImpl implements ThemeService {
|
|||
Path themePath = Paths.get(themeProperty.getThemePath());
|
||||
try (Stream<Path> pathStream = Files.list(themePath)) {
|
||||
return pathStream.filter(path -> StringUtils.startsWithIgnoreCase(path.getFileName().toString(), prefix))
|
||||
.filter(path -> !(HaloConst.POST_PASSWORD_TEMPLATE + HaloConst.SUFFIX_FTL).equals(path.getFileName().toString()))
|
||||
.map(path -> {
|
||||
// Remove prefix
|
||||
String customTemplate = StringUtils.removeStartIgnoreCase(path.getFileName().toString(), prefix);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<div style="text-align:center">
|
||||
<img src="${user.avatar!}" width="100" height="100" alt="${user.nickname!}">
|
||||
<h3>${blog_title!}</h3>
|
||||
<h4>
|
||||
<a href="${blog_url!}" target="_blank">${blog_url!}</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<@postTag method="archiveYear">
|
||||
<#list archives as archive>
|
||||
## ${archive.year?c}
|
||||
<#list archive.posts?sort_by("createTime")?reverse as post>
|
||||
- <a href="<#if !globalAbsolutePathEnabled!true>${blog_url!}</#if>${post.fullPath!}" title="${post.title!}" target="_blank">${post.title!}</a>
|
||||
</#list>
|
||||
</#list>
|
||||
</@postTag>
|
||||
|
||||
## 分类目录
|
||||
<@categoryTag method="list">
|
||||
<#list categories as category>
|
||||
- <a href="<#if !globalAbsolutePathEnabled!true>${blog_url!}</#if>${category.fullPath!}" target="_blank">${category.name!}</a>
|
||||
</#list>
|
||||
</@categoryTag>
|
||||
|
||||
## 标签
|
||||
<@tagTag method="list">
|
||||
<#list tags as tag>
|
||||
- <a href="<#if !globalAbsolutePathEnabled!true>${blog_url!}</#if>${tag.fullPath!}" target="_blank">${tag.name!}</a>
|
||||
</#list>
|
||||
</@tagTag>
|
Loading…
Reference in New Issue