use of run.halo.app.model.vo.SheetDetailVO in project halo by ruibaby.
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 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 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-plugin-experimental by guqing.
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) {
SheetDetailVO sheetDetailVO = sheetService.convertToDetailVo(sheetService.getBySlug(slug));
if (formatDisabled) {
// Clear the format content
sheetDetailVO.setFormatContent(null);
}
if (sourceDisabled) {
// Clear the original content
sheetDetailVO.setOriginalContent(null);
}
sheetService.publishVisitEvent(sheetDetailVO.getId());
return sheetDetailVO;
}
Aggregations