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 2006/12/07 00:24:35 UTC
svn commit: r483290 - in
/incubator/roller/branches/roller_3.1/src/org/apache/roller:
ui/rendering/model/URLModel.java util/URLUtilities.java
Author: agilliland
Date: Wed Dec 6 15:24:35 2006
New Revision: 483290
URL: http://svn.apache.org/viewvc?view=rev&rev=483290
Log:
merging changes from trunk revisions 483279 and 483281 which contain some fixes for tag based urls and include some new tag based methods to the URLModel.
Modified:
incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/model/URLModel.java
incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java
Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/model/URLModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/model/URLModel.java?view=diff&rev=483290&r1=483289&r2=483290
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/model/URLModel.java (original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/model/URLModel.java Wed Dec 6 15:24:35 2006
@@ -19,9 +19,9 @@
package org.apache.roller.ui.rendering.model;
import java.net.MalformedURLException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.jsp.PageContext;
import org.apache.commons.logging.Log;
@@ -193,16 +193,27 @@
return URLUtilities.getWeblogCollectionURL(weblog, locale, catPath, null, null, pageNum, true);
}
+
public String tag(String tag) {
return URLUtilities.getWeblogCollectionURL(weblog, locale, null, null, Arrays.asList(new String[]{tag}) , -1, true);
}
-
-
+
+
public String tag(String tag, int pageNum) {
return URLUtilities.getWeblogCollectionURL(weblog, locale, null, null, Arrays.asList(new String[]{tag}), pageNum, true);
}
+ public String tags(List tags) {
+ return URLUtilities.getWeblogCollectionURL(weblog, locale, null, null, tags , -1, true);
+ }
+
+
+ public String tags(List tags, int pageNum) {
+ return URLUtilities.getWeblogCollectionURL(weblog, locale, null, null, tags, -1, true);
+ }
+
+
public String collection(String dateString, String catPath) {
return URLUtilities.getWeblogCollectionURL(weblog, locale, catPath, dateString, null, -1, true);
}
@@ -322,12 +333,20 @@
return URLUtilities.getWeblogFeedURL(weblog, locale, "entries", "rss", catPath, null, excerpts, true);
}
+ public String rss(List tags, boolean excerpts) {
+ return URLUtilities.getWeblogFeedURL(weblog, locale, "entries", "rss", null, tags, excerpts, true);
+ }
+
public String getAtom() {
return URLUtilities.getWeblogFeedURL(weblog, locale, "entries", "atom", null, null, false, true);
}
public String atom(String catPath, boolean excerpts) {
return URLUtilities.getWeblogFeedURL(weblog, locale, "entries", "atom", catPath, null, excerpts, true);
+ }
+
+ public String atom(List tags, boolean excerpts) {
+ return URLUtilities.getWeblogFeedURL(weblog, locale, "entries", "atom", null, tags, excerpts, true);
}
}
Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java?view=diff&rev=483290&r1=483289&r2=483290
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java (original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java Wed Dec 6 15:24:35 2006
@@ -181,7 +181,7 @@
pathinfo.append("date/").append(dateString);
} else if(tags != null && tags.size() > 0) {
- pathinfo.append("tags/").append(encode(Utilities.stringArrayToString((String[])tags.toArray(), "+")));
+ pathinfo.append("tags/").append(getEncodedTagsString(tags));
} else {
if(dateString != null) params.put("date", dateString);
if(cat != null) params.put("cat", encode(cat));
@@ -228,7 +228,7 @@
params.put("cat", encode(category));
}
if(tags != null && tags.size() > 0) {
- params.put("tags",encode(Utilities.stringArrayToString((String[])tags.toArray(), "+")));
+ params.put("tags", getEncodedTagsString(tags));
}
if(pageNum > 0) {
params.put("page", Integer.toString(pageNum));
@@ -268,7 +268,7 @@
params.put("cat", encode(category));
}
if(tags != null && tags.size() > 0) {
- params.put("tags",encode(Utilities.stringArrayToString((String[])tags.toArray(), "+")));
+ params.put("tags", getEncodedTagsString(tags));
}
if(excerpts) {
params.put("excerpts", "true");
@@ -546,4 +546,24 @@
return decodedStr;
}
+
+ public static final String getEncodedTagsString(List tags) {
+ StringBuffer tagsString = new StringBuffer();
+ if(tags != null && tags.size() > 0) {
+ String tag = null;
+ Iterator tagsIT = tags.iterator();
+
+ // do first tag
+ tag = (String) tagsIT.next();
+ tagsString.append(encode(tag));
+
+ // do rest of tags, joining them with a '+'
+ while(tagsIT.hasNext()) {
+ tag = (String) tagsIT.next();
+ tagsString.append("+");
+ tagsString.append(encode(tag));
+ }
+ }
+ return tagsString.toString();
+ }
}