Skip to content

Commit

Permalink
データの保存先を変更 #32
Browse files Browse the repository at this point in the history
   -> .knowledgeディレクトリではなく、環境変数の直下にデータを格納
GitHubの絵文字に対応してもらえると嬉しい #33
コメントでもmarkdownを使えるようにする #37
プレビュー時と実際の表示が異なる #20
  • Loading branch information
koda-masaru committed May 10, 2015
1 parent 00e5910 commit 5b43f45
Showing 13 changed files with 62 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -13,7 +13,8 @@
"jquery-file-upload": "9.8.1",
"teambox.free-file-icons": "teambox/Free-file-icons",
"echojs": "1.6.0",
"notify.js": "1.2.5"
"notify.js": "1.2.5",
"emoji-parser": "0.1.1"
},
"devDependencies": {}
}
4 changes: 4 additions & 0 deletions src/main/java/org/support/project/knowledge/dao/TagsDao.java
Original file line number Diff line number Diff line change
@@ -93,6 +93,7 @@ public List<TagsEntity> selectTagsWithCount(int offset, int limit) {
* @param offset
* @param limit
* @return
* @deprecated
*/
public List<TagsEntity> selectTagsWithCountOnUser(int userid, int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCountOnUser.sql");
@@ -111,6 +112,9 @@ public List<TagsEntity> selectWithKnowledgeCount(int userId, List<GroupsEntity>
StringJoinBuilder builder = new StringJoinBuilder();
List<Integer> params = new ArrayList<>();
params.add(new Integer(userId));

builder.append("?");
params.add(-1);
for (GroupsEntity group : groups) {
builder.append("?");
params.add(group.getGroupId());
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public List<String> diff(String content, String content2) {
Patch patch = DiffUtils.diff(oldLines, newLines);
for (Delta delta : patch.getDeltas()) {
StringBuilder builder = new StringBuilder();
builder.append(String.format("[History (%d)]", delta.getOriginal().getPosition() + 1));
builder.append(String.format("[History line-(%d)]", delta.getOriginal().getPosition() + 1));
builder.append("\n");
for (Object line : delta.getOriginal().getLines()) {
builder.append(line);
@@ -38,12 +38,14 @@ public List<String> diff(String content, String content2) {
builder.append("↓");
builder.append("\n");

builder.append(String.format("[Now (%d)]", delta.getRevised().getPosition() + 1));
builder.append(String.format("[Now line-(%d)]", delta.getRevised().getPosition() + 1));
builder.append("\n");
for (Object line : delta.getRevised().getLines()) {
builder.append(line);
builder.append("\n");
}
builder.append("\n\n"); // 次の差分表示までの間に2行あける

changes.add(builder.toString());
}
return changes;
16 changes: 15 additions & 1 deletion src/main/java/org/support/project/knowledge/logic/TagLogic.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.support.project.knowledge.logic;

import java.util.ArrayList;
import java.util.List;

import org.support.project.common.log.Log;
@@ -8,6 +9,7 @@
import org.support.project.knowledge.dao.TagsDao;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.entity.GroupsEntity;

public class TagLogic {
/** ログ */
@@ -33,7 +35,19 @@ public List<TagsEntity> selectTagsWithCount(LoginedUser loginedUser, int offset,
if (loginedUser != null) {
userid = loginedUser.getUserId();
}
return tagsDao.selectTagsWithCountOnUser(userid, offset, limit);
List<GroupsEntity> groups = new ArrayList<GroupsEntity>();
if (loginedUser != null && loginedUser.getGroups() != null) {
groups = loginedUser.getGroups();
}

TagsDao tagsDao = TagsDao.get();
List<TagsEntity> tags;
if (loginedUser != null && loginedUser.isAdmin()) {
tags = tagsDao.selectWithKnowledgeCountAdmin(offset, limit);
} else {
tags = tagsDao.selectWithKnowledgeCount(userid, groups, offset * offset, limit);
}
return tags;
}


2 changes: 1 addition & 1 deletion src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ message.allready.updated=Allready updated.
message.allready.started=Allready started.

# Common Label
label.version=0.5.1 pre1
label.version=0.5.1 pre2
label.login=Sign in
label.previous = Previous
label.next=Next
2 changes: 1 addition & 1 deletion src/main/resources/appresource_ja.properties
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ message.allready.updated=すでに更新されています
message.allready.started=すでに開始済です

# Common Label
label.version=0.5.1 pre1
label.version=0.5.1 pre2
label.login=サインイン
label.previous = 前へ
label.next = 次へ
1 change: 1 addition & 0 deletions src/main/webapp/WEB-INF/views/index/index.jsp
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
<link rel="stylesheet" href="<%=request.getContextPath()%>/bower/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/bower/bootstrap/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/bower/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/markdown.css") %>" />

<title><%=jspUtil.label("knowledge.title")%></title>

1 change: 1 addition & 0 deletions src/main/webapp/WEB-INF/views/open/knowledge/view.jsp
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
<c:param name="PARAM_SCRIPTS">
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/echojs/dist/echo.min.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/emoji-parser/main.min.js"></script>
<script type="text/javascript" src="<%= jspUtil.mustReloadFile("/js/knowledge-view.js") %>"></script>

<script>
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<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/emoji-parser/main.min.js"></script>
<script type="text/javascript" src="<%= jspUtil.mustReloadFile("/js/knowledge-edit.js") %>"></script>

<script>
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
<script type="text/javascript" src="<%= request.getContextPath() %>/bower/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<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/emoji-parser/main.min.js"></script>
<script type="text/javascript" src="<%= jspUtil.mustReloadFile("/js/knowledge-edit.js") %>"></script>

<script>
5 changes: 5 additions & 0 deletions src/main/webapp/css/markdown.css
Original file line number Diff line number Diff line change
@@ -408,3 +408,8 @@
background-color: transparent;
border: none;
}

.emoji-img {
height: 20px;
}

9 changes: 6 additions & 3 deletions src/main/webapp/js/knowledge-edit.js
Original file line number Diff line number Diff line change
@@ -206,6 +206,7 @@ var removeAddedFile = function(fileNo) {


var preview = function() {

$.post(_CONTEXT + '/open.knowledge/escape', {
title : $('#input_title').val(),
content : $('#content').val()
@@ -218,15 +219,17 @@ var preview = function() {
html += data.title;
html += '</h3>';
html += '<p style="word-break:break-all" id="content">';
html += marked(data.content);
var emoji = window.emojiParser;
var content = emoji(data.content, _CONTEXT + '/bower/emoji-parser/emoji', {classes: 'emoji-img'});
content = marked(content);
html += content;
html += '</p>';
html += '</div>';
html += '</div>';
html += '</div>';
html += '</div>';

$('#preview').html(html);
$('#preview').each(function(i, block) {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
21 changes: 20 additions & 1 deletion src/main/webapp/js/knowledge-view.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ $(document).ready(function(){
return code;
}
});
$('#content').html(marked($('#content_text').text()));
var emoji = window.emojiParser;
var content = emoji($('#content_text').text(), _CONTEXT + '/bower/emoji-parser/emoji', {classes: 'emoji-img'});
$('#content').html(marked(content));
echo.init();

$('#commentsLink').click(function(){
@@ -24,6 +26,23 @@ $(document).ready(function(){
event.cancel = true;
});

$('.arrow_question').each(function(i, block) {
var content = $(this).text().trim();
content = emoji(content, _CONTEXT + '/bower/emoji-parser/emoji', {classes: 'emoji-img'});
console.log(content);
content = marked(content);
console.log(content);
$(this).html(content);
});
$('.arrow_answer').each(function(i, block) {
var content = $(this).text().trim();
content = emoji(content, _CONTEXT + '/bower/emoji-parser/emoji', {classes: 'emoji-img'});
console.log(content);
content = marked(content);
console.log(content);
$(this).html(content);
});

});


0 comments on commit 5b43f45

Please sign in to comment.