roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r374275 - in /incubator/roller/branches/roller_2.1_tagging: ./ metadata/database/ metadata/database/hibernate/ metadata/xdoclet/ src/org/roller/business/ src/org/roller/business/hibernate/ src/org/roller/model/ src/org/roller/pojos/ src/org...
Date Thu, 02 Feb 2006 05:53:18 GMT
Author: eliast
Date: Wed Feb  1 21:53:01 2006
New Revision: 374275

URL: http://svn.apache.org/viewcvs?rev=374275&view=rev
Log:
Committing IBM's internal tagging modification to Roller.
Most of the work was originally written by Phay Tac Lau,
integration done by Elias Torres.

Changes consist of the following:

- Added new table to createdb.vm to store tagging information
- Created new pojo and query results wrapper
- Modified the WeblogManager interface to support tags
- Implemented WeblogManager using a HibernateStrategy
- Modified WeblogEditEntry Form to enter tags
- Added new sidebar, tagcloud, etc to Main Page

-Elias


Added:
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagData.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagListEntryWrapper.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagCloudEntry.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagPageAction.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagsPageAction.java
    incubator/roller/branches/roller_2.1_tagging/web/tag.jsp
    incubator/roller/branches/roller_2.1_tagging/web/tags.jsp
Modified:
    incubator/roller/branches/roller_2.1_tagging/build.xml
    incubator/roller/branches/roller_2.1_tagging/metadata/database/createdb.vm
    incubator/roller/branches/roller_2.1_tagging/metadata/database/droptables.sql
    incubator/roller/branches/roller_2.1_tagging/metadata/database/hibernate/hibernate.cfg.xml
    incubator/roller/branches/roller_2.1_tagging/metadata/xdoclet/global-forwards.xml
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/WeblogManagerImpl.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/model/WeblogManager.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/WeblogEntryData.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/MainPageAction.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageHelper.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageModel.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
    incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
    incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/tiles-defs.xml
    incubator/roller/branches/roller_2.1_tagging/web/main-sidebar.jsp
    incubator/roller/branches/roller_2.1_tagging/web/main.jsp
    incubator/roller/branches/roller_2.1_tagging/web/theme/bannerStatus.jsp
    incubator/roller/branches/roller_2.1_tagging/web/theme/roller.css
    incubator/roller/branches/roller_2.1_tagging/web/weblog/WeblogEdit.jsp

Modified: incubator/roller/branches/roller_2.1_tagging/build.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/build.xml?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/build.xml (original)
+++ incubator/roller/branches/roller_2.1_tagging/build.xml Wed Feb  1 21:53:01 2006
@@ -240,6 +240,7 @@
             <include name="org/roller/pojos/RefererData.java"/>
             <include name="org/roller/pojos/Template.java"/>
             <include name="org/roller/pojos/UserData.java"/>
+            <include name="org/roller/pojos/TagData.java"/>
             <include name="org/roller/pojos/WeblogEntryData.java"/>
             <include name="org/roller/pojos/WeblogCategoryData.java"/>
             <include name="org/roller/pojos/WebsiteData.java"/>

Modified: incubator/roller/branches/roller_2.1_tagging/metadata/database/createdb.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/metadata/database/createdb.vm?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/metadata/database/createdb.vm (original)
+++ incubator/roller/branches/roller_2.1_tagging/metadata/database/createdb.vm Wed Feb  1 21:53:01 2006
@@ -195,6 +195,18 @@
 create index we_userid_idx on weblogentry(userid);
 create index we_status_idx on weblogentry(status);
 
+create table weblogentrytag (
+    id              varchar(48)   not null primary key,
+    entryid         varchar(48)   not null,
+    name            varchar(255)  not null,
+#    normalname      varchar(255)  not null,
+#    authorusername	varchar(255)  not null,
+#    posttime        timestamp     not null,
+    tagtime         timestamp     not null
+);
+
+create index wet_entryid_idx on weblogentrytag( entryid );
+
 create table newsfeed (
     id              varchar(48) not null primary key,
     name            varchar(255) not null,
@@ -430,6 +442,9 @@
 
 alter table webpage add constraint wp_websiteid_fk
     foreign key ( websiteid ) references website( id ) $!ADDL_FK_PARAMS ;
+
+alter table weblogentrytag add constraint wet_entryid_fk
+    foreign key ( entryid ) references weblogentry( id ) $!ADDL_FK_PARAMS ;
 
 alter table weblogentry add constraint we_websiteid_fk
     foreign key ( websiteid ) references website( id ) $!ADDL_FK_PARAMS ;

Modified: incubator/roller/branches/roller_2.1_tagging/metadata/database/droptables.sql
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/metadata/database/droptables.sql?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/metadata/database/droptables.sql (original)
+++ incubator/roller/branches/roller_2.1_tagging/metadata/database/droptables.sql Wed Feb  1 21:53:01 2006
@@ -9,6 +9,7 @@
 drop table roller_comment;
 drop table entryattribute;
 drop table weblogentry;
+drop table weblogentrytag;
 drop table weblogcategory;
 drop table folder;
 drop table folderassoc;

Modified: incubator/roller/branches/roller_2.1_tagging/metadata/database/hibernate/hibernate.cfg.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/metadata/database/hibernate/hibernate.cfg.xml?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/metadata/database/hibernate/hibernate.cfg.xml (original)
+++ incubator/roller/branches/roller_2.1_tagging/metadata/database/hibernate/hibernate.cfg.xml Wed Feb  1 21:53:01 2006
@@ -61,6 +61,7 @@
         <mapping resource="org/roller/pojos/RefererData.hbm.xml" />
         <mapping resource="org/roller/pojos/RoleData.hbm.xml" />
         <mapping resource="org/roller/pojos/RollerConfigData.hbm.xml" />
+       	<mapping resource="org/roller/pojos/TagData.hbm.xml" />
         <mapping resource="org/roller/pojos/UserData.hbm.xml" />
         <mapping resource="org/roller/pojos/WeblogCategoryData.hbm.xml" />
         <mapping resource="org/roller/pojos/WeblogCategoryAssoc.hbm.xml" />

Modified: incubator/roller/branches/roller_2.1_tagging/metadata/xdoclet/global-forwards.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/metadata/xdoclet/global-forwards.xml?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/metadata/xdoclet/global-forwards.xml (original)
+++ incubator/roller/branches/roller_2.1_tagging/metadata/xdoclet/global-forwards.xml Wed Feb  1 21:53:01 2006
@@ -8,6 +8,7 @@
 <forward name="page"                   path="/page"/>
 <forward name="main"                   path="/main.do"/>
 <forward name="home.page"              path="/main.do"/>
+<forward name="tags"                   path="/tags.do"/>
 <forward name="planet"                 path="/planet.do"/>
 <forward name="createUser"             path="/user.do?method=createUser"/>
 <forward name="registerUser"           path="/user.do?method=registerUser"/>

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/WeblogManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/WeblogManagerImpl.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/WeblogManagerImpl.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/WeblogManagerImpl.java Wed Feb  1 21:53:01 2006
@@ -10,6 +10,7 @@
 import org.roller.model.Roller;
 import org.roller.model.WeblogManager;
 import org.roller.pojos.CommentData;
+import org.roller.pojos.TagData;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogCategoryAssoc;
 import org.roller.pojos.WeblogCategoryData;
@@ -54,6 +55,26 @@
     */
     
     private SimpleDateFormat formatter = DateUtil.get8charDateFormat();
+
+	public abstract List findTags(String pattern, int maxResults) 
+			throws RollerException;	
+		
+    public abstract List getWebsiteTags(
+            WebsiteData website) throws RollerException;
+    
+	public abstract List getWeblogEntriesByTag(WebsiteData website, String tag)
+			throws RollerException;
+
+	public abstract List getAllTags()
+			throws RollerException;
+
+    public void removeTag(String id) throws RollerException
+    {
+        mStrategy.remove(id, TagData.class);
+    }
+
+    public abstract List getTagsOrderByCount(int maxResults)
+    	throws RollerException;
 
     public abstract List getWeblogEntries(
                     WebsiteData website, 

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/business/hibernate/HibernateWeblogManagerImpl.java Wed Feb  1 21:53:01 2006
@@ -10,6 +10,11 @@
 import org.hibernate.criterion.Junction;
 import org.hibernate.criterion.Order;
 
+import org.hibernate.criterion.CriteriaSpecification;
+import org.hibernate.criterion.Projections;
+import org.hibernate.Query;
+import org.roller.pojos.TagData;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.roller.RollerException;
@@ -27,6 +32,7 @@
 import org.roller.util.StringUtils;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -50,6 +56,164 @@
         mLogger.debug("Instantiating Weblog Manager");
     }
     
+    /**
+     * Find tags with pattern, % is wild card
+     *
+     * @author Phay Tac Lau
+     */
+	public List findTags(String pattern, int maxResults) throws RollerException
+	{
+    	String sql =
+    		"select count(t), t.name from org.roller.pojos.TagData t "
+    		+"where t.name like '" + pattern
+    		+ "' group by t.name order by count(t) desc, t.name asc";
+
+        try
+        {
+			Session session = ((HibernateStrategy)mStrategy).getSession();
+			Query query = session.createQuery(sql);
+			query.setMaxResults(maxResults);
+			return query.list();
+        }
+        catch (HibernateException e)
+        {
+            throw new RollerException(e);
+        }
+	}
+	
+    /**
+     * Get a list of all tags a website is marked with.
+     * Returns a list of arrays [ Integer count, String tagName ]
+     *
+     * @author Phay Tac Lau
+     * @param website Website to retrieve tags for
+     */    
+    public List getWebsiteTags(
+            WebsiteData website) throws RollerException
+	{
+		String websiteId = website.getId();
+		
+		String sql = new StringBuffer()
+				.append("select count(t), t.name from org.roller.pojos.TagData ")
+				.append("t, org.roller.pojos.WeblogEntryData w where w.website.id='")
+				.append(websiteId)
+				.append("' and t.entry.id=w.id ")
+				.append(" group by t.name order by t.name asc")
+				.toString();		
+		try
+		{
+			Session session = ((HibernateStrategy)mStrategy).getSession();
+			Query query = session.createQuery(sql);
+			return query.list();
+		}
+		catch (HibernateException e)
+		{
+		   throw new RollerException(e);
+		}
+	}
+
+    
+    /**
+     * Get a list of tags ordered by count.
+     *
+     * @author Phay Tac Lau
+     * @param maxResults maximum number of tags to return
+     */
+    public List getTagsOrderByCount(int maxResults)
+		throws RollerException
+    {
+    	
+    	String sql =
+    		"select count(t), t.name from org.roller.pojos.TagData "
+    		+ "t group by t.name";// order by count(t) desc, t.name asc";
+
+        try
+        {
+			Session session = ((HibernateStrategy)mStrategy).getSession();
+			Query query = session.createQuery(sql);
+			query.setMaxResults(maxResults);
+			return query.list();
+        }
+        catch (HibernateException e)
+        {
+            throw new RollerException(e);
+        }
+    	
+    	/*     Hibernate generates invalid DB2 SQL for this
+        try
+        {
+			Session session = ((HibernateStrategy)mStrategy).getSession();
+            Criteria criteria = session.createCriteria(TagData.class)
+                .setProjection(Projections.projectionList()
+                    .add(Projections.rowCount(), "count")
+                    .add(Projections.groupProperty("name"))
+                )
+                .setMaxResults(maxResults)
+                .addOrder(Order.desc("count"))
+                .addOrder(Order.asc("name"));
+            return criteria.list();
+        }
+        catch (HibernateException e)
+        {
+            throw new RollerException(e);
+        }
+        */
+    }
+
+    /**
+     * Get a list of all tags present in the database and the occurance
+	 * count of each tag.
+     *
+     * @author Phay Tac Lau
+     */
+	public List getAllTags() throws RollerException
+	{
+        try
+        {
+			Session session = ((HibernateStrategy)mStrategy).getSession();
+            Criteria criteria = session.createCriteria(TagData.class)
+                .setProjection(Projections.projectionList()
+                    .add(Projections.rowCount())
+                    .add(Projections.groupProperty("name"))
+                ).addOrder(Order.asc("name"));
+            return criteria.list();
+        }
+        catch (HibernateException e)
+        {
+            throw new RollerException(e);
+        }
+	}
+
+    /**
+     * Get the weblog entries marked with tag.
+     *
+     * @author Phay Tac Lau
+     */
+     public List getWeblogEntriesByTag(WebsiteData website, String tag) throws RollerException
+     {
+         if (tag == null)
+             throw new RollerException("tag is null");
+
+        try
+        {
+    		Session session = ((HibernateStrategy)mStrategy).getSession();
+            Criteria criteria = session.createCriteria(WeblogEntryData.class);
+            criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
+            criteria.createAlias("tagSet", "t");
+            criteria.add(Expression.eq("t.name", tag));
+            if(website != null)
+            {
+            	criteria.add(Expression.eq("website", website));
+            }            
+            criteria.addOrder(Order.desc("pubTime"));
+            return criteria.list();
+        }
+        catch (HibernateException e)
+        {
+            throw new RollerException(e);
+        }
+    }
+        
     public List getNextPrevEntries(
             WeblogEntryData current, String catName, int maxEntries, boolean next)
         throws RollerException

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/model/WeblogManager.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/model/WeblogManager.java Wed Feb  1 21:53:01 2006
@@ -27,7 +27,27 @@
      */
     public void release();
 
-    //------------------------------------------------ WeblogCategoryData CRUD
+    //------------------------------------------------ Tagging
+
+    public List getWebsiteTags(WebsiteData website) 
+    	throws RollerException;
+    
+	public List getWeblogEntriesByTag(WebsiteData website, String tag)
+			throws RollerException;
+
+	public List getAllTags()
+			throws RollerException;
+
+    public List getTagsOrderByCount(int count)
+			throws RollerException;
+
+    public void removeTag(String id)
+			throws RollerException;
+
+	public List findTags(String pattern, int maxResults) 
+			throws RollerException;
+
+	//------------------------------------------------ WeblogCategoryData CRUD
 
     /** Create new weblog category, NOT a persistent instance. */
     public WeblogCategoryData createWeblogCategory();

Added: incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagData.java?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagData.java (added)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagData.java Wed Feb  1 21:53:01 2006
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2005 IBM Corporation
+ *
+ * Licensed 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.
+ */
+
+package org.roller.pojos;
+
+import java.sql.Timestamp;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.RollerException;
+import org.roller.model.RollerFactory;
+/**
+ * Represents a user's tags within a weblog entry.
+ *
+ * @ejb:bean name="TagData"
+ * @struts.form include-all="true"
+ * @hibernate.class table="weblogentrytag"
+ * hibernate.jcs-cache usage="read-write"
+ * @author Phay Tac Lau
+ */
+public class TagData extends PersistentObject implements java.io.Serializable
+{
+    private static Log mLogger = LogFactory.getFactory().getInstance(TagData.class);
+    protected String      		id			= null;
+    protected WeblogEntryData 		entry 			= null;
+    protected Timestamp 		tagTime 		= null;
+//  protected Timestamp 		postTime 		= null;
+    protected String 			name 			= null;
+//    protected String 			normalizedName 		= null;
+//    protected String 			authorUsername 		= null;
+
+    /** Creates a new instance of TagData */
+    public TagData()
+    {
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.id column="id"  generator-class="uuid.hex" unsaved-value="null"
+     */
+    public java.lang.String getId()
+    {
+        return this.id;
+    }
+    /** @ejb:persistent-field */
+    public void setId(java.lang.String id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="pojo"
+     * @ejb:persistent-field
+     * @hibernate.many-to-one column="entryid" cascade="none" not-null="true"
+     */
+    public WeblogEntryData getEntry()
+    {
+        return entry;
+    }
+    /** @ejb:persistent-field */
+    public void setEntry(WeblogEntryData entry)
+    {
+        this.entry = entry;
+    }
+    /**
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="tagtime" non-null="true" unique="false"
+     */
+    public java.sql.Timestamp getTagTime()
+    {
+        return this.tagTime;
+    }
+
+    /** @ejb:persistent-field */
+    public void setTagTime(java.sql.Timestamp tagTime)
+    {
+        this.tagTime = tagTime;
+    }
+
+/*    *//**
+    *
+    * @roller.wrapPojoMethod type="simple"
+    * @ejb:persistent-field
+    * @hibernate.property column="posttime" non-null="true" unique="false"
+    *//*
+   public java.sql.Timestamp getPostTime()
+   {
+       return this.postTime;
+   }
+
+   *//** @ejb:persistent-field *//*
+   public void setPostTime(java.sql.Timestamp postTime)
+   {
+       this.postTime = postTime;
+   }*/
+    
+    /**
+	 * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="name" non-null="true" unique="false"
+     */
+   public String getName()
+   {
+      return this.name;
+   }
+   /** @ejb:persistent-field */
+   public void setName( String name )
+   {
+      this.name = name;
+   }
+   
+/*   *//**
+	 * @roller.wrapPojoMethod type="simple"
+	 * @ejb:persistent-field
+	 * @hibernate.property column="normalname" non-null="true" unique="false"
+	 *//*
+	public String getNormalizedName() {
+		return this.normalizedName;
+	}
+
+	*//** @ejb:persistent-field *//*
+	public void setNormalizedName(String normalizedName) {
+		this.normalizedName = normalizedName;
+	}   
+	
+    *//**
+	 * @roller.wrapPojoMethod type="simple"
+	 * @ejb:persistent-field
+	 * @hibernate.property column="authorusername" non-null="true" unique="false"
+	 *//*
+	public String getAuthorUsername() {
+		return this.authorUsername;
+	}
+
+	*//** @ejb:persistent-field *//*
+	public void setAuthorUsername(String username) {
+		this.authorUsername = username;
+	}	*/
+   
+    /**
+	 * Set data from other object (no-op).
+	 */
+    public void setData(PersistentObject vo)
+    {
+        // no-op
+    }
+
+	public int hashCode() {
+		return name.hashCode();
+	}
+
+	public boolean equals(Object data)
+    {
+		return this.getName().equals(((TagData)data).getName());
+	}
+
+    public void remove() throws RollerException
+    {
+        RollerFactory.getRoller().getWeblogManager().removeTag(this.id);
+    }
+}

Added: incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagListEntryWrapper.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagListEntryWrapper.java?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagListEntryWrapper.java (added)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/TagListEntryWrapper.java Wed Feb  1 21:53:01 2006
@@ -0,0 +1,39 @@
+package org.roller.pojos;
+	
+/**
+ * <p>Wrapper for tags and their number of occurrrences</p>
+ * 
+ * @author Phay Tac Lau
+ */
+public class TagListEntryWrapper
+{
+	
+	private String name;
+	private int count;
+	
+	public TagListEntryWrapper( String name, int count ) 
+	{
+		this.name = name;
+		this.count = count;
+	}
+	
+	public String getName() 
+	{
+		return name;
+	}
+	
+	public int getCount() 
+	{
+		return count;		
+	}
+	
+	public void setName(String name) 
+	{
+		this.name = name;
+	}
+	
+	public void setCount(int count) 
+	{
+		this.count = count;
+	}
+}
\ No newline at end of file

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/WeblogEntryData.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/pojos/WeblogEntryData.java Wed Feb  1 21:53:01 2006
@@ -17,7 +17,9 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.TreeSet;
-
+import java.util.HashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -72,7 +74,8 @@
     // Collection of name/value entry attributes
     private Map attMap = new HashMap();
     private Set attSet = new TreeSet();
-    
+    private Set tagSet = new HashSet();
+
     //----------------------------------------------------------- Construction
 
     public WeblogEntryData()
@@ -138,8 +141,125 @@
     }
 
     //------------------------------------------------------ Simple properties
+
+    //-------------------------------------------------------------Tagging
+    /**
+     *
+     * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.TagData"
+     * @ejb:persistent-field
+     * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all"
+     * @hibernate.collection-key column="entryid" type="String"
+     * @hibernate.collection-one-to-many class="org.roller.pojos.TagData"
+     */
+    public Set getTagSet()
+    {
+        return tagSet;
+    }
+    /** @ejb:persistent-field */
+    public void setTagSet(Set tagSet) throws RollerException
+    {
+    	this.tagSet = tagSet;
+    }
+
+    /**
+     * Returns the tags as a comma seperated list
+     * @param id Weblog category ID.
+     */
+    public String buildTagsString()
+    {
+    	StringBuffer sb = new StringBuffer(" ");
+    	Iterator itr = getTagSet().iterator();
+    	while(itr.hasNext())
+		{
+    		sb.append(((TagData)itr.next()).getName()).append(" ");
+    	}
+    	sb.deleteCharAt(sb.length()-1);
+    	return sb.toString().trim();
+    }
+
+    private static final String TAGREGEX = "[^a-zA-Z0-9-_.]";
+    private static final Pattern tagPattern = Pattern.compile(TAGREGEX);
+
+    /**
+     * Until we use Java 1.5, we'll have to do this
+     * @param tagsString Comma seperated list of tags
+     */
+    public String removeInvalidTagChars(String tag) {
+	 Matcher m = tagPattern.matcher(tag);
+	 StringBuffer sb = new StringBuffer();
+	 while (m.find()) {
+	     m.appendReplacement(sb, "");
+	 }
+	 m.appendTail(sb);
+	 return sb.toString();
+    }
+
+    public boolean checkValidTagChar(char c) {
+    	return  c == 45 || c == 46 || c == 95 || 
+				(48 <= c && c <= 57) ||
+				(65 <= c && c <= 90) ||
+				(97 <= c && c <= 122) ||
+				Character.isUnicodeIdentifierPart(c) ||
+				Character.isUnicodeIdentifierStart(c);
+    }
+    
+    public String stripInvalidTagChars(String s) 
+    {
+    	StringBuffer sb = new StringBuffer();
+    	char [] charArray = s.toCharArray();
+    	for(int i = 0; i < charArray.length; i++) 
+    	{
+    		if(checkValidTagChar(charArray[i]))
+    			sb.append(charArray[i]);
+    	}
+    	return sb.toString();
+    }
     
-    /** 
+    /**
+     * Updates the entries tags
+     * @param tagsString Comma seperated list of tags
+     */
+    public void updateTags(String tagsString) throws RollerException
+    {
+    	Set newTags = new HashSet();
+    	String [] arr = StringUtils.split(tagsString, " ,");
+
+    	if( arr == null ) return;
+
+    	Calendar cal = Calendar.getInstance();
+    	for(int i = 0; i < arr.length; i++)
+    	{
+    		TagData data = new TagData();
+    		data.setEntry(this);
+    		data.setName(stripInvalidTagChars(arr[i].trim().toLowerCase()));
+    		//data.setNormalizedName(stripInvalidTagChars(arr[i].trim().toLowerCase()));
+    		//data.setAuthorUsername(this.creator.getUserName());
+    		data.setTagTime(new Timestamp(cal.getTimeInMillis()));
+    		//data.setPostTime(this.updateTime);
+    		newTags.add(data);
+    	}
+
+		// remove the old tags that aren't present in tagsString
+    	Set delSet = new HashSet();
+    	delSet.addAll(tagSet);
+    	delSet.removeAll(newTags);
+
+        Set keepSet = new HashSet();
+        keepSet.addAll(tagSet);      // add current tags
+        keepSet.retainAll(newTags);  // only keep if also in new list
+        keepSet.addAll(newTags);     // add only non-existent tags
+
+        tagSet.clear();              // clear associations before removing
+        // remove from database
+        Iterator itr = delSet.iterator();
+    	while(itr.hasNext())
+		{
+    		((TagData)itr.next()).remove();
+    	}
+        tagSet.addAll(keepSet);       // the new set
+    }
+
+    /**
      * @roller.wrapPojoMethod type="simple"
      * @ejb:persistent-field 
      * @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/MainPageAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/MainPageAction.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/MainPageAction.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/MainPageAction.java Wed Feb  1 21:53:01 2006
@@ -88,6 +88,20 @@
             list = roller.getRefererManager().getDaysPopularWebsites(num);
             return list;
         }
+
+
+        /**
+         * Get list of most popular tags in terms of occurence.
+         * @param num Number of tags to return (takes effect on next cache refresh)
+         */
+        public List getPopularTags(int num) throws RollerException
+        {
+            List list = null;
+            mLogger.debug("Refreshing popular tags list");
+            Roller roller = RollerFactory.getRoller();
+            list = roller.getWeblogManager().getTagsOrderByCount(num);
+            return list;
+       }        
         
         /**
          * Get list of recent weblog entries.

Added: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagCloudEntry.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagCloudEntry.java?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagCloudEntry.java (added)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagCloudEntry.java Wed Feb  1 21:53:01 2006
@@ -0,0 +1,48 @@
+package org.roller.presentation;
+
+/**
+ * @author Phay Tac Lau
+ */
+public class TagCloudEntry implements Comparable {
+
+	/**
+	 * @param tag
+	 * @param size
+	 */
+	public TagCloudEntry(String tag, int size) {
+		super();
+		this.tag = tag;
+		this.size = size;
+	}
+	
+	private String tag;
+	private int size;
+	
+	public int compareTo(Object o) {
+		return tag.compareTo(((TagCloudEntry)o).getTag());
+	}
+	/**
+	 * @return Returns the size.
+	 */
+	public int getSize() {
+		return size;
+	}
+	/**
+	 * @param size The size to set.
+	 */
+	public void setSize(int size) {
+		this.size = size;
+	}
+	/**
+	 * @return Returns the tag.
+	 */
+	public String getTag() {
+		return tag;
+	}
+	/**
+	 * @param tag The tag to set.
+	 */
+	public void setTag(String tag) {
+		this.tag = tag;
+	}
+}

Added: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagPageAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagPageAction.java?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagPageAction.java (added)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagPageAction.java Wed Feb  1 21:53:01 2006
@@ -0,0 +1,106 @@
+package org.roller.presentation;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.roller.RollerException;
+import org.roller.config.RollerRuntimeConfig;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.WebsiteData;
+
+/**
+ * Main page action for Roller.
+ * @author Phay Tac Lau
+ * @struts.action name="tag" path="/tag" scope="request"
+ * @struts.action-forward name="tag.page" path=".tag"
+ */
+public class TagPageAction extends Action
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(TagPageAction.class);
+
+	/**
+	 * Loads model and forwards to main.page.
+     */
+	public ActionForward execute(
+		ActionMapping mapping, ActionForm form,
+		HttpServletRequest req, HttpServletResponse res)
+		throws Exception
+	{
+        RollerContext rctx = RollerContext.getRollerContext();
+
+        if(req.getParameter("tag") != null) {
+        	req.setAttribute("tagName", req.getParameter("tag"));
+        }
+
+        req.setAttribute("version",rctx.getRollerVersion());
+        req.setAttribute("buildTime",rctx.getRollerBuildTime());
+        req.setAttribute("baseURL", rctx.getContextUrl(req));
+        
+        TagPageData model = new TagPageData(req, res, mapping);
+        req.setAttribute("model", model);
+        req.setAttribute("data", model);
+
+        // Determines if register new sers
+        boolean allowNewUsers =
+                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
+
+        java.security.Principal prince = req.getUserPrincipal();
+        if (prince != null)
+        {
+            req.setAttribute("loggedIn",Boolean.TRUE);
+            req.setAttribute("userName",prince.getName());
+        }
+        else if (allowNewUsers)
+        {
+            req.setAttribute("allowNewUsers",Boolean.TRUE);
+        }
+        req.setAttribute("leftPage","/theme/status.jsp");
+
+        return mapping.findForward("tag.page");
+	}
+
+    /**
+     * Page model.
+     * Extends MainPageData beacuse it needs model for the sidebar.
+     */
+    public static class TagPageData extends MainPageAction.MainPageData
+    {
+        public TagPageData(
+                HttpServletRequest req, 
+                HttpServletResponse res, 
+                ActionMapping mapping) 
+        {
+            super(req, res, mapping);
+        }
+
+        /**
+         * Get all weblog entries with a specific tag
+         * @param tag Tag of weblog entires to return
+         */
+        public List getWeblogEntriesWithTag(String handle, String tag)
+        	throws RollerException
+        {
+        	Roller roller = RollerFactory.getRoller();
+        	if(handle != null && handle.length() > 0)
+        	{
+        		WebsiteData data = roller.getUserManager().getWebsiteByHandle(handle);
+        		return roller.getWeblogManager().getWeblogEntriesByTag(data, tag);
+        	}
+        	else 
+        	{
+        		return roller.getWeblogManager().getWeblogEntriesByTag(null, tag);
+        	}
+        }
+    }
+}
+

Added: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagsPageAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagsPageAction.java?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagsPageAction.java (added)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/TagsPageAction.java Wed Feb  1 21:53:01 2006
@@ -0,0 +1,132 @@
+package org.roller.presentation;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.roller.RollerException;
+import org.roller.config.RollerRuntimeConfig;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.presentation.TagCloudEntry;
+
+/**
+ * Main page action for Roller.
+ * @author Phay Tac Lau
+ * @struts.action name="tags" path="/tags" scope="request"
+ * @struts.action-forward name="tags.page" path=".tags"
+ */
+public class TagsPageAction extends Action
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(TagsPageAction.class);
+
+	/**
+	 * Loads model and forwards to main.page.
+     */
+	public ActionForward execute(
+		ActionMapping mapping, ActionForm form,
+		HttpServletRequest req, HttpServletResponse res)
+		throws Exception
+	{
+        RollerContext rctx = RollerContext.getRollerContext();
+
+        req.setAttribute("version",rctx.getRollerVersion());
+        req.setAttribute("buildTime",rctx.getRollerBuildTime());
+        req.setAttribute("baseURL", rctx.getContextUrl(req));
+        
+        TagsPageData model = new TagsPageData(req, res, mapping);
+        req.setAttribute("model", model);
+        req.setAttribute("data", model);
+
+        // Determines if register new sers
+        boolean allowNewUsers =
+                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
+
+        java.security.Principal prince = req.getUserPrincipal();
+        if (prince != null)
+        {
+            req.setAttribute("loggedIn",Boolean.TRUE);
+            req.setAttribute("userName",prince.getName());
+        }
+        else if (allowNewUsers)
+        {
+            req.setAttribute("allowNewUsers",Boolean.TRUE);
+        }
+        req.setAttribute("leftPage","/theme/status.jsp");
+
+        return mapping.findForward("tags.page");
+	}
+
+    /**
+     * Page model.
+     * Extends MainPageData beacuse it needs model for the sidebar.
+     */
+    public static class TagsPageData extends MainPageAction.MainPageData
+    {
+    	private static final int MAX_FONT = 12;
+    	
+        public TagsPageData(
+                HttpServletRequest req, 
+                HttpServletResponse res, 
+                ActionMapping mapping) 
+        {
+            super(req, res, mapping);
+        }
+
+        /**
+         * Get all tags of all weblog entries.
+         */
+        public List getTags(int maxResults) throws RollerException
+        {
+            Roller roller = RollerFactory.getRoller();
+            //List tags = roller.getWeblogManager().getAllTags();
+            
+            if(maxResults == 0) 
+            	maxResults = Integer.MAX_VALUE;
+            
+            List tags = roller.getWeblogManager().getTagsOrderByCount(maxResults);           
+            
+            int max = 0;   
+            int [] counts = new int[tags.size()];
+            int i = 0;
+            Iterator itr = tags.iterator();
+            while(itr.hasNext()) 
+            {
+            	Object [] oArray = (Object [])itr.next();
+            	int a = ((Integer)oArray[0]).intValue();
+            	counts[i++] = a;
+            	if(a > max) 
+            	{
+            		max = a;
+            	}            	            	
+            }
+            for(i = 0; i < counts.length; i++)
+            {
+            	int scale = (int)Math.floor((counts[i]/(float)max)*MAX_FONT);
+            	Object [] oArray = (Object [])tags.get(i);
+            	oArray[0] = new Integer(scale);
+            }    
+            
+            List result = new ArrayList(tags.size());
+            for(int j = 0; j < tags.size(); j++) {
+            	Object [] oArray = (Object [])tags.get(j);
+            	result.add(new TagCloudEntry((String)oArray[1],
+            			((Integer)oArray[0]).intValue()));
+            }
+            Collections.sort(result);
+            return result;
+        }
+    }
+}
+

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageHelper.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageHelper.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageHelper.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageHelper.java Wed Feb  1 21:53:01 2006
@@ -38,6 +38,9 @@
 import org.roller.presentation.weblog.tags.WeblogCalendarModel;
 import org.roller.util.StringUtils;
 
+import java.util.Arrays;
+import org.roller.pojos.wrapper.TagDataWrapper;
+
 /**
  * Provides assistance to VelociMacros, filling in where Velocity falls.
  * 
@@ -57,7 +60,7 @@
     private Map                  mPagePlugins = null;  // Plugins keyed by name   
     private boolean              mSkipFlag = false;
     private WebsiteData          mWebsite = null;
-    
+
     //------------------------------------------------------------------------
     
     /**
@@ -278,8 +281,44 @@
         menuTag.setView(template);
         return menuTag.emit();
     }
-    
-    //------------------------------------------------- WeblogCalendar methods
+
+    /**
+     * Return the tag links of an weblog entry.
+     *
+     * @param entry
+     * @return tag links as HTML
+     */
+	public String getTagLinksHTML(WeblogEntryDataWrapper entry)
+	{
+		List tagList = entry.getTagSet();
+		String [] tags = new String[tagList.size()];
+		Iterator itr = tagList.iterator();
+		int i = 0;
+		while(itr.hasNext())
+		{
+			tags[i++] = ((TagDataWrapper)itr.next()).getName();
+		}
+
+		Arrays.sort(tags);
+		StringBuffer tagLinks = new StringBuffer("<b>[</b>&nbsp;&nbsp; ");
+
+		for(int j = 0; j < tags.length; j++) {
+			if(j > 0) tagLinks.append("|&nbsp;&nbsp;");
+			tagLinks.append("<a href=\"");
+			tagLinks.append("CONTEXTPATH").append("/tag.do?tag=");
+			tagLinks.append(tags[j]).append("\">");
+			String tag = tags[j];
+			if(tag.length() > 32) {
+				tag = tag.substring(0, 32) + "...";
+			}
+			tagLinks.append(tag);
+			tagLinks.append("</a>&nbsp;&nbsp;");
+		}
+		tagLinks.append("<b>]</b>");
+		return tagLinks.toString();
+	}
+
+	//------------------------------------------------- WeblogCalendar methods
 
     /** 
      * Display weblog calendar.

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageModel.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageModel.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageModel.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/velocity/PageModel.java Wed Feb  1 21:53:01 2006
@@ -36,6 +36,9 @@
 import org.roller.presentation.RollerSession;
 import org.roller.util.StringUtils;
 
+import org.roller.pojos.TagListEntryWrapper;
+import org.roller.util.DateUtil;
+
 /**
  * Provides Roller page templates with access to Roller domain model objects.
  *
@@ -171,9 +174,42 @@
     
     //------------------------------------------------------------------------
     
-    /** Get comments for weblog entry specified by request */
-    public List getComments(WeblogEntryDataWrapper entry) {
-        return getComments(entry, true, true);
+    
+    /**
+     * Get a list of all the tags of website and their occurrence
+     * @return List of TagListEntryWrapper objects
+     */
+    public List getWebsiteTagsArray()
+    {
+        List ret = new ArrayList();
+        try
+        {
+            WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+
+            List mTags = mgr.getWebsiteTags(
+                            mRollerReq.getWebsite());
+
+            // wrap with pojos
+            ret = new ArrayList(mTags.size());
+            Iterator it = mTags.iterator();
+            int i=0;
+            while(it.hasNext()) {
+            	Object [] o = (Object[])it.next();
+            	TagListEntryWrapper wrapper =
+            		new TagListEntryWrapper((String)o[1],
+            				((Integer)o[0]).intValue());
+            	ret.add(i, wrapper);
+                i++;
+
+            }
+            return ret;
+
+        }
+        catch (Exception e)
+        {
+            mLogger.error("PageModel getWebsiteTagsArray()", e);
+            return ret;
+        }
     }
     
     /** Get comments for weblog entry specified by request */

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java Wed Feb  1 21:53:01 2006
@@ -292,6 +292,8 @@
                     mLogger.debug("Validated MediaCast attributes");
                 }
                 
+                entry.updateTags(form.getTags());
+                
                 // Store value object (creates new or updates existing)
                 entry.setUpdateTime(new Timestamp(new Date().getTime()));
                 mLogger.debug("Saving entry");

Modified: incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java (original)
+++ incubator/roller/branches/roller_2.1_tagging/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java Wed Feb  1 21:53:01 2006
@@ -54,7 +54,8 @@
     private String[] spamComments = new String[0];
     private String trackbackUrl = null;
     private Map attributes = new HashMap();
-    
+    private String mTags = null;
+
     public WeblogEntryFormEx()
     {
         super();
@@ -146,8 +147,13 @@
         if (getPinnedToMain() == null)
         {
             entry.setPinnedToMain(Boolean.FALSE);
-        }        
-        
+        }
+
+        if(mTags != null)
+		{
+            entry.updateTags(mTags);
+		}
+
         Iterator params = paramMap.keySet().iterator();
         while (params.hasNext())
         {
@@ -194,6 +200,8 @@
             EntryAttributeData att = (EntryAttributeData)atts.next();
             attributes.put(att.getName(), att.getValue());
         }
+     
+        mTags = entry.buildTagsString();
     }
     
     public Map getAttributes()
@@ -232,6 +240,15 @@
     }
 
     /**
+     * Returns the tags.
+     * @return String
+     */
+    public String getTags()
+    {
+        return mTags;
+	}
+
+    /**
      * Returns the category ID.
      * @return String
      */
@@ -286,7 +303,16 @@
     {
         return mSeconds;
     }
-    
+
+    /**
+     * Sets the tags.
+     * @param tags  the tags to set
+     */
+    public void setTags(String tags)
+    {
+        this.mTags = tags;
+    }
+
     /**
      * Sets the category id.
      * @param categoryId  the category id to set

Modified: incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/classes/ApplicationResources.properties?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/classes/ApplicationResources.properties Wed Feb  1 21:53:01 2006
@@ -664,7 +664,9 @@
 mainPage.currentWebsite=editing weblog
 mainPage.sidebarHelpTitle=What is this?
 mainPage.adminWarning=You have <b>Global Admin</b><br /> permission, use it wisely.
-
+mainPage.hotTags=Hot Tags : Number of Entries
+mainPage.noTags=No tags found.
+mainPage.entries=entries
 mainPage.mainMenu=Main Menu
 
 # ------------------------------------------------------------------ Maintenance
@@ -1306,6 +1308,7 @@
 weblogEdit.spellMode=Spellcheck
 weblogEdit.submitForReview=Submit for Review
 weblogEdit.submittedForReview=Entry submitted for review
+weblogEdit.tags=Tags
 weblogEdit.title=Title
 weblogEdit.unsaved=Not saved
 weblogEdit.updateTime=Last updated 

Modified: incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/tiles-defs.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/tiles-defs.xml?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/tiles-defs.xml (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/WEB-INF/tiles-defs.xml Wed Feb  1 21:53:01 2006
@@ -55,6 +55,16 @@
    <put name="menu" value="/theme/menu-admin.jsp" />
 </definition>
 
+<definition name=".tag" extends=".tiles-frontpage" >
+    <put name="content" value="/tag.jsp" />
+    <put name="sidebar" value="/main-sidebar.jsp" />
+</definition> 
+
+<definition name=".tags" extends=".tiles-frontpage" >
+    <put name="content" value="/tags.jsp" />
+    <put name="sidebar" value="/main-sidebar.jsp" />
+</definition> 
+
 <definition name=".main" extends=".tiles-frontpage" >
     <put name="content" value="/main.jsp" />
     <put name="head"    value="/theme/head-main.jsp" />

Modified: incubator/roller/branches/roller_2.1_tagging/web/main-sidebar.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/main-sidebar.jsp?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/main-sidebar.jsp (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/main-sidebar.jsp Wed Feb  1 21:53:01 2006
@@ -26,6 +26,30 @@
     <br />
 </div>
 
+<br/>
 
-    
-    
\ No newline at end of file
+<div class="sidebarBodyHead">
+    <div class="menu-tr">
+        <div class="menu-tl">
+            <h3><fmt:message key="mainPage.hotTags" /></h3>		
+        </div>
+    </div>
+</div>	
+
+<div class="sidebarBody"> 
+        <c:if test="${empty popularTags}"><fmt:message key="mainPage.noTags" /></c:if>
+            <c:if test="${not empty popularTags}">
+                        <ul>
+                        <c:forEach var="tag" items="${popularTags}">
+                                <li>
+                                <c:url value="tag.do" var="myUrl">
+                                    <c:param name="tag" value='${tag[1]}'/>
+                                </c:url>
+                                <a href='<c:out value="${myUrl}"/>'><c:out escapeXml="false" value="${tag[1]}" /></a>: 
+                                <c:out escapeXml="false" value="${tag[0]}" /> <fmt:message key="mainPage.entries" />
+                                </li>
+                        </c:forEach>
+                        </ul>
+        </c:if>
+        <br/>
+</div>
\ No newline at end of file

Modified: incubator/roller/branches/roller_2.1_tagging/web/main.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/main.jsp?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/main.jsp (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/main.jsp Wed Feb  1 21:53:01 2006
@@ -12,6 +12,8 @@
 	((MainPageAction.MainPageData)request.getAttribute("data")).getRecentWeblogEntries(45));
 request.setAttribute("popularWebsites",
 	((MainPageAction.MainPageData)request.getAttribute("data")).getPopularWebsites(65));
+request.setAttribute("popularTags",
+        ((MainPageAction.MainPageData)request.getAttribute("data")).getPopularTags(20));	
 %>
 
 <c:if test="${!planetEnabled}">
@@ -44,6 +46,14 @@
                 </str:truncateNicely></a> |
                 <c:out value="${post.category.name}" /> |
                 <fmt:formatDate value="${post.pubTime}" type="both" dateStyle="medium" timeStyle="medium" /> |
+	            <c:if test="${!empty post.tagSet}">                
+					<c:forEach var="tag" items="${post.tagSet}">
+			    	<c:url value="tag.do" var="myUrl">
+						<c:param name="tag" value='${tag.name}'/>		
+			   		</c:url>		    						
+					<a href='<c:out value="${myUrl}" />'><c:out escapeXml="false" value="${tag.name}"/></a>&nbsp;
+					</c:forEach> |
+				</c:if>
                 <fmt:message key="mainPage.postedBy" />&nbsp;
                 <c:out value="${post.creator.userName}" />
                 <c:if test="${!empty post.link}">
@@ -75,6 +85,14 @@
             </str:truncateNicely></a> |
             <c:out value="${post.category.name}" /> |
             <fmt:formatDate value="${post.pubTime}" type="both" dateStyle="medium" timeStyle="medium" /> |
+            <c:if test="${!empty post.tagSet}">
+				<c:forEach var="tag" items="${post.tagSet}">
+		    	<c:url value="tag.do" var="myUrl">
+					<c:param name="tag" value='${tag.name}'/>		
+		   		</c:url>		    						
+				<a href='<c:out value="${myUrl}" />'><c:out escapeXml="false" value="${tag.name}"/></a>&nbsp;
+				</c:forEach> |        
+			</c:if>
             <fmt:message key="mainPage.postedBy" />
             <c:out value="${post.creator.userName}" />
             <c:if test="${!empty post.link}">

Added: incubator/roller/branches/roller_2.1_tagging/web/tag.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/tag.jsp?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/tag.jsp (added)
+++ incubator/roller/branches/roller_2.1_tagging/web/tag.jsp Wed Feb  1 21:53:01 2006
@@ -0,0 +1,74 @@
+<%@ page import="org.roller.presentation.TagPageAction" %>
+<%@ page import="java.util.Locale" %>
+<%@ include file="/taglibs.jsp" %>
+<%
+String tagName = (String)request.getAttribute("tagName");
+String handle = request.getParameter("handle");
+if(tagName != null) 
+{
+	request.setAttribute("posts",
+		((TagPageAction.TagPageData)request.getAttribute("data")).getWeblogEntriesWithTag(handle, tagName));
+}
+request.setAttribute("popularWebsites",
+	((TagPageAction.TagPageData)request.getAttribute("data")).getPopularWebsites(20));
+request.setAttribute("popularTags",
+	((TagPageAction.TagPageData)request.getAttribute("data")).getPopularTags(20));
+%>
+
+<div class="entryTitleBox">
+	Tag: <c:out escapeXml="false" value="${tagName}" />
+</div>
+	
+<div class="entriesBox">
+<div class="entriesBoxInner">
+
+<c:forEach var="post" items="${posts}">       	
+	<c:if test="${!empty tagName}">
+    <div class="entryBox">
+
+        <a href='<c:out value="${baseURL}" /><c:out value="${post.permaLink}" />' class="entryTitle">
+            <str:truncateNicely upper="90" >
+               <c:out value="${post.displayTitle}" />
+            </str:truncateNicely></a>
+        </a><br />
+
+        <span class="entryDetails">
+            <a href='<c:out value="${baseURL}" />/page/<c:out value="${post.website.handle}" />'>
+            <str:truncateNicely upper="50" >
+               <c:out value="${post.website.name}" />
+            </str:truncateNicely></a> |
+            <c:out value="${post.category.name}" /> |
+            <fmt:formatDate value="${post.pubTime}" type="both" dateStyle="medium" timeStyle="medium" /> |
+			<c:forEach var="tag" items="${post.tagSet}">
+		    	<c:url value="tag.do" var="myUrl">
+					<c:param name="tag" value='${tag.name}'/>		
+		   		</c:url>		    						
+				<a href='<c:out value="${myUrl}" />'><c:out escapeXml="false" value="${tag.name}"/></a>&nbsp;
+			</c:forEach> |
+            <fmt:message key="mainPage.postedBy" />
+            <c:out value="${post.creator.userName}" />
+            <c:if test="${!empty post.link}">
+               | <a href='<c:out value="${post.link}" />' class="entryDetails"><fmt:message key="mainPage.link" /></a>
+            </c:if>
+            <br/>
+        </span>
+        
+        <span class="entryDescription">
+        <roller:ApplyPlugins name="post" scope="page" stripHtml="true" maxLength="120" skipFlag="true" />
+        </span>
+        
+    </div>
+    </c:if>
+</c:forEach>
+
+</div> <!-- entriesBoxInner -->
+</div> <!-- entriesBox -->
+
+<br />
+
+<a href='<c:url value="/rss"/>' title='<fmt:message key="mainPage.rss.tip" />'>
+    <img src='<c:url value="/images/rssbadge.gif"/>' border="0"
+        alt='<fmt:message key="mainPage.rss.tip" />' />
+</a>
+<fmt:message key="mainPage.rss.instructions" />
+

Added: incubator/roller/branches/roller_2.1_tagging/web/tags.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/tags.jsp?rev=374275&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/tags.jsp (added)
+++ incubator/roller/branches/roller_2.1_tagging/web/tags.jsp Wed Feb  1 21:53:01 2006
@@ -0,0 +1,48 @@
+<%@ page import="org.roller.presentation.TagsPageAction" %>
+<%@ page import="java.util.Locale" %>
+<%@ include file="/taglibs.jsp" %>
+<%
+String sMax = request.getParameter("max");
+int max = 200;
+if(sMax != null)
+	max = Integer.parseInt(sMax);
+if(max == 0)
+	request.setAttribute("showingall","true");	
+request.setAttribute("tags",
+	((TagsPageAction.TagsPageData)request.getAttribute("data")).getTags(max));
+request.setAttribute("popularWebsites",
+	((TagsPageAction.TagsPageData)request.getAttribute("data")).getPopularWebsites(20));
+request.setAttribute("popularTags",
+	((TagsPageAction.TagsPageData)request.getAttribute("data")).getPopularTags(20));	
+%>
+<div class="entryTitleBox">
+	TagCloud
+</div>
+
+<div class="entriesBox">
+   <c:choose>
+        <c:when test='${empty showingall}'>
+		  		<c:url value="tags.do" var="myUrl">
+						<c:param name="max" value='0'/>		
+		  		</c:url>		
+		  		<a href='<c:out value="${myUrl}"/>'>Show All Tags</a>
+        </c:when>
+        <c:otherwise>
+		  		<c:url value="tags.do" var="myUrl">
+		  		</c:url>		
+		  		<a href='<c:out value="${myUrl}"/>'>Show Top 200 Tags</a>
+        </c:otherwise>
+    </c:choose>	
+	<c:if test="${!empty tags}">	    
+		    <ul id="tagcloud">
+			    <c:forEach var="tag" items="${tags}">    
+			    	<c:forEach var="item" begin="0" end="${tag.size}"><em></c:forEach>
+			    		<c:url value="tag.do" var="myUrl">
+								<c:param name="tag" value='${tag.tag}'/>		
+			    		</c:url>		    				    				    			
+				      	<li><a href='<c:out escapeXml="false" value="${myUrl}"/>'><c:out escapeXml="false" value="${tag.tag}" /></a></li>
+			    	<c:forEach var="item" begin="0" end="${tag.size}"></em></c:forEach>                  
+			    </c:forEach>        
+		    </ul>
+	</c:if>
+</div>

Modified: incubator/roller/branches/roller_2.1_tagging/web/theme/bannerStatus.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/theme/bannerStatus.jsp?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/theme/bannerStatus.jsp (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/theme/bannerStatus.jsp Wed Feb  1 21:53:01 2006
@@ -40,10 +40,14 @@
             <%= RollerRuntimeConfig.getProperty("site.shortName") %>
         </roller:link>
 
+        | <roller:link forward="tags">
+            <fmt:message key="mainPage.tagsMenu" />
+        </roller:link>        
+
         | <roller:link forward="yourWebsites">
             <fmt:message key="mainPage.mainMenu" />
         </roller:link>
-
+        
         <% if (user != null) { %>
             | <html:link forward="logout-redirect">
                 <fmt:message key="navigationBar.logout"/>

Modified: incubator/roller/branches/roller_2.1_tagging/web/theme/roller.css
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/theme/roller.css?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/theme/roller.css (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/theme/roller.css Wed Feb  1 21:53:01 2006
@@ -641,3 +641,26 @@
     overflow: auto;
     overflow-x: auto;
 }
+
+/* ----------------------------------------------------------------------
+Tag cloud list styles
+---------------------------------------------------------------------- */
+ul#tagcloud { 
+	font-size:1.0em;
+}
+ul#tagcloud li {
+	display: inline;
+	line-height:2em;
+}
+ul#tagcloud a, ul#tagcloud a:visited {
+	font-weight: bold; 
+	cursor: pointer;
+	text-decoration: none;
+}
+ul#tagcloud a:hover { 
+	text-decoration: underline;
+}
+ul#tagcloud em {
+	font-style: normal; 
+	font-size: 1.05em;
+}

Modified: incubator/roller/branches/roller_2.1_tagging/web/weblog/WeblogEdit.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.1_tagging/web/weblog/WeblogEdit.jsp?rev=374275&r1=374274&r2=374275&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.1_tagging/web/weblog/WeblogEdit.jsp (original)
+++ incubator/roller/branches/roller_2.1_tagging/web/weblog/WeblogEdit.jsp Wed Feb  1 21:53:01 2006
@@ -103,6 +103,12 @@
             <html:optionsCollection name="model" property="categories" value="id" label="path"  />
         </html:select>
     </td></tr>
+
+    <tr><td class="entryEditFormLabel">
+      <label style="width:10%; float:left;" for="title"><fmt:message key="weblogEdit.tags" /></label>
+        </th><td>
+        <html:text  property="tags" size="70" maxlength="255" tabindex="2" /><br/>
+    </td></tr>
     
     <tr>
         <td class="entryEditFormLabel">



Mime
View raw message