Commit ab9a3dfd authored by Liang Ding's avatar Liang Ding

Merge pull request #122 from b3log/0.5.5

0.5.5
parents cf566c0f eba75ced
...@@ -41,7 +41,7 @@ import org.json.JSONObject; ...@@ -41,7 +41,7 @@ import org.json.JSONObject;
* This listener is responsible for sending article to B3log Rhythm. * This listener is responsible for sending article to B3log Rhythm.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.2.1, Oct 18, 2012 * @version 1.0.2.2, Nov 2, 2012
* @since 0.3.1 * @since 0.3.1
*/ */
public final class ArticleSender extends AbstractEventListener<JSONObject> { public final class ArticleSender extends AbstractEventListener<JSONObject> {
...@@ -61,7 +61,7 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> { ...@@ -61,7 +61,7 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
/** /**
* B3log Rhythm address. * B3log Rhythm address.
*/ */
public static final String B3LOG_RHYTHM_ADDRESS = "http://rhythm.b3log.org:11000"; public static final String B3LOG_RHYTHM_ADDRESS = "http://rhythm.b3log.org:80";
/** /**
* URL of adding article to Rhythm. * URL of adding article to Rhythm.
*/ */
......
...@@ -23,8 +23,6 @@ import javax.servlet.http.HttpServletRequest; ...@@ -23,8 +23,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.RuntimeEnv;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.servlet.HTTPRequestContext; import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.HTTPRequestMethod; import org.b3log.latke.servlet.HTTPRequestMethod;
...@@ -37,13 +35,14 @@ import org.b3log.solo.model.Common; ...@@ -37,13 +35,14 @@ import org.b3log.solo.model.Common;
import org.b3log.solo.model.Page; import org.b3log.solo.model.Page;
import org.b3log.solo.service.CommentMgmtService; import org.b3log.solo.service.CommentMgmtService;
import org.b3log.solo.util.Comments; import org.b3log.solo.util.Comments;
import org.b3log.solo.util.Users;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Comment processor. * Comment processor.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.1.0.8, Sep 10, 2012 * @version 1.1.0.9, Nov 2, 2012
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -115,21 +114,25 @@ public final class CommentProcessor { ...@@ -115,21 +114,25 @@ public final class CommentProcessor {
return; return;
} }
if (RuntimeEnv.BAE != Latkes.getRuntimeEnv()) { final HttpSession session = httpServletRequest.getSession(false);
final String captcha = requestJSONObject.optString(CaptchaProcessor.CAPTCHA); if (null == session) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
final HttpSession session = httpServletRequest.getSession(false); return;
if (null != session) { }
final String storedCaptcha = (String) session.getAttribute(CaptchaProcessor.CAPTCHA);
if (null == storedCaptcha || !storedCaptcha.equals(captcha)) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
return; if (!Users.getInstance().isLoggedIn(httpServletRequest, httpServletResponse)) {
} final String storedCaptcha = (String) session.getAttribute(CaptchaProcessor.CAPTCHA);
final String captcha = requestJSONObject.optString(CaptchaProcessor.CAPTCHA);
if (null == storedCaptcha || !storedCaptcha.equals(captcha)) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
session.removeAttribute(CaptchaProcessor.CAPTCHA); return;
} }
session.removeAttribute(CaptchaProcessor.CAPTCHA);
} }
try { try {
...@@ -198,23 +201,27 @@ public final class CommentProcessor { ...@@ -198,23 +201,27 @@ public final class CommentProcessor {
return; return;
} }
if (RuntimeEnv.BAE != Latkes.getRuntimeEnv()) { final HttpSession session = httpServletRequest.getSession(false);
final String captcha = requestJSONObject.optString(CaptchaProcessor.CAPTCHA); if (null == session) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
final HttpSession session = httpServletRequest.getSession(false); return;
if (null != session) { }
final String storedCaptcha = (String) session.getAttribute(CaptchaProcessor.CAPTCHA);
if (null == storedCaptcha || !storedCaptcha.equals(captcha)) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
return; if (!Users.getInstance().isLoggedIn(httpServletRequest, httpServletResponse)) {
} final String storedCaptcha = (String) session.getAttribute(CaptchaProcessor.CAPTCHA);
final String captcha = requestJSONObject.optString(CaptchaProcessor.CAPTCHA);
if (null == storedCaptcha || !storedCaptcha.equals(captcha)) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("captchaErrorLabel"));
session.removeAttribute(CaptchaProcessor.CAPTCHA); return;
} }
session.removeAttribute(CaptchaProcessor.CAPTCHA);
} }
try { try {
final JSONObject addResult = commentMgmtService.addArticleComment(requestJSONObject); final JSONObject addResult = commentMgmtService.addArticleComment(requestJSONObject);
......
...@@ -49,4 +49,4 @@ cache=BAE ...@@ -49,4 +49,4 @@ cache=BAE
userService=LOCAL userService=LOCAL
#### Static resource version #### #### Static resource version ####
staticResourceVersion=201206280945 staticResourceVersion=201211021410
\ No newline at end of file \ No newline at end of file
...@@ -48,4 +48,4 @@ cache=GAE ...@@ -48,4 +48,4 @@ cache=GAE
userService=LOCAL userService=LOCAL
#### Static resource version #### #### Static resource version ####
staticResourceVersion=201206280945 staticResourceVersion=201211021410
\ No newline at end of file \ No newline at end of file
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
# Configures the followings before deploy # Configures the followings before deploy
serverScheme=http serverScheme=http
serverHost=localhost serverHost=localhost
serverPort=11099 serverPort=8080
staticServerScheme=http staticServerScheme=http
staticServerHost=localhost staticServerHost=localhost
staticServerPort=11099 staticServerPort=8080
# Note: The context path and static path should be "" if deploy app on ROOT. For other cases, starts with '/' # Note: The context path and static path should be "" if deploy app on ROOT. For other cases, starts with '/'
# and not ends with '/', for example, /blog # and not ends with '/', for example, /blog
contextPath= contextPath=
...@@ -48,4 +48,4 @@ cache=LOCAL ...@@ -48,4 +48,4 @@ cache=LOCAL
userService=LOCAL userService=LOCAL
#### Static resource version #### #### Static resource version ####
staticResourceVersion=201206280945 staticResourceVersion=201211021410
\ No newline at end of file \ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent"); "url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
$.ajax({ $.ajax({
url: "http://symphony.b3log.org:80/get-news", url: "http://localhost:8080/apis/news",
type: "GET", type: "GET",
dataType:"jsonp", dataType:"jsonp",
jsonp: "callback", jsonp: "callback",
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
var article = articles[i]; var article = articles[i];
var articleLiHtml = "<li>" var articleLiHtml = "<li>"
+ "<a target='_blank' href='" + article.articlePermalink + "'>" + "<a target='_blank' href='" + article.articlePermalink + "'>"
+ article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateDate, 1); + "</span></li>" + article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateTime, 1); + "</span></li>"
listHTML += articleLiHtml listHTML += articleLiHtml
} }
listHTML += "</ul>"; listHTML += "</ul>";
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
# #
# Description: Description of plugin symphony-news-getter. # Description: Description of plugin symphony-news-getter.
# Version: 1.0.0.1, Oct 30, 2011 # Version: 1.0.0.2, Nov 8, 2012
# Author: Liang Ding # Author: Liang Ding
# #
author=<a href="http://88250.b3log.org">88250</a> & <a href="http://vanessa.b3log.org">Vanessa</a> author=<a href="http://88250.b3log.org">88250</a> & <a href="http://vanessa.b3log.org">Vanessa</a>
name=Symphony News Getter name=Symphony News Getter
version=0.0.2 version=0.0.3
types=ADMIN types=ADMIN
classesDirPath=/WEB-INF/classes/ classesDirPath=/WEB-INF/classes/
......
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