mirror of https://github.com/halo-dev/halo
Merge remote-tracking branch 'origin/dev' into dev
commit
4f00dace1e
|
@ -20,7 +20,7 @@ public abstract class BaseController {
|
||||||
protected Logger log = Logger.getLogger(getClass());
|
protected Logger log = Logger.getLogger(getClass());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主题名称渲染页面
|
* 根据模板名称渲染页面
|
||||||
*
|
*
|
||||||
* @param pageName pageName
|
* @param pageName pageName
|
||||||
* @return 返回拼接好的模板路径
|
* @return 返回拼接好的模板路径
|
||||||
|
@ -29,7 +29,23 @@ public abstract class BaseController {
|
||||||
final StrBuilder themeStr = new StrBuilder("themes/");
|
final StrBuilder themeStr = new StrBuilder("themes/");
|
||||||
themeStr.append(THEME);
|
themeStr.append(THEME);
|
||||||
themeStr.append("/");
|
themeStr.append("/");
|
||||||
return themeStr.append(pageName).toString();
|
themeStr.append(pageName);
|
||||||
|
return themeStr.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主题以及模板名渲染页面
|
||||||
|
*
|
||||||
|
* @param theme 主题
|
||||||
|
* @param pageName 模板名
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String render(String theme, String pageName) {
|
||||||
|
final StrBuilder themeStr = new StrBuilder("themes/");
|
||||||
|
themeStr.append(theme);
|
||||||
|
themeStr.append("/");
|
||||||
|
themeStr.append(pageName);
|
||||||
|
return themeStr.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import static cc.ryanc.halo.model.support.HaloConst.OPTIONS;
|
import static cc.ryanc.halo.model.support.HaloConst.OPTIONS;
|
||||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
@ -44,8 +45,9 @@ public class FrontIndexController extends BaseController {
|
||||||
* @return 模板路径
|
* @return 模板路径
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String index(Model model) {
|
public String index(@RequestParam(value = "theme", defaultValue = "") String theme,
|
||||||
return this.index(model, 1, Sort.by(DESC, "postPriority").and(Sort.by(DESC, "postDate")));
|
Model model) {
|
||||||
|
return this.index(model, theme, 1, Sort.by(DESC, "postPriority").and(Sort.by(DESC, "postDate")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +59,7 @@ public class FrontIndexController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "page/{page}")
|
@GetMapping(value = "page/{page}")
|
||||||
public String index(Model model,
|
public String index(Model model,
|
||||||
|
@RequestParam(value = "theme", defaultValue = "") String theme,
|
||||||
@PathVariable(value = "page") Integer page,
|
@PathVariable(value = "page") Integer page,
|
||||||
@SortDefault.SortDefaults({
|
@SortDefault.SortDefaults({
|
||||||
@SortDefault(sort = "postPriority", direction = DESC),
|
@SortDefault(sort = "postPriority", direction = DESC),
|
||||||
|
@ -79,6 +82,9 @@ public class FrontIndexController extends BaseController {
|
||||||
model.addAttribute("is_index", true);
|
model.addAttribute("is_index", true);
|
||||||
model.addAttribute("posts", posts);
|
model.addAttribute("posts", posts);
|
||||||
model.addAttribute("rainbow", rainbow);
|
model.addAttribute("rainbow", rainbow);
|
||||||
|
if (StrUtil.isNotEmpty(theme)) {
|
||||||
|
return this.render(theme, "index");
|
||||||
|
}
|
||||||
return this.render("index");
|
return this.render("index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
}
|
}
|
||||||
|
.theme-title a{
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
.btn-delete:hover{
|
.btn-delete:hover{
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +55,9 @@
|
||||||
<div class="pull-right btn-delete" style="display: none" onclick="modelShow('/admin/themes/remove?themeName=${theme.themeName}')"><i class="fa fa-times fa-lg" aria-hidden="true"></i></div>
|
<div class="pull-right btn-delete" style="display: none" onclick="modelShow('/admin/themes/remove?themeName=${theme.themeName}')"><i class="fa fa-times fa-lg" aria-hidden="true"></i></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<span class="theme-title">${theme.themeName!?cap_first}</span>
|
<span class="theme-title">
|
||||||
|
<a href="${options.blog_url!}?theme=${theme.themeName!}" target="_blank" title="点击预览该主题">${theme.themeName!?cap_first}</a>
|
||||||
|
</span>
|
||||||
<#if theme.hasOptions>
|
<#if theme.hasOptions>
|
||||||
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="halo.layerModal('/admin/themes/options?theme=${theme.themeName!}&hasUpdate=<#if theme.hasUpdate>true<#else>false</#if>','${theme.themeName!} <@spring.message code="admin.themes.js.theme-setting" />')" style="display: none"><@spring.message code='admin.themes.btn.setting' /></button>
|
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="halo.layerModal('/admin/themes/options?theme=${theme.themeName!}&hasUpdate=<#if theme.hasUpdate>true<#else>false</#if>','${theme.themeName!} <@spring.message code="admin.themes.js.theme-setting" />')" style="display: none"><@spring.message code='admin.themes.btn.setting' /></button>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
Loading…
Reference in New Issue