Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
🐛 fixed #438
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Sep 16, 2018
1 parent 196af2c commit ca14634
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.blade.mvc.WebContext;
import com.blade.mvc.annotation.*;
import com.blade.mvc.http.Request;
import com.blade.mvc.http.Response;
import com.blade.mvc.ui.RestResponse;
import com.tale.annotation.SysLog;
import com.tale.bootstrap.TaleConst;
Expand Down Expand Up @@ -67,9 +68,16 @@ public RestResponse sysLogs(PageParam pageParam) {
@GetRoute("articles/:cid")
public RestResponse article(@PathParam String cid) {
Contents contents = contentsService.getContents(cid);
contents.setContent("");
return RestResponse.ok(contents);
}

@GetRoute("articles/content/:cid")
public void articleContent(@PathParam String cid, Response response) {
Contents contents = contentsService.getContents(cid);
response.text(contents.getContent());
}

@PostRoute("article/new")
public RestResponse newArticle(@BodyParam Contents contents) {
CommonValidator.valid(contents);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/tale/service/ContentsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ private Contents mapContent(Contents contents) {
} else {
contents.setUrl("/article/" + contents.getCid());
}
if (StringKit.isNotEmpty(contents.getContent())) {
contents.setContent(contents.getContent().replaceAll("\\\\\"", "\\\""));
String content = contents.getContent();
if (StringKit.isNotEmpty(content)) {
content = content.replaceAll("\\\\\"", "\\\"");
contents.setContent(content);
}
return contents;
}
Expand Down
20 changes: 14 additions & 6 deletions src/main/resources/static/admin/js/edit_article.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,19 @@ var vm = new Vue({
alert(error || '数据加载失败');
}
});

tale.get({
url: '/admin/api/articles/' + cid,
success: function (data) {
$vm.article = data.payload;
$vm.article.tags = data.payload.tags;
$vm.article.tags = data.payload.tags || "";
$vm.article.selected = [];

var selected = data.payload.categories.split(',');
for(item in selected){
$vm.article.selected.push(selected[item]);
}

if ($vm.article.fmtType === 'markdown') {
mditor.value = data.payload.content;
} else {
htmlEditor.summernote("code", data.payload.content);
}
$vm.article.createdTime = moment.unix($vm.article.created).format('YYYY-MM-DD HH:mm')

var tags = data.payload.tags.split(',');
Expand Down Expand Up @@ -176,6 +172,18 @@ var vm = new Vue({
alert(error || '数据加载失败');
}
});

tale.get({
url: '/admin/api/articles/content/' + cid,
success: function (data) {
if ($vm.article.fmtType === 'markdown') {
mditor.value = data;
} else {
htmlEditor.summernote("code", data);
}
}
});

},
autoSave: function (callback) {
var $vm = this;
Expand Down

0 comments on commit ca14634

Please sign in to comment.