From e33b91aa4d43246ad62832e66e2acfad3dfb3608 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 04 Nov 2011 22:28:32 -0400
Subject: [PATCH] Support pagination in RSS feeds. Standardize pg as page parameter.

---
 src/com/gitblit/utils/SyndicationUtils.java |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/com/gitblit/utils/SyndicationUtils.java b/src/com/gitblit/utils/SyndicationUtils.java
index 4ba5622..6919cd2 100644
--- a/src/com/gitblit/utils/SyndicationUtils.java
+++ b/src/com/gitblit/utils/SyndicationUtils.java
@@ -100,7 +100,7 @@
 			content.setType(entryModel.contentType);
 			content.setValue(entryModel.content);
 			entry.setDescription(content);
-			
+
 			entries.add(entry);
 		}
 		feed.setEntries(entries);
@@ -123,17 +123,22 @@
 	 * @param numberOfEntries
 	 *            the number of entries to retrieve. if <= 0 the server default
 	 *            is used.
+	 * @param page
+	 *            0-indexed. used to paginate the results.
 	 * @param username
 	 * @param password
 	 * @return a list of SyndicationModel entries
 	 * @throws {@link IOException}
 	 */
 	public static List<SyndicatedEntryModel> readFeed(String url, String repository, String branch,
-			int numberOfEntries, String username, char[] password) throws IOException {
+			int numberOfEntries, int page, String username, char[] password) throws IOException {
 		// build feed url
 		List<String> parameters = new ArrayList<String>();
 		if (numberOfEntries > 0) {
 			parameters.add("l=" + numberOfEntries);
+		}
+		if (page > 0) {
+			parameters.add("pg=" + page);
 		}
 		if (!StringUtils.isEmpty(branch)) {
 			parameters.add("h=" + branch);
@@ -155,6 +160,8 @@
 	 * @param numberOfEntries
 	 *            the number of entries to retrieve. if <= 0 the server default
 	 *            is used.
+	 * @param page
+	 *            0-indexed. used to paginate the results.
 	 * @param username
 	 * @param password
 	 * @return a list of SyndicationModel entries
@@ -162,13 +169,16 @@
 	 */
 	public static List<SyndicatedEntryModel> readSearchFeed(String url, String repository,
 			String branch, String fragment, Constants.SearchType searchType, int numberOfEntries,
-			String username, char[] password) throws IOException {
+			int page, String username, char[] password) throws IOException {
 		// determine parameters
 		List<String> parameters = new ArrayList<String>();
 		parameters.add("s=" + StringUtils.encodeURL(fragment));
 		if (numberOfEntries > 0) {
 			parameters.add("l=" + numberOfEntries);
 		}
+		if (page > 0) {
+			parameters.add("pg=" + page);
+		}
 		if (!StringUtils.isEmpty(branch)) {
 			parameters.add("h=" + branch);
 		}

--
Gitblit v1.9.1