Commit 6413c250 by 钟明宏

增加根据端口来判断是否使用https协议

parent 83af40f8
......@@ -7,4 +7,7 @@
3. 优化过期文档删除功能
### 1.0.7
1. 重构上传规则,一次性上传所有信息
\ No newline at end of file
1. 重构上传规则,一次性上传所有信息
### 1.0.9
1. 增加https协议上传
\ No newline at end of file
......@@ -5,7 +5,7 @@
<parent>
<artifactId>maven-document-upload-parent</artifactId>
<groupId>cn.yunmaozj.tools</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -37,6 +37,23 @@ public class IndexController {
@Autowired
private Project project;
private final String openWindowJS = new StringBuilder().append("<script>").append("$(\".btn-danger\").click(function(){\n")
.append("\t\t\tvar url = $(this).attr(\"url\");\n")
.append("\t\t\twindow.location=url;\n")
.append("\t\t})\n")
.append("\t\t$(\".btn-link\").click(function(){\n")
.append("\t\t\tvar url = $(this).attr(\"url\");\n")
.append("if(url == undefined)return;\n")
.append("\t\t\twindow.open(url,'_blank');\n")
.append("\t\t})").append("</script>").toString();
private final String headHtml = new StringBuilder().append("<head>")
.append("<meta charset=\"utf-8\">")
.append("<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />")
.append("<title>Document</title>")
.append("<link rel=\"stylesheet\" href=\"/bootstrap.min.css\" />")
.append("</head>").toString();
@RequestMapping(value = {"index.html", "/"})
public void index(HttpServletResponse response) throws IOException {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
......@@ -46,12 +63,7 @@ public class IndexController {
StringBuilder html = new StringBuilder();
html.append("<!DOCTYPE html>");
html.append("<html>");
html.append("<head>");
html.append("<meta charset=\"utf-8\">");
html.append("<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />");
html.append("<title>Document</title>");
html.append("<link rel=\"stylesheet\" href=\"/bootstrap.min.css\" />");
html.append("</head>");
html.append(headHtml);
html.append("<body>");
html.append("<table class=\"table table-hover\">");
html.append("<thead>");
......@@ -95,21 +107,10 @@ public class IndexController {
html.append("</table>");
html.append("</body>");
html.append("<script type=\"text/javascript\" src=\"/jquery-3.4.1.min.js\" ></script>");
html.append("<script>");
html.append("$(\".btn-danger\").click(function(){\n")
.append("\t\t\tvar url = $(this).attr(\"url\");\n")
.append("\t\t\twindow.location=url;\n")
.append("\t\t})\n")
.append("\t\t$(\".btn-link\").click(function(){\n")
.append("\t\t\tvar url = $(this).attr(\"url\");\n")
.append("if(url == undefined)return;")
.append("\t\t\twindow.location=url;\n")
.append("\t\t})");
html.append("</script>");
html.append(openWindowJS);
html.append("</html>");
response.setContentType("text/html;charset=UTF-8");
response.getOutputStream().write(html.toString().getBytes("UTF-8"));
// return html.toString();
}
@ResponseBody
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>maven-document-upload-parent</artifactId>
<groupId>cn.yunmaozj.tools</groupId>
<version>1.0.8</version>
<version>1.0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -116,7 +116,7 @@ public class DocumentUploadMojo extends AbstractMojo {
.build();
HttpUrl.Builder httpUrlBuilder = new HttpUrl.Builder();
if (ssl) {
if (ssl || siteServerPort == 443) {
httpUrlBuilder.scheme("https");
} else {
httpUrlBuilder.scheme("http");
......@@ -128,9 +128,11 @@ public class DocumentUploadMojo extends AbstractMojo {
httpUrlBuilder.addPathSegment("site-upload");
Request request = new Request.Builder().url(httpUrlBuilder.build())
.post(body).build();
long timeStart = System.currentTimeMillis();
Response response = getClient().newCall(request).execute();
getLog().info("Uploading file:[" + outFile + "] to [" + request.url() + "]");
getLog().info(response.toString());
getLog().info("execute time:"+((System.currentTimeMillis() - timeStart) / 1000f));
if (!response.isSuccessful())
getLog().info("Response Body[" + response.body().string() + "]");
}
......
......@@ -11,7 +11,7 @@
<groupId>cn.yunmaozj.tools</groupId>
<artifactId>maven-document-upload-parent</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<description>站点上传插件</description>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment