Skip to content

Commit

Permalink
Merge pull request #379 from support-project/feature/issue374_urlcopy
Browse files Browse the repository at this point in the history
#374 Add clip url button on knowledge view page
  • Loading branch information
koda-masaru committed May 20, 2016
2 parents a1b8c4b + f9e2354 commit d1e92de
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/appresource_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=検索キーワード
Expand Down
5 changes: 4 additions & 1 deletion src/main/webapp/WEB-INF/views/open/knowledge/view.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/jquery-file-upload/js/jquery.fileupload.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/jquery-file-upload/js/jquery.iframe-transport.js"></script>

<script type="text/javascript" src="<%= request.getContextPath() %>/bower/clipboard/dist/clipboard.min.js"></script>

<script type="text/javascript" src="<%= jspUtil.mustReloadFile("/js/knowledge-common.js") %>"></script>
<script type="text/javascript" src="<%= jspUtil.mustReloadFile("/js/knowledge-view.js") %>"></script>

Expand All @@ -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") %>';
</script>

</c:param>
Expand Down Expand Up @@ -219,7 +222,7 @@ var _MSG_TOC_EMPTY = '<%= jspUtil.label("knowledge.view.msg.toc.empty") %>';
<i class="fa fa-list"></i>&nbsp;
<%=jspUtil.label("knowledge.view.label.show.toc")%>
</button>
<button class="btn btn-default btn_copy_url" onclick="copyUrl();">
<button class="btn btn-default btn_copy_url" data-clipboard-text="<%= jspUtil.out("url") %>" id="urlBtn">
<i class="fa fa-copy"></i>&nbsp;
<%=jspUtil.label("knowledge.view.label.copy.url")%>
</button>
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/js/knowledge-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit d1e92de

Please sign in to comment.