Skip to content

Commit

Permalink
for v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JPressProjects committed Apr 19, 2016
1 parent 441ca18 commit 16e56cb
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jpress/WebRoot/WEB-INF/admin/content/edit.html
Original file line number Diff line number Diff line change
@@ -176,7 +176,7 @@ <h3 class="box-title">属性设置</h3>
<div class="tab-content jp-aside-hg">
<div class="tab-pane active jp-left-margv35" id="tab_1">
Flag: <input type="text" name="content.flag" value="${(content.flag)!}">
作者: <input type="text" name="content.flag" value="${(content.flag)!}">
作者: <input type="text" name="username" value="${(content.username)!}">
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="tab_2">
16 changes: 14 additions & 2 deletions jpress/src/io/jpress/controller/admin/_ContentController.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import io.jpress.model.Content;
import io.jpress.model.Mapping;
import io.jpress.model.Taxonomy;
import io.jpress.model.User;
import io.jpress.template.Module;
import io.jpress.template.Module.TaxonomyType;
import io.jpress.utils.StringUtils;
@@ -184,10 +185,10 @@ public List<Long> getOrCreateTaxonomyIds(String moduleName) {
if (id == 0) {
Taxonomy taxonomy = new Taxonomy();
taxonomy.setTitle(title);
taxonomy.setSlug(title);
taxonomy.setContentModule(moduleName);
taxonomy.setType(type.getName());
taxonomy.save();

id = taxonomy.getId();
}
tIds.add(id);
@@ -204,7 +205,7 @@ public List<Long> getOrCreateTaxonomyIds(String moduleName) {

private long getIdFromList(String string, List<Taxonomy> list) {
for (Taxonomy taxonomy : list) {
if (string.equals(taxonomy.getTitle()))
if (string.equals(taxonomy.getSlug()))
return taxonomy.getId();
}
return 0;
@@ -213,12 +214,23 @@ private long getIdFromList(String string, List<Taxonomy> list) {
@Before(UCodeInterceptor.class)
@Override
public void save() {

Content content = getContent();
if (null == content.getSlug()) {
String title = content.getTitle();
String slug = title.replace(".", "_").replaceAll("\\s+", "_");
content.setSlug(slug);
}

String username = getPara("username");
if(StringUtils.isNotBlank(username)){
User user = User.findUserByUsername(username);
if(user == null){
renderAjaxResultForError("系统没有该用户:"+username);
return;
}
content.setUserId(user.getId());
}

Content dbContent = mDao.findBySlug(content.getSlug());
if (dbContent != null && dbContent.getId() != content.getId()) {

0 comments on commit 16e56cb

Please sign in to comment.