incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r967172 - in /incubator/esme/branches/tagandconversationfollow/src/main: scala/bootstrap/liftweb/ scala/org/apache/esme/lib/ scala/org/apache/esme/model/ scala/org/apache/esme/snippet/ webapp/info_view/
Date Fri, 23 Jul 2010 17:23:39 GMT
Author: esjewett
Date: Fri Jul 23 17:23:38 2010
New Revision: 967172

URL: http://svn.apache.org/viewvc?rev=967172&view=rev
Log:
[ESME-256] Add tag following mechanism - note: this just records the tag follow/unfollow -
it does not yet deliver all messages with the tag to the user

Added:
    incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala
Modified:
    incubator/esme/branches/tagandconversationfollow/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
    incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/Tag.scala
    incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/User.scala
    incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
    incubator/esme/branches/tagandconversationfollow/src/main/webapp/info_view/tag.html

Modified: incubator/esme/branches/tagandconversationfollow/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/bootstrap/liftweb/Boot.scala?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/bootstrap/liftweb/Boot.scala
(original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/bootstrap/liftweb/Boot.scala
Fri Jul 23 17:23:38 2010
@@ -83,7 +83,7 @@ class Boot {
 
     if (Props.mode == Props.RunModes.Test) {
       Schemifier.destroyTables_!!(Log.infoF _, User, ExtSession,
-        Message, Mailbox, Tag,
+        Message, Mailbox, Tag, UserTagFollow,
         Relationship, MessageTag,
         AuthToken, UrlStore, Tracking,
         Action, AccessPool,
@@ -91,7 +91,7 @@ class Boot {
     }
 
     Schemifier.schemify(true, Log.infoF _, User, ExtSession, Message,
-      Mailbox, Tag,
+      Mailbox, Tag, UserTagFollow,
       Relationship, MessageTag, AuthToken,
       UrlStore, Tracking, Action, 
       AccessPool, Privilege, UserAuth, UserCryptoSig)

Modified: incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/lib/ProfileMgr.scala?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
(original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
Fri Jul 23 17:23:38 2010
@@ -140,7 +140,7 @@ object ProfileMgr {
                        "password" -%> password(pwd, p => pwd = p.trim),
                        "confirm" -%> password(pwd, p => checkEmailPassword(p.trim)),
                        "openid" -%> text(openIdUrl, registerOpenID(_)),
-                       "save" -%> submit("Save", user.save))
+                       "save" -%> submit("Save", user.save _))
     }).getOrElse(NodeSeq.Empty)
 
   }

Modified: incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/Tag.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/Tag.scala?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/Tag.scala
(original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/Tag.scala
Fri Jul 23 17:23:38 2010
@@ -61,12 +61,14 @@ object Tag extends Tag with MetaProtoTag
   
 }
 
-class Tag extends ProtoTag[Tag] {
-  def getSingleton = Tag // what's the "meta" server
+class Tag extends ProtoTag[Tag] with ManyToMany {
+  def getSingleton = Tag // what's the "meta" server    
   
   def findMessages(): List[Message] =
   Message.findAndPrime(In.fk(MessageTag.message, By(MessageTag.tag, this)),
 		       OrderBy(Message.id, Descending))
 
-  override def toXml = <tag id={id.is.toString} name={name.is}>{"#" + name.is}</tag>
-}
+  override def toXml = <tag id={id.is.toString} name={name.is}>{"#" + name.is}</tag>
   
+                                                                                        
  
+  object followers extends MappedManyToMany(UserTagFollow, UserTagFollow.tag, UserTagFollow.user,
User)                                                                                    
    
+}               

Modified: incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/User.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/User.scala?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/User.scala
(original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/User.scala
Fri Jul 23 17:23:38 2010
@@ -198,7 +198,7 @@ object User extends User with KeyedMetaM
 /**
  * An O-R mapped "User" class that includes first name, last name, password
  */
-class User extends KeyedMapper[Long, User] with UserIdAsString {// OpenIDProtoUser[User]
{
+class User extends KeyedMapper[Long, User] with UserIdAsString with ManyToMany {// OpenIDProtoUser[User]
{
   import S._
 
   def getSingleton = User // what's the "meta" server
@@ -400,5 +400,7 @@ class User extends KeyedMapper[Long, Use
 
   def timezoneDisplayName = S.?("base_user_ui_timezone")
 
-  def localeDisplayName = S.?("base_user_ui_locale")
+  def localeDisplayName = S.?("base_user_ui_locale")  
+  
+  object tagsfollowing extends MappedManyToMany(UserTagFollow, UserTagFollow.user, UserTagFollow.tag,
Tag)
 }

Added: incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala?rev=967172&view=auto
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala
(added)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala
Fri Jul 23 17:23:38 2010
@@ -0,0 +1,37 @@
+package org.apache.esme.model
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. 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.
+ */              
+ 
+import net.liftweb._
+//import http._         
+import mapper._
+//import util._
+//import actor._
+//import common._
+//import Helpers._  
+
+object UserTagFollow extends UserTagFollow with LongKeyedMetaMapper[UserTagFollow]
+
+class UserTagFollow extends LongKeyedMapper[UserTagFollow] with IdPK {  
+  def getSingleton = UserTagFollow
+
+  object user extends LongMappedMapper(this, User)
+  object tag extends LongMappedMapper(this, Tag)
+}
\ No newline at end of file

Modified: incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/snippet/TagDisplay.scala?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
(original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
Fri Jul 23 17:23:38 2010
@@ -82,17 +82,47 @@ object TagDisplay {
            "date" -> Text(new Date(m.when.is).toString))
     }
 
-  def display(in: NodeSeq): NodeSeq = {
-    val name = (S.param("tag") openOr "N/A").trim
+  def display(in: NodeSeq): NodeSeq = {  
+  
+    val name = (S.param("tag") openOr "N/A").trim 
+    
+    val tag = Tag.findAll(By(Tag.name, name))
+    val user = User.currentUser
 
     val tagList: List[Message] =
     for {
-      tag <- Tag.findAll(By(Tag.name, name))
-      item <- tag.findMessages()
-    } yield item
+      t <- tag
+      item <- t.findMessages()
+    } yield item   
+    
+    def followOrUnfollow: NodeSeq = {          
+      val ret: Box[NodeSeq] = for { 
+        u <- user
+        t = tag.first
+      } yield {                 
+        if (!t.followers.contains(u)) {
+          ajaxButton("Follow tag", () => {  
+            t.followers += u
+            t.save       
+            updateFollow
+          })
+        } else {
+          ajaxButton("Unfollow tag", () => {    
+            t.followers -= u
+            t.save
+            updateFollow
+          })
+        }  
+      }
+                             
+      ret.open_!                                      
+    }  
+    
+    def updateFollow: JsCmd = SetHtml("following", followOrUnfollow)
 
     bind("tag", in, "name" -> name,
-         "each" -> bindTag(tagList) _)
+         "each" -> bindTag(tagList) _,
+         "followButton" -> followOrUnfollow )
 
   }
 }

Modified: incubator/esme/branches/tagandconversationfollow/src/main/webapp/info_view/tag.html
URL: http://svn.apache.org/viewvc/incubator/esme/branches/tagandconversationfollow/src/main/webapp/info_view/tag.html?rev=967172&r1=967171&r2=967172&view=diff
==============================================================================
--- incubator/esme/branches/tagandconversationfollow/src/main/webapp/info_view/tag.html (original)
+++ incubator/esme/branches/tagandconversationfollow/src/main/webapp/info_view/tag.html Fri
Jul 23 17:23:38 2010
@@ -22,7 +22,8 @@
     <lift:tag_display>
 <div id="back-header">
 	<h1><lift:loc>ui_tag_title</lift:loc><i> '<tag:name/>'</i></h1>
-<div class="container-settings">
+<div class="container-settings">    
+      <span id="following"><tag:followButton/></span> 
 
               <table id="esme-table" class="tablesorter">
             <thead>



Mime
View raw message