mirror of https://github.com/halo-dev/halo
fix: failure of suffixes in posts. (#619)
parent
d82f3847c2
commit
491b8c89e8
|
@ -37,7 +37,7 @@ public class AttachmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@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) {
|
AttachmentQuery attachmentQuery) {
|
||||||
return attachmentService.pageDtosBy(pageable, attachmentQuery);
|
return attachmentService.pageDtosBy(pageable, attachmentQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class CategoryController {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists all categories")
|
@ApiOperation("Lists all categories")
|
||||||
public List<? extends CategoryDTO> listAll(
|
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) {
|
@RequestParam(name = "more", required = false, defaultValue = "false") boolean more) {
|
||||||
if (more) {
|
if (more) {
|
||||||
return postCategoryService.listCategoryWithPostCountDto(sort);
|
return postCategoryService.listCategoryWithPostCountDto(sort);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class JournalCommentController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists journal comments")
|
@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) {
|
CommentQuery commentQuery) {
|
||||||
Page<JournalComment> journalCommentPage = journalCommentService.pageBy(commentQuery, pageable);
|
Page<JournalComment> journalCommentPage = journalCommentService.pageBy(commentQuery, pageable);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class LogController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists logs")
|
@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);
|
Page<Log> logPage = logService.listAll(pageable);
|
||||||
return logPage.map(log -> new LogDTO().convertFrom(log));
|
return logPage.map(log -> new LogDTO().convertFrom(log));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class PhotoController {
|
||||||
|
|
||||||
@GetMapping(value = "latest")
|
@GetMapping(value = "latest")
|
||||||
@ApiOperation("Lists latest photos")
|
@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);
|
return photoService.listDtos(sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists photos")
|
@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) {
|
PhotoQuery photoQuery) {
|
||||||
return photoService.pageDtosBy(pageable, photoQuery);
|
return photoService.pageDtosBy(pageable, photoQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PostCommentController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists post comments")
|
@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) {
|
CommentQuery commentQuery) {
|
||||||
Page<PostComment> commentPage = postCommentService.pageBy(commentQuery, pageable);
|
Page<PostComment> commentPage = postCommentService.pageBy(commentQuery, pageable);
|
||||||
return postCommentService.convertToWithPostVo(commentPage);
|
return postCommentService.convertToWithPostVo(commentPage);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SheetCommentController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists sheet comments")
|
@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) {
|
CommentQuery commentQuery) {
|
||||||
Page<SheetComment> sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable);
|
Page<SheetComment> sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable);
|
||||||
return sheetCommentService.convertToWithSheetVo(sheetCommentPage);
|
return sheetCommentService.convertToWithSheetVo(sheetCommentPage);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class TagController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists tags")
|
@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")
|
@ApiParam("Return more information(post count) if it is set")
|
||||||
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
|
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
|
||||||
if (more) {
|
if (more) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class ContentContentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{prefix}/{slug:.+}")
|
@GetMapping("{prefix}/{slug}")
|
||||||
public String content(@PathVariable("prefix") String prefix,
|
public String content(@PathVariable("prefix") String prefix,
|
||||||
@PathVariable("slug") String slug,
|
@PathVariable("slug") String slug,
|
||||||
@RequestParam(value = "token", required = false) String token,
|
@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,
|
public String content(@PathVariable("year") Integer year,
|
||||||
@PathVariable("month") Integer month,
|
@PathVariable("month") Integer month,
|
||||||
@PathVariable("slug") String slug,
|
@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,
|
public String content(@PathVariable("year") Integer year,
|
||||||
@PathVariable("month") Integer month,
|
@PathVariable("month") Integer month,
|
||||||
@PathVariable("day") Integer day,
|
@PathVariable("day") Integer day,
|
||||||
|
|
|
@ -77,15 +77,32 @@ public class CategoryModel {
|
||||||
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
||||||
|
|
||||||
// Next page and previous page url.
|
// Next page and previous page url.
|
||||||
StringBuilder nextPageFullPath = new StringBuilder(categoryDTO.getFullPath());
|
StringBuilder nextPageFullPath = new StringBuilder();
|
||||||
StringBuilder prePageFullPath = new StringBuilder(categoryDTO.getFullPath());
|
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/")
|
nextPageFullPath.append("/page/")
|
||||||
.append(posts.getNumber() + 2)
|
.append(posts.getNumber() + 2)
|
||||||
.append(optionService.getPathSuffix());
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
if (posts.getNumber() == 1) {
|
if (posts.getNumber() == 1) {
|
||||||
prePageFullPath.append("/");
|
prePageFullPath.append(optionService.getPathSuffix());
|
||||||
} else {
|
} else {
|
||||||
prePageFullPath.append("/page/")
|
prePageFullPath.append("/page/")
|
||||||
.append(posts.getNumber())
|
.append(posts.getNumber())
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class JournalModel {
|
||||||
.append(optionService.getPathSuffix());
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
if (journals.getNumber() == 1) {
|
if (journals.getNumber() == 1) {
|
||||||
prePageFullPath.append("/");
|
prePageFullPath.append(optionService.getPathSuffix());
|
||||||
} else {
|
} else {
|
||||||
prePageFullPath.append("/page/")
|
prePageFullPath.append("/page/")
|
||||||
.append(journals.getNumber())
|
.append(journals.getNumber())
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class PhotoModel {
|
||||||
.append(optionService.getPathSuffix());
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
if (photos.getNumber() == 1) {
|
if (photos.getNumber() == 1) {
|
||||||
prePageFullPath.append("/");
|
prePageFullPath.append(optionService.getPathSuffix());
|
||||||
} else {
|
} else {
|
||||||
prePageFullPath.append("/page/")
|
prePageFullPath.append("/page/")
|
||||||
.append(photos.getNumber())
|
.append(photos.getNumber())
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class PostModel {
|
||||||
.append(optionService.getPathSuffix());
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
if (posts.getNumber() == 1) {
|
if (posts.getNumber() == 1) {
|
||||||
prePageFullPath.append("/");
|
prePageFullPath.append(optionService.getPathSuffix());
|
||||||
} else {
|
} else {
|
||||||
prePageFullPath.append("/page/")
|
prePageFullPath.append("/page/")
|
||||||
.append(posts.getNumber())
|
.append(posts.getNumber())
|
||||||
|
|
|
@ -63,15 +63,32 @@ public class TagModel {
|
||||||
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3);
|
||||||
|
|
||||||
// Next page and previous page url.
|
// Next page and previous page url.
|
||||||
StringBuilder nextPageFullPath = new StringBuilder(tagDTO.getFullPath());
|
StringBuilder nextPageFullPath = new StringBuilder();
|
||||||
StringBuilder prePageFullPath = new StringBuilder(tagDTO.getFullPath());
|
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/")
|
nextPageFullPath.append("/page/")
|
||||||
.append(posts.getNumber() + 2)
|
.append(posts.getNumber() + 2)
|
||||||
.append(optionService.getPathSuffix());
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
if (posts.getNumber() == 1) {
|
if (posts.getNumber() == 1) {
|
||||||
prePageFullPath.append("/");
|
prePageFullPath.append(optionService.getPathSuffix());
|
||||||
} else {
|
} else {
|
||||||
prePageFullPath.append("/page/")
|
prePageFullPath.append("/page/")
|
||||||
.append(posts.getNumber())
|
.append(posts.getNumber())
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.util.NestedServletException;
|
import org.springframework.web.util.NestedServletException;
|
||||||
import run.halo.app.exception.HaloException;
|
import run.halo.app.exception.HaloException;
|
||||||
import run.halo.app.exception.NotFoundException;
|
import run.halo.app.exception.NotFoundException;
|
||||||
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.ThemeService;
|
import run.halo.app.service.ThemeService;
|
||||||
import run.halo.app.utils.FilenameUtils;
|
import run.halo.app.utils.FilenameUtils;
|
||||||
|
|
||||||
|
@ -52,13 +53,17 @@ public class CommonController extends AbstractErrorController {
|
||||||
|
|
||||||
private final ErrorAttributes errorAttributes;
|
private final ErrorAttributes errorAttributes;
|
||||||
|
|
||||||
|
private final OptionService optionService;
|
||||||
|
|
||||||
public CommonController(ThemeService themeService,
|
public CommonController(ThemeService themeService,
|
||||||
ErrorAttributes errorAttributes,
|
ErrorAttributes errorAttributes,
|
||||||
ServerProperties serverProperties) {
|
ServerProperties serverProperties,
|
||||||
|
OptionService optionService) {
|
||||||
super(errorAttributes);
|
super(errorAttributes);
|
||||||
this.themeService = themeService;
|
this.themeService = themeService;
|
||||||
this.errorAttributes = errorAttributes;
|
this.errorAttributes = errorAttributes;
|
||||||
this.errorProperties = serverProperties.getError();
|
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)));
|
Map<String, Object> errorDetail = Collections.unmodifiableMap(getErrorAttributes(request, isIncludeStackTrace(request)));
|
||||||
model.addAttribute("error", errorDetail);
|
model.addAttribute("error", errorDetail);
|
||||||
|
model.addAttribute("meta_keywords", optionService.getSeoKeywords());
|
||||||
|
model.addAttribute("meta_description", optionService.getSeoDescription());
|
||||||
|
|
||||||
log.debug("Error detail: [{}]", errorDetail);
|
log.debug("Error detail: [{}]", errorDetail);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue