incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r1006328 - in /incubator/esme/trunk/server: ./ src/main/resources/props/ src/main/scala/bootstrap/liftweb/ src/main/scala/org/apache/esme/actor/ src/main/scala/org/apache/esme/lib/ src/main/scala/org/apache/esme/model/ src/main/scala/org/ap...
Date Sun, 10 Oct 2010 18:07:49 GMT
Author: esjewett
Date: Sun Oct 10 18:07:49 2010
New Revision: 1006328

URL: http://svn.apache.org/viewvc?rev=1006328&view=rev
Log:
Merge tagandconversationfollow branch into trunk

Added:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/ConvDistributor.scala
      - copied unchanged from r1006324, incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/actor/ConvDistributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/TagDistributor.scala
      - copied unchanged from r1006324, incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/actor/TagDistributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UserConvFollow.scala
      - copied unchanged from r1006324, incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserConvFollow.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UserTagFollow.scala
      - copied unchanged from r1006324, incubator/esme/branches/tagandconversationfollow/src/main/scala/org/apache/esme/model/UserTagFollow.scala
Modified:
    incubator/esme/trunk/server/   (props changed)
    incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml   (props
changed)
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ConversationMgr.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/MessageTag.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Tag.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
    incubator/esme/trunk/server/src/main/webapp/info_view/conversation.html
    incubator/esme/trunk/server/src/main/webapp/info_view/tag.html

Propchange: incubator/esme/trunk/server/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Oct 10 18:07:49 2010
@@ -1,3 +1,4 @@
 /incubator/esme/branches/lift-2.0/server:928728-939625
 /incubator/esme/branches/metadata:966215-979767
+/incubator/esme/branches/tagandconversationfollow:966215-1006324
 /incubator/esme/branches/ui-2010-03-05:919339-923098

Propchange: incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Oct 10 18:07:49 2010
@@ -1 +1,2 @@
 /incubator/esme/branches/metadata/src/main/resources/props/compass.filesystem.cfg.xml:966215-979767
+/incubator/esme/branches/tagandconversationfollow/src/main/resources/props/compass.filesystem.cfg.xml:966215-1006324

Modified: incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Sun Oct 10 18:07:49
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, UserConvFollow,
         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, UserConvFollow,
       Relationship, MessageTag, AuthToken,
       UrlStore, Tracking, Action, 
       AccessPool, Privilege, UserAuth, UserCryptoSig)
@@ -233,7 +233,9 @@ class Boot {
     // start Scala Actors used in ESME
     Distributor.touch
     SchedulerActor.touch
-    MessagePullActor.touch
+    MessagePullActor.touch   
+    TagDistributor.touch  
+    ConvDistributor.touch
     // ScalaInterpreter.touch
 
 

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala Sun
Oct 10 18:07:49 2010
@@ -74,7 +74,9 @@ object Distributor extends LiftActor {
 
       case nm @ NewMessage(msg) =>
         val toSend = UserActor.TestForTracking(msg)
-        users.values.foreach(_ ! toSend)
+        users.values.foreach(_ ! toSend) 
+        TagDistributor ! nm      
+        ConvDistributor ! nm
         listeners.foreach(_ ! nm)    
 
       case UpdateTrackingFor(userId, ttype) =>

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ConversationMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ConversationMgr.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ConversationMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ConversationMgr.scala Sun
Oct 10 18:07:49 2010
@@ -49,24 +49,59 @@ object ConversationMgr {
 
   val menuItems =
   Menu(Loc("conversation", List("info_view", "conversation"), S.?("base_conv_menu"), ifIsLoggedIn,
-           Loc.Snippet("displayConversation", displayConversation))) ::
-  Nil
-
-  def displayConversation(in: NodeSeq): NodeSeq = {
-
-    val jsId = "timeline_messages"                  
+           Loc.Snippet("conv_info", convInfo))) ::
+  Nil         
+  
+  def convInfo(in: NodeSeq): NodeSeq = {  
 
     val cid = S.param("cid").map(toLong).openOr(-1L)
+    val messages = Message.findMessages(List(cid))   
+    val user = User.currentUser  
 
-    val msgs = Message.findAndPrime(By(Message.conversation, cid),
-                                    OrderBy(Message.id, Descending))
-
-    Script(
-      OnLoad(JsCrVar(jsId, JsArray(
-          msgs.map(m => JsObj(("message", m.asJs)) ) :_*)) &
-      JsFunc(" displayMessages", JsVar(jsId), jsId).cmd)
-    )
-
-  }
-
+    def followOrUnfollow: NodeSeq = {          
+      val ret: Box[NodeSeq] = for { 
+        u <- user
+        m = messages.values.toList.first
+      } yield {                 
+        if (!m.followers.contains(u)) {
+          ajaxButton("Follow conversation", () => {  
+            m.followers += u
+            m.save       
+            updateFollow
+          })
+        } else {
+          ajaxButton("Unfollow conversation", () => {    
+            m.followers -= u
+            m.save
+            updateFollow
+          })
+        }  
+      }
+                         
+      ret.open_!                                     
+    }      
+    
+    def displayConversation(in: NodeSeq): NodeSeq = {
+
+      val jsId = "timeline_messages"                  
+
+      val cid = S.param("cid").map(toLong).openOr(-1L)
+
+      val msgs = Message.findAndPrime(By(Message.conversation, cid),
+                                      OrderBy(Message.id, Descending))
+
+      Script(
+        OnLoad(JsCrVar(jsId, JsArray(
+            msgs.map(m => JsObj(("message", m.asJs)) ) :_*)) &
+        JsFunc(" displayMessages", JsVar(jsId), jsId).cmd)
+      )
+
+    }
+
+    def updateFollow: JsCmd = SetHtml("following", followOrUnfollow)
+
+    bind("conv", in, 
+         "followButton" -> followOrUnfollow,
+         "displayConversation" -> displayConversation _ )       
+  }                                
 }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala Sun Oct
10 18:07:49 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/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala Sun Oct
10 18:07:49 2010
@@ -102,6 +102,12 @@ case class DirectReason(fromUserId: Long
 }
 case class ConversationReason(conversationId: Long) extends MailboxReason {
   def attr = new UnprefixedAttribute("conversation", conversationId.toString, Null)
+}                                                                                 
+case class TagFollowReason(tagName: String) extends MailboxReason {
+  def attr = new UnprefixedAttribute("tag", tagName, Null)
+}            
+case class ConvFollowReason(convId: Long) extends MailboxReason {
+  def attr = new UnprefixedAttribute("conversation", convId, Null)
 }
 case class LoginReason(userId: Long) extends MailboxReason {
   def attr = new UnprefixedAttribute("login", userId.toString, Null)

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala Sun Oct
10 18:07:49 2010
@@ -279,7 +279,7 @@ object Message extends Message with Long
 
 
 @Searchable
-class Message extends LongKeyedMapper[Message] {
+class Message extends LongKeyedMapper[Message] with ManyToMany {
   import Message._
   
   def getSingleton = Message // what's the "meta" server
@@ -324,7 +324,9 @@ class Message extends LongKeyedMapper[Me
 
   object replyTo extends MappedLongForeignKey(this, Message)
 
-  object conversation extends MappedLongForeignKey(this, Message)
+  object conversation extends MappedLongForeignKey(this, Message)  
+  
+  object followers extends MappedManyToMany(UserConvFollow, UserConvFollow.conversation,
UserConvFollow.user, User) 
 
   object pool extends MappedLongForeignKey(this, AccessPool) {
     override def asJs = 

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/MessageTag.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/MessageTag.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/MessageTag.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/MessageTag.scala Sun
Oct 10 18:07:49 2010
@@ -36,7 +36,7 @@ class MessageTag extends LongKeyedMapper
   object id extends MappedLongIndex(this)
   
   object message extends MappedLongForeignKey(this, Message)
-  object tag extends MappedLongForeignKey(this, Tag) // MappedText(this)
+  object tag extends MappedLongForeignKey(this, Tag)
   object sentTo extends MappedLongForeignKey(this, User)
   object url extends MappedLongForeignKey(this, UrlStore)
 }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Tag.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Tag.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Tag.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Tag.scala Sun Oct 10
18:07:49 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/trunk/server/src/main/scala/org/apache/esme/model/User.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala Sun Oct 10
18:07:49 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,9 @@ 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)
+  
+  object convsfollowing extends MappedManyToMany(UserConvFollow, UserConvFollow.user, UserConvFollow.conversation,
Message) 
 }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/TagDisplay.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/TagDisplay.scala?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/TagDisplay.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/TagDisplay.scala Sun
Oct 10 18:07:49 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/trunk/server/src/main/webapp/info_view/conversation.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/conversation.html?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/conversation.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/conversation.html Sun Oct 10 18:07:49
2010
@@ -17,24 +17,25 @@
  under the License.                                           *
 -->
 <lift:surround with="base" at="left">
-    <lift:TableSorterSnip/>
-    <link rel="stylesheet" type="text/css" href="../style/style.css" />
-<head>
-        <script src="../scripts/display_messages.js" type="text/javascript"/> 
-        <script src="../scripts/pretty.js" type="text/javascript"/> 
-</head>
-
-<div id="back-header">
-	<h1><lift:loc>ui_default_conversation</lift:loc></h1>
-	<div class="container-aux">
-        <div>
-            <lift:displayConversation/>
-	    <lift:embed what="templates-hidden/message_core"/>
-        </div>
-	</div><!--container-settings-->
+  <lift:TableSorterSnip/>
+  <link rel="stylesheet" type="text/css" href="../style/style.css" />
+  <head>
+    <script src="../scripts/display_messages.js" type="text/javascript"/> 
+    <script src="../scripts/pretty.js" type="text/javascript"/> 
+  </head>
+                   
+  <div id="back-header">  
+    <lift:conv_info>
+    <h1><lift:loc>ui_default_conversation</lift:loc></h1>
+    <div class="container-aux">        
+      <span id="following"><conv:followButton/></span>
+      <div>
+        <conv:displayConversation/>
+        <lift:embed what="templates-hidden/message_core"/>
+      </div>
+    </div><!--container-settings-->    
+    </lift:conv_info>
 	</div>
-
-	<!-- End demo -->    
 </lift:surround>
 
 

Modified: incubator/esme/trunk/server/src/main/webapp/info_view/tag.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/tag.html?rev=1006328&r1=1006327&r2=1006328&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/tag.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/tag.html Sun Oct 10 18:07:49 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