Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IEQEFCR
halo
提交
8930f9d0
H
halo
项目概览
IEQEFCR
/
halo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
halo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8930f9d0
编写于
5月 04, 2019
作者:
J
johnniang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor some theme services
上级
cbabebff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
13 deletion
+17
-13
src/main/java/run/halo/app/controller/content/ContentSheetController.java
...n/halo/app/controller/content/ContentSheetController.java
+4
-5
src/main/java/run/halo/app/service/ThemeService.java
src/main/java/run/halo/app/service/ThemeService.java
+6
-5
src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java
...main/java/run/halo/app/service/impl/ThemeServiceImpl.java
+7
-3
未找到文件。
src/main/java/run/halo/app/controller/content/ContentSheetController.java
浏览文件 @
8930f9d0
package
run.halo.app.controller.content
;
import
cn.hutool.core.util.StrUtil
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -13,6 +12,8 @@ import run.halo.app.service.SheetService;
import
run.halo.app.service.ThemeService
;
/**
* Content sheet controller.
*
* @author ryanwang
* @date : 2019-03-21
*/
...
...
@@ -68,10 +69,8 @@ public class ContentSheetController {
model
.
addAttribute
(
"post"
,
sheetService
.
convertToDetail
(
sheet
));
model
.
addAttribute
(
"is_sheet"
,
true
);
if
(
StrUtil
.
isNotEmpty
(
sheet
.
getTemplate
()))
{
if
(
themeService
.
templateExists
(
ThemeService
.
CUSTOM_SHEET_PREFIX
+
sheet
.
getTemplate
()
+
HaloConst
.
SUFFIX_FTL
))
{
return
themeService
.
render
(
ThemeService
.
CUSTOM_SHEET_PREFIX
+
sheet
.
getTemplate
());
}
if
(
themeService
.
templateExists
(
ThemeService
.
CUSTOM_SHEET_PREFIX
+
sheet
.
getTemplate
()
+
HaloConst
.
SUFFIX_FTL
))
{
return
themeService
.
render
(
ThemeService
.
CUSTOM_SHEET_PREFIX
+
sheet
.
getTemplate
());
}
return
themeService
.
render
(
"sheet"
);
}
...
...
src/main/java/run/halo/app/service/ThemeService.java
浏览文件 @
8930f9d0
package
run.halo.app.service
;
import
org.springframework.lang.NonNull
;
import
org.springframework.lang.Nullable
;
import
org.springframework.web.multipart.MultipartFile
;
import
run.halo.app.handler.theme.config.support.Group
;
import
run.halo.app.handler.theme.config.support.ThemeProperty
;
...
...
@@ -82,11 +83,11 @@ public interface ThemeService {
/**
* Get theme property by theme id.
*
* @param themeId
must not be blank
* @param themeId
theme id
* @return a optional theme property
*/
@NonNull
Optional
<
ThemeProperty
>
getThemeBy
(
@N
onNull
String
themeId
);
Optional
<
ThemeProperty
>
getThemeBy
(
@N
ullable
String
themeId
);
/**
* Gets all themes
...
...
@@ -126,15 +127,15 @@ public interface ThemeService {
* @param template template must not be blank
* @return boolean
*/
boolean
templateExists
(
@N
onNull
String
template
);
boolean
templateExists
(
@N
ullable
String
template
);
/**
* Checks whether theme exists under template path
*
* @param themeId theme
name
* @param themeId theme
id
* @return boolean
*/
boolean
themeExists
(
@N
onNull
String
themeId
);
boolean
themeExists
(
@N
ullable
String
themeId
);
/**
* Gets theme base path.
...
...
src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java
浏览文件 @
8930f9d0
...
...
@@ -105,7 +105,9 @@ public class ThemeServiceImpl implements ThemeService {
@Override
public
Optional
<
ThemeProperty
>
getThemeBy
(
String
themeId
)
{
Assert
.
hasText
(
themeId
,
"Theme id must not be blank"
);
if
(
StringUtils
.
isBlank
(
themeId
))
{
return
Optional
.
empty
();
}
// Get all themes
Set
<
ThemeProperty
>
themes
=
getThemes
();
...
...
@@ -181,7 +183,9 @@ public class ThemeServiceImpl implements ThemeService {
@Override
public
boolean
templateExists
(
String
template
)
{
Assert
.
hasText
(
template
,
"Template must not be blank"
);
if
(
StringUtils
.
isBlank
(
template
))
{
return
false
;
}
// Resolve template path
Path
templatePath
=
Paths
.
get
(
getActivatedTheme
().
getThemePath
(),
template
);
...
...
@@ -507,7 +511,7 @@ public class ThemeServiceImpl implements ThemeService {
*/
private
void
setActivatedTheme
(
@Nullable
ThemeProperty
activatedTheme
)
{
this
.
activatedTheme
=
activatedTheme
;
this
.
activatedThemeId
=
activatedTheme
.
getId
(
);
this
.
activatedThemeId
=
Optional
.
ofNullable
(
activatedTheme
).
map
(
ThemeProperty:
:
getId
).
orElse
(
null
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录