Commit 7bc5d236 authored by mainlove's avatar mainlove

Merge branch '0.5.6' of https://github.com/b3log/b3log-solo.git into

0.5.6
parents 11d350f2 44ef41b2
......@@ -566,6 +566,70 @@ public final class ArticleProcessor {
renderer.setJSONObject(jsonObject);
}
/**
* Gets author articles paged with the specified context.
*
* @param context the specified context
* @param request the specified request
*/
@RequestProcessing(value = "/articles/authors/\\d+/\\d+", uriPatternsMode = URIPatternMode.REGEX,
method = HTTPRequestMethod.GET)
public void getAuthorsArticlesByPage(final HTTPRequestContext context, final HttpServletRequest request) {
final JSONObject jsonObject = new JSONObject();
final String authorId = getAuthorsArticlesPagedAuthorId(request.getRequestURI());
final int currentPageNum = getAuthorsArticlesPagedCurrentPageNum(request.getRequestURI());
Stopwatchs.start("Get Author-Articles Paged[authorId=" + authorId + ", pageNum=" + currentPageNum + ']');
try {
jsonObject.put(Keys.STATUS_CODE, true);
final JSONObject preference = preferenceQueryService.getPreference();
final int pageSize = preference.getInt(Preference.ARTICLE_LIST_DISPLAY_COUNT);
final JSONObject authorRet = userQueryService.getUser(authorId);
if (null == authorRet) {
context.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
final JSONObject author = authorRet.getJSONObject(User.USER);
final String authorEmail = author.optString(User.USER_EMAIL);
final List<JSONObject> articles = articleQueryService.getArticlesByAuthorEmail(authorEmail, currentPageNum, pageSize);
if (!articles.isEmpty()) {
filler.setArticlesExProperties(articles, author, preference);
}
final int articleCount = author.getInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT);
final int pageCount = (int) Math.ceil((double) articleCount / (double) pageSize);
final JSONObject result = new JSONObject();
final JSONObject pagination = new JSONObject();
pagination.put(Pagination.PAGINATION_PAGE_COUNT, pageCount);
result.put(Pagination.PAGINATION, pagination);
result.put(Article.ARTICLES, articles);
jsonObject.put(Keys.RESULTS, result);
} catch (final Exception e) {
jsonObject.put(Keys.STATUS_CODE, false);
LOGGER.log(Level.SEVERE, "Gets article paged failed", e);
} finally {
Stopwatchs.end();
}
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
renderer.setJSONObject(jsonObject);
}
/**
* Shows author articles with the specified context.
*
......@@ -1012,6 +1076,32 @@ public final class ArticleProcessor {
return StringUtils.substringBeforeLast(archiveAndPageNum, "/");
}
/**
* Gets the request page number from the specified request URI.
*
* @param requestURI the specified request URI
* @return page number
*/
private static int getAuthorsArticlesPagedCurrentPageNum(final String requestURI) {
return Requests.getCurrentPageNum(StringUtils.substringAfterLast(requestURI, "/"));
}
/**
* Gets the request author id from the specified request URI.
*
* @param requestURI the specified request URI
* @return author id
*/
private static String getAuthorsArticlesPagedAuthorId(final String requestURI) {
String authorIdAndPageNum = requestURI.substring((Latkes.getContextPath() + "/articles/authors/").length());
if (!authorIdAndPageNum.endsWith("/")) {
authorIdAndPageNum += "/";
}
return StringUtils.substringBefore(authorIdAndPageNum, "/");
}
/**
* Gets the request page number from the specified request URI and author id.
*
......
......@@ -362,6 +362,8 @@ public final class ArticleQueryService {
// Skips the unpublished article
continue;
}
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
// Markdown to HTML for content and abstract
markdown(article);
......@@ -420,6 +422,8 @@ public final class ArticleQueryService {
// Skips the unpublished article
continue;
}
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
// Markdown to HTML for content and abstract
markdown(article);
......@@ -649,6 +653,8 @@ public final class ArticleQueryService {
for (int i = 0; i < articles.length(); i++) {
final JSONObject article = articles.getJSONObject(i);
article.put(ARTICLE_CREATE_TIME, ((Date) article.get(ARTICLE_CREATE_DATE)).getTime());
// Markdown to HTML for content and abstract
markdown(article);
......
......@@ -2,7 +2,7 @@
</div>
<div id="pluginPagination" class="margin12 right">
</div>
<div class="clear"></div>
<div id="PluginSetting" class="none">
<div id="pluginSetting" class="none">
</div>
<div class="clear"></div>
${plugins}
......@@ -3017,6 +3017,12 @@ admin.pluginList = {
}]);
this.tablePagination.initPagination();
$("#pluginSetting").dialog({
width: 700,
height: 180,
"modal": true,
"hideFooter": true
});
this.getList(page);
},
......@@ -3062,7 +3068,15 @@ admin.pluginList = {
}
});
},
<<<<<<< HEAD
=======
<<<<<<< HEAD
=======
>>>>>>> 692cfe019926f553440bb6a3e2517360118353a7
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
toSetting:function(pluginId){
$("#loadMsg").text(Label.loadingLabel);
......@@ -3078,6 +3092,7 @@ admin.pluginList = {
success: function(result, textStatus){
$("#tipMsg").text(result.msg);
<<<<<<< HEAD
$("#PluginSetting").html(result);
$("#PluginSetting").dialog({
width: 700,
......@@ -3086,11 +3101,36 @@ admin.pluginList = {
"hideFooter": true
});
$("#PluginSetting").dialog("open");
=======
<<<<<<< HEAD
$("#PluginSetting").html(result);
$("#PluginSetting").dialog({
width: 700,
height: 190,
"modal": true,
"hideFooter": true
});
$("#PluginSetting").dialog("open");
=======
$("#pluginSetting").html(result);
$("#pluginSetting").dialog("open");
>>>>>>> 692cfe019926f553440bb6a3e2517360118353a7
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
$("#loadMsg").text("");
}
});
},
<<<<<<< HEAD
=======
<<<<<<< HEAD
=======
>>>>>>> 692cfe019926f553440bb6a3e2517360118353a7
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
changeStatus: function (pluginId, status) {
if (status === "ENABLED") {
status = "DISABLED";
......@@ -3133,7 +3173,15 @@ admin.register["plugin-list"] = {
"refresh": function () {
$("#loadMsg").text("");
}
<<<<<<< HEAD
}
=======
<<<<<<< HEAD
}
=======
}
>>>>>>> 692cfe019926f553440bb6a3e2517360118353a7
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
......@@ -3833,4 +3881,4 @@ admin.register["about"] = {
"refresh": function () {
$("#loadMsg").text("");
}
}
\ No newline at end of file
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -56,6 +56,12 @@ admin.pluginList = {
}]);
this.tablePagination.initPagination();
$("#pluginSetting").dialog({
width: 700,
height: 180,
"modal": true,
"hideFooter": true
});
this.getList(page);
},
......@@ -101,7 +107,7 @@ admin.pluginList = {
}
});
},
toSetting:function(pluginId){
$("#loadMsg").text(Label.loadingLabel);
......@@ -117,6 +123,7 @@ admin.pluginList = {
success: function(result, textStatus){
$("#tipMsg").text(result.msg);
<<<<<<< HEAD
$("#PluginSetting").html(result);
$("#PluginSetting").dialog({
width: 700,
......@@ -125,11 +132,21 @@ admin.pluginList = {
"hideFooter": true
});
$("#PluginSetting").dialog("open");
=======
$("#pluginSetting").html(result);
$("#pluginSetting").dialog("open");
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
$("#loadMsg").text("");
}
});
},
<<<<<<< HEAD
=======
>>>>>>> branch '0.5.6' of https://github.com/b3log/b3log-solo.git
changeStatus: function (pluginId, status) {
if (status === "ENABLED") {
status = "DISABLED";
......@@ -172,4 +189,4 @@ admin.register["plugin-list"] = {
"refresh": function () {
$("#loadMsg").text("");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment