Beautify some details

pull/137/head
johnniang 2019-04-02 22:42:18 +08:00
parent b5fd862b65
commit 327aecae18
9 changed files with 20 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package cc.ryanc.halo.config.properties; package cc.ryanc.halo.config.properties;
import cc.ryanc.halo.model.support.HaloConst;
import lombok.Data; import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
@ -12,8 +13,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("halo") @ConfigurationProperties("halo")
public class HaloProperties { public class HaloProperties {
private final static String USER_HOME = System.getProperty("user.home");
/** /**
* Doc api disabled. (Default is true) * Doc api disabled. (Default is true)
*/ */
@ -32,5 +31,5 @@ public class HaloProperties {
/** /**
* Work directory. * Work directory.
*/ */
private String workDir = USER_HOME + "/halo/"; private String workDir = HaloConst.USER_HOME + "/halo/";
} }

View File

@ -14,6 +14,10 @@ import java.util.Map;
*/ */
public class HaloConst { public class HaloConst {
/**
* User home directory.
*/
public final static String USER_HOME = System.getProperties().getProperty("user.home");
/** /**
* Default theme name. * Default theme name.

View File

@ -6,6 +6,8 @@ import lombok.ToString;
import java.util.List; import java.util.List;
/** /**
* Theme file.
*
* @author RYAN0UP * @author RYAN0UP
* @date 2019/04/02 * @date 2019/04/02
*/ */

View File

@ -7,7 +7,7 @@ import lombok.ToString;
import java.util.Comparator; import java.util.Comparator;
/** /**
* Archive vo. * Month archive vo.
* *
* @author johnniang * @author johnniang
* @date 4/2/19 * @date 4/2/19

View File

@ -9,7 +9,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
/** /**
* Archive vo. * Year archive vo.
* *
* @author johnniang * @author johnniang
* @date 4/2/19 * @date 4/2/19

View File

@ -1,5 +1,6 @@
package cc.ryanc.halo.service.impl; package cc.ryanc.halo.service.impl;
import cc.ryanc.halo.config.properties.HaloProperties;
import cc.ryanc.halo.model.support.HaloConst; import cc.ryanc.halo.model.support.HaloConst;
import cc.ryanc.halo.model.support.Theme; import cc.ryanc.halo.model.support.Theme;
import cc.ryanc.halo.model.support.ThemeFile; import cc.ryanc.halo.model.support.ThemeFile;
@ -22,6 +23,12 @@ import java.util.List;
@Service @Service
public class ThemeServiceImpl implements ThemeService { public class ThemeServiceImpl implements ThemeService {
private final HaloProperties haloProperties;
public ThemeServiceImpl(HaloProperties haloProperties) {
this.haloProperties = haloProperties;
}
/** /**
* Gets all themes * Gets all themes
* *
@ -158,7 +165,7 @@ public class ThemeServiceImpl implements ThemeService {
*/ */
@Override @Override
public File getThemeBasePath() { public File getThemeBasePath() {
return new File(System.getProperties().getProperty("user.home"), "halo/templates/themes"); return new File(haloProperties.getWorkDir(), "templates/themes");
} }
/** /**

View File

@ -33,7 +33,6 @@ import java.util.UUID;
@Slf4j @Slf4j
public class HaloUtils { public class HaloUtils {
@NonNull @NonNull
public static String timeFormat(long totalSeconds) { public static String timeFormat(long totalSeconds) {
if (totalSeconds <= 0) { if (totalSeconds <= 0) {

View File

@ -60,7 +60,7 @@ public class ThemeController {
* *
* @return List<ThemeFile> * @return List<ThemeFile>
*/ */
@GetMapping(value = "/files") @GetMapping("files")
public List<ThemeFile> listFiles() { public List<ThemeFile> listFiles() {
return themeService.listThemeFolderBy(BaseContentController.THEME); return themeService.listThemeFolderBy(BaseContentController.THEME);
} }

View File

@ -15,6 +15,7 @@ public abstract class BaseContentController {
/** /**
* Default theme * Default theme
*/ */
@Deprecated
public static String THEME = DEFAULT_THEME_NAME; public static String THEME = DEFAULT_THEME_NAME;
/** /**