From 8d5ad54a20f74886998dc3b4a8d214d1de0a50f8 Mon Sep 17 00:00:00 2001 From: lxyer <237809796@qq.com> Date: Thu, 1 Mar 2018 14:03:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=BA=E3=80=90wangEditor3?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 --- root/index.html | 1 - root/jie/add.html | 11 +++++- root/jie/detail.html | 20 ++++++---- root/res/mods/index.js | 9 +++++ root/res/mods/jie.js | 13 ++++++- src/com/lxyer/bbs/servlet/IndexServlet.java | 42 ++++++++++++++++++++- 7 files changed, 82 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 1373abb..dc94e7d 100644 --- a/pom.xml +++ b/pom.xml @@ -38,12 +38,6 @@ 3.3 - - com.jfinal - jfinal - 3.3 - - diff --git a/root/index.html b/root/index.html index 0cad5b7..1fc17f6 100644 --- a/root/index.html +++ b/root/index.html @@ -162,7 +162,6 @@

- 最新加入| 总用户:0

diff --git a/root/jie/add.html b/root/jie/add.html index 58cfc47..5567e16 100644 --- a/root/jie/add.html +++ b/root/jie/add.html @@ -68,8 +68,11 @@
-
+ +
+ #(bean.content??)
#if(x.userId == bean.userId??) (楼主) @@ -137,9 +137,10 @@
-
- -
+ +
@@ -186,6 +187,7 @@ #end #define js() + #end \ No newline at end of file diff --git a/root/res/mods/index.js b/root/res/mods/index.js index 338e5ba..bb93334 100644 --- a/root/res/mods/index.js +++ b/root/res/mods/index.js @@ -250,6 +250,15 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'face'], f } + ,editer: function(){ + var E = window.wangEditor; + var editor = new E('#editor'); + editor.customConfig.uploadImgServer = '/upload/img'; + editor.create() + + return editor; + } + ,escape: function(html){ return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); diff --git a/root/res/mods/jie.js b/root/res/mods/jie.js index 71fef76..b774380 100644 --- a/root/res/mods/jie.js +++ b/root/res/mods/jie.js @@ -13,13 +13,20 @@ layui.define(['fly','laypage'], function(exports){ var form = layui.form; var laypage = layui.laypage; var fly = layui.fly; - + + var editor; var gather = {}, dom = { jieda: $('#jieda') ,content: $('#L_content') ,jiedaCount: $('#jiedaCount') }; + var jie = { + createEditer : function(){ + editor = fly.editer(); + } + } + //监听专栏选择 form.on('select(column)', function(obj){ var value = obj.value @@ -233,6 +240,7 @@ layui.define(['fly','laypage'], function(exports){ ["contentId","title", "content", "type"].forEach(function (value) { bean[value] = data.field[value]; }); + bean["content"] = editor.txt.html(); console.log(bean); fly.json("/os/content/save",{ @@ -249,6 +257,7 @@ layui.define(['fly','laypage'], function(exports){ ["contentId","pid", "content"].forEach(function (value) { bean[value] = data.field[value]; }); + bean["content"] = editor.txt.html(); console.log(bean); fly.json("/os/comment/save",{ @@ -305,5 +314,5 @@ layui.define(['fly','laypage'], function(exports){ }); } - exports('jie', null); + exports('jie', jie); }); \ No newline at end of file diff --git a/src/com/lxyer/bbs/servlet/IndexServlet.java b/src/com/lxyer/bbs/servlet/IndexServlet.java index c53a1e8..e49fc99 100644 --- a/src/com/lxyer/bbs/servlet/IndexServlet.java +++ b/src/com/lxyer/bbs/servlet/IndexServlet.java @@ -6,9 +6,9 @@ import com.lxyer.bbs.base.user.User; import com.lxyer.bbs.base.user.UserBean; import com.lxyer.bbs.base.user.UserInfo; import com.lxyer.bbs.comment.CommentInfo; +import com.lxyer.bbs.comment.CommentService; import com.lxyer.bbs.content.ContentBean; import com.lxyer.bbs.content.ContentInfo; -import com.lxyer.bbs.comment.CommentService; import com.lxyer.bbs.content.ContentService; import org.redkale.net.http.*; import org.redkale.source.FilterExpress; @@ -17,6 +17,12 @@ import org.redkale.source.Flipper; import org.redkale.util.Sheet; import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; @@ -26,6 +32,7 @@ import java.util.function.Supplier; @WebServlet({"/","/column","/column/*" ,"/user", "/user/*" ,"/jie" ,"/jie/*" + ,"/upload","/upload/*" }) public class IndexServlet extends BaseServlet { @@ -237,6 +244,39 @@ public class IndexServlet extends BaseServlet { //====================================帖子相关==================================== + //====================================上传相关====================================、 + + private static final String dir = "/var/www/upload/redbbs/"; + private static final String view = "http://img.1216.top/redbbs/"; + private static final String format = "%1$tY%1$tm%1$td%1$tH%1$tM%1$tS"; + protected static final boolean winos = System.getProperty("os.name").contains("Window"); + @HttpMapping(url = "/upload/img", auth = false, comment = "图片上传") + public void uploadImg(HttpRequest request, HttpResponse response){ + try { + Map ret = new HashMap(); + ret.put("errno", 0); + List data = new ArrayList(); + + for (MultiPart part : request.multiParts()) { + String name = part.getName(); + String suffix = name.substring(name.lastIndexOf(".")); + String path = String.format(format, System.currentTimeMillis()) + suffix; + File destFile = new File((winos ? "D:/wk/_own/redbbs/root/tem/" : dir) + path); + destFile.getParentFile().mkdir(); + + part.save(destFile); + + data.add((winos ? "/tem/": view) + path); + } + ret.put("data", data); + + response.setContentType("application/json; charset=utf-8"); + response.finish(ret); + } catch (IOException e) { + e.printStackTrace(); + } + + } }