Commit a9286462 authored by Liang Ding's avatar Liang Ding

文章、评论同步信息

parent abe438a4
......@@ -42,7 +42,7 @@ import org.jsoup.Jsoup;
* Article receiver (from B3log Symphony).
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.1, Oct 12, 2012
* @version 1.0.0.2, Nov 19, 2012
* @since 0.5.5
*/
@RequestProcessor
......@@ -131,8 +131,12 @@ public final class ArticleReceiver {
article.put(Common.POST_TO_COMMUNITY, false);
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
String content = article.getString(Article.ARTICLE_CONTENT);
final String articleId = article.getString(Keys.OBJECT_ID);
content += "<br/><p><i>该文章同步自 <a href='http://symphony.b3log.org/article/" + articleId + "'>B3log 社区</a></i></p>";
article.put(Article.ARTICLE_CONTENT, content);
final String articleId = articleMgmtService.addArticle(requestJSONObject);
articleMgmtService.addArticle(requestJSONObject);
ret.put(Keys.OBJECT_ID, articleId);
ret.put(Keys.MSG, "add article succ");
......
......@@ -65,7 +65,7 @@ import org.json.JSONObject;
* Comment receiver (from B3log Symphony).
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.1, Oct 17, 2012
* @version 1.0.0.2, Nov 19, 2012
* @since 0.5.5
*/
@RequestProcessor
......@@ -130,6 +130,7 @@ public final class CommentReceiver {
* "comment": {
* "userB3Key": "",
* "oId": "",
* "commentSymphonyArticleId": "",
* "commentOnArticleId": "",
* "commentAuthorName": "",
* "commentAuthorEmail": "",
......@@ -177,12 +178,15 @@ public final class CommentReceiver {
final String commentName = symphonyCmt.getString("commentAuthorName");
final String commentEmail = symphonyCmt.getString("commentAuthorEmail").trim().toLowerCase();
final String commentURL = "http://" + symphonyCmt.optString("commentAuthorURL");
final String commentContent = symphonyCmt.getString(Comment.COMMENT_CONTENT);
final String commentId = symphonyCmt.optString(Keys.OBJECT_ID);
String commentContent = symphonyCmt.getString(Comment.COMMENT_CONTENT);
commentContent += "<br/><p><i>该评论同步自 <a href='http://symphony.b3log.org/article/"
+ symphonyCmt.optString("commentSymphonyArticleId") + "#" + commentId + "'>B3log 社区</a></i></p>";
final String originalCommentId = symphonyCmt.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID);
// Step 1: Add comment
final JSONObject comment = new JSONObject();
JSONObject originalComment = null;
final String commentId = symphonyCmt.optString(Keys.OBJECT_ID);
comment.put(Keys.OBJECT_ID, commentId);
comment.put(Comment.COMMENT_NAME, commentName);
comment.put(Comment.COMMENT_EMAIL, commentEmail);
......@@ -209,7 +213,7 @@ public final class CommentReceiver {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
}
setCommentThumbnailURL(comment);
ret.put(Comment.COMMENT_THUMBNAIL_URL, comment.getString(Comment.COMMENT_THUMBNAIL_URL));
// Sets comment on article....
......
......@@ -41,7 +41,7 @@ import org.json.JSONObject;
* This listener is responsible for sending article to B3log Rhythm.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.2.2, Nov 2, 2012
* @version 1.0.2.3, Nov 19, 2012
* @since 0.3.1
*/
public final class ArticleSender extends AbstractEventListener<JSONObject> {
......@@ -95,11 +95,11 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
}
final String blogHost = preference.getString(Preference.BLOG_HOST).toLowerCase();
// if (blogHost.contains("localhost")) {
// LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
// new Object[]{originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
// return;
// }
if (blogHost.contains("localhost")) {
LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
new Object[]{originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
return;
}
final HTTPRequest httpRequest = new HTTPRequest();
httpRequest.setURL(ADD_ARTICLE_URL);
......
......@@ -89,11 +89,11 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
}
final String blogHost = preference.getString(Preference.BLOG_HOST).toLowerCase();
// if (blogHost.contains("localhost")) {
// LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this comment[id={0}] to Symphony",
// new Object[]{orginalComment.getString(Keys.OBJECT_ID)});
// return;
// }
if (blogHost.contains("localhost")) {
LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this comment[id={0}] to Symphony",
new Object[]{originalComment.getString(Keys.OBJECT_ID)});
return;
}
final HTTPRequest httpRequest = new HTTPRequest();
httpRequest.setURL(ADD_COMMENT_URL);
......
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