mirror of https://github.com/halo-dev/halo
commit
8508a374e6
|
@ -1,4 +1,4 @@
|
|||
FROM openjdk:8-jdk-alpine
|
||||
FROM openjdk:8-jre-alpine
|
||||
|
||||
VOLUME /tmp
|
||||
|
||||
|
|
28
README.md
28
README.md
|
@ -1,13 +1,12 @@
|
|||
<h1 align="center"><a href="https://github.com/halo-dev" target="_blank">Halo</a></h1>
|
||||
|
||||
> Halo 可能是最好的 Java 博客系统。
|
||||
> Halo 是一款现代化的个人独立博客系统,给习惯写博客的同学一个更好的选择。
|
||||
|
||||
<p align="center">
|
||||
<a href="https://ryanc.cc"><img alt="Author" src="https://img.shields.io/badge/author-ruibaby-red.svg?style=flat-square"/></a>
|
||||
<a href="#"><img alt="JDK" src="https://img.shields.io/badge/JDK-1.8-yellow.svg?style=flat-square"/></a>
|
||||
<a href="https://github.com/halo-dev/halo/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/halo-dev/halo.svg?style=flat-square"/></a>
|
||||
<a href="https://travis-ci.org/halo-dev/halo"><img alt="Travis CI" src="https://img.shields.io/travis/halo-dev/halo.svg?style=flat-square"/></a>
|
||||
<a href="https://hub.docker.com/r/halo-dev/halo/"><img alt="Docker Build Status" src="https://img.shields.io/docker/build/halo-dev/halo.svg?style=flat-square"/></a>
|
||||
</p>
|
||||
|
||||
------------------------------
|
||||
|
@ -32,28 +31,13 @@
|
|||
|
||||
## 博客示例
|
||||
|
||||
[Ryan0up'S Blog](https://ryanc.cc)
|
||||
请看 <[https://github.com/halo-dev/halo/issues/26](https://github.com/halo-dev/halo/issues/26)>。
|
||||
|
||||
[SNAIL BLOG](https://slogc.cc)
|
||||
## 周边
|
||||
|
||||
[宋浩志博客](http://songhaozhi.com)
|
||||
|
||||
[KingYiFan'S Blog](https://blog.cnbuilder.cn)
|
||||
|
||||
[AquanBlog](https://blog.eunji.cn/)
|
||||
|
||||
## 主题
|
||||
|
||||
除了内置的 [Anatole](https://github.com/hi-caicai/farbox-theme-Anatole) 和 [Material](https://github.com/viosey/hexo-theme-material) ,还有下列主题没有集成在项目里,如有需要,请自行下载之后通过后台上传上去使用。
|
||||
|
||||
- [Vno](https://github.com/halo-dev/vno-halo) - 来自 Jekyll 的一款主题,作者 [Wei Wang](https://onevcat.com/)。
|
||||
- [Hux](https://github.com/halo-dev/hux-halo) - 来自 Jekyll 的一款主题,作者 [Xuan Huang](https://huangxuan.me/)。
|
||||
- [Story](https://github.com/halo-dev/story-halo) - 来自 Typecho 的一款主题,作者 [Trii Hsia](https://yumoe.com/)。
|
||||
- [NexT](https://github.com/halo-dev/next-halo) - 来自 Hexo 的一款主题,作者 [iissnan](https://notes.iissnan.com/)。
|
||||
- [Casper](https://github.com/halo-dev/casper-halo) - 来自 Ghost 的一款主题,作者 [Ghost](https://github.com/TryGhost)。
|
||||
- [Pinghsu](https://github.com/halo-dev/pinghsu-halo) - 来自 Typecho 的一款主题,作者 [Chakhsu.Lau](https://github.com/chakhsu)。
|
||||
|
||||
> 声明:不接受任何对**移植主题**功能上的意见和建议。
|
||||
- 后台管理源码:<[https://github.com/halo-dev/halo-admin](https://github.com/halo-dev/halo-admin)>
|
||||
- 主题仓库:<[https://halo.run/theme](https://halo.run/theme)>
|
||||
- 管理 APP:<[https://github.com/halo-dev/halo-app](https://github.com/halo-dev/halo-app)>
|
||||
|
||||
## 许可证
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package run.halo.app;
|
||||
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import run.halo.app.repository.base.BaseRepositoryImpl;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import run.halo.app.repository.base.BaseRepositoryImpl;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
|
|
@ -94,6 +94,12 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
log.debug("Removed key: [{}]", key);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
log.debug("Cancelling all timer tasks");
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache cleaner.
|
||||
*
|
||||
|
@ -111,10 +117,4 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
log.debug("Cancelling all timer tasks");
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
@ -114,7 +113,7 @@ public class HaloConfiguration {
|
|||
ApiAuthenticationFilter apiFilter = new ApiAuthenticationFilter(haloProperties, optionService);
|
||||
apiFilter.addExcludeUrlPatterns(
|
||||
"/api/content/*/comments",
|
||||
"/api/content/**/comments/*"
|
||||
"/api/content/**/comments/**"
|
||||
);
|
||||
|
||||
DefaultAuthenticationFailureHandler failureHandler = new DefaultAuthenticationFailureHandler();
|
||||
|
|
|
@ -3,7 +3,6 @@ package run.halo.app.config;
|
|||
import com.fasterxml.classmate.TypeResolver;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
|
@ -57,7 +56,7 @@ public class SwaggerConfiguration {
|
|||
new ResponseMessageBuilder().code(404).message("Not found").build(),
|
||||
new ResponseMessageBuilder().code(500).message("Internal server error").build());
|
||||
|
||||
public SwaggerConfiguration( HaloProperties haloProperties) {
|
||||
public SwaggerConfiguration(HaloProperties haloProperties) {
|
||||
this.haloProperties = haloProperties;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class LogController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
public Page<LogDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable){
|
||||
public Page<LogDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
||||
Page<Log> logPage = logService.listAll(pageable);
|
||||
return logPage.map(log -> new LogDTO().convertFrom(log));
|
||||
}
|
||||
|
|
|
@ -4,10 +4,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.OptionDTO;
|
||||
import run.halo.app.model.params.MailParam;
|
||||
import run.halo.app.model.params.OptionParam;
|
||||
import run.halo.app.model.support.BaseResponse;
|
||||
import run.halo.app.service.MailService;
|
||||
import run.halo.app.service.OptionService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.controller.base;
|
||||
|
||||
import run.halo.app.model.support.BaseResponse;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package run.halo.app.controller.base;
|
||||
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import run.halo.app.exception.HaloException;
|
||||
import run.halo.app.model.support.BaseResponse;
|
||||
import run.halo.app.utils.ExceptionUtils;
|
||||
import run.halo.app.utils.ValidationUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
|
|
|
@ -33,15 +33,11 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
@Controller
|
||||
public class ContentFeedController {
|
||||
|
||||
private final PostService postService;
|
||||
|
||||
private final OptionService optionService;
|
||||
|
||||
private final FreeMarkerConfigurer freeMarker;
|
||||
|
||||
private final static String UTF_8_SUFFIX = ";charset=UTF-8";
|
||||
|
||||
private final static String XML_MEDIA_TYPE = MediaType.APPLICATION_XML_VALUE + UTF_8_SUFFIX;
|
||||
private final PostService postService;
|
||||
private final OptionService optionService;
|
||||
private final FreeMarkerConfigurer freeMarker;
|
||||
|
||||
public ContentFeedController(PostService postService,
|
||||
OptionService optionService,
|
||||
|
|
|
@ -59,8 +59,16 @@ public class MainController {
|
|||
@GetMapping("/logo")
|
||||
public void logo(HttpServletResponse response) throws IOException {
|
||||
String blogLogo = optionService.getByProperty(BlogProperties.BLOG_LOGO).orElse("").toString();
|
||||
if(StringUtils.isNotEmpty(blogLogo)){
|
||||
if (StringUtils.isNotEmpty(blogLogo)) {
|
||||
response.sendRedirect(blogLogo);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/favicon.ico")
|
||||
public void favicon(HttpServletResponse response) throws IOException {
|
||||
String favicon = optionService.getByProperty(BlogProperties.BLOG_FAVICON).orElse("").toString();
|
||||
if (StringUtils.isNotEmpty(favicon)) {
|
||||
response.sendRedirect(favicon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package run.halo.app.controller.content.api;
|
||||
|
||||
import run.halo.app.model.vo.ArchiveMonthVO;
|
||||
import run.halo.app.model.vo.ArchiveYearVO;
|
||||
import run.halo.app.service.PostService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import run.halo.app.model.vo.ArchiveMonthVO;
|
||||
import run.halo.app.model.vo.ArchiveYearVO;
|
||||
import run.halo.app.service.PostService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package run.halo.app.controller.content.api;
|
||||
|
||||
import run.halo.app.model.vo.LinkTeamVO;
|
||||
import run.halo.app.service.LinkService;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package run.halo.app.controller.content.api;
|
||||
|
||||
import run.halo.app.model.dto.MenuDTO;
|
||||
import run.halo.app.service.MenuService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import run.halo.app.model.dto.MenuDTO;
|
||||
import run.halo.app.service.MenuService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package run.halo.app.controller.content.api;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import run.halo.app.model.dto.OptionDTO;
|
||||
import run.halo.app.model.support.BaseResponse;
|
||||
import run.halo.app.service.OptionService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -97,7 +97,6 @@ public class PostController {
|
|||
return postCommentService.convertTo(postComments);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("{postId:\\d+}/comments/tree_view")
|
||||
@ApiOperation("Lists comments with tree view")
|
||||
public Page<BaseCommentVO> listCommentsTree(@PathVariable("postId") Integer postId,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package run.halo.app.controller.content.api;
|
||||
|
||||
import run.halo.app.model.dto.UserDTO;
|
||||
import run.halo.app.service.UserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import run.halo.app.model.dto.UserDTO;
|
||||
import run.halo.app.service.UserService;
|
||||
|
||||
/**
|
||||
* Portal user controller.
|
||||
|
@ -26,6 +26,6 @@ public class UserController {
|
|||
@GetMapping("profile")
|
||||
@ApiOperation("Gets blogger profile")
|
||||
public UserDTO getProfile() {
|
||||
return userService.getCurrentUser().map(user -> new UserDTO().<UserDTO>convertFrom(user)).get();
|
||||
return userService.getCurrentUser().map(user -> (UserDTO) new UserDTO().convertFrom(user)).get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class CommonController implements ErrorController {
|
|||
return "common/error/404";
|
||||
}
|
||||
StrBuilder path = new StrBuilder("themes/");
|
||||
path.append(themeService.getActivatedThemeId());
|
||||
path.append(themeService.getActivatedTheme().getFolderName());
|
||||
path.append("/404");
|
||||
return path.toString();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class CommonController implements ErrorController {
|
|||
return "common/error/500";
|
||||
}
|
||||
StrBuilder path = new StrBuilder("themes/");
|
||||
path.append(themeService.getActivatedThemeId());
|
||||
path.append(themeService.getActivatedTheme().getFolderName());
|
||||
path.append("/500");
|
||||
return path.toString();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.controller.support;
|
||||
|
||||
import run.halo.app.model.support.CommentPage;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class CommentEventListener {
|
|||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
if (newEvent.getSource() instanceof PostService) {
|
||||
if (newEvent.getSource() instanceof PostCommentService) {
|
||||
// Get postComment id
|
||||
PostComment postComment = postCommentService.getById(newEvent.getCommentId());
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class CommentEventListener {
|
|||
data.put("page", post.getTitle());
|
||||
data.put("author", postComment.getAuthor());
|
||||
data.put("content", postComment.getContent());
|
||||
} else if (newEvent.getSource() instanceof SheetService) {
|
||||
} else if (newEvent.getSource() instanceof SheetCommentService) {
|
||||
SheetComment sheetComment = sheetCommentService.getById(newEvent.getCommentId());
|
||||
|
||||
log.debug("Got sheet comment: [{}]", sheetComment);
|
||||
|
@ -99,7 +99,7 @@ public class CommentEventListener {
|
|||
data.put("page", sheet.getTitle());
|
||||
data.put("author", sheetComment.getAuthor());
|
||||
data.put("content", sheetComment.getContent());
|
||||
} else if (newEvent.getSource() instanceof JournalService) {
|
||||
} else if (newEvent.getSource() instanceof JournalCommentService) {
|
||||
JournalComment journalComment = journalCommentService.getById(newEvent.getCommentId());
|
||||
|
||||
log.debug("Got journal comment: [{}]", journalComment);
|
||||
|
|
|
@ -78,6 +78,7 @@ public class FreemarkerConfigAwareListener {
|
|||
log.debug("Received option updated event");
|
||||
|
||||
loadOptionsConfig();
|
||||
loadThemeConfig();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package run.halo.app.event.theme;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
||||
|
||||
/**
|
||||
* Theme activated event.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package run.halo.app.event.theme;
|
||||
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import run.halo.app.cache.StringCacheStore;
|
||||
import run.halo.app.event.options.OptionUpdatedEvent;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package run.halo.app.filter;
|
||||
|
||||
import run.halo.app.security.filter.AdminAuthenticationFilter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.cors.CorsUtils;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
import run.halo.app.security.filter.AdminAuthenticationFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -22,6 +22,39 @@ public interface FileHandler {
|
|||
|
||||
MediaType IMAGE_TYPE = MediaType.valueOf("image/*");
|
||||
|
||||
/**
|
||||
* Check whether media type provided is an image type.
|
||||
*
|
||||
* @param mediaType media type provided
|
||||
* @return true if it is an image type
|
||||
*/
|
||||
static boolean isImageType(@Nullable String mediaType) {
|
||||
return mediaType != null && IMAGE_TYPE.includes(MediaType.valueOf(mediaType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether media type provided is an image type.
|
||||
*
|
||||
* @param mediaType media type provided
|
||||
* @return true if it is an image type
|
||||
*/
|
||||
static boolean isImageType(@Nullable MediaType mediaType) {
|
||||
return mediaType != null && IMAGE_TYPE.includes(mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize directory full name, ensure the end path separator.
|
||||
*
|
||||
* @param dir directory full name must not be blank
|
||||
* @return normalized directory full name with end path separator
|
||||
*/
|
||||
@NonNull
|
||||
static String normalizeDirectory(@NonNull String dir) {
|
||||
Assert.hasText(dir, "Directory full name must not be blank");
|
||||
|
||||
return StringUtils.appendIfMissing(dir, FILE_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads file.
|
||||
*
|
||||
|
@ -47,39 +80,4 @@ public interface FileHandler {
|
|||
* @return true if supported; false or else
|
||||
*/
|
||||
boolean supportType(@Nullable AttachmentType type);
|
||||
|
||||
|
||||
/**
|
||||
* Check whether media type provided is an image type.
|
||||
*
|
||||
* @param mediaType media type provided
|
||||
* @return true if it is an image type
|
||||
*/
|
||||
static boolean isImageType(@Nullable String mediaType) {
|
||||
return mediaType != null && IMAGE_TYPE.includes(MediaType.valueOf(mediaType));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether media type provided is an image type.
|
||||
*
|
||||
* @param mediaType media type provided
|
||||
* @return true if it is an image type
|
||||
*/
|
||||
static boolean isImageType(@Nullable MediaType mediaType) {
|
||||
return mediaType != null && IMAGE_TYPE.includes(mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize directory full name, ensure the end path separator.
|
||||
*
|
||||
* @param dir directory full name must not be blank
|
||||
* @return normalized directory full name with end path separator
|
||||
*/
|
||||
@NonNull
|
||||
static String normalizeDirectory(@NonNull String dir) {
|
||||
Assert.hasText(dir, "Directory full name must not be blank");
|
||||
|
||||
return StringUtils.appendIfMissing(dir, FILE_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package run.halo.app.handler.file;
|
||||
|
||||
import run.halo.app.exception.FileOperationException;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.model.support.UploadResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
@ -12,6 +8,10 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import run.halo.app.exception.FileOperationException;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.model.support.UploadResult;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package run.halo.app.handler.file;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import run.halo.app.config.properties.HaloProperties;
|
||||
import run.halo.app.exception.FileOperationException;
|
||||
import run.halo.app.exception.ServiceException;
|
||||
|
@ -8,13 +15,6 @@ import run.halo.app.model.support.UploadResult;
|
|||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.utils.FilenameUtils;
|
||||
import run.halo.app.utils.HaloUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
|
|
@ -115,6 +115,7 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
|
|||
item.setDataType(DataType.typeOf(dataType));
|
||||
item.setType(InputType.typeOf(itemMap.get("type")));
|
||||
item.setDefaultValue(itemMap.get("default"));
|
||||
item.setPlaceholder(itemMap.getOrDefault("placeholder", "").toString());
|
||||
|
||||
// Handle options
|
||||
item.setOptions(handleOptions(itemMap.get("options")));
|
||||
|
@ -140,6 +141,7 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
|
|||
item.setDataType(DataType.typeOf(dataType));
|
||||
item.setType(InputType.typeOf(itemMap.get("type")));
|
||||
item.setDefaultValue(itemMap.get("default"));
|
||||
item.setPlaceholder(itemMap.getOrDefault("placeholder", "").toString());
|
||||
|
||||
// Handle options
|
||||
item.setOptions(handleOptions(itemMap.get("options")));
|
||||
|
|
|
@ -41,6 +41,11 @@ public class Item {
|
|||
*/
|
||||
private Object defaultValue;
|
||||
|
||||
/**
|
||||
* Text item placeholder.
|
||||
*/
|
||||
private String placeholder;
|
||||
|
||||
/**
|
||||
* Item's options, default is empty list
|
||||
*/
|
||||
|
|
|
@ -73,6 +73,19 @@ public class ThemeProperty {
|
|||
*/
|
||||
private String screenshots;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ThemeProperty that = (ThemeProperty) o;
|
||||
return id.equals(that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Author {
|
||||
|
||||
|
@ -91,17 +104,4 @@ public class ThemeProperty {
|
|||
*/
|
||||
private String avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ThemeProperty that = (ThemeProperty) o;
|
||||
return id.equals(that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.listener;
|
||||
|
||||
import com.sun.nio.zipfs.JarFileSystemProvider;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
|
@ -10,20 +9,15 @@ import org.springframework.core.Ordered;
|
|||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import run.halo.app.config.properties.HaloProperties;
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.model.params.UserParam;
|
||||
import run.halo.app.model.properties.PrimaryProperties;
|
||||
import run.halo.app.model.support.CreateCheck;
|
||||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.service.ThemeService;
|
||||
import run.halo.app.service.UserService;
|
||||
import run.halo.app.utils.FileUtils;
|
||||
import run.halo.app.utils.ValidationUtils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The method executed after the application is started.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Attachment;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Category;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Category output dto.
|
||||
|
@ -26,4 +28,6 @@ public class CategoryDTO implements OutputConverter<CategoryDTO, Category> {
|
|||
private String description;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Link;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Link output dto.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Log;
|
||||
import run.halo.app.model.enums.LogType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Log;
|
||||
import run.halo.app.model.enums.LogType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Menu;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Menu output dto.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Photo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Tag output dto.
|
||||
|
@ -18,4 +20,6 @@ public class TagDTO implements OutputConverter<TagDTO, Tag> {
|
|||
private String name;
|
||||
|
||||
private String slugName;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package run.halo.app.model.dto;
|
||||
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.User;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import run.halo.app.model.dto.base.OutputConverter;
|
||||
import run.halo.app.model.entity.User;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package run.halo.app.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package run.halo.app.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
|
|
@ -29,12 +29,6 @@ public enum DataType implements ValueEnum<Integer> {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data type of string.
|
||||
*
|
||||
|
@ -53,6 +47,11 @@ public enum DataType implements ValueEnum<Integer> {
|
|||
return STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts data to corresponding type.
|
||||
*
|
||||
|
|
|
@ -12,13 +12,6 @@ import java.util.stream.Stream;
|
|||
*/
|
||||
public interface ValueEnum<T> {
|
||||
|
||||
/**
|
||||
* Gets enum value.
|
||||
*
|
||||
* @return enum value
|
||||
*/
|
||||
T getValue();
|
||||
|
||||
/**
|
||||
* Converts value to corresponding enum.
|
||||
*
|
||||
|
@ -39,4 +32,11 @@ public interface ValueEnum<T> {
|
|||
.orElseThrow(() -> new IllegalArgumentException("unknown database value: " + value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets enum value.
|
||||
*
|
||||
* @return enum value
|
||||
*/
|
||||
T getValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.model.enums.converter;
|
||||
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
import run.halo.app.model.enums.AttachmentType;
|
||||
|
||||
import javax.persistence.Converter;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MenuTagDirective implements TemplateDirectiveModel {
|
|||
|
||||
private final MenuService menuService;
|
||||
|
||||
public MenuTagDirective(Configuration configuration,MenuService menuService) {
|
||||
public MenuTagDirective(Configuration configuration, MenuService menuService) {
|
||||
this.menuService = menuService;
|
||||
configuration.setSharedVariable("menuTag", this);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class MenuTagDirective implements TemplateDirectiveModel {
|
|||
env.setVariable("menus", builder.build().wrap(menuService.listAll()));
|
||||
break;
|
||||
case "tree":
|
||||
env.setVariable("menus",builder.build().wrap(menuService.listAsTree(Sort.by(DESC, "priority"))));
|
||||
env.setVariable("menus", builder.build().wrap(menuService.listAsTree(Sort.by(DESC, "priority"))));
|
||||
break;
|
||||
case "count":
|
||||
env.setVariable("count", builder.build().wrap(menuService.count()));
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Category;
|
||||
import run.halo.app.utils.HaloUtils;
|
||||
import run.halo.app.utils.SlugUtils;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Link;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Link;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import lombok.Data;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Option;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.enums.PostCreateFrom;
|
||||
import run.halo.app.model.enums.PostStatus;
|
||||
import run.halo.app.utils.HaloUtils;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.utils.HaloUtils;
|
||||
import run.halo.app.utils.SlugUtils;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import run.halo.app.model.dto.base.InputConverter;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.utils.HaloUtils;
|
||||
import run.halo.app.utils.SlugUtils;
|
||||
|
||||
|
|
|
@ -51,4 +51,5 @@ public enum CommentProperties implements PropertyEnum {
|
|||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum OtherProperties implements PropertyEnum {
|
|||
/**
|
||||
* 是否禁止爬虫
|
||||
*/
|
||||
SPIDER_DISABLED("spider_disabled",Boolean.class,"false");
|
||||
SPIDER_DISABLED("spider_disabled", Boolean.class, "false");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public enum SeoProperties implements PropertyEnum {
|
|||
private final String value;
|
||||
|
||||
private final Class<?> type;
|
||||
|
||||
|
||||
private final String defaultValue;
|
||||
|
||||
SeoProperties(String value, Class<?> type, String defaultValue) {
|
||||
|
@ -47,4 +47,5 @@ public enum SeoProperties implements PropertyEnum {
|
|||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,9 @@ public enum UpYunProperties implements PropertyEnum {
|
|||
|
||||
OSS_SMALL_URL("oss_upyun_small_url", String.class, "");
|
||||
|
||||
private String value;
|
||||
|
||||
private Class<?> type;
|
||||
|
||||
private final String defaultValue;
|
||||
private String value;
|
||||
private Class<?> type;
|
||||
|
||||
UpYunProperties(String value, Class<?> type, String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package run.halo.app.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import run.halo.app.model.dto.CategoryDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.model.vo;
|
||||
|
||||
import run.halo.app.model.dto.LinkDTO;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import run.halo.app.model.dto.LinkDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.Category;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.JournalComment;
|
||||
import run.halo.app.model.projection.CommentCountProjection;
|
||||
import run.halo.app.repository.base.BaseCommentRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Journal comment repository.
|
||||
*
|
||||
|
|
|
@ -2,7 +2,6 @@ package run.halo.app.repository;
|
|||
|
||||
import run.halo.app.model.entity.Link;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
/**
|
||||
* Link repository.
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.Menu;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Menu repository.
|
||||
|
|
|
@ -2,7 +2,6 @@ package run.halo.app.repository;
|
|||
|
||||
import run.halo.app.model.entity.Option;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.PostComment;
|
||||
import run.halo.app.model.projection.CommentCountProjection;
|
||||
import run.halo.app.repository.base.BaseCommentRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PostComment repository.
|
||||
*
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.PostTag;
|
||||
import run.halo.app.model.projection.TagPostPostCountProjection;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.SheetComment;
|
||||
import run.halo.app.model.projection.CommentCountProjection;
|
||||
import run.halo.app.repository.base.BaseCommentRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sheet comment repository.
|
||||
*
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
|
|
@ -40,6 +40,26 @@ public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN,
|
|||
this.entityManager = entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a count query and transparently sums up all values returned.
|
||||
*
|
||||
* @param query must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
private static long executeCountQuery(TypedQuery<Long> query) {
|
||||
|
||||
Assert.notNull(query, "TypedQuery must not be null!");
|
||||
|
||||
List<Long> totals = query.getResultList();
|
||||
long total = 0L;
|
||||
|
||||
for (Long element : totals) {
|
||||
total += element == null ? 0 : element;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all domain by id list and the specified sort.
|
||||
*
|
||||
|
@ -140,24 +160,4 @@ public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN,
|
|||
return path.in(this.parameter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a count query and transparently sums up all values returned.
|
||||
*
|
||||
* @param query must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
private static long executeCountQuery(TypedQuery<Long> query) {
|
||||
|
||||
Assert.notNull(query, "TypedQuery must not be null!");
|
||||
|
||||
List<Long> totals = query.getResultList();
|
||||
long total = 0L;
|
||||
|
||||
for (Long element : totals) {
|
||||
total += element == null ? 0 : element;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package run.halo.app.security.authentication;
|
||||
|
||||
import run.halo.app.security.support.UserDetail;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.security.support.UserDetail;
|
||||
|
||||
/**
|
||||
* Authentication.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.security.context;
|
||||
|
||||
import run.halo.app.security.authentication.Authentication;
|
||||
import org.springframework.lang.Nullable;
|
||||
import run.halo.app.security.authentication.Authentication;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.security.context;
|
||||
|
||||
import run.halo.app.security.authentication.Authentication;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
|
@ -31,19 +31,15 @@ import java.util.Set;
|
|||
*/
|
||||
public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
protected final AntPathMatcher antPathMatcher;
|
||||
protected final HaloProperties haloProperties;
|
||||
protected final OptionService optionService;
|
||||
private AuthenticationFailureHandler failureHandler;
|
||||
|
||||
/**
|
||||
* Exclude url patterns.
|
||||
*/
|
||||
private Set<String> excludeUrlPatterns = new HashSet<>(2);
|
||||
|
||||
protected final AntPathMatcher antPathMatcher;
|
||||
|
||||
protected final HaloProperties haloProperties;
|
||||
|
||||
protected final OptionService optionService;
|
||||
|
||||
protected AbstractAuthenticationFilter(HaloProperties haloProperties,
|
||||
OptionService optionService) {
|
||||
this.haloProperties = haloProperties;
|
||||
|
@ -70,17 +66,6 @@ public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter
|
|||
return excludeUrlPatterns.stream().anyMatch(p -> antPathMatcher.match(p, request.getServletPath()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets exclude url patterns.
|
||||
*
|
||||
* @param excludeUrlPatterns exclude urls
|
||||
*/
|
||||
public void setExcludeUrlPatterns(@NonNull Collection<String> excludeUrlPatterns) {
|
||||
Assert.notNull(excludeUrlPatterns, "Exclude url patterns must not be null");
|
||||
|
||||
this.excludeUrlPatterns = new HashSet<>(excludeUrlPatterns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds exclude url patterns.
|
||||
*
|
||||
|
@ -102,6 +87,16 @@ public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter
|
|||
return excludeUrlPatterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets exclude url patterns.
|
||||
*
|
||||
* @param excludeUrlPatterns exclude urls
|
||||
*/
|
||||
public void setExcludeUrlPatterns(@NonNull Collection<String> excludeUrlPatterns) {
|
||||
Assert.notNull(excludeUrlPatterns, "Exclude url patterns must not be null");
|
||||
|
||||
this.excludeUrlPatterns = new HashSet<>(excludeUrlPatterns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets authentication failure handler. (Default: @DefaultAuthenticationFailureHandler)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.security.handler;
|
||||
|
||||
import run.halo.app.exception.HaloException;
|
||||
import run.halo.app.exception.HaloException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package run.halo.app.security.resolver;
|
||||
|
||||
import run.halo.app.exception.AuthenticationException;
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.security.authentication.Authentication;
|
||||
import run.halo.app.security.context.SecurityContextHolder;
|
||||
import run.halo.app.security.support.UserDetail;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
@ -12,6 +7,11 @@ import org.springframework.web.bind.support.WebDataBinderFactory;
|
|||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
import run.halo.app.exception.AuthenticationException;
|
||||
import run.halo.app.model.entity.User;
|
||||
import run.halo.app.security.authentication.Authentication;
|
||||
import run.halo.app.security.context.SecurityContextHolder;
|
||||
import run.halo.app.security.support.UserDetail;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package run.halo.app.security.support;
|
||||
|
||||
import run.halo.app.exception.AuthenticationException;
|
||||
import run.halo.app.model.entity.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.exception.AuthenticationException;
|
||||
import run.halo.app.model.entity.User;
|
||||
|
||||
/**
|
||||
* User detail.
|
||||
|
|
|
@ -50,6 +50,7 @@ public interface AdminService {
|
|||
|
||||
/**
|
||||
* Get system environments
|
||||
*
|
||||
* @return environments
|
||||
*/
|
||||
@NonNull
|
||||
|
|
|
@ -59,6 +59,7 @@ public interface AttachmentService extends CrudService<Attachment, Integer> {
|
|||
|
||||
/**
|
||||
* List all media type.
|
||||
*
|
||||
* @return list of media type
|
||||
*/
|
||||
List<String> listAllMediaType();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package run.halo.app.service;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import run.halo.app.model.dto.LinkDTO;
|
||||
import run.halo.app.model.entity.Link;
|
||||
import run.halo.app.model.params.LinkParam;
|
||||
import run.halo.app.model.vo.LinkTeamVO;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package run.halo.app.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import run.halo.app.model.dto.LogDTO;
|
||||
import run.halo.app.model.entity.Log;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
/**
|
||||
* Log service.
|
||||
|
|
|
@ -32,11 +32,11 @@ public interface MailService {
|
|||
/**
|
||||
* Send mail with attachments
|
||||
*
|
||||
* @param to recipient
|
||||
* @param subject subject
|
||||
* @param content content
|
||||
* @param templateName template name
|
||||
* @param attachFilename attachment path
|
||||
* @param to recipient
|
||||
* @param subject subject
|
||||
* @param content content
|
||||
* @param templateName template name
|
||||
* @param attachFilename attachment path
|
||||
*/
|
||||
void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachFilename);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public interface PhotoService extends CrudService<Photo, Integer> {
|
|||
/**
|
||||
* Pages photo output dtos.
|
||||
*
|
||||
* @param pageable page info must not be null
|
||||
* @param pageable page info must not be null
|
||||
* @param photoQuery photoQuery
|
||||
* @return a page of photo output dto
|
||||
*/
|
||||
|
|
|
@ -106,6 +106,24 @@ public interface PostService extends BasePostService<Post> {
|
|||
@NonNull
|
||||
Post importMarkdown(@NonNull String markdown);
|
||||
|
||||
/**
|
||||
* Export post to markdown file by post id.
|
||||
*
|
||||
* @param id post id
|
||||
* @return markdown file content
|
||||
*/
|
||||
@NonNull
|
||||
String exportMarkdown(@NonNull Integer id);
|
||||
|
||||
/**
|
||||
* Export post to markdown file by post.
|
||||
*
|
||||
* @param post current post
|
||||
* @return markdown file content
|
||||
*/
|
||||
@NonNull
|
||||
String exportMarkdown(@NonNull Post post);
|
||||
|
||||
/**
|
||||
* Converts to detail vo.
|
||||
*
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package run.halo.app.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import run.halo.app.model.dto.TagWithPostCountDTO;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.entity.PostTag;
|
||||
import run.halo.app.model.entity.Tag;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
|
@ -54,6 +54,24 @@ public interface SheetService extends BasePostService<Sheet> {
|
|||
@NonNull
|
||||
Sheet importMarkdown(@NonNull String markdown);
|
||||
|
||||
/**
|
||||
* Export sheet to markdown file by sheet id.
|
||||
*
|
||||
* @param id sheet id
|
||||
* @return markdown file content
|
||||
*/
|
||||
@NonNull
|
||||
String exportMarkdown(@NonNull Integer id);
|
||||
|
||||
/**
|
||||
* Export sheet to markdown file by sheet.
|
||||
*
|
||||
* @param sheet current sheet
|
||||
* @return markdown file content
|
||||
*/
|
||||
@NonNull
|
||||
String exportMarkdown(@NonNull Sheet sheet);
|
||||
|
||||
/**
|
||||
* Converts to list dto page.
|
||||
*
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package run.halo.app.service.base;
|
||||
|
||||
import run.halo.app.exception.NotFoundException;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import run.halo.app.exception.NotFoundException;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
|
|
@ -122,6 +122,7 @@ public interface BasePostService<POST extends BasePost> extends CrudService<POST
|
|||
|
||||
/**
|
||||
* Lists latest posts.
|
||||
*
|
||||
* @param top top number must not be less than 0
|
||||
* @return latest posts
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package run.halo.app.service.base;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import run.halo.app.exception.NotFoundException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import run.halo.app.exception.NotFoundException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
|
@ -192,7 +192,7 @@ public class AdminServiceImpl implements AdminService {
|
|||
Assert.hasText(refreshToken, "Refresh token must not be blank");
|
||||
|
||||
Integer userId = cacheStore.getAny(SecurityUtils.buildTokenRefreshKey(refreshToken), Integer.class)
|
||||
.orElseThrow(() -> new BadRequestException("The refresh token may have been expired already").setErrorData(refreshToken));
|
||||
.orElseThrow(() -> new BadRequestException("登陆状态已失效,请重新登陆").setErrorData(refreshToken));
|
||||
|
||||
// Get user info
|
||||
User user = userService.getById(userId);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -55,13 +56,10 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extends AbstractCrudService<COMMENT, Long> implements BaseCommentService<COMMENT> {
|
||||
|
||||
private final BaseCommentRepository<COMMENT> baseCommentRepository;
|
||||
|
||||
protected final OptionService optionService;
|
||||
|
||||
protected final UserService userService;
|
||||
|
||||
protected final ApplicationEventPublisher eventPublisher;
|
||||
private final BaseCommentRepository<COMMENT> baseCommentRepository;
|
||||
|
||||
public BaseCommentServiceImpl(BaseCommentRepository<COMMENT> baseCommentRepository,
|
||||
OptionService optionService,
|
||||
|
@ -247,6 +245,10 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
|
|||
comment.setGavatarMd5(DigestUtils.md5Hex(comment.getEmail()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(comment.getAuthorUrl())) {
|
||||
comment.setAuthorUrl(URLUtil.normalize(comment.getAuthorUrl()));
|
||||
}
|
||||
|
||||
if (authentication != null) {
|
||||
// Comment of blogger
|
||||
comment.setIsAdmin(true);
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import run.halo.app.exception.AlreadyExistsException;
|
||||
import run.halo.app.model.dto.LinkDTO;
|
||||
import run.halo.app.model.entity.Link;
|
||||
|
@ -9,13 +16,6 @@ import run.halo.app.repository.LinkRepository;
|
|||
import run.halo.app.service.LinkService;
|
||||
import run.halo.app.service.base.AbstractCrudService;
|
||||
import run.halo.app.utils.ServiceUtils;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -107,7 +107,7 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return links.stream().map(link -> new LinkDTO().<LinkDTO>convertFrom(link))
|
||||
return links.stream().map(link -> (LinkDTO) new LinkDTO().convertFrom(link))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import run.halo.app.model.dto.LogDTO;
|
||||
import run.halo.app.model.entity.Log;
|
||||
import run.halo.app.repository.LogRepository;
|
||||
import run.halo.app.service.LogService;
|
||||
import run.halo.app.service.base.AbstractCrudService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import run.halo.app.model.dto.LogDTO;
|
||||
import run.halo.app.model.entity.Log;
|
||||
import run.halo.app.repository.LogRepository;
|
||||
import run.halo.app.service.LogService;
|
||||
import run.halo.app.service.base.AbstractCrudService;
|
||||
|
||||
/**
|
||||
* LogService implementation class
|
||||
|
|
|
@ -153,7 +153,7 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
|
|||
}
|
||||
|
||||
return menus.stream()
|
||||
.map(menu -> new MenuDTO().<MenuDTO>convertFrom(menu))
|
||||
.map(menu -> (MenuDTO) new MenuDTO().convertFrom(menu))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import run.halo.app.model.dto.CategoryDTO;
|
||||
import run.halo.app.model.dto.CategoryWithPostCountDTO;
|
||||
import run.halo.app.model.entity.Category;
|
||||
import run.halo.app.model.entity.Post;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
@ -147,7 +148,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
@Override
|
||||
public PostDetailVO createBy(Post postToCreate, Set<Integer> tagIds, Set<Integer> categoryIds, boolean autoSave) {
|
||||
PostDetailVO createdPost = createOrUpdate(postToCreate, tagIds, categoryIds);
|
||||
if(!autoSave){
|
||||
if (!autoSave) {
|
||||
// Log the creation
|
||||
LogEvent logEvent = new LogEvent(this, createdPost.getId().toString(), LogType.POST_PUBLISHED, createdPost.getTitle());
|
||||
eventPublisher.publishEvent(logEvent);
|
||||
|
@ -160,7 +161,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
// Set edit time
|
||||
postToUpdate.setEditTime(DateUtils.now());
|
||||
PostDetailVO updatedPost = createOrUpdate(postToUpdate, tagIds, categoryIds);
|
||||
if(!autoSave){
|
||||
if (!autoSave) {
|
||||
// Log the creation
|
||||
LogEvent logEvent = new LogEvent(this, updatedPost.getId().toString(), LogType.POST_EDITED, updatedPost.getTitle());
|
||||
eventPublisher.publishEvent(logEvent);
|
||||
|
@ -286,6 +287,51 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportMarkdown(Integer id) {
|
||||
Assert.notNull(id, "Post id must not be null");
|
||||
Post post = getById(id);
|
||||
return exportMarkdown(post);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportMarkdown(Post post) {
|
||||
Assert.notNull(post, "Post must not be null");
|
||||
|
||||
StrBuilder content = new StrBuilder("---\n");
|
||||
|
||||
content.append("type: ").append("post").append("\n");
|
||||
content.append("title: ").append(post.getTitle()).append("\n");
|
||||
content.append("permalink: ").append(post.getUrl()).append("\n");
|
||||
content.append("thumbnail: ").append(post.getThumbnail()).append("\n");
|
||||
content.append("status: ").append(post.getStatus()).append("\n");
|
||||
content.append("date: ").append(post.getCreateTime()).append("\n");
|
||||
content.append("updated: ").append(post.getEditTime()).append("\n");
|
||||
content.append("comments: ").append(!post.getDisallowComment()).append("\n");
|
||||
|
||||
List<Tag> tags = postTagService.listTagsBy(post.getId());
|
||||
|
||||
if (tags.size() > 0) {
|
||||
content.append("tags:").append("\n");
|
||||
for (Tag tag : tags) {
|
||||
content.append(" - ").append(tag.getName()).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
List<Category> categories = postCategoryService.listCategoryBy(post.getId());
|
||||
|
||||
if (categories.size() > 0) {
|
||||
content.append("categories:").append("\n");
|
||||
for (Category category : categories) {
|
||||
content.append(" - ").append(category.getName()).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
content.append("---\n\n");
|
||||
content.append(post.getOriginalContent());
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostDetailVO convertToDetailVo(Post post) {
|
||||
return convertTo(post,
|
||||
|
@ -349,7 +395,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
.orElseGet(LinkedList::new)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(tag -> new TagDTO().<TagDTO>convertFrom(tag))
|
||||
.map(tag -> (TagDTO) new TagDTO().convertFrom(tag))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Set categories
|
||||
|
@ -357,7 +403,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
.orElseGet(LinkedList::new)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(category -> new CategoryDTO().<CategoryDTO>convertFrom(category))
|
||||
.map(category -> (CategoryDTO) new CategoryDTO().convertFrom(category))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Set comment count
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import run.halo.app.model.dto.TagWithPostCountDTO;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.entity.PostTag;
|
||||
|
@ -11,12 +17,6 @@ import run.halo.app.repository.TagRepository;
|
|||
import run.halo.app.service.PostTagService;
|
||||
import run.halo.app.service.base.AbstractCrudService;
|
||||
import run.halo.app.utils.ServiceUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -108,6 +109,33 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements Shee
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportMarkdown(Integer id) {
|
||||
Assert.notNull(id, "sheet id must not be null");
|
||||
Sheet sheet = getById(id);
|
||||
return exportMarkdown(sheet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportMarkdown(Sheet sheet) {
|
||||
Assert.notNull(sheet, "Sheet must not be null");
|
||||
|
||||
StrBuilder content = new StrBuilder("---\n");
|
||||
|
||||
content.append("type: ").append("sheet").append("\n");
|
||||
content.append("title: ").append(sheet.getTitle()).append("\n");
|
||||
content.append("permalink: ").append(sheet.getUrl()).append("\n");
|
||||
content.append("thumbnail: ").append(sheet.getThumbnail()).append("\n");
|
||||
content.append("status: ").append(sheet.getStatus()).append("\n");
|
||||
content.append("date: ").append(sheet.getCreateTime()).append("\n");
|
||||
content.append("updated: ").append(sheet.getEditTime()).append("\n");
|
||||
content.append("comments: ").append(!sheet.getDisallowComment()).append("\n");
|
||||
|
||||
content.append("---\n\n");
|
||||
content.append(sheet.getOriginalContent());
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheet removeById(Integer id) {
|
||||
Sheet sheet = super.removeById(id);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package run.halo.app.service.support;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.utils;
|
||||
|
||||
import run.halo.app.exception.BeanUtilsException;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue