Merge remote-tracking branch 'origin/dev' into dev

pull/137/head
johnniang 2019-03-08 20:50:15 +08:00
commit 4f00dace1e
3 changed files with 32 additions and 5 deletions

View File

@ -20,7 +20,7 @@ public abstract class BaseController {
protected Logger log = Logger.getLogger(getClass());
/**
*
*
*
* @param pageName pageName
* @return
@ -29,7 +29,23 @@ public abstract class BaseController {
final StrBuilder themeStr = new StrBuilder("themes/");
themeStr.append(THEME);
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();
}
/**

View File

@ -17,6 +17,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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 org.springframework.data.domain.Sort.Direction.DESC;
@ -44,8 +45,9 @@ public class FrontIndexController extends BaseController {
* @return
*/
@GetMapping
public String index(Model model) {
return this.index(model, 1, Sort.by(DESC, "postPriority").and(Sort.by(DESC, "postDate")));
public String index(@RequestParam(value = "theme", defaultValue = "") String theme,
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}")
public String index(Model model,
@RequestParam(value = "theme", defaultValue = "") String theme,
@PathVariable(value = "page") Integer page,
@SortDefault.SortDefaults({
@SortDefault(sort = "postPriority", direction = DESC),
@ -79,6 +82,9 @@ public class FrontIndexController extends BaseController {
model.addAttribute("is_index", true);
model.addAttribute("posts", posts);
model.addAttribute("rainbow", rainbow);
if (StrUtil.isNotEmpty(theme)) {
return this.render(theme, "index");
}
return this.render("index");
}
}

View File

@ -27,6 +27,9 @@
font-size: 18px;
line-height: 30px;
}
.theme-title a{
color: #000;
}
.btn-delete:hover{
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>
<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>
<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>