From f9e23547cee2c66c05a3a397b569ef4e26b25f0b Mon Sep 17 00:00:00 2001 From: Koda Date: Fri, 20 May 2016 23:06:31 +0900 Subject: [PATCH] #374 Add clip url button on knowledge view page --- bower.json | 3 ++- .../control/open/KnowledgeControl.java | 18 +++++++++++++++++- src/main/resources/appresource.properties | 1 + src/main/resources/appresource_ja.properties | 1 + .../WEB-INF/views/open/knowledge/view.jsp | 5 ++++- src/main/webapp/js/knowledge-view.js | 5 +++++ 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index f18bc1283..ce817895c 100644 --- a/bower.json +++ b/bower.json @@ -23,7 +23,8 @@ "bluebird": "3.0.6", "jquery-oembed-all": "nfl/jquery-oembed-all", "flag-icon-css": "0.8.5", - "moment": "2.12.0" + "moment": "2.12.0", + "clipboard": "1.5.10" }, "devDependencies": {}, "resolutions": { diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index f6eb4f0bb..4340b3355 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -10,6 +10,7 @@ import org.support.project.common.util.StringUtils; import org.support.project.di.DI; import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.control.KnowledgeControlBase; import org.support.project.knowledge.dao.CommentsDao; @@ -46,10 +47,13 @@ import org.support.project.web.bean.LoginedUser; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; +import org.support.project.web.common.HttpUtil; import org.support.project.web.control.service.Get; import org.support.project.web.control.service.Post; +import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; import org.support.project.web.exception.InvalidParamException; @@ -82,8 +86,20 @@ public class KnowledgeControl extends KnowledgeControlBase { public Boundary view() throws InvalidParamException, ParseException { // 共通処理呼の表示条件の保持の呼び出し setViewParam(); - + Long knowledgeId = super.getPathLong(Long.valueOf(-1)); + + SystemConfigsDao dao = SystemConfigsDao.get(); + SystemConfigsEntity config = dao.selectOnKey(SystemConfig.SYSTEM_URL, AppConfig.get().getSystemName()); + StringBuilder url = new StringBuilder(); + if (config == null) { + url.append(HttpUtil.getContextUrl(getRequest())); + } else { + url.append(config.getConfigValue()); + } + url.append("/knowledge/").append(knowledgeId); + setAttribute("url", url.toString()); + KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); LoginedUser loginedUser = getLoginedUser(); diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 677ef1852..7d8c7024f 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -236,6 +236,7 @@ knowledge.view.label.show.toc=Show TOC knowledge.view.label.copy.url=Clip Page URL knowledge.view.label.toc=TOC knowledge.view.msg.toc.empty=TOC item is not found. +knowledge.view.msg.url.copy=Copied the URL knowledge.search.title=Search Knowledge knowledge.search.placeholder=Search keyword knowledge.search.keyword=Keyword diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index fd5a9778d..15d1f7453 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -236,6 +236,7 @@ knowledge.view.label.show.toc=目次を表示 knowledge.view.label.copy.url=URLをコピー knowledge.view.label.toc=目次 knowledge.view.msg.toc.empty=目次になる「見出し」が見つかりません。「見出し」はMarkdownで「#」で開始する行に付きます。 +knowledge.view.msg.url.copy=URLをコピーしました knowledge.search.title=ナレッジ検索 knowledge.search.placeholder=キーワードでナレッジを検索 knowledge.search.keyword=検索キーワード diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp index c86a50224..9a454a797 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp @@ -31,6 +31,8 @@ + + @@ -46,6 +48,7 @@ var _FAIL_REMOVE_FILE = '<%= jspUtil.label("knowledge.edit.label.fail.delete.upl var _CONFIRM = '<%= jspUtil.label("knowledge.edit.label.confirm.delete") %>'; var _SET_IMAGE_LABEL= '<%= jspUtil.label("knowledge.edit.set.image.path") %>'; var _MSG_TOC_EMPTY = '<%= jspUtil.label("knowledge.view.msg.toc.empty") %>'; +var _MSG_COPIED = '<%= jspUtil.label("knowledge.view.msg.url.copy") %>'; @@ -219,7 +222,7 @@ var _MSG_TOC_EMPTY = '<%= jspUtil.label("knowledge.view.msg.toc.empty") %>';   <%=jspUtil.label("knowledge.view.label.show.toc")%> - diff --git a/src/main/webapp/js/knowledge-view.js b/src/main/webapp/js/knowledge-view.js index 446c26964..50bd4dad1 100644 --- a/src/main/webapp/js/knowledge-view.js +++ b/src/main/webapp/js/knowledge-view.js @@ -135,6 +135,11 @@ $(document).ready(function(){ } }).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled'); + var clipboard = new Clipboard('#urlBtn'); + clipboard.on('success', function(e) { + $.notify(_MSG_COPIED, 'success'); + }); + changeTemplate(); });