You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/06/21 22:42:57 UTC
svn commit: r416103 [1/2] - in /incubator/roller/branches/roller_3.0:
src/org/apache/roller/ui/rendering/model/ src/org/apache/roller/util/
web/WEB-INF/classes/ web/WEB-INF/velocity/
web/WEB-INF/velocity/templates/feeds/
Author: snoopdave
Date: Wed Jun 21 13:42:56 2006
New Revision: 416103
URL: http://svn.apache.org/viewvc?rev=416103&view=rev
Log:
Ongoing dev: Ripped RollerRequest out of WeblogPageModel, now use name , plus feed template improvements (still not quite done)
Modified:
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/util/DateUtil.java
incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/feeds.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-atom.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-rss.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-atom.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-rss.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-atom.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-rss.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-atom.vm
incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-rss.vm
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java Wed Jun 21 13:42:56 2006
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import org.apache.roller.RollerException;
import org.apache.roller.config.RollerRuntimeConfig;
import org.apache.roller.ui.core.RollerContext;
@@ -58,7 +59,7 @@
}
/** Init page model based on request */
- public void init(Map map) {
+ public void init(Map map) throws RollerException {
this.request = (HttpServletRequest)map.get("request");
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java Wed Jun 21 13:42:56 2006
@@ -160,6 +160,8 @@
args.put("request", request);
pageModel.init(args);
map.put(pageModel.getModelName(), pageModel);
+ } catch (RollerException re) {
+ log.warn("ERROR: initializing a plugin: " + weblogModels[i]);
} catch (ClassNotFoundException cnfe) {
log.warn("ERROR: can't find page model: " + weblogModels[i]);
} catch (InstantiationException ie) {
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java Wed Jun 21 13:42:56 2006
@@ -18,7 +18,7 @@
package org.apache.roller.ui.rendering.model;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
+import org.apache.roller.RollerException;
/**
* Represents a page model to be used in the blog/feed templates.
@@ -31,5 +31,5 @@
/**
* Initialize via request.
*/
- public void init(Map params);
+ public void init(Map params) throws RollerException;
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java Wed Jun 21 13:42:56 2006
@@ -24,9 +24,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
import org.apache.roller.model.RefererManager;
import org.apache.roller.model.Roller;
import org.apache.roller.model.RollerFactory;
@@ -41,7 +41,6 @@
import org.apache.roller.pojos.wrapper.UserDataWrapper;
import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
-import org.apache.roller.ui.rendering.velocity.deprecated.OldWeblogPageModel;
/**
* Page model that provides access to site-wide users, weblogs and entries for
@@ -55,7 +54,7 @@
return "sitePageModel";
}
- public void init(Map map) {
+ public void init(Map map) throws RollerException {
// no-op for now
}
@@ -188,9 +187,9 @@
*/
public List getWeblogEntries(String handle, String userName, String cat, int sinceDays, int offset, int length) {
List results = new ArrayList();
- if (handle.equals(OldWeblogPageModel.VELOCITY_NULL)) handle = null;
- if (userName.equals(OldWeblogPageModel.VELOCITY_NULL)) userName = null;
- if (cat.equals(OldWeblogPageModel.VELOCITY_NULL)) cat = null;
+ if (handle != null && handle.equals("nil")) handle = null;
+ if (userName != null && userName.equals("nil")) userName = null;
+ if (cat != null && cat.equals("nil")) cat = null;
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1 * sinceDays);
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java Wed Jun 21 13:42:56 2006
@@ -1,22 +1,24 @@
/*
-* 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.
-*/
+ * 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.ui.rendering.model;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -26,10 +28,13 @@
import java.util.Map;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.RollerException;
+import org.apache.roller.model.Roller;
import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
import org.apache.roller.model.WeblogManager;
import org.apache.roller.pojos.CommentData;
import org.apache.roller.pojos.WeblogCategoryData;
@@ -40,18 +45,16 @@
import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
import org.apache.roller.ui.authoring.struts.formbeans.CommentFormEx;
-import org.apache.roller.ui.core.RollerRequest;
import org.apache.roller.ui.core.RollerSession;
+import org.apache.roller.ui.rendering.util.WeblogFeedRequest;
+import org.apache.roller.ui.rendering.util.WeblogPageRequest;
import org.apache.roller.util.DateUtil;
/*
* Roller 3.0 development notes
- *
- * - I'm still using RollerRequest here, but I'd like to factor it out
- * so I'm working to isolate it's usage as much as possible.
*
* - I'm still using 'nil' for Velocity null, but perhaps that is unnecessary
- * or nil-advised ;-) Maybe we can use an undefined variable like $nullValue
+ * or nil-advised ;-) Maybe we can use an undefined variable like $nullValue
* insteaed to indicate null when using the new page models.
*
* - Note to self - make sure POJOs provide these methods:
@@ -65,14 +68,19 @@
* New Atlas minimalistic page model provides access to a weblog, possibly
* a weblog entry and pageable collections of entries and comments.
*/
-public class WeblogPageModel implements PageModel {
- private HttpServletRequest request = null;
+public class WeblogPageModel implements PageModel {
+ private HttpServletRequest request = null;
+ private WebsiteData weblog = null;
+ private String weblogHandle = null;
+ private String categoryPath = null;
+ private String entryAnchor = null;
+ private String dateString = null;
private WeblogEntryDataWrapper nextEntry = null;
private WeblogEntryDataWrapper prevEntry = null;
private WeblogEntryDataWrapper firstEntry = null;
private WeblogEntryDataWrapper lastEntry = null;
- protected static Log logger =
+ protected static Log log =
LogFactory.getFactory().getInstance(WeblogPageModel.class);
/** Creates a new instance of AtlasWeblogPageModel */
@@ -81,113 +89,156 @@
/** Template context name to be used for model */
public String getModelName() {
- return "can't be just 'page' :(";
+ return "model";
}
-
+
/** Init page model based on request */
- public void init(Map map) {
- this.request = (HttpServletRequest)map.get("request");
+ public void init(Map map) throws RollerException {
+ HttpServletRequest request = (HttpServletRequest)map.get("request");
+ try {
+ // Can we parse it as a page request?
+ WeblogPageRequest parsed = new WeblogPageRequest(request);
+ weblogHandle = parsed.getWeblogHandle();
+ categoryPath = parsed.getWeblogCategory();
+ entryAnchor = parsed.getWeblogAnchor();
+ dateString = parsed.getWeblogDate();
+ } catch(Exception ignored) {}
+ if (weblogHandle == null) {
+ try {
+ // Can we parse it as feed request?
+ WeblogFeedRequest parsed = new WeblogFeedRequest(request);
+ weblogHandle = parsed.getWeblogHandle();
+ categoryPath = parsed.getWeblogCategory();
+ } catch(Exception e) {
+ // Can't parse as either; we've got a problem
+ throw new RollerException("ERROR: parsing request", e);
+ }
+ }
+ Roller roller = RollerFactory.getRoller();
+ UserManager umgr = roller.getUserManager();
+ weblog = umgr.getWebsiteByHandle(weblogHandle, Boolean.TRUE);
}
/**
* Get website being displayed.
*/
- public WebsiteDataWrapper getWeblog() {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WebsiteData weblog = rreq.getWebsite();
-
- WebsiteDataWrapper ret = null;
- if (weblog != null) {
- ret = WebsiteDataWrapper.wrap(weblog);
- }
- return ret;
+ public WebsiteDataWrapper getWeblog() {
+ return WebsiteDataWrapper.wrap(weblog);
}
- /**
+ /**
* Get weblog entry to be displayed; null if not on single-entry page or if entry not published.
*/
public WeblogEntryDataWrapper getWeblogEntry() {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WeblogEntryData entry = rreq.getWeblogEntry();
-
- WeblogEntryDataWrapper ret = null;
- if (entry != null && entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
- ret = WeblogEntryDataWrapper.wrap(entry);
+ WeblogEntryDataWrapper ret = null;
+ try {
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ WeblogEntryData entry =
+ wmgr.getWeblogEntryByAnchor(weblog, entryAnchor);
+ if (entry != null && entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
+ ret = WeblogEntryDataWrapper.wrap(entry);
+ }
+
+ } catch (Exception e) {
+ log.error("ERROR: fetching entry");
}
return ret;
}
-
- /**
+
+ /**
* Get weblog category or null if request does not specify one.
*/
public WeblogCategoryDataWrapper getWeblogCategory() {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WeblogCategoryData cat = rreq.getWeblogCategory();
-
WeblogCategoryDataWrapper ret = null;
- if (cat != null) {
- ret = WeblogCategoryDataWrapper.wrap(cat);
+ try {
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ WeblogCategoryData cat = wmgr.getWeblogCategoryByPath(
+ weblog, categoryPath);
+ if (cat != null) {
+ ret = WeblogCategoryDataWrapper.wrap(cat);
+ }
+ } catch (Exception e) {
+ log.error("ERROR: fetching category");
}
return ret;
}
/**
- * Get most recent weblog entries for date and category specified by request.
- * @return List of WeblogEntryDataWrapper objects.
+ * Get weblog entries as specified by the date and category specified or
+ * implied by the URL.
+ * @param cat Category restriction or null for all categories
+ * @return List of WeblogEntryDataWrapper objects.
*/
- public List getWeblogEntries(String cat, int offset, int length) {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- Date date = rreq.getDate();
- WebsiteData weblog = rreq.getWebsite();
- WeblogCategoryData category = rreq.getWeblogCategory();
- boolean isDaySpecified = rreq.isDaySpecified();
- boolean isMonthSpecified = rreq.isMonthSpecified();
-
- if ("nil".equals(cat)) cat = null;
+ public List getWeblogEntries(String cat, int offset) {
+ if (cat != null && "nil".equals(cat)) cat = null;
List ret = new ArrayList();
try {
- if (date == null) date = new Date();
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ Date date = parseDate(dateString);
- // If request specifies a category, then use that
- String catParam = null;
- if (category != null) {
- catParam = category.getPath();
- } else if (cat != null) {
- // use category argument instead
- catParam = cat;
- } else if (weblog != null) // MAIN
- {
- catParam = weblog.getDefaultCategory().getPath();
- if (catParam.equals("/")) {
- catParam = null;
- }
+ boolean isDaySpecified = false;
+ boolean isMonthSpecified = false;
+ if (dateString != null && dateString.length() == 8) {
+ isDaySpecified = true;
+ }
+ else if (dateString != null && dateString.length() == 6) {
+ isMonthSpecified = true;
}
- WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
- List mEntries = mgr.getWeblogEntries(
- weblog, // weblog
- null, // user
- null, // startDate
- date, // endDate
- catParam, // catName
+
+ String chosenCatPath = cat != null ? cat : categoryPath;
+ if (chosenCatPath == null) {
+ // no category specifed so use default
+ chosenCatPath = weblog.getDefaultCategory().getPath();
+ chosenCatPath = chosenCatPath.equals("/") ? null : chosenCatPath;
+ }
+
+ // if weblog is specified, use its timezone
+ Calendar cal = null;
+ if (weblog != null) {
+ TimeZone tz = weblog.getTimeZoneInstance();
+ cal = Calendar.getInstance(tz);
+ } else {
+ cal = Calendar.getInstance();
+ }
+
+ Date startDate = null;
+ Date endDate = date;
+ if (endDate == null) endDate = new Date();
+ if (isDaySpecified) {
+ // URL specified a specific day so get all entries for it
+ startDate = DateUtil.getStartOfDay(endDate, cal);
+ endDate = DateUtil.getEndOfDay(endDate, cal);
+ } else if (isMonthSpecified) {
+ // URL specified a specific month so get all entries for it
+ startDate = DateUtil.getStartOfMonth(endDate, cal);
+ endDate = DateUtil.getEndOfMonth(endDate, cal);
+ }
+ List entries = wmgr.getWeblogEntries(
+ weblog, // weblog
+ null, // user
+ startDate, // startDate
+ endDate, // endDate
+ chosenCatPath, // catName
WeblogEntryData.PUBLISHED, // status
- null, // sortby (null for pubTime)
- offset, // offset into results
- length); // max results to return
+ null, // sortby (null for pubTime)
+ offset, // offset into results
+ weblog.getEntryDisplayCount()); // max results to return
// wrap pojos
- ret = new ArrayList(mEntries.size());
- Iterator it = mEntries.iterator();
+ ret = new ArrayList(entries.size());
+ Iterator it = entries.iterator();
int i=0;
while(it.hasNext()) {
ret.add(i, WeblogEntryDataWrapper.wrap((WeblogEntryData) it.next()));
i++;
}
+ setFirstAndLastEntries( ret );
+
} catch (Exception e) {
- logger.error("ERROR: getting entry list", e);
+ log.error("ERROR: getting entry list", e);
}
return ret;
}
@@ -196,60 +247,60 @@
* Get most recent weblog entries for day or month specified by request.
* @return Map of Lists of weblog entry objects, keyed by 8-char date strings.
*/
- public Map getWeblogEntriesMonthMap(String cat, int offset, int length) {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- Date date = rreq.getDate();
- WebsiteData weblog = rreq.getWebsite();
- WeblogCategoryData category = rreq.getWeblogCategory();
- boolean isDaySpecified = rreq.isDaySpecified();
- boolean isMonthSpecified = rreq.isMonthSpecified();
-
- if ("nil".equals(cat)) cat = null;
+ public Map getWeblogEntriesMonthMap(String cat, int offset) {
+ if (cat != null && "nil".equals(cat)) cat = null;
Map ret = new HashMap();
- try {
- String catParam = null;
- if (category != null) {
- // request specified category so use it
- catParam = category.getPath();
- } else if (cat != null) {
- // use category argument instead
- catParam = cat;
- } else if (weblog != null) {
- // otherwise use default category of weblog
- catParam = weblog.getDefaultCategory().getPath();
- if (catParam.equals("/")) {
- catParam = null;
- }
+ try {
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ Date date = parseDate(dateString);
+
+ boolean isDaySpecified = false;
+ boolean isMonthSpecified = false;
+ if (dateString != null && dateString.length() == 8) {
+ isDaySpecified = true;
+ }
+ else if (dateString != null && dateString.length() == 6) {
+ isMonthSpecified = true;
+ }
+
+ String chosenCatPath = cat != null ? cat : categoryPath;
+ if (chosenCatPath == null) {
+ // no category specifed so use default
+ chosenCatPath = weblog.getDefaultCategory().getPath();
+ chosenCatPath = chosenCatPath.equals("/") ? null : chosenCatPath;
}
// if weblog is specified, use its timezone
Calendar cal = null;
- if (weblog != null) {
+ if (weblog != null) {
TimeZone tz = weblog.getTimeZoneInstance();
cal = Calendar.getInstance(tz);
} else {
cal = Calendar.getInstance();
}
- int limit = length;
+ int limit = weblog.getEntryDisplayCount();
Date startDate = null;
Date endDate = date;
if (endDate == null) endDate = new Date();
- if (isDaySpecified) {
- // URL specified a specific day so get all entries for that day
+ if (isDaySpecified) {
+ // URL specified a specific day so get all entries for it
+ startDate = DateUtil.getStartOfDay(endDate, cal);
endDate = DateUtil.getEndOfDay(endDate, cal);
- startDate = DateUtil.getStartOfDay(endDate, cal);
- limit = -1;
} else if (isMonthSpecified) {
+ // URL specified a specific month so get all entries for it
+ startDate = DateUtil.getStartOfMonth(endDate, cal);
endDate = DateUtil.getEndOfMonth(endDate, cal);
}
Map mmap = RollerFactory.getRoller().getWeblogManager().getWeblogEntryObjectMap(
weblog,
- startDate,
- endDate,
- catParam,
- WeblogEntryData.PUBLISHED, 0, -1);
+ startDate,
+ endDate,
+ chosenCatPath,
+ WeblogEntryData.PUBLISHED,
+ 0,
+ weblog.getEntryDisplayCount());
// need to wrap pojos
java.util.Date key = null;
@@ -262,7 +313,7 @@
List entries = (List) mmap.get(key);
for(int i=0; i < entries.size(); i++) {
wrappedEntries.add(i,
- WeblogEntryDataWrapper.wrap((WeblogEntryData)entries.get(i)));
+ WeblogEntryDataWrapper.wrap((WeblogEntryData)entries.get(i)));
}
mmap.put(key, wrappedEntries);
}
@@ -272,72 +323,68 @@
setFirstAndLastEntries( ret );
} catch (Exception e) {
- logger.error("ERROR: getting entry month map", e);
+ log.error("ERROR: getting entry month map", e);
}
return ret;
}
- /**
+ /**
* Get weblog entry to be displayed or null if not on single-entry page.
*/
public WeblogEntryDataWrapper getWeblogEntryNext() {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WeblogCategoryData category = rreq.getWeblogCategory();
-
- WeblogEntryDataWrapper currentEntry = getWeblogEntry();
- if (firstEntry != null) currentEntry = firstEntry;
- if (nextEntry == null && currentEntry != null) {
- String catName = null;
- if (category != null) {
- catName = category.getName();
- }
- try {
- WeblogManager wmgr =
- RollerFactory.getRoller().getWeblogManager();
+ try {
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ WeblogCategoryData category = wmgr.getWeblogCategoryByPath(
+ weblog, categoryPath);
+ WeblogEntryDataWrapper currentEntry = getWeblogEntry();
+ if (firstEntry != null) currentEntry = firstEntry;
+ if (nextEntry == null && currentEntry != null) {
+ String catName = null;
+ if (category != null) {
+ catName = category.getName();
+ }
WeblogEntryData next =
- wmgr.getNextEntry(currentEntry.getPojo(), catName);
-
+ wmgr.getNextEntry(currentEntry.getPojo(), catName);
+
if (nextEntry != null)
nextEntry = WeblogEntryDataWrapper.wrap(next);
-
+
// make sure that mNextEntry is not published to future
if (nextEntry != null && nextEntry.getPubTime().after(new Date())) {
nextEntry = null;
}
- } catch (RollerException e) {
- logger.error("ERROR: getting next entry", e);
}
+ } catch (RollerException e) {
+ log.error("ERROR: getting next entry", e);
}
return nextEntry;
}
- /**
+ /**
* Get weblog entry to be displayed or null if not on single-entry page.
*/
public WeblogEntryDataWrapper getWeblogEntryPrev() {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WeblogCategoryData category = rreq.getWeblogCategory();
-
- WeblogEntryDataWrapper currentEntry = getWeblogEntry();
- if (lastEntry != null) currentEntry = lastEntry;
- if (prevEntry == null && currentEntry != null ) {
- String catName = null;
- if (category != null) {
- catName = category.getName();
- }
- try {
- WeblogManager wmgr =
- RollerFactory.getRoller().getWeblogManager();
+ try {
+ Roller roller = RollerFactory.getRoller();
+ WeblogManager wmgr = roller.getWeblogManager();
+ WeblogCategoryData category = wmgr.getWeblogCategoryByPath(
+ weblog, categoryPath);
+ WeblogEntryDataWrapper currentEntry = getWeblogEntry();
+ if (lastEntry != null) currentEntry = lastEntry;
+ if (prevEntry == null && currentEntry != null ) {
+ String catName = null;
+ if (category != null) {
+ catName = category.getName();
+ }
WeblogEntryData prev =
- wmgr.getPreviousEntry(currentEntry.getPojo(), catName);
+ wmgr.getPreviousEntry(currentEntry.getPojo(), catName);
if(prev != null) {
- prevEntry = WeblogEntryDataWrapper.wrap(prev);
+ prevEntry = WeblogEntryDataWrapper.wrap(prev);
}
- } catch (RollerException e) {
- logger.error("ERROR: getting previous entry", e);
}
+ } catch (RollerException e) {
+ log.error("ERROR: getting next entry", e);
}
return prevEntry;
}
@@ -346,11 +393,7 @@
* Get most recent approved and non-spam comments in weblog.
* @return List of CommentDataWrapper objects.
*/
- public List getComments(int offset, int length) {
-
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
- WebsiteData weblog = rreq.getWebsite();
-
+ public List getComments(int offset) {
List recentComments = new ArrayList();
try {
WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
@@ -365,7 +408,7 @@
Boolean.FALSE, // no spam
true, // we want reverse chrono order
offset, // offset
- length); // length
+ weblog.getEntryDisplayCount()); // length
// wrap pojos
recentComments = new ArrayList(recent.size());
@@ -374,7 +417,7 @@
recentComments.add(CommentDataWrapper.wrap((CommentData) it.next()));
}
} catch (RollerException e) {
- logger.error("ERROR: getting comments", e);
+ log.error("ERROR: getting comments", e);
}
return recentComments;
}
@@ -384,9 +427,9 @@
*/
public CommentFormEx getCommentForm() {
CommentFormEx commentForm =
- (CommentFormEx) request.getAttribute("commentForm");
+ (CommentFormEx) request.getAttribute("commentForm");
if (commentForm == null) {
- commentForm = new CommentFormEx();
+ commentForm = new CommentFormEx();
// Set fields to spaces to please Velocity
commentForm.setName("");
commentForm.setEmail("");
@@ -394,7 +437,7 @@
commentForm.setContent("");
}
return commentForm;
- }
+ }
/**
* Get preview comment or null if none exists.
@@ -408,35 +451,33 @@
CommentFormEx commentForm = getCommentForm();
commentForm.copyTo(comment, request.getLocale());
commentWrapper = CommentDataWrapper.wrap(comment);
- }
+ }
} catch (RollerException e) {
- logger.warn("ERROR: creating comment form", e);
+ log.warn("ERROR: creating comment form", e);
}
return commentWrapper;
}
public boolean isUserAuthorizedToAdmin() {
try {
- RollerRequest rreq = RollerRequest.getRollerRequest(request);
RollerSession rses = RollerSession.getRollerSession(request);
- if (rses.getAuthenticatedUser() != null
- && rreq.getWebsite() != null) {
- return rses.isUserAuthorizedToAdmin(rreq.getWebsite());
+ if (rses.getAuthenticatedUser() != null) {
+ return rses.isUserAuthorizedToAdmin(weblog);
}
} catch (RollerException e) {
- logger.warn("ERROR: checking user authorization", e);
+ log.warn("ERROR: checking user authorization", e);
}
return false;
}
-
+
public boolean isUserAuthenticated() {
return (request.getUserPrincipal() != null);
}
- /** Pull the last WeblogEntryData out of the Map. */
+ /** Pull the last WeblogEntryData out of the Map. */
private void setFirstAndLastEntries(Map days) {
int numDays = days.keySet().size();
- if (numDays > 0) // there is at least one day
+ if (numDays > 0) // there is at least one day
{
// get first entry in map
Object[] keys = days.keySet().toArray(new Object[numDays]);
@@ -454,7 +495,53 @@
}
}
}
-
+
+ /** Pull the last WeblogEntryData out of the List. */
+ private void setFirstAndLastEntries(List entries) {
+ if (entries.size() > 0) {
+ firstEntry = (WeblogEntryDataWrapper)entries.get(0);
+ if (entries.size() > 1) {
+ lastEntry = (WeblogEntryDataWrapper)entries.get(entries.size() - 1);
+ } else {
+ lastEntry = (WeblogEntryDataWrapper)entries.get(0);
+ }
+ }
+ }
+
+ private Date parseDate(String dateString) {
+ Date ret = null;
+ SimpleDateFormat char8DateFormat = DateUtil.get8charDateFormat();
+ SimpleDateFormat char6DateFormat = DateUtil.get6charDateFormat();
+ if ( dateString!=null
+ && dateString.length()==8
+ && StringUtils.isNumeric(dateString) ) {
+ ParsePosition pos = new ParsePosition(0);
+ ret = char8DateFormat.parse( dateString, pos );
+
+ // make sure the requested date is not in the future
+ Date today = getToday();
+ if (ret.after(today)) ret = today;
+ }
+ if ( dateString!=null
+ && dateString.length()==6
+ && StringUtils.isNumeric(dateString) ) {
+ ParsePosition pos = new ParsePosition(0);
+ ret = char6DateFormat.parse( dateString, pos );
+
+ // make sure the requested date is not in the future
+ Date today = getToday();
+ if (ret.after(today)) ret = today;
+ }
+ return ret;
+ }
+
+ private Date getToday() {
+ Calendar todayCal = Calendar.getInstance();
+ todayCal = Calendar.getInstance(
+ weblog.getTimeZoneInstance(),weblog.getLocaleInstance());
+ todayCal.setTime(new Date());
+ return todayCal.getTime();
+ }
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/util/DateUtil.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/util/DateUtil.java?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/util/DateUtil.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/util/DateUtil.java Wed Jun 21 13:42:56 2006
@@ -1 +1 @@
-/*
* 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.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util
.Locale;
import org.apache.commons.lang.StringUtils;
/**
* General purpose date utilities.
* @author Mark Saarinen
* @author Lance Lavandowska
*/
public abstract class DateUtil extends Object
{
public static final long millisInDay = 86400000;
// some static date formats
private static SimpleDateFormat[] mDateFormats = loadDateFormats();
private static final SimpleDateFormat mFormat8chars =
new SimpleDateFormat("yyyyMMdd");
private static final SimpleDateFormat mFormat6chars =
new SimpleDateFormat("yyyyMM");
private static final SimpleDateFormat mFormatIso8601Day =
new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat mFormatIso8601 =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
// http://www.w3.org/Protocols/rfc822/Overview.html#z28
// Using Locale.US to fix ROL-725 and ROL-628
private static final SimpleDateFormat mFormatRfc822 =
new SimpleDateForma
t("EEE, d MMM yyyy HH:mm:ss Z", Locale.US);
private static SimpleDateFormat[] loadDateFormats()
{
SimpleDateFormat[] temp = {
//new SimpleDateFormat("MM/dd/yyyy hh:mm:ss.SSS a"),
new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"), // standard Date.toString() results
new SimpleDateFormat("M/d/yy hh:mm:ss"),
new SimpleDateFormat("M/d/yyyy hh:mm:ss"),
new SimpleDateFormat("M/d/yy hh:mm a"),
new SimpleDateFormat("M/d/yyyy hh:mm a"),
new SimpleDateFormat("M/d/yy HH:mm"),
new SimpleDateFormat("M/d/yyyy HH:mm"),
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"),
new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS"),
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"), // standard Timestamp.toString() results
new SimpleDateFormat("M-d-yy HH:mm"),
new SimpleDateFormat("M-d-yyyy HH:mm"),
new SimpleDateFormat("MM/dd/
yyyy HH:mm:ss.SSS"),
new SimpleDateFormat("M/d/yy"),
new SimpleDateFormat("M/d/yyyy"),
new SimpleDateFormat("M-d-yy"),
new SimpleDateFormat("M-d-yyyy"),
new SimpleDateFormat("MMMM d, yyyyy"),
new SimpleDateFormat("MMM d, yyyyy")
};
return temp;
}
//-----------------------------------------------------------------------
/**
* Gets the array of SimpleDateFormats that DateUtil knows about.
**/
private static SimpleDateFormat[] getFormats()
{
return mDateFormats;
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the last possible millisecond of the day, just
* before midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getEndOfDay(Date day)
{
return getEndOfDay(day,Calendar.getInstance());
}
public static Date getEndOfDay(D
ate day,Calendar cal)
{
if (day == null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
return cal.getTime();
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the last possible millisecond of the day, just
* before midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getEndOfMonth(Date day)
{
return getEndOfMonth(day,Calendar.getInstance());
}
public static Date getEndOfMonth(Date day,Calendar cal)
{
if (day == null) day = new Date();
cal.setTime(day);
// set time to end of day
cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
cal
.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
// set time to first day of month
cal.set(Calendar.DAY_OF_MONTH, 1);
// add one month
cal.add(Calendar.MONTH, 1);
// back up one day
cal.add(Calendar.DAY_OF_MONTH, -1);
return cal.getTime();
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the first possible millisecond of the day, just
* after midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getStartOfDay(Date day)
{
return getStartOfDay(day, Calendar.getInstance());
}
/**
* Returns a Date set to the first possible millisecond of the day, just
* after midnight. If a null day is passed in, a new Date is
created.
* midnight (00m 00h 00s)
*/
public static Date getStartOfDay(Date day, Calendar cal)
{
if (day == null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
return cal.getTime();
}
/**
* Returns a Date set just to Noon, to the closest possible millisecond
* of the day. If a null day is passed in, a new Date is created.
* nnoon (00m 12h 00s)
*/
public static Date getNoonOfDay(Date day, Calendar cal)
{
if (day == null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal
.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
return cal.getTime();
}
//-----------------------------------------------------------------------
public static Date parseFromFormats(String aValue)
{
if (StringUtils.isEmpty(aValue)) return null;
// get DateUtil's formats
SimpleDateFormat formats[] = DateUtil.getFormats();
if (formats == null) return null;
// iterate over the array and parse
Date myDate = null;
for (int i = 0; i <formats.length; i++)
{
try
{
myDate = DateUtil.parse(aValue, formats[i]);
//if (myDate instanceof Date)
return myDate;
}
catch (Exception e)
{
// do nothing because we want to try the next
// format if current one fails
}
}
// haven't returned so couldn't parse
return n
ull;
}
//-----------------------------------------------------------------------
public static java.sql.Timestamp parseTimestampFromFormats(String aValue)
{
if (StringUtils.isEmpty(aValue)) return null;
// call the regular Date formatter
Date myDate = DateUtil.parseFromFormats(aValue);
if (myDate != null) return new java.sql.Timestamp(myDate.getTime());
return null;
}
//-----------------------------------------------------------------------
/**
* Returns a java.sql.Timestamp equal to the current time
**/
public static java.sql.Timestamp now()
{
return new java.sql.Timestamp(new java.util.Date().getTime());
}
//-----------------------------------------------------------------------
/**
* Returns a string the represents the passed-in date parsed
* according to the passed-in format. Returns an empty string
* if the date or the format is null.
**/
p
ublic static String format(Date aDate, SimpleDateFormat aFormat)
{
if (aDate == null || aFormat == null ) { return ""; }
synchronized (aFormat)
{
return aFormat.format(aDate);
}
}
//-----------------------------------------------------------------------
/**
* Tries to take the passed-in String and format it as a date string in the
* the passed-in format.
**/
public static String formatDateString(String aString, SimpleDateFormat aFormat)
{
if (StringUtils.isEmpty(aString) || aFormat == null) return "";
try
{
java.sql.Timestamp aDate = parseTimestampFromFormats(aString);
if (aDate != null)
{
return DateUtil.format(aDate, aFormat);
}
}
catch (Exception e)
{
// Could not parse aString.
}
return "";
}
//-----------------------------------------------
------------------------
/**
* Returns a Date using the passed-in string and format. Returns null if the string
* is null or empty or if the format is null. The string must match the format.
**/
public static Date parse(String aValue, SimpleDateFormat aFormat) throws ParseException
{
if (StringUtils.isEmpty(aValue) || aFormat == null)
{
return null;
}
return aFormat.parse(aValue);
}
//-----------------------------------------------------------------------
/**
* Returns true if endDate is after startDate or if startDate equals endDate
* or if they are the same date. Returns false if either value is null.
**/
public static boolean isValidDateRange(Date startDate, Date endDate)
{
return isValidDateRange(startDate, endDate, true);
}
//-----------------------------------------------------------------------
/**
* Returns true if endDate is after st
artDate or if startDate equals endDate.
* Returns false if either value is null. If equalOK, returns true if the
* dates are equal.
**/
public static boolean isValidDateRange(Date startDate, Date endDate, boolean equalOK)
{
// false if either value is null
if (startDate == null || endDate == null) { return false; }
if (equalOK)
{
// true if they are equal
if (startDate.equals(endDate)) { return true; }
}
// true if endDate after startDate
if (endDate.after(startDate)) { return true; }
return false;
}
//-----------------------------------------------------------------------
// returns full timestamp format
public static java.text.SimpleDateFormat defaultTimestampFormat()
{
return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
//-----------------------------------------------------------------------
// conveni
ence method returns minimal date format
public static java.text.SimpleDateFormat get8charDateFormat()
{
return DateUtil.mFormat8chars;
}
// convenience method returns minimal date format
public static java.text.SimpleDateFormat get6charDateFormat()
{
return DateUtil.mFormat6chars;
}
//-----------------------------------------------------------------------
// convenience method returns minimal date format
public static java.text.SimpleDateFormat defaultDateFormat()
{
return DateUtil.friendlyDateFormat(true);
}
//-----------------------------------------------------------------------
// convenience method
public static String defaultTimestamp(Date date)
{
return DateUtil.format(date, DateUtil.defaultTimestampFormat());
}
//-----------------------------------------------------------------------
// convenience method
public static String defaultDate(Date
date)
{
return DateUtil.format(date, DateUtil.defaultDateFormat());
}
//-----------------------------------------------------------------------
// convenience method returns long friendly timestamp format
public static java.text.SimpleDateFormat friendlyTimestampFormat()
{
return new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
}
//-----------------------------------------------------------------------
// convenience method returns long friendly formatted timestamp
public static String friendlyTimestamp(Date date)
{
return DateUtil.format(date, DateUtil.friendlyTimestampFormat());
}
//-----------------------------------------------------------------------
// convenience method returns long friendly formatted timestamp
public static String format8chars(Date date)
{
return DateUtil.format(date, mFormat8chars);
}
//--------------------------------------------------
---------------------
// convenience method returns long friendly formatted timestamp
public static String formatIso8601Day(Date date)
{
return DateUtil.format(date, mFormatIso8601Day);
}
//-----------------------------------------------------------------------
public static String formatRfc822(Date date)
{
return DateUtil.format(date,mFormatRfc822);
}
//-----------------------------------------------------------------------
// This is a hack, but it seems to work
public static String formatIso8601(Date date)
{
if (date == null) return "";
// Add a colon 2 chars before the end of the string
// to make it a valid ISO-8601 date.
String str = DateUtil.format(date,mFormatIso8601);
StringBuffer sb = new StringBuffer();
sb.append( str.substring(0,str.length()-2) );
sb.append( ":" );
sb.append( str.substring(str.length()-2) );
return sb.toString();
}
//-----------------------------------------------------------------------
// convenience method returns minimal date format
public static java.text.SimpleDateFormat minimalDateFormat()
{
return DateUtil.friendlyDateFormat(true);
}
//-----------------------------------------------------------------------
// convenience method using minimal date format
public static String minimalDate(Date date)
{
return DateUtil.format(date, DateUtil.minimalDateFormat());
}
//-----------------------------------------------------------------------
// convenience method that returns friendly data format
// using full month, day, year digits.
public static java.text.SimpleDateFormat fullDateFormat()
{
return DateUtil.friendlyDateFormat(false);
}
//-----------------------------------------------------------------------
public static String fullDate(Date date)
{
return DateUtil.format(date, DateUtil.fullDateFormat());
}
//-----------------------------------------------------------------------
/** Returns a "friendly" date format.
* @param mimimalFormat Should the date format allow single digits.
**/
public static java.text.SimpleDateFormat friendlyDateFormat(boolean minimalFormat)
{
if (minimalFormat)
{
return new java.text.SimpleDateFormat("d.M.yy");
}
return new java.text.SimpleDateFormat("dd.MM.yyyy");
}
//-----------------------------------------------------------------------
/**
* Format the date using the "friendly" date format.
*/
public static String friendlyDate(Date date, boolean minimalFormat)
{
return DateUtil.format(date, DateUtil.friendlyDateFormat(minimalFormat));
}
//-----------------------------------------------------------------------
// convenience method
public static String frie
ndlyDate(Date date)
{
return DateUtil.format(date, DateUtil.friendlyDateFormat(true));
}
public static Date parseIso8601(String value) throws Exception
{
return ISO8601DateParser.parse(value);
}
}
\ No newline at end of file
+/*
* 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.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.apache.commons.lang.StringUtils;
/**
* General purpose date utilities.
* @author Mark Saarinen
* @author Lance Lavandowska
*/
public abstract class DateUtil extends Object {
public static final long millisInDay = 86400000;
// some static date formats
private static SimpleDateFormat[] mDateFormats = loadDateFormats();
private static final SimpleDateFormat mFormat8chars =
new SimpleDateFormat("yyyyMMdd");
private static final SimpleDateFormat mFormat6chars =
new SimpleDateFormat("yyyyMM");
private static final SimpleDateFormat mFormatIso8601Day =
new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat mFormatIso8601 =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
// http://www.w3.org/Protocols/rfc822/Overview.html#z28
// Using Locale.US to fix ROL-725 and ROL-628
private static final SimpleDateFormat
mFormatRfc822 =
new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US);
private static SimpleDateFormat[] loadDateFormats() {
SimpleDateFormat[] temp = {
//new SimpleDateFormat("MM/dd/yyyy hh:mm:ss.SSS a"),
new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"), // standard Date.toString() results
new SimpleDateFormat("M/d/yy hh:mm:ss"),
new SimpleDateFormat("M/d/yyyy hh:mm:ss"),
new SimpleDateFormat("M/d/yy hh:mm a"),
new SimpleDateFormat("M/d/yyyy hh:mm a"),
new SimpleDateFormat("M/d/yy HH:mm"),
new SimpleDateFormat("M/d/yyyy HH:mm"),
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"),
new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS"),
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"), // standard Timestamp.toString() results
new SimpleDateFormat("M-d-yy HH:mm"),
new SimpleDateFormat("M-d-yyyy HH:
mm"),
new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS"),
new SimpleDateFormat("M/d/yy"),
new SimpleDateFormat("M/d/yyyy"),
new SimpleDateFormat("M-d-yy"),
new SimpleDateFormat("M-d-yyyy"),
new SimpleDateFormat("MMMM d, yyyyy"),
new SimpleDateFormat("MMM d, yyyyy")
};
return temp;
}
//-----------------------------------------------------------------------
/**
* Gets the array of SimpleDateFormats that DateUtil knows about.
**/
private static SimpleDateFormat[] getFormats() {
return mDateFormats;
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the last possible millisecond of the day, just
* before midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getEndOfDay(Date day) {
return
getEndOfDay(day,Calendar.getInstance());
}
public static Date getEndOfDay(Date day,Calendar cal) {
if (day == null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
return cal.getTime();
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the first possible millisecond of the month, just
* after midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getStartOfMonth(Date day) {
return getStartOfMonth(day, Calendar.getInstance());
}
public static Date getStartOfMonth(Date day, Calendar cal) {
if (day == null) day = new Date();
cal.setTime(day);
// set time to start of day
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
// set time to first day of month
cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime();
}
/**
* Returns a Date set to the last possible millisecond of the month, just
* before midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getEndOfMonth(Date day) {
return getEndOfMonth(day, Calendar.getInstance());
}
public static Date getEndOfMonth(Date day,Calendar cal) {
if (day == null) day = new Date();
cal.setTime(day);
// set time to end of day
cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
// set time to first day of month
cal.set(Calendar.DAY_OF_MONTH, 1);
// add one month
cal.add(Calendar.MONTH, 1);
// back up one day
cal.add(Calendar.DAY_OF_MONTH, -1);
return cal.getTime();
}
//-----------------------------------------------------------------------
/**
* Returns a Date set to the first possible millisecond of the day, just
* after midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getStartOfDay(Date day) {
re
turn getStartOfDay(day, Calendar.getInstance());
}
/**
* Returns a Date set to the first possible millisecond of the day, just
* after midnight. If a null day is passed in, a new Date is created.
* midnight (00m 00h 00s)
*/
public static Date getStartOfDay(Date day, Calendar cal) {
if (day == null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
return cal.getTime();
}
/**
* Returns a Date set just to Noon, to the closest possible millisecond
* of the day. If a null day is passed in, a new Date is created.
* nnoon (00m 12h 00s)
*/
public static Date getNoonOfDay(Date day, Calendar cal) {
if (day
== null) day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
return cal.getTime();
}
//-----------------------------------------------------------------------
public static Date parseFromFormats(String aValue) {
if (StringUtils.isEmpty(aValue)) return null;
// get DateUtil's formats
SimpleDateFormat formats[] = DateUtil.getFormats();
if (formats == null) return null;
// iterate over the array and parse
Date myDate = null;
for (int i = 0; i <formats.length; i++) {
try {
myDate = DateUtil.parse(aValue, formats[i]);
//if (myDate instanceof Date)
return myDate;
} catch (Exception e) {
// do nothing because we want to try the next
// format if current one fails
}
}
// haven't returned so couldn't parse
return null;
}
//-----------------------------------------------------------------------
public static java.sql.Timestamp parseTimestampFromFormats(String aValue) {
if (StringUtils.isEmpty(aValue)) return null;
// call the regular Date formatter
Date myDate = DateUtil.parseFromFormats(aValue);
if (myDate != null) return new java.sql.Timestamp(myDate.getTime());
return null;
}
//-----------------------------------------------------------------------
/**
* Returns a java.sql.Timestamp equal to the current time
**/
public static java.sql.Timestamp now() {
return new java.sql.Timestamp(new java.util.Date().getTime());
}
//------------------------------------
-----------------------------------
/**
* Returns a string the represents the passed-in date parsed
* according to the passed-in format. Returns an empty string
* if the date or the format is null.
**/
public static String format(Date aDate, SimpleDateFormat aFormat) {
if (aDate == null || aFormat == null ) { return ""; }
synchronized (aFormat) {
return aFormat.format(aDate);
}
}
//-----------------------------------------------------------------------
/**
* Tries to take the passed-in String and format it as a date string in the
* the passed-in format.
**/
public static String formatDateString(String aString, SimpleDateFormat aFormat) {
if (StringUtils.isEmpty(aString) || aFormat == null) return "";
try {
java.sql.Timestamp aDate = parseTimestampFromFormats(aString);
if (aDate != null) {
return DateUtil.format(aDate, a
Format);
}
} catch (Exception e) {
// Could not parse aString.
}
return "";
}
//-----------------------------------------------------------------------
/**
* Returns a Date using the passed-in string and format. Returns null if the string
* is null or empty or if the format is null. The string must match the format.
**/
public static Date parse(String aValue, SimpleDateFormat aFormat) throws ParseException {
if (StringUtils.isEmpty(aValue) || aFormat == null) {
return null;
}
return aFormat.parse(aValue);
}
//-----------------------------------------------------------------------
/**
* Returns true if endDate is after startDate or if startDate equals endDate
* or if they are the same date. Returns false if either value is null.
**/
public static boolean isValidDateRange(Date startDate, Date endDate) {
return isValidDateRange(startDate, endDate, true);
}
//-----------------------------------------------------------------------
/**
* Returns true if endDate is after startDate or if startDate equals endDate.
* Returns false if either value is null. If equalOK, returns true if the
* dates are equal.
**/
public static boolean isValidDateRange(Date startDate, Date endDate, boolean equalOK) {
// false if either value is null
if (startDate == null || endDate == null) { return false; }
if (equalOK) {
// true if they are equal
if (startDate.equals(endDate)) { return true; }
}
// true if endDate after startDate
if (endDate.after(startDate)) { return true; }
return false;
}
//-----------------------------------------------------------------------
// returns full timestamp format
public static java.text.SimpleDateForm
at defaultTimestampFormat() {
return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
//-----------------------------------------------------------------------
// convenience method returns minimal date format
public static java.text.SimpleDateFormat get8charDateFormat() {
return DateUtil.mFormat8chars;
}
// convenience method returns minimal date format
public static java.text.SimpleDateFormat get6charDateFormat() {
return DateUtil.mFormat6chars;
}
//-----------------------------------------------------------------------
// convenience method returns minimal date format
public static java.text.SimpleDateFormat defaultDateFormat() {
return DateUtil.friendlyDateFormat(true);
}
//-----------------------------------------------------------------------
// convenience method
public static String defaultTimestamp(Date date) {
return DateUtil.format(da
te, DateUtil.defaultTimestampFormat());
}
//-----------------------------------------------------------------------
// convenience method
public static String defaultDate(Date date) {
return DateUtil.format(date, DateUtil.defaultDateFormat());
}
//-----------------------------------------------------------------------
// convenience method returns long friendly timestamp format
public static java.text.SimpleDateFormat friendlyTimestampFormat() {
return new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
}
//-----------------------------------------------------------------------
// convenience method returns long friendly formatted timestamp
public static String friendlyTimestamp(Date date) {
return DateUtil.format(date, DateUtil.friendlyTimestampFormat());
}
//-----------------------------------------------------------------------
// convenience method returns long frie
ndly formatted timestamp
public static String format8chars(Date date) {
return DateUtil.format(date, mFormat8chars);
}
//-----------------------------------------------------------------------
// convenience method returns long friendly formatted timestamp
public static String formatIso8601Day(Date date) {
return DateUtil.format(date, mFormatIso8601Day);
}
//-----------------------------------------------------------------------
public static String formatRfc822(Date date) {
return DateUtil.format(date,mFormatRfc822);
}
//-----------------------------------------------------------------------
// This is a hack, but it seems to work
public static String formatIso8601(Date date) {
if (date == null) return "";
// Add a colon 2 chars before the end of the string
// to make it a valid ISO-8601 date.
String str = DateUtil.format(date,mFormatIso86
01);
StringBuffer sb = new StringBuffer();
sb.append( str.substring(0,str.length()-2) );
sb.append( ":" );
sb.append( str.substring(str.length()-2) );
return sb.toString();
}
//-----------------------------------------------------------------------
// convenience method returns minimal date format
public static java.text.SimpleDateFormat minimalDateFormat() {
return DateUtil.friendlyDateFormat(true);
}
//-----------------------------------------------------------------------
// convenience method using minimal date format
public static String minimalDate(Date date) {
return DateUtil.format(date, DateUtil.minimalDateFormat());
}
//-----------------------------------------------------------------------
// convenience method that returns friendly data format
// using full month, day, year digits.
public static java.text.SimpleDateFormat fullDateFormat() {
return DateUtil.friendlyDateFormat(false);
}
//-----------------------------------------------------------------------
public static String fullDate(Date date) {
return DateUtil.format(date, DateUtil.fullDateFormat());
}
//-----------------------------------------------------------------------
/** Returns a "friendly" date format.
* @param mimimalFormat Should the date format allow single digits.
**/
public static java.text.SimpleDateFormat friendlyDateFormat(boolean minimalFormat) {
if (minimalFormat) {
return new java.text.SimpleDateFormat("d.M.yy");
}
return new java.text.SimpleDateFormat("dd.MM.yyyy");
}
//-----------------------------------------------------------------------
/**
* Format the date using the "friendly" date format.
*/
public static String friendlyDate(Date date, boolean minimalFormat) {
return DateUtil.format
(date, DateUtil.friendlyDateFormat(minimalFormat));
}
//-----------------------------------------------------------------------
// convenience method
public static String friendlyDate(Date date) {
return DateUtil.format(date, DateUtil.friendlyDateFormat(true));
}
public static Date parseIso8601(String value) throws Exception {
return ISO8601DateParser.parse(value);
}
}
\ No newline at end of file
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties Wed Jun 21 13:42:56 2006
@@ -103,6 +103,7 @@
# Set of page models to be created for site-wide rendering
rendering.sitePageModels=\
org.apache.roller.ui.rendering.model.SitePageModel,\
+org.apache.roller.ui.rendering.model.WeblogPageModel,\
org.apache.roller.ui.rendering.model.ConfigPageModel
# Deprecated Roller 2.X page model configuration
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/feeds.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/feeds.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/feeds.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/feeds.vm Wed Jun 21 13:42:56 2006
@@ -84,7 +84,7 @@
#end
#end
-#macro(showEntriesRSS20 $entries)
+#macro(showCommentsRSS20 $entries)
#foreach($entry in $entries)
<item>
<!-- TODO: 3.0 Fix this, it's not a unique ID -->
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-atom.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-atom.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-atom.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-atom.vm Wed Jun 21 13:42:56 2006
@@ -1,13 +1,13 @@
$pageHelper.setContentType("application/atom+xml;charset=utf-8")<?xml version="1.0" encoding='utf-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="html">$utils.escapeHTML($config.getConfigProperty("site.name"))) (Comments)</title>
- <id>$page.absoluteContextURL/atom/$page.weblog.handle</id>
- <link rel="alternate" type="text/html" href="$page.weblog.URL" />
+ <id>$model.absoluteContextURL/atom/$model.weblog.handle</id>
+ <link rel="alternate" type="text/html" href="$model.weblog.URL" />
<link rel="self" type="application/atom+xml"
- href="$page.absoluteContextURL/atom/$page.weblog.handle/comments" />
- <updated>$utils.formatIso8601Date($page.weblog.lastModified)</updated>
+ href="$model.absoluteContextURL/atom/$model.weblog.handle/comments" />
+ <updated>$utils.formatIso8601Date($model.weblog.lastModified)</updated>
<generator uri="http://rollerweblogger.org" version="$config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)">Roller Weblogger</generator>
- #set($comments = $site.getComments(-1, 0, $page.weblog.entryDisplayCount))
+ #set($comments = $site.getComments(-1, 0, $model.weblog.entryDisplayCount))
#showCommentsAtom10($comments)
</feed>
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-rss.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-rss.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-rss.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-comments-rss.vm Wed Jun 21 13:42:56 2006
@@ -4,13 +4,13 @@
xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
<title>$utils.escapeHTML($config.getConfigProperty("site.name")) (Comments)</title>
- <link>$page.absoluteContextURL</link>
- <description>$utils.escapeHTML($page.weblog.description)</description>
+ <link>$model.absoluteContextURL</link>
+ <description>$utils.escapeHTML($model.weblog.description)</description>
<language>en-us</language>
- <copyright>Copyright $utils.formatDate($page.weblog.lastModified, "yyyy")</copyright>
- <lastBuildDate>$utils.formatRfc822Date($page.weblog.lastModified)</lastBuildDate>
+ <copyright>Copyright $utils.formatDate($model.weblog.lastModified, "yyyy")</copyright>
+ <lastBuildDate>$utils.formatRfc822Date($model.weblog.lastModified)</lastBuildDate>
<generator>Roller Weblogger $config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)</generator>
- #set($comments = $site.getComments(-1, 0, $page.weblog.entryDisplayCount))
+ #set($comments = $site.getComments(-1, 0, $model.weblog.entryDisplayCount))
#showCommentsAtom10($comments)
</channel>
</rss>
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-atom.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-atom.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-atom.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-atom.vm Wed Jun 21 13:42:56 2006
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding='utf-8'?>
<!-- TODO: this won't work, we need to use category string -->
-#if($page.weblogCategory && $page.weblogCategory.path.length() > 0)
- #set($postfix = "?catname=$page.weblogCategory.path")
- #set($cat = $page.weblogCategory.path)
+#if($model.weblogCategory && $model.weblogCategory.path.length() > 0)
+ #set($postfix = "?catname=$model.weblogCategory.path")
+ #set($cat = $model.weblogCategory.path)
#else
#set($postfix = "")
#end
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="html">$utils.escapeHTML($config.getConfigProperty("site.name"))</title>
<subtitle type="html">$utils.escapeHTML($config.getConfigProperty("site.description"))</subtitle>
- <id>$page.absoluteContextURL</id>
- <link rel="alternate" type="text/html" href="$page.absoluteContextURL" />
+ <id>$model.absoluteContextURL</id>
+ <link rel="alternate" type="text/html" href="$model.absoluteContextURL" />
<link rel="self" type="application/atom+xml"
- href="$page.absoluteContextURL/$page.weblog.handle/feeds/entries/atom$postfix" />
- <updated>$utils.formatIso8601Date($page.weblog.lastModified)</updated>
+ href="$model.absoluteContextURL/$model.weblog.handle/feeds/entries/atom$postfix" />
+ <updated>$utils.formatIso8601Date($model.weblog.lastModified)</updated>
<generator uri="http://rollerweblogger.org" version="$config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)">Roller Weblogger</generator>
#set($entries = $site.getWeblogEntries($null, $null, $cat, -1, 0, $config.getConfigProperty("site.newsfeeds.maxEntries")) )
#showEntriesAtom10($entries)
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-rss.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-rss.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-rss.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/site-entries-rss.vm Wed Jun 21 13:42:56 2006
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- TODO: this won't work, we need to use category string -->
-#if($page.weblogCategory && $page.weblogCategory.path.length() > 0)
- #set($postfix = "?catname=$page.weblogCategory.path")
- #set($cat = $page.weblogCategory.path)
+#if($model.weblogCategory && $model.weblogCategory.path.length() > 0)
+ #set($postfix = "?catname=$model.weblogCategory.path")
+ #set($cat = $model.weblogCategory.path)
#else
#set($postfix = "")
#end
@@ -11,11 +11,11 @@
xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
<title>$utils.escapeHTML($config.getConfigProperty("site.name"))</title>
- <link>$page.absoluteContextURL</link>
+ <link>$model.absoluteContextURL</link>
<description>$utils.escapeHTML($config.getConfigProperty("site.description"))</description>
<language>en-us</language>
- <copyright>Copyright #formatDate("yyyy" $page.now)</copyright>
- <lastBuildDate>$utilities.formatRfc822Date($page.now)</lastBuildDate>
+ <copyright>Copyright #formatDate("yyyy" $model.now)</copyright>
+ <lastBuildDate>$utilities.formatRfc822Date($model.now)</lastBuildDate>
<generator>Roller Weblogger $config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)</generator>
#set($entries = $site.getWeblogEntries($null, $null, $cat, -1, 0, $config.getConfigProperty("site.newsfeeds.maxEntries")) )
#showEntriesRSS20($entries)
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-atom.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-atom.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-atom.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-atom.vm Wed Jun 21 13:42:56 2006
@@ -1,13 +1,13 @@
$pageHelper.setContentType("application/atom+xml;charset=utf-8")<?xml version="1.0" encoding='utf-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
- <title type="html">$utils.escapeHTML($page.weblog.name) (Comments)</title>
- <id>$page.absoluteContextURL/atom/$page.weblog.handle</id>
- <link rel="alternate" type="text/html" href="$page.weblog.URL" />
+ <title type="html">$utils.escapeHTML($model.weblog.name) (Comments)</title>
+ <id>$model.absoluteContextURL/atom/$model.weblog.handle</id>
+ <link rel="alternate" type="text/html" href="$model.weblog.URL" />
<link rel="self" type="application/atom+xml"
- href="$page.absoluteContextURL/atom/$page.weblog.handle/comments" />
- <updated>$utils.formatIso8601Date($page.weblog.lastModified)</updated>
+ href="$model.absoluteContextURL/atom/$model.weblog.handle/comments" />
+ <updated>$utils.formatIso8601Date($model.weblog.lastModified)</updated>
<generator uri="http://rollerweblogger.org" version="$config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)">Roller Weblogger</generator>
- #set($comments = $page.getComments(0, $page.weblog.entryDisplayCount))
+ #set($comments = $model.getComments(0, $model.weblog.entryDisplayCount))
#showCommentsAtom10($comments)
</feed>
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-rss.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-rss.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-rss.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-comments-rss.vm Wed Jun 21 13:42:56 2006
@@ -3,14 +3,14 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
- <title>$utils.escapeHTML($utils.removeHTML($page.weblog.name)) (Comments)</title>
- <link>$page.absoluteContextURL</link>
- <description>$utils.escapeHTML($page.weblog.description)</description>
+ <title>$utils.escapeHTML($utils.removeHTML($model.weblog.name)) (Comments)</title>
+ <link>$model.absoluteContextURL</link>
+ <description>$utils.escapeHTML($model.weblog.description)</description>
<language>en-us</language>
- <copyright>Copyright $utils.formatDate($page.weblog.lastModified, "yyyy")</copyright>
- <lastBuildDate>$utils.formatRfc822Date($page.weblog.lastModified)</lastBuildDate>
+ <copyright>Copyright $utils.formatDate($model.weblog.lastModified, "yyyy")</copyright>
+ <lastBuildDate>$utils.formatRfc822Date($model.weblog.lastModified)</lastBuildDate>
<generator>Roller Weblogger $config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)</generator>
- #set($comments = $page.getComments(0, $page.weblog.entryDisplayCount))
+ #set($comments = $model.getComments(0, $model.weblog.entryDisplayCount))
#showCommentsRSS20($comments)
</channel>
</rss>
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-atom.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-atom.vm?rev=416103&r1=416102&r2=416103&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-atom.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/templates/feeds/weblog-entries-atom.vm Wed Jun 21 13:42:56 2006
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding='utf-8'?>
-#if($page.weblogCategory && $page.weblogCategory.path.length() > 0)
- #set($postfix = "?catname=$page.weblogCategory.path")
- #set($cat = $page.weblogCategory.path)
+#if($model.weblogCategory && $model.weblogCategory.path.length() > 0)
+ #set($postfix = "?catname=$model.weblogCategory.path")
+ #set($cat = $model.weblogCategory.path)
#else
#set($postfix = "")
#end
<feed xmlns="http://www.w3.org/2005/Atom">
- <title type="html">$utils.escapeHTML($website.name)</title>
- <subtitle type="html">$utils.escapeHTML($website.description)</subtitle>
- <id>$page.absoluteContextURL/atom/$page.weblog.handle</id>
- <link rel="alternate" type="text/html" href="$page.weblog.URL" />
+ <title type="html">$utils.escapeHTML($model.weblog.name)</title>
+ <subtitle type="html">$utils.escapeHTML($model.weblog.description)</subtitle>
+ <id>$model.absoluteContextURL/atom/$model.weblog.handle</id>
+ <link rel="alternate" type="text/html" href="$model.weblog.URL" />
<link rel="self" type="application/atom+xml"
- href="$page.absoluteContextURL/atom/$page.weblog.handle$postfix" />
- <updated>$utils.formatIso8601Date($page.weblog.lastModified)</updated>
+ href="$model.absoluteContextURL/atom/$model.weblog.handle$postfix" />
+ <updated>$utils.formatIso8601Date($model.weblog.lastModified)</updated>
<generator uri="http://rollerweblogger.org" version="$config.rollerVersion ($config.rollerBuildTime:$config.rollerBuildUser)">Roller Weblogger</generator>
- #set($entries = $page.getWeblogEntries($cat, 0, $page.weblog.entryDisplayCount) )
+ #set($entries = $model.getWeblogEntries($cat, 0) )
#showEntriesAtom10($entries)
</feed>