pull/296/head
ruibaby 2019-09-08 21:29:25 +08:00
parent ff134941c2
commit b27123adf5
10 changed files with 30 additions and 33 deletions

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Tue Apr 23 17:12:17 CST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

2
gradlew vendored
View File

@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"

2
gradlew.bat vendored
View File

@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -29,14 +29,9 @@ public class BackupController {
this.backupService = backupService; this.backupService = backupService;
} }
@PostMapping("import/markdowns") @PostMapping("import/markdown")
@ApiOperation("Import markdowns") @ApiOperation("Import markdown")
public List<BasePostDetailDTO> backupMarkdowns(@RequestPart("files") MultipartFile[] files) throws IOException { public BasePostDetailDTO backupMarkdowns(@RequestPart("file") MultipartFile file) throws IOException {
List<BasePostDetailDTO> result = new LinkedList<>(); return backupService.importMarkdown(file);
for (MultipartFile file : files) {
BasePostDetailDTO post = backupService.importMarkdowns(file);
result.add(post);
}
return result;
} }
} }

View File

@ -21,9 +21,7 @@ import run.halo.app.model.vo.PostListVO;
import run.halo.app.service.OptionService; import run.halo.app.service.OptionService;
import run.halo.app.service.PostService; import run.halo.app.service.PostService;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -140,8 +138,7 @@ public class PostController {
} }
@GetMapping("preview/{postId:\\d+}") @GetMapping("preview/{postId:\\d+}")
public void preview(@PathVariable("postId") Integer postId, public String preview(@PathVariable("postId") Integer postId) {
HttpServletResponse response) throws IOException {
Post post = postService.getById(postId); Post post = postService.getById(postId);
String token = IdUtil.simpleUUID(); String token = IdUtil.simpleUUID();
@ -149,10 +146,7 @@ public class PostController {
// cache preview token // cache preview token
cacheStore.putAny("preview-post-token-" + postId, token, 10, TimeUnit.MINUTES); cacheStore.putAny("preview-post-token-" + postId, token, 10, TimeUnit.MINUTES);
// build preview post url // build preview post url and return
String redirect = String.format("%s/archives/%s?preview=true&token=%s", optionService.getBlogBaseUrl(), post.getUrl(), token); return String.format("%s/archives/%s?preview=true&token=%s", optionService.getBlogBaseUrl(), post.getUrl(), token);
// redirect to preview url
response.sendRedirect(redirect);
} }
} }

View File

@ -16,9 +16,7 @@ import run.halo.app.model.vo.SheetListVO;
import run.halo.app.service.OptionService; import run.halo.app.service.OptionService;
import run.halo.app.service.SheetService; import run.halo.app.service.SheetService;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -113,8 +111,7 @@ public class SheetController {
} }
@GetMapping("preview/{sheetId:\\d+}") @GetMapping("preview/{sheetId:\\d+}")
public void preview(@PathVariable("sheetId") Integer sheetId, public String preview(@PathVariable("sheetId") Integer sheetId) {
HttpServletResponse response) throws IOException {
Sheet sheet = sheetService.getById(sheetId); Sheet sheet = sheetService.getById(sheetId);
String token = IdUtil.simpleUUID(); String token = IdUtil.simpleUUID();
@ -122,10 +119,7 @@ public class SheetController {
// cache preview token // cache preview token
cacheStore.putAny("preview-sheet-token-" + sheetId, token, 10, TimeUnit.MINUTES); cacheStore.putAny("preview-sheet-token-" + sheetId, token, 10, TimeUnit.MINUTES);
// build preview sheet url // build preview post url and return
String redirect = String.format("%s/s/%s?preview=true&token=%s", optionService.getBlogBaseUrl(), sheet.getUrl(), token); return String.format("%s/s/%s?preview=true&token=%s", optionService.getBlogBaseUrl(), sheet.getUrl(), token);
// redirect to preview url
response.sendRedirect(redirect);
} }
} }

View File

@ -10,6 +10,21 @@ import run.halo.app.model.enums.AttachmentType;
*/ */
public enum AttachmentProperties implements PropertyEnum { public enum AttachmentProperties implements PropertyEnum {
/**
* Upload image preview enable
*/
UPLOAD_IMAGE_PREVIEW_ENABLE("attachment_upload_image_preview_enable", Boolean.class, "true"),
/**
* Upload max parallel uploads
*/
UPLOAD_MAX_PARALLEL_UPLOADS("attachment_upload_max_parallel_uploads", Integer.class, "3"),
/**
* Upload max files
*/
UPLOAD_MAX_FILES("attachment_upload_max_files", Integer.class, "50"),
/** /**
* attachment_type * attachment_type
*/ */

View File

@ -19,5 +19,5 @@ public interface BackupService {
* @param file file * @param file file
* @return post info * @return post info
*/ */
BasePostDetailDTO importMarkdowns(MultipartFile file) throws IOException; BasePostDetailDTO importMarkdown(MultipartFile file) throws IOException;
} }

View File

@ -26,7 +26,7 @@ public class BackupServiceImpl implements BackupService {
} }
@Override @Override
public BasePostDetailDTO importMarkdowns(MultipartFile file) throws IOException { public BasePostDetailDTO importMarkdown(MultipartFile file) throws IOException {
// Read markdown content. // Read markdown content.
String markdown = IoUtil.read(file.getInputStream(), StandardCharsets.UTF_8); String markdown = IoUtil.read(file.getInputStream(), StandardCharsets.UTF_8);