You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ko...@apache.org on 2015/05/19 13:36:46 UTC
svn commit: r1680255 - in
/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering:
model/ plugins/comments/
Author: kohei
Date: Tue May 19 11:36:45 2015
New Revision: 1680255
URL: http://svn.apache.org/r1680255
Log:
ROL-1377 MathCommentAuthenticator should use Weblog's locale
Added:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticatorUtils.java
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/LdapCommentAuthenticator.java
roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java?rev=1680255&r1=1680254&r2=1680255&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java Tue May 19 11:36:45 2015
@@ -133,7 +133,7 @@ public class URLModel implements Model {
public String getCommentAuthenticator() {
- return getSite()+"/CommentAuthenticatorServlet";
+ return getSite()+"/CommentAuthenticatorServlet?weblog="+weblog.getHandle();
}
Added: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticatorUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticatorUtils.java?rev=1680255&view=auto
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticatorUtils.java (added)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticatorUtils.java Tue May 19 11:36:45 2015
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.rendering.plugins.comments;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.Weblog;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Locale;
+
+class CommentAuthenticatorUtils {
+ private static Log log = LogFactory.getLog(CommentAuthenticatorUtils.class);
+
+ public static Locale getLocale(HttpServletRequest request) {
+ String handle = request.getParameter("weblog");
+ try {
+ Weblog weblog = WebloggerFactory.getWeblogger().getWeblogManager().getWeblogByHandle(handle);
+ return weblog.getLocaleInstance();
+ } catch (WebloggerException e) {
+ log.debug("Failed to determine weblog's locale. fallback to the locale of the request", e);
+ return request.getLocale();
+ }
+ }
+}
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/LdapCommentAuthenticator.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/LdapCommentAuthenticator.java?rev=1680255&r1=1680254&r2=1680255&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/LdapCommentAuthenticator.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/LdapCommentAuthenticator.java Tue May 19 11:36:45 2015
@@ -18,6 +18,7 @@
package org.apache.roller.weblogger.ui.rendering.plugins.comments;
import java.util.Hashtable;
+import java.util.Locale;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -73,7 +74,8 @@ public class LdapCommentAuthenticator im
ldapPass = ldapPassTemp != null ? ldapPassTemp : "";
}
- I18nMessages messages = I18nMessages.getMessages(request.getLocale());
+ Locale locale = CommentAuthenticatorUtils.getLocale(request);
+ I18nMessages messages = I18nMessages.getMessages(locale);
StringBuilder sb = new StringBuilder();
sb.append("<p>");
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java?rev=1680255&r1=1680254&r2=1680255&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java Tue May 19 11:36:45 2015
@@ -18,6 +18,7 @@
package org.apache.roller.weblogger.ui.rendering.plugins.comments;
+import java.util.Locale;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -58,7 +59,8 @@ public class MathCommentAuthenticator im
Integer value1o = (Integer)request.getSession().getAttribute("mathValue1");
Integer value2o = (Integer)request.getSession().getAttribute("mathValue2");
- I18nMessages messages = I18nMessages.getMessages(request.getLocale());
+ Locale locale = CommentAuthenticatorUtils.getLocale(request);
+ I18nMessages messages = I18nMessages.getMessages(locale);
StringBuilder sb = new StringBuilder();
sb.append("<p>");