Author: agilliland
Date: Tue May 15 16:25:33 2007
New Revision: 538381
URL: http://svn.apache.org/viewvc?view=rev&rev=538381
Log:
struts2 version of entry management action.
Added:
roller/trunk/src/org/apache/roller/ui/authoring/struts2/Entries.java
roller/trunk/src/org/apache/roller/ui/authoring/struts2/EntriesBean.java
roller/trunk/web/WEB-INF/jsps/authoring/struts2/Entries.jsp
roller/trunk/web/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp
Modified:
roller/trunk/web/WEB-INF/classes/struts.xml
roller/trunk/web/WEB-INF/tiles.xml
Added: roller/trunk/src/org/apache/roller/ui/authoring/struts2/Entries.java
URL:
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/Entries.java?view=auto&rev=538381
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/Entries.java (added)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/Entries.java Tue
May 15 16:25:33 2007
@@ -0,0 +1,180 @@
+/*
+ * 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.authoring.struts2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.business.RollerFactory;
+import org.apache.roller.business.WeblogManager;
+import org.apache.roller.pojos.PermissionsData;
+import org.apache.roller.pojos.WeblogEntryData;
+import org.apache.roller.ui.core.util.struts2.KeyValueObject;
+import org.apache.roller.ui.core.util.struts2.UIAction;
+
+
+/**
+ * A list view of entries in a weblog.
+ */
+public class Entries extends UIAction {
+
+ private static Log log = LogFactory.getLog(Entries.class);
+
+ // bean for managing submitted data
+ private EntriesBean bean = new EntriesBean();
+
+ // list of entries to display
+ private List<WeblogEntryData> entries = Collections.EMPTY_LIST;
+
+ // first entry in the list
+ private WeblogEntryData firstEntry = null;
+
+ // last entry in the list
+ private WeblogEntryData lastEntry = null;
+
+ // are there more results for the query?
+ private boolean moreResults = false;
+
+
+ public Entries() {
+ this.actionName = "entries";
+ this.desiredMenu = "editor";
+ this.pageTitle = "weblogEntryQuery.title";
+ }
+
+
+ @Override
+ public short requiredWeblogPermissions() {
+ return PermissionsData.AUTHOR;
+ }
+
+
+ public String execute() {
+
+ if(log.isDebugEnabled()) {
+ log.debug("entries bean is ...\n"+getBean().toString());
+ }
+
+ try {
+ String status = getBean().getStatus();
+
+ WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ List<WeblogEntryData> entries = wmgr.getWeblogEntries(
+ getActionWeblog(),
+ null,
+ getBean().getStartDate(),
+ getBean().getEndDate(),
+ getBean().getCategoryPath(),
+ getBean().getTags(),
+ ("ALL".equals(status)) ? null : status,
+ getBean().getText(),
+ getBean().getSortBy(),
+ null,
+ null,
+ getBean().getOffset(),
+ getBean().getCount() + 1);
+
+ if(entries != null && entries.size() > 0) {
+ log.debug("query found "+entries.size()+" results");
+
+ if(entries.size() > getBean().getCount()) {
+ entries.remove(entries.size()-1);
+ setMoreResults(true);
+ }
+
+ setEntries(entries);
+ setFirstEntry((WeblogEntryData)entries.get(0));
+ setLastEntry((WeblogEntryData)entries.get(entries.size()-1));
+ }
+ } catch (RollerException ex) {
+ log.error("Error looking up entries", ex);
+ // TODO: i18n
+ addError("Error looking up entries");
+ }
+
+ return LIST;
+ }
+
+
+ public List<KeyValueObject> getSortByOptions() {
+ List<KeyValueObject> opts = new ArrayList();
+
+ opts.add(new KeyValueObject("pubTime",
getText("weblogEntryQuery.label.pubTime")));
+ opts.add(new KeyValueObject("updateTime",
getText("weblogEntryQuery.label.updateTime")));
+
+ return opts;
+ }
+
+ public List<KeyValueObject> getStatusOptions() {
+ List<KeyValueObject> opts = new ArrayList();
+
+ opts.add(new KeyValueObject("ALL",
getText("weblogEntryQuery.label.allEntries")));
+ opts.add(new KeyValueObject("DRAFT",
getText("weblogEntryQuery.label.draftOnly")));
+ opts.add(new KeyValueObject("PUBLISHED",
getText("weblogEntryQuery.label.publishedOnly")));
+ opts.add(new KeyValueObject("PENDING",
getText("weblogEntryQuery.label.pendingOnly")));
+ opts.add(new KeyValueObject("SCHEDULED",
getText("weblogEntryQuery.label.scheduledOnly")));
+
+ return opts;
+ }
+
+
+ public EntriesBean getBean() {
+ return bean;
+ }
+
+ public void setBean(EntriesBean bean) {
+ this.bean = bean;
+ }
+
+ public List<WeblogEntryData> getEntries() {
+ return entries;
+ }
+
+ public void setEntries(List<WeblogEntryData> entries) {
+ this.entries = entries;
+ }
+
+ public WeblogEntryData getFirstEntry() {
+ return firstEntry;
+ }
+
+ public void setFirstEntry(WeblogEntryData firstEntry) {
+ this.firstEntry = firstEntry;
+ }
+
+ public WeblogEntryData getLastEntry() {
+ return lastEntry;
+ }
+
+ public void setLastEntry(WeblogEntryData lastEntry) {
+ this.lastEntry = lastEntry;
+ }
+
+ public boolean isMoreResults() {
+ return moreResults;
+ }
+
+ public void setMoreResults(boolean moreResults) {
+ this.moreResults = moreResults;
+ }
+
+}
Added: roller/trunk/src/org/apache/roller/ui/authoring/struts2/EntriesBean.java
URL:
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/EntriesBean.java?view=auto&rev=538381
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/EntriesBean.java
(added)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/EntriesBean.java
Tue May 15 16:25:33 2007
@@ -0,0 +1,148 @@
+/*
+ * 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.authoring.struts2;
+
+import java.util.Date;
+import java.util.List;
+import org.apache.roller.util.Utilities;
+
+
+/**
+ * A bean for managing entries query data.
+ */
+public class EntriesBean {
+
+ private Date endDate = null;
+ private Date startDate = null;
+ private String categoryPath = null;
+ private String tagsAsString = null;
+ private String text = null;
+ private String status = "ALL";
+ private String sortBy = "updateTime";
+
+ /** max entries displayed per page */
+ private int count = 30;
+
+ /** offset into current query results */
+ private int offset = 0;
+
+
+ public EntriesBean() {
+ }
+
+ // convenience method
+ public List<String> getTags() {
+ if(getTagsAsString() != null) {
+ return Utilities.splitStringAsTags(getTagsAsString());
+ } else {
+ return null;
+ }
+ }
+
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public String getCategoryPath() {
+ return categoryPath;
+ }
+
+ public void setCategoryPath(String categoryId) {
+ this.categoryPath = categoryId;
+ }
+
+ public String getTagsAsString() {
+ return tagsAsString;
+ }
+
+ public void setTagsAsString(String tags) {
+ this.tagsAsString = tags;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getSortBy() {
+ return sortBy;
+ }
+
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append("startDate = ").append(getStartDate()).append("\n");
+ buf.append("endDate = ").append(getEndDate()).append("\n");
+ buf.append("status = ").append(getStatus()).append("\n");
+ buf.append("sortBy = ").append(getSortBy()).append("\n");
+ buf.append("catPath = ").append(getCategoryPath()).append("\n");
+ buf.append("tags = ").append(getTagsAsString()).append("\n");
+ buf.append("text = ").append(getText()).append("\n");
+ buf.append("offset = ").append(getOffset()).append("\n");
+ buf.append("count = ").append(getCount()).append("\n");
+
+ return buf.toString();
+ }
+
+}
Modified: roller/trunk/web/WEB-INF/classes/struts.xml
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/struts.xml?view=diff&rev=538381&r1=538380&r2=538381
==============================================================================
--- roller/trunk/web/WEB-INF/classes/struts.xml (original)
+++ roller/trunk/web/WEB-INF/classes/struts.xml Tue May 15 16:25:33 2007
@@ -213,8 +213,9 @@
<result name="success" type="chain">entryAdd</result>
</action>
- <action name="entries">
-
<result>/roller-ui/authoring/weblogEntryManagement.do?method=query</result>
+ <action name="entries"
+ class="org.apache.roller.ui.authoring.struts2.Entries">
+ <result name="list" type="tiles">.Entries</result>
</action>
<action name="comments!*" method="{1}"
Added: roller/trunk/web/WEB-INF/jsps/authoring/struts2/Entries.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/Entries.jsp?view=auto&rev=538381
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/Entries.jsp (added)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/Entries.jsp Tue May 15
16:25:33 2007
@@ -0,0 +1,171 @@
+<!--
+ 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.
+-->
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<p class="subtitle">
+ <s:text name="weblogEntryQuery.subtitle" >
+ <s:param value="actionWeblog.handle" />
+ </s:text>
+</p>
+<p class="pagetip">
+ <s:text name="weblogEntryQuery.tip" />
+</p>
+
+
+<%-- ============================================================= --%>
+<%-- Number of comments and date message --%>
+<%-- ============================================================= --%>
+
+<div class="tablenav">
+
+ <div style="float:left;">
+ <s:text name="weblogEntryQuery.nowShowing">
+ <s:param value="entries.size()" />
+ </s:text>
+ </div>
+ <div style="float:right;">
+ <s:date name="firstEntry.pubTime" format="MM/dd/yy hh:mm a" />
+ ---
+ <s:date name="lastEntry.pubTime" format="MM/dd/yy hh:mm a" />
+ </div>
+ <br />
+
+
+ <%-- ============================================================= --%>
+ <%-- Next / previous links --%>
+ <%-- ============================================================= --%>
+
+ <%--
+ <c:choose>
+ <c:when test="${!empty model.prevLink && !empty model.nextLink}">
+ <br /><center>
+ «
+ <a href='<s:property value="${model.prevLink}" />'>
+ <s:text name="weblogEntryQuery.prev" /></a>
+ | <a href='<s:property value="${model.nextLink}" />'>
+ <s:text name="weblogEntryQuery.next" /></a>
+ »
+ </center><br />
+ </c:when>
+ <c:when test="${!empty model.prevLink}">
+ <br /><center>
+ «
+ <a href='<s:property value="${model.prevLink}" />'>
+ <s:text name="weblogEntryQuery.prev" /></a>
+ | <s:text name="weblogEntryQuery.next" />
+ »
+ </center><br />
+ </c:when>
+ <c:when test="${!empty model.nextLink}">
+ <br /><center>
+ «
+ <s:text name="weblogEntryQuery.prev" />
+ | <a class="" href='<s:property value="${model.nextLink}" />'>
+ <s:text name="weblogEntryQuery.next" /></a>
+ »
+ </center><br />
+ </c:when>
+ <c:otherwise><br /></c:otherwise>
+ </c:choose>
+ --%>
+</div> <%-- class="tablenav" --%>
+
+
+<%-- ============================================================= --%>
+<%-- Entry table--%>
+<%-- ============================================================= --%>
+
+<p>
+ <span class="draftEntryBox"> </span>
+ <s:text name="weblogEntryQuery.draft" />
+ <span class="pendingEntryBox"> </span>
+ <s:text name="weblogEntryQuery.pending" />
+</p>
+
+<table class="rollertable" width="100%">
+
+<tr>
+ <th class="rollertable" width="5%">
+ <s:text name="weblogEntryQuery.pubTime" />
+ </th>
+ <th class="rollertable" width="5%">
+ <s:text name="weblogEntryQuery.updateTime" />
+ </th>
+ <th class="rollertable">
+ <s:text name="weblogEntryQuery.title" />
+ </th>
+ <th class="rollertable" width="5%">
+ <s:text name="weblogEntryQuery.category" />
+ </th>
+ <th class="rollertable" width="5%">
+ </th>
+ <th class="rollertable" width="5%">
+ </th>
+</tr>
+
+<s:iterator id="post" value="entries">
+ <%-- <td> with style if comment is spam or pending --%>
+ <s:if test="#post.status == 'DRAFT'">
+ <tr class="draftentry">
+ </s:if>
+ <s:elseif test="#post.status == 'PENDING'">
+ <tr class="pendingentry">
+ </s:elseif>
+ <s:else>
+ <tr>
+ </s:else>
+
+ <td>
+ <s:property value="#post.pubTime" />
+ </td>
+
+ <td>
+ <s:property value="#post.updateTime" />
+ </td>
+
+ <td>
+ <str:truncateNicely upper="80"><s:property value="#post.displayTitle"
/></str:truncateNicely>
+ </td>
+
+ <td>
+ <s:property value="#post.category.name" />
+ </td>
+
+ <td>
+ <s:url id="editUrl" action="entryEdit">
+ <s:param name="weblog" value="%{actionWeblog.handle}" />
+ <s:param name="bean.id" value="#post.id" />
+ </s:url>
+ <s:a href="%{editUrl}"><s:text name="weblogEntryQuery.edit" /></s:a>
+ </td>
+
+ <td>
+ <s:if test="#post.status == 'PUBLISHED'">
+ <a href='<s:property value="#post.permalink" />'><s:text
name="weblogEntryQuery.view" /></a>
+ </s:if>
+ </td>
+
+ </tr>
+</s:iterator>
+
+</table>
+
+<s:if test="entries.isEmpty">
+ <s:text name="weblogEntryQuery.noneFound" />
+ <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
+</s:if>
Added: roller/trunk/web/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp?view=auto&rev=538381
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp (added)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp Tue May
15 16:25:33 2007
@@ -0,0 +1,135 @@
+<%--
+ 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.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<div class="sidebarFade">
+ <div class="menu-tr">
+ <div class="menu-tl">
+
+ <div class="sidebarInner">
+
+ <h3><s:text name="weblogEntryQuery.sidebarTitle" /></h3>
+ <hr size="1" noshade="noshade" />
+
+ <p><s:text name="weblogEntryQuery.sidebarDescription" /></p>
+
+ <s:form action="entries">
+ <s:hidden name="weblog" />
+ <s:hidden name="bean.count" />
+ <s:hidden name="bean.offset" />
+
+ <%--
========================================================= --%>
+ <%-- filter by category --%>
+
+ <div class="sideformrow">
+ <label for="categoryId" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.category"
/></label>
+ <s:select name="bean.categoryPath"
list="actionWeblog.weblogCategories" listKey="path" listValue="path" size="1" />
+ </div>
+ <br />
+ <br />
+
+ <%--
========================================================= --%>
+ <%-- filter by tag --%>
+
+ <div class="sideformrow">
+ <label for="tags" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.tags" /></label>
+ <s:textfield name="bean.tagsAsString" size="14" />
+ </div>
+ <br />
+ <br />
+
+ <%--
========================================================= --%>
+ <%-- filter by text --%>
+
+ <div class="sideformrow">
+ <label for="text" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.text" /></label>
+ <s:textfield name="bean.text" size="14" />
+ </div>
+ <br />
+ <br />
+
+ <%--
========================================================= --%>
+ <%-- filter by date --%>
+
+ <div class="sideformrow">
+ <label for="startDateString" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.startDate" />:
+ </label>
+ <s:datetimepicker name="bean.startDate" />
+ </div>
+
+ <div class="sideformrow">
+ <label for="endDateString" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.endDate" />:
+ </label>
+ <s:datetimepicker name="bean.endDate" />
+ </div>
+ <br />
+ <br />
+
+ <%--
========================================================= --%>
+ <%-- filter by status --%>
+
+ <div class="sideformrow">
+ <label for="status" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.status" />:
+ <br />
+ <br />
+ <br />
+ <br />
+ <br />
+ <br />
+ </label>
+ <div>
+ <s:radio name="bean.status" list="statusOptions"
listKey="key" listValue="value" />
+ </div>
+ </div>
+
+ <%--
========================================================= --%>
+ <%-- sort by --%>
+
+ <div class="sideformrow">
+ <label for="status" class="sideformrow">
+ <s:text name="weblogEntryQuery.label.sortby" />:
+ <br />
+ <br />
+ </label>
+ <div>
+ <s:radio name="bean.sortBy" list="sortByOptions"
listKey="key" listValue="value" />
+ </div>
+ </div>
+
+ <%--
========================================================= --%>
+ <%-- search button --%>
+
+ <br />
+
+ <s:submit key="weblogEntryQuery.button.query" />
+
+ </s:form>
+
+ <br />
+ <br />
+ </div> <!-- sidebarInner -->
+
+ </div>
+ </div>
+</div>
Modified: roller/trunk/web/WEB-INF/tiles.xml
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/tiles.xml?view=diff&rev=538381&r1=538380&r2=538381
==============================================================================
--- roller/trunk/web/WEB-INF/tiles.xml (original)
+++ roller/trunk/web/WEB-INF/tiles.xml Tue May 15 16:25:33 2007
@@ -158,9 +158,10 @@
<put name="styles"
value="/WEB-INF/jsps/tiles/struts2/css-nosidebar.jsp" />
</definition>
- <definition name=".WeblogEntryManagement" extends=".tiles-tabbedpage" >
- <put name="content"
value="/WEB-INF/jsps/authoring/WeblogEntryManagement.jsp" />
- <put name="sidebar"
value="/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp" />
+ <definition name=".Entries" extends=".tiles-tabbedpage" >
+ <put name="head" value="/WEB-INF/jsps/tiles/struts2/head-ajax.jsp" />
+ <put name="content"
value="/WEB-INF/jsps/authoring/struts2/Entries.jsp" />
+ <put name="sidebar"
value="/WEB-INF/jsps/authoring/struts2/EntriesSidebar.jsp" />
<put name="styles" value="/WEB-INF/jsps/tiles/struts2/css-sidebar.jsp"
/>
</definition>