mirror of https://github.com/halo-dev/halo
Enable getDefaultPageSize again
parent
3456e097c8
commit
0d814e88a2
|
@ -1,5 +1,6 @@
|
||||||
package cc.ryanc.halo.utils;
|
package cc.ryanc.halo.utils;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.enums.BlogProperties;
|
||||||
import cn.hutool.core.text.StrBuilder;
|
import cn.hutool.core.text.StrBuilder;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.qiniu.common.Zone;
|
import com.qiniu.common.Zone;
|
||||||
|
@ -88,18 +89,18 @@ public class HaloUtils {
|
||||||
return machineAddress.getHostAddress();
|
return machineAddress.getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Gets default page size.
|
* Gets default page size.
|
||||||
// *
|
*
|
||||||
// * @return default page size
|
* @return default page size
|
||||||
// */
|
*/
|
||||||
// public static int getDefaultPageSize() {
|
public static int getDefaultPageSize() {
|
||||||
// if (StrUtil.isNotBlank(OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()))) {
|
if (StrUtil.isNotBlank(OPTIONS.get(BlogProperties.INDEX_POSTS))) {
|
||||||
// return Integer.parseInt(OPTIONS.get(BlogPropertiesEnum.INDEX_POSTS.getProp()));
|
return Integer.parseInt(OPTIONS.get(BlogProperties.INDEX_POSTS));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return DEFAULT_PAGE_SIZE;
|
return DEFAULT_PAGE_SIZE;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets default qiniuyun zone.
|
* Gets default qiniuyun zone.
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package cc.ryanc.halo.web.controller.content;
|
package cc.ryanc.halo.web.controller.content;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.enums.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.enums.PostStatus;
|
import cc.ryanc.halo.model.enums.PostStatus;
|
||||||
import cc.ryanc.halo.model.enums.PostType;
|
import cc.ryanc.halo.model.enums.PostType;
|
||||||
import cc.ryanc.halo.model.vo.PostListVO;
|
import cc.ryanc.halo.model.vo.PostListVO;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
||||||
import cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -20,7 +19,6 @@ 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 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,16 +66,14 @@ public class ContentIndexController extends BaseContentController {
|
||||||
}) Sort sort) {
|
}) Sort sort) {
|
||||||
log.debug("Requested index page, sort info: [{}]", sort);
|
log.debug("Requested index page, sort info: [{}]", sort);
|
||||||
|
|
||||||
int size = 10;
|
int size = HaloUtils.getDefaultPageSize();
|
||||||
if (StrUtil.isNotBlank(OPTIONS.get(BlogProperties.INDEX_POSTS.getValue()))) {
|
Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||||
size = Integer.parseInt(OPTIONS.get(BlogProperties.INDEX_POSTS.getValue()));
|
Page<PostListVO> posts = postService.pageListVoBy(PostStatus.PUBLISHED, PostType.POST, pageable);
|
||||||
}
|
|
||||||
final Pageable pageable = PageRequest.of(page - 1, size, sort);
|
|
||||||
final Page<PostListVO> posts = postService.pageListVoBy(PostStatus.PUBLISHED, PostType.POST, pageable);
|
|
||||||
if (null == posts) {
|
if (null == posts) {
|
||||||
|
// TODO There will never be null
|
||||||
return this.renderNotFound();
|
return this.renderNotFound();
|
||||||
}
|
}
|
||||||
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue