You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2005/09/16 22:09:00 UTC
svn commit: r289644 - in /incubator/roller/branches/roller_2.0:
src/org/roller/presentation/ src/org/roller/presentation/weblog/
web/WEB-INF/classes/
Author: agilliland
Date: Fri Sep 16 13:08:56 2005
New Revision: 289644
URL: http://svn.apache.org/viewcvs?rev=289644&view=rev
Log:
added 2 new runtime properties which control enabling/disabling of comments and trackbacks
for the entire site. this was mainly brought on by the need to quickly disable trackbacks
when spam becomes an issue.
Modified:
incubator/roller/branches/roller_2.0/src/org/roller/presentation/CommentServlet.java
incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/TrackbackServlet.java
incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties
incubator/roller/branches/roller_2.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml
Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/CommentServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/CommentServlet.java?rev=289644&r1=289643&r2=289644&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/CommentServlet.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/CommentServlet.java Fri Sep 16 13:08:56 2005
@@ -122,9 +122,13 @@
mLogger.debug("Doing comment posting for entry = "+entry_permalink);
+ // check if we even allow comments
+ if(!RollerRuntimeConfig.getBooleanProperty("users.comments.enabled"))
+ throw new Exception("Comments are disabled for this site.");
+
if (!entry.getWebsite().getAllowComments().booleanValue() ||
!entry.getCommentsStillAllowed())
- throw new Exception("Comments not allowed");
+ throw new Exception("Comments not allowed on this entry");
WebsiteData website = entry.getWebsite();
Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/TrackbackServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/TrackbackServlet.java?rev=289644&r1=289643&r2=289644&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/TrackbackServlet.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/TrackbackServlet.java Fri Sep 16 13:08:56 2005
@@ -13,7 +13,7 @@
import javax.servlet.http.HttpServletResponse;
import java.sql.Timestamp;
import java.util.Date;
-import org.roller.model.RollerFactory;
+import org.roller.config.RollerRuntimeConfig;
import org.roller.pojos.CommentData;
import org.roller.util.CommentSpamChecker;
@@ -24,118 +24,105 @@
/**
* Roller's Trackback server implementation. POSTing to this Servlet will add a
- * Trackback to a Weblog Entrty. For more info on Trackback, read the spec:
+ * Trackback to a Weblog Entrty. For more info on Trackback, read the spec:
* <a href="http://www.movabletype.org/docs/mttrackback.html>MT Trackback</a>.
- *
+ *
* @web.servlet name="TrackbackServlet"
* @web.servlet-mapping url-pattern="/trackback/*"
- *
+ *
* @author David M Johnson
*/
-public class TrackbackServlet extends HttpServlet
-{
+public class TrackbackServlet extends HttpServlet {
/** Request parameter to indicate a trackback "tb" */
//private static final String TRACKBACK_PARAM = "tb";
-
+
/** Request parameter for the trackback "title" */
private static final String TRACKBACK_TITLE_PARAM = "title";
-
+
/** Request parameter for the trackback "excerpt" */
private static final String TRACKBACK_EXCERPT_PARAM = "excerpt";
-
+
/** Request parameter for the trackback "url" */
private static final String TRACKBACK_URL_PARAM = "url";
-
+
/** Request parameter for the trackback "blog_name" */
private static final String TRACKBACK_BLOG_NAME_PARAM = "blog_name";
-
+
/** Key under which the trackback return code will be placed
* (example: on the request for the JSPDispatcher) */
- public static final String BLOJSOM_TRACKBACK_RETURN_CODE =
+ public static final String BLOJSOM_TRACKBACK_RETURN_CODE =
"BLOJSOM_TRACKBACK_RETURN_CODE";
-
+
/** Key under which the trackback error message will be placed
* (example: on the request for the JSPDispatcher) */
- public static final String BLOJSOM_TRACKBACK_MESSAGE =
+ public static final String BLOJSOM_TRACKBACK_MESSAGE =
"BLOJSOM_TRACKBACK_MESSAGE";
-
+
/** Trackback success page */
//private static final String TRACKBACK_SUCCESS_PAGE = "trackback-success";
-
+
/** Trackback failure page */
//private static final String TRACKBACK_FAILURE_PAGE = "trackback-failure";
-
+
/**
* Constructor.
*/
- public TrackbackServlet()
- {
+ public TrackbackServlet() {
super();
}
-
- /**
+
+ /**
* POSTing to this Servlet will add a Trackback to a Weblog Entrty.
*/
protected void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
+ throws ServletException, IOException {
doPost(req,res);
}
- /**
+ /**
* POSTing to this Servlet will add a Trackback to a Weblog Entrty.
*/
protected void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- try
- {
+ throws ServletException, IOException {
+
+ try {
// insure that incoming data is parsed as UTF-8
req.setCharacterEncoding("UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
throw new ServletException("Can't set incoming encoding to UTF-8");
}
-
+
String url = req.getParameter(TRACKBACK_URL_PARAM);
String title = req.getParameter(TRACKBACK_TITLE_PARAM);
String excerpt = req.getParameter(TRACKBACK_EXCERPT_PARAM);
String blogName = req.getParameter(TRACKBACK_BLOG_NAME_PARAM);
-
- if ((title == null) || "".equals(title))
- {
+
+ if ((title == null) || "".equals(title)) {
title = url;
}
-
- if (excerpt == null)
- {
+
+ if (excerpt == null) {
excerpt = "";
- }
- else
- {
- if (excerpt.length() >= 255)
- {
+ } else {
+ if (excerpt.length() >= 255) {
excerpt = excerpt.substring(0, 252);
excerpt += "...";
}
}
-
+
String error = null;
PrintWriter pw = new PrintWriter(res.getOutputStream());
- try
- {
- if ( title==null || url==null || excerpt==null || blogName==null )
- {
+ try {
+ if(!RollerRuntimeConfig.getBooleanProperty("users.trackbacks.enabled")) {
+ error = "Trackbacks are disabled for this site";
+ } else if ( title==null || url==null ||
+ excerpt==null || blogName==null ) {
error = "title, url, excerpt, and blog_name not specified.";
- }
- else
- {
+ } else {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
WeblogEntryData entry = rreq.getWeblogEntry();
- if (entry!=null && entry.getCommentsStillAllowed())
- {
+ if (entry!=null && entry.getCommentsStillAllowed()) {
String modTitle = blogName + ": " + title;
if (modTitle.length() >= 250) {
modTitle = modTitle.substring(0, 257);
@@ -168,29 +155,21 @@
pw.println("</response>");
pw.flush();
}
- }
- else if (entry!=null)
- {
+ } else if (entry!=null) {
error = "Comments and Trackbacks are disabled for the entry you specified.";
- }
- else
- {
+ } else {
error = "Entry not specified.";
- }
+ }
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
error = e.getMessage();
- if ( error == null )
- {
+ if ( error == null ) {
error = e.getClass().getName();
}
}
- if ( error!= null )
- {
+ if ( error!= null ) {
pw.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
pw.println("<response>");
pw.println("<error>1</error>");
Modified: incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties?rev=289644&r1=289643&r2=289644&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties Fri Sep 16 13:08:56 2005
@@ -201,6 +201,10 @@
configForm.escapeCommentHtml=Escape Comment HTML?
configForm.emailComments=Email notification of comments?
+configForm.commentSettings=Comment and Trackback Settings
+configForm.enableComments=Allow weblog comments?
+configForm.enableTrackbacks=Allow weblog trackbacks?
+
configForm.fileUploadSettings=File Upload Settings
configForm.enableFileUploads=Enable File Uploads?
configForm.allowedExtensions=Allowed Extensions
Modified: incubator/roller/branches/roller_2.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml?rev=289644&r1=289643&r2=289644&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml (original)
+++ incubator/roller/branches/roller_2.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml Fri Sep 16 13:08:56 2005
@@ -54,12 +54,7 @@
<property-def name="pings.suspendPingProcessing" key="configForm.suspendPingProcessing">
<type>boolean</type>
<default-value>false</default-value>
- </property-def>
- <property-def name="site.emailnotify" key="configForm.emailNotification">
- <type>boolean</type>
- <!-- defaults to false because we don't distribute mail jars -->
- <default-value>false</default-value>
- </property-def>
+ </property-def>
</display-group >
<!-- User Settings Group -->
@@ -74,6 +69,20 @@
<default-value>editor-ekit.jsp,editor-text.jsp,editor-dhtml.jsp,editor-text-js.jsp,editor-wiki-js.jsp,editor-rte.jsp</default-value>
<rows>3</rows>
<cols>40</cols>
+ </property-def>
+
+ </display-group >
+
+ <!-- Comment Settings Group -->
+ <display-group name="commentSettings" key="configForm.commentSettings" >
+
+ <property-def name="users.comments.enabled" key="configForm.enableComments">
+ <type>boolean</type>
+ <default-value>true</default-value>
+ </property-def>
+ <property-def name="users.trackbacks.enabled" key="configForm.enableTrackbacks">
+ <type>boolean</type>
+ <default-value>true</default-value>
</property-def>
<property-def name="users.comments.autoformat" key="configForm.autoformatComments">
<type>boolean</type>