From e493cfdfa99ba780f1cd61c5575e169c8eb46845 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 09 Nov 2011 17:01:59 -0500
Subject: [PATCH] Restored html content to feeds. Include regex substitutions in content.

---
 src/com/gitblit/utils/SyndicationUtils.java |   16 +++++++++++-----
 src/com/gitblit/client/GitblitClient.java   |    2 +-
 docs/04_releases.mkd                        |    1 +
 src/com/gitblit/client/SearchDialog.java    |    2 +-
 src/com/gitblit/client/FeedsPanel.java      |    2 +-
 src/com/gitblit/SyndicationServlet.java     |    7 ++++---
 docs/00_index.mkd                           |    1 +
 7 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/docs/00_index.mkd b/docs/00_index.mkd
index 5139f04..f8c7fd4 100644
--- a/docs/00_index.mkd
+++ b/docs/00_index.mkd
@@ -47,6 +47,7 @@
 - added: setting to control Gitblit GO context path for proxy setups  
     **New:** *server.contextPath = /*
 - added: *combined-md5* password storage option which stores the hash of username+password as the password
+- added: RSS feeds now include regex substitutions on commit messages for bug trackers, etc
 - fixed: federation protocol timestamps.  dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard.  
     **This breaks 0.6.0 federation clients/servers.**
 - fixed: collision on rename for repositories and users
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index a2161d2..0b6537b 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -20,6 +20,7 @@
 - added: setting to control Gitblit GO context path for proxy setups  
     **New:** *server.contextPath = /*
 - added: *combined-md5* password storage option which stores the hash of username+password as the password
+- added: RSS feeds now include regex substitutions on commit messages for bug trackers, etc
 - fixed: federation protocol timestamps.  dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard.  
     **This breaks 0.6.0 federation clients/servers.**
 - fixed: collision on rename for repositories and users
diff --git a/src/com/gitblit/SyndicationServlet.java b/src/com/gitblit/SyndicationServlet.java
index 66415d1..1de3d79 100644
--- a/src/com/gitblit/SyndicationServlet.java
+++ b/src/com/gitblit/SyndicationServlet.java
@@ -28,9 +28,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.gitblit.models.FeedEntryModel;
 import com.gitblit.models.RefModel;
 import com.gitblit.models.RepositoryModel;
-import com.gitblit.models.FeedEntryModel;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.JGitUtils;
 import com.gitblit.utils.StringUtils;
@@ -189,8 +189,9 @@
 			entry.link = MessageFormat.format(urlPattern, gitblitUrl,
 					StringUtils.encodeURL(model.name), commit.getName());
 			entry.published = commit.getCommitterIdent().getWhen();
-			entry.contentType = "text/plain";
-			entry.content = commit.getFullMessage();
+			entry.contentType = "text/html";
+			String message = GitBlit.self().processCommitMessage(model.name, commit.getFullMessage());
+			entry.content = message;
 			entry.repository = model.name;
 			entry.branch = objectId;
 			List<RefModel> refs = allRefs.get(commit.getId());
diff --git a/src/com/gitblit/client/FeedsPanel.java b/src/com/gitblit/client/FeedsPanel.java
index 9f8de8c..97f37c0 100644
--- a/src/com/gitblit/client/FeedsPanel.java
+++ b/src/com/gitblit/client/FeedsPanel.java
@@ -42,8 +42,8 @@
 import javax.swing.event.ListSelectionListener;
 import javax.swing.table.TableRowSorter;
 
-import com.gitblit.models.FeedModel;
 import com.gitblit.models.FeedEntryModel;
+import com.gitblit.models.FeedModel;
 import com.gitblit.utils.StringUtils;
 
 /**
diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java
index c590dcc..c027537 100644
--- a/src/com/gitblit/client/GitblitClient.java
+++ b/src/com/gitblit/client/GitblitClient.java
@@ -32,11 +32,11 @@
 import com.gitblit.GitBlitException.UnknownRequestException;
 import com.gitblit.Keys;
 import com.gitblit.models.FederationModel;
+import com.gitblit.models.FeedEntryModel;
 import com.gitblit.models.FeedModel;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.models.ServerSettings;
 import com.gitblit.models.ServerStatus;
-import com.gitblit.models.FeedEntryModel;
 import com.gitblit.models.UserModel;
 import com.gitblit.utils.RpcUtils;
 import com.gitblit.utils.StringUtils;
diff --git a/src/com/gitblit/client/SearchDialog.java b/src/com/gitblit/client/SearchDialog.java
index 8c94a5b..cf17116 100644
--- a/src/com/gitblit/client/SearchDialog.java
+++ b/src/com/gitblit/client/SearchDialog.java
@@ -43,8 +43,8 @@
 import javax.swing.event.ListSelectionListener;
 
 import com.gitblit.Constants;
-import com.gitblit.models.RepositoryModel;
 import com.gitblit.models.FeedEntryModel;
+import com.gitblit.models.RepositoryModel;
 import com.gitblit.utils.StringUtils;
 
 /**
diff --git a/src/com/gitblit/utils/SyndicationUtils.java b/src/com/gitblit/utils/SyndicationUtils.java
index 6ba8d73..061d12a 100644
--- a/src/com/gitblit/utils/SyndicationUtils.java
+++ b/src/com/gitblit/utils/SyndicationUtils.java
@@ -97,8 +97,14 @@
 			}
 
 			SyndContent content = new SyndContentImpl();
-			content.setType(entryModel.contentType);
-			content.setValue(entryModel.content);
+			if (StringUtils.isEmpty(entryModel.contentType)
+					|| entryModel.contentType.equalsIgnoreCase("text/plain")) {
+				content.setType("text/html");
+				content.setValue(StringUtils.breakLinesForHtml(entryModel.content));
+			} else {
+				content.setType(entryModel.contentType);
+				content.setValue(entryModel.content);
+			}
 			entry.setDescription(content);
 
 			entries.add(entry);
@@ -167,9 +173,9 @@
 	 * @return a list of SyndicationModel entries
 	 * @throws {@link IOException}
 	 */
-	public static List<FeedEntryModel> readSearchFeed(String url, String repository,
-			String branch, String fragment, Constants.SearchType searchType, int numberOfEntries,
-			int page, String username, char[] password) throws IOException {
+	public static List<FeedEntryModel> readSearchFeed(String url, String repository, String branch,
+			String fragment, Constants.SearchType searchType, int numberOfEntries, int page,
+			String username, char[] password) throws IOException {
 		// determine parameters
 		List<String> parameters = new ArrayList<String>();
 		parameters.add("s=" + StringUtils.encodeURL(fragment));

--
Gitblit v1.9.1