fix: failure of suffixes in posts. (#619)

pull/621/head
Ryan Wang 2020-03-06 14:09:36 +08:00 committed by GitHub
parent d82f3847c2
commit 491b8c89e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 63 additions and 22 deletions

View File

@ -37,7 +37,7 @@ public class AttachmentController {
}
@GetMapping
public Page<AttachmentDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
public Page<AttachmentDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable,
AttachmentQuery attachmentQuery) {
return attachmentService.pageDtosBy(pageable, attachmentQuery);
}

View File

@ -46,7 +46,7 @@ public class CategoryController {
@GetMapping
@ApiOperation("Lists all categories")
public List<? extends CategoryDTO> listAll(
@SortDefault(sort = "updateTime", direction = DESC) Sort sort,
@SortDefault(sort = "createTime", direction = DESC) Sort sort,
@RequestParam(name = "more", required = false, defaultValue = "false") boolean more) {
if (more) {
return postCategoryService.listCategoryWithPostCountDto(sort);

View File

@ -45,7 +45,7 @@ public class JournalCommentController {
@GetMapping
@ApiOperation("Lists journal comments")
public Page<JournalCommentWithJournalVO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
public Page<JournalCommentWithJournalVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable,
CommentQuery commentQuery) {
Page<JournalComment> journalCommentPage = journalCommentService.pageBy(commentQuery, pageable);

View File

@ -40,7 +40,7 @@ public class LogController {
@GetMapping
@ApiOperation("Lists logs")
public Page<LogDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
public Page<LogDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) {
Page<Log> logPage = logService.listAll(pageable);
return logPage.map(log -> new LogDTO().convertFrom(log));
}

View File

@ -36,13 +36,13 @@ public class PhotoController {
@GetMapping(value = "latest")
@ApiOperation("Lists latest photos")
public List<PhotoDTO> listPhotos(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
public List<PhotoDTO> listPhotos(@SortDefault(sort = "createTime", direction = Sort.Direction.DESC) Sort sort) {
return photoService.listDtos(sort);
}
@GetMapping
@ApiOperation("Lists photos")
public Page<PhotoDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
public Page<PhotoDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable,
PhotoQuery photoQuery) {
return photoService.pageDtosBy(pageable, photoQuery);
}

View File

@ -47,7 +47,7 @@ public class PostCommentController {
@GetMapping
@ApiOperation("Lists post comments")
public Page<PostCommentWithPostVO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
public Page<PostCommentWithPostVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable,
CommentQuery commentQuery) {
Page<PostComment> commentPage = postCommentService.pageBy(commentQuery, pageable);
return postCommentService.convertToWithPostVo(commentPage);

View File

@ -47,7 +47,7 @@ public class SheetCommentController {
@GetMapping
@ApiOperation("Lists sheet comments")
public Page<SheetCommentWithSheetVO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
public Page<SheetCommentWithSheetVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable,
CommentQuery commentQuery) {
Page<SheetComment> sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable);
return sheetCommentService.convertToWithSheetVo(sheetCommentPage);

View File

@ -38,7 +38,7 @@ public class TagController {
@GetMapping
@ApiOperation("Lists tags")
public List<? extends TagDTO> listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort,
public List<? extends TagDTO> listTags(@SortDefault(sort = "createTime", direction = Sort.Direction.DESC) Sort sort,
@ApiParam("Return more information(post count) if it is set")
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
if (more) {

View File

@ -118,7 +118,7 @@ public class ContentContentController {
}
}
@GetMapping("{prefix}/{slug:.+}")
@GetMapping("{prefix}/{slug}")
public String content(@PathVariable("prefix") String prefix,
@PathVariable("slug") String slug,
@RequestParam(value = "token", required = false) String token,
@ -154,7 +154,7 @@ public class ContentContentController {
}
}
@GetMapping("{year:\\d+}/{month:\\d+}/{slug:.+}")
@GetMapping("{year:\\d+}/{month:\\d+}/{slug}")
public String content(@PathVariable("year") Integer year,
@PathVariable("month") Integer month,
@PathVariable("slug") String slug,
@ -169,7 +169,7 @@ public class ContentContentController {
}
}
@GetMapping("{year:\\d+}/{month:\\d+}/{day:\\d+}/{slug:.+}")
@GetMapping("{year:\\d+}/{month:\\d+}/{day:\\d+}/{slug}")
public String content(@PathVariable("year") Integer year,
@PathVariable("month") Integer month,
@PathVariable("day") Integer day,

View File

@ -77,15 +77,32 @@ public class CategoryModel {
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
// Next page and previous page url.
StringBuilder nextPageFullPath = new StringBuilder(categoryDTO.getFullPath());
StringBuilder prePageFullPath = new StringBuilder(categoryDTO.getFullPath());
StringBuilder nextPageFullPath = new StringBuilder();
StringBuilder prePageFullPath = new StringBuilder();
if (optionService.isEnabledAbsolutePath()) {
nextPageFullPath.append(optionService.getBlogBaseUrl())
.append("/");
prePageFullPath.append(optionService.getBlogBaseUrl())
.append("/");
} else {
nextPageFullPath.append("/");
prePageFullPath.append("/");
}
nextPageFullPath.append(optionService.getCategoriesPrefix())
.append("/")
.append(category.getSlug());
prePageFullPath.append(optionService.getCategoriesPrefix())
.append("/")
.append(category.getSlug());
nextPageFullPath.append("/page/")
.append(posts.getNumber() + 2)
.append(optionService.getPathSuffix());
if (posts.getNumber() == 1) {
prePageFullPath.append("/");
prePageFullPath.append(optionService.getPathSuffix());
} else {
prePageFullPath.append("/page/")
.append(posts.getNumber())

View File

@ -70,7 +70,7 @@ public class JournalModel {
.append(optionService.getPathSuffix());
if (journals.getNumber() == 1) {
prePageFullPath.append("/");
prePageFullPath.append(optionService.getPathSuffix());
} else {
prePageFullPath.append("/page/")
.append(journals.getNumber())

View File

@ -65,7 +65,7 @@ public class PhotoModel {
.append(optionService.getPathSuffix());
if (photos.getNumber() == 1) {
prePageFullPath.append("/");
prePageFullPath.append(optionService.getPathSuffix());
} else {
prePageFullPath.append("/page/")
.append(photos.getNumber())

View File

@ -212,7 +212,7 @@ public class PostModel {
.append(optionService.getPathSuffix());
if (posts.getNumber() == 1) {
prePageFullPath.append("/");
prePageFullPath.append(optionService.getPathSuffix());
} else {
prePageFullPath.append("/page/")
.append(posts.getNumber())

View File

@ -63,15 +63,32 @@ public class TagModel {
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
// Next page and previous page url.
StringBuilder nextPageFullPath = new StringBuilder(tagDTO.getFullPath());
StringBuilder prePageFullPath = new StringBuilder(tagDTO.getFullPath());
StringBuilder nextPageFullPath = new StringBuilder();
StringBuilder prePageFullPath = new StringBuilder();
if (optionService.isEnabledAbsolutePath()) {
nextPageFullPath.append(optionService.getBlogBaseUrl())
.append("/");
prePageFullPath.append(optionService.getBlogBaseUrl())
.append("/");
} else {
nextPageFullPath.append("/");
prePageFullPath.append("/");
}
nextPageFullPath.append(optionService.getTagsPrefix())
.append("/")
.append(tag.getSlug());
prePageFullPath.append(optionService.getTagsPrefix())
.append("/")
.append(tag.getSlug());
nextPageFullPath.append("/page/")
.append(posts.getNumber() + 2)
.append(optionService.getPathSuffix());
if (posts.getNumber() == 1) {
prePageFullPath.append("/");
prePageFullPath.append(optionService.getPathSuffix());
} else {
prePageFullPath.append("/page/")
.append(posts.getNumber())

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.util.NestedServletException;
import run.halo.app.exception.HaloException;
import run.halo.app.exception.NotFoundException;
import run.halo.app.service.OptionService;
import run.halo.app.service.ThemeService;
import run.halo.app.utils.FilenameUtils;
@ -52,13 +53,17 @@ public class CommonController extends AbstractErrorController {
private final ErrorAttributes errorAttributes;
private final OptionService optionService;
public CommonController(ThemeService themeService,
ErrorAttributes errorAttributes,
ServerProperties serverProperties) {
ServerProperties serverProperties,
OptionService optionService) {
super(errorAttributes);
this.themeService = themeService;
this.errorAttributes = errorAttributes;
this.errorProperties = serverProperties.getError();
this.optionService = optionService;
}
/**
@ -79,6 +84,8 @@ public class CommonController extends AbstractErrorController {
Map<String, Object> errorDetail = Collections.unmodifiableMap(getErrorAttributes(request, isIncludeStackTrace(request)));
model.addAttribute("error", errorDetail);
model.addAttribute("meta_keywords", optionService.getSeoKeywords());
model.addAttribute("meta_description", optionService.getSeoDescription());
log.debug("Error detail: [{}]", errorDetail);