use of run.halo.app.model.vo.SheetDetailVO in project halo by ruibaby.
the class SheetController method getBy.
@GetMapping("{sheetId:\\d+}")
@ApiOperation("Gets a sheet")
public SheetDetailVO getBy(@PathVariable("sheetId") Integer sheetId, @RequestParam(value = "formatDisabled", required = false, defaultValue = "true") Boolean formatDisabled, @RequestParam(value = "sourceDisabled", required = false, defaultValue = "false") Boolean sourceDisabled) {
Sheet sheet = sheetService.getById(sheetId);
SheetDetailVO sheetDetailVO = sheetRenderAssembler.convertToDetailVo(sheet);
if (formatDisabled) {
// Clear the format content
sheetDetailVO.setContent(null);
}
if (sourceDisabled) {
// Clear the original content
sheetDetailVO.setOriginalContent(null);
}
sheetService.publishVisitEvent(sheetDetailVO.getId());
return sheetDetailVO;
}
use of run.halo.app.model.vo.SheetDetailVO in project halo by ruibaby.
the class SheetController method getBy.
@GetMapping("/slug")
@ApiOperation("Gets a sheet by slug")
public SheetDetailVO getBy(@RequestParam("slug") String slug, @RequestParam(value = "formatDisabled", required = false, defaultValue = "true") Boolean formatDisabled, @RequestParam(value = "sourceDisabled", required = false, defaultValue = "false") Boolean sourceDisabled) {
Sheet sheet = sheetService.getBySlug(slug);
SheetDetailVO sheetDetailVO = sheetRenderAssembler.convertToDetailVo(sheet);
if (formatDisabled) {
// Clear the format content
sheetDetailVO.setContent(null);
}
if (sourceDisabled) {
// Clear the original content
sheetDetailVO.setOriginalContent(null);
}
sheetService.publishVisitEvent(sheetDetailVO.getId());
return sheetDetailVO;
}
use of run.halo.app.model.vo.SheetDetailVO in project halo by halo-dev.
the class SheetAssembler method convertTo.
@NonNull
public SheetDetailVO convertTo(@NonNull Sheet sheet, List<SheetMeta> metas) {
Assert.notNull(sheet, "Sheet must not be null");
// Convert to base detail vo
SheetDetailVO sheetDetailVO = new SheetDetailVO().convertFrom(sheet);
Set<Long> metaIds = ServiceUtils.fetchProperty(metas, SheetMeta::getId);
// Get sheet meta ids
sheetDetailVO.setMetaIds(metaIds);
sheetDetailVO.setMetas(sheetMetaService.convertTo(metas));
generateAndSetSummaryIfAbsent(sheet, sheetDetailVO);
sheetDetailVO.setCommentCount(sheetCommentService.countByStatusAndPostId(CommentStatus.PUBLISHED, sheet.getId()));
sheetDetailVO.setFullPath(buildFullPath(sheet));
PatchedContent sheetContent = sheet.getContent();
sheetDetailVO.setContent(sheetContent.getContent());
sheetDetailVO.setOriginalContent(sheetContent.getOriginalContent());
// Sheet currently drafting in process
Boolean inProgress = contentService.draftingInProgress(sheet.getId());
sheetDetailVO.setInProgress(inProgress);
return sheetDetailVO;
}
use of run.halo.app.model.vo.SheetDetailVO in project halo by halo-dev.
the class SheetModel method content.
/**
* Sheet content.
*
* @param sheet sheet
* @param token token
* @param model model
* @return template name
*/
public String content(Sheet sheet, String token, Model model) {
SheetDetailVO sheetDetailVo;
if (StringUtils.isEmpty(token)) {
sheet = sheetService.getBy(PostStatus.PUBLISHED, sheet.getSlug());
sheetDetailVo = sheetRenderAssembler.convertToDetailVo(sheet);
} else {
// verify token
String cachedToken = cacheStore.getAny(token, String.class).orElseThrow(() -> new ForbiddenException("您没有该页面的访问权限"));
if (!cachedToken.equals(token)) {
throw new ForbiddenException("您没有该页面的访问权限");
}
sheetDetailVo = sheetRenderAssembler.convertToPreviewDetailVo(sheet);
}
sheetService.publishVisitEvent(sheet.getId());
List<SheetMeta> metas = sheetMetaService.listBy(sheet.getId());
// Generate meta keywords.
if (StringUtils.isNotEmpty(sheet.getMetaKeywords())) {
model.addAttribute("meta_keywords", sheet.getMetaKeywords());
} else {
model.addAttribute("meta_keywords", optionService.getSeoKeywords());
}
// Generate meta description.
if (StringUtils.isNotEmpty(sheet.getMetaDescription())) {
model.addAttribute("meta_description", sheet.getMetaDescription());
} else {
model.addAttribute("meta_description", sheetService.generateDescription(sheet.getContent().getContent()));
}
// sheet and post all can use
model.addAttribute("sheet", sheetDetailVo);
model.addAttribute("post", sheetDetailVo);
model.addAttribute("is_sheet", true);
model.addAttribute("metas", sheetMetaService.convertToMap(metas));
if (themeService.templateExists(ThemeService.CUSTOM_SHEET_PREFIX + sheet.getTemplate() + HaloConst.SUFFIX_FTL)) {
return themeService.render(ThemeService.CUSTOM_SHEET_PREFIX + sheet.getTemplate());
}
return themeService.render("sheet");
}
use of run.halo.app.model.vo.SheetDetailVO in project halo by halo-dev.
the class SheetController method getBy.
@GetMapping("{sheetId:\\d+}")
@ApiOperation("Gets a sheet")
public SheetDetailVO getBy(@PathVariable("sheetId") Integer sheetId, @RequestParam(value = "formatDisabled", required = false, defaultValue = "true") Boolean formatDisabled, @RequestParam(value = "sourceDisabled", required = false, defaultValue = "false") Boolean sourceDisabled) {
Sheet sheet = sheetService.getById(sheetId);
SheetDetailVO sheetDetailVO = sheetRenderAssembler.convertToDetailVo(sheet);
if (formatDisabled) {
// Clear the format content
sheetDetailVO.setContent(null);
}
if (sourceDisabled) {
// Clear the original content
sheetDetailVO.setOriginalContent(null);
}
sheetService.publishVisitEvent(sheetDetailVO.getId());
return sheetDetailVO;
}
Aggregations