incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r792682 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/ scala/org/apache/esme/actor/ scala/org/apache/esme/comet/ scala/org/apache/esme/model/ webapp/templates-hidden/
Date Thu, 09 Jul 2009 20:49:49 GMT
Author: vdichev
Date: Thu Jul  9 20:49:49 2009
New Revision: 792682

URL: http://svn.apache.org/viewvc?rev=792682&view=rev
Log:
ESME-77 Reason for message displayed in timeline.

Modified:
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/PublicTimeline.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/TagCloud.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/Timeline.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala
    incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html

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=792682&r1=792681&r2=792682&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 Thu Jul  9 20:49:49
2009
@@ -110,7 +110,6 @@
       Loc.Snippet("user_info", TagDisplay.userInfo))) ::
     Menu(Loc("conv", List("user_view", "conversation"), "Conversation", Hidden)) ::
     Menu(Loc("about", List("static", "about"), "About", Hidden)) ::
-    Menu(Loc("openid", List("static", "openid"), "OpenID", Hidden)) ::
     Menu(Loc("tag", List("info_view", "tag"), "Tag", Hidden, Loc.Snippet("tag_display", TagDisplay.display)))
::
     Menu(Loc("search", List("user_view", "search"), "Search", Hidden)) ::
     User.sitemap :::

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala?rev=792682&r1=792681&r2=792682&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala Thu Jul
 9 20:49:49 2009
@@ -71,7 +71,7 @@
 
   private var perform: List[PerformMatcher] = Nil
   
-  private var _mailbox: Array[Long] = Array()
+  private var _mailbox: Array[(Long,MailboxReason)] = Array()
   
   private var pools: Set[Long] = Set()
 
@@ -98,7 +98,7 @@
         foreach(u => userTimezone = TimeZone.getTimeZone(u.timezone))
 
         _mailbox = Mailbox.mostRecentMessagesFor(userId, 500).
-        map(_._1.id.is).toArray
+        map(m => (m._1.id.is, m._2) ).toArray
         
         pools = Privilege.findViewablePools(userId)
 
@@ -221,7 +221,7 @@
         }
         mb.saveMe
           
-        _mailbox = (msg.id.is :: _mailbox.toList).take(500).toArray
+        _mailbox = ((msg.id.is, reason) :: _mailbox.toList).take(500).toArray
 
         listeners.foreach(_ ! MessageReceived(msg, reason))
             

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/PublicTimeline.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/PublicTimeline.scala?rev=792682&r1=792681&r2=792682&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/PublicTimeline.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/PublicTimeline.scala
Thu Jul  9 20:49:49 2009
@@ -63,7 +63,7 @@
     val jsId = "public_timeline_messages";
 
     OnLoad(JsCrVar(jsId, JsArray(
-        toDisplay.map(_.asJs) :_*)) &
+        toDisplay.map(m => JsObj(("message", m.asJs)) ) :_*)) &
     JsFunc("displayMessages", JsVar(jsId), jsId).cmd)
   }
 

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/TagCloud.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/TagCloud.scala?rev=792682&r1=792681&r2=792682&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/TagCloud.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/TagCloud.scala Thu Jul
 9 20:49:49 2009
@@ -45,7 +45,7 @@
     for (user <- User.currentUser) {
       Distributor ! Distributor.Listen(user.id, this)
       Distributor !? (2000, Distributor.LatestMessages(user.id, 40)) match {
-        case Some(msg: List[Long]) => messages = msg
+        case Some(msg: List[(Long,MailboxReason)]) => messages = msg map {_._1}
         case x =>
       }
     }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/Timeline.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/Timeline.scala?rev=792682&r1=792681&r2=792682&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/Timeline.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/comet/Timeline.scala Thu Jul
 9 20:49:49 2009
@@ -37,14 +37,14 @@
 import java.text._
 
 class Timeline extends CometActor {
-  private var messages: List[Long] = Nil
+  private var messages: List[(Long,MailboxReason)] = Nil
   
   override def localSetup() {
     super.localSetup()
     for (user <- User.currentUser) {
       Distributor ! Distributor.Listen(user.id, this)
       Distributor !? (2000, Distributor.LatestMessages(user.id, 40)) match {
-        case Some(msg: List[Long]) => messages = msg
+        case Some(msg: List[(Long,MailboxReason)]) => messages = msg
         case x =>
       }
     }
@@ -58,18 +58,18 @@
   }
   
   def render = {
-    val msgMap = Message.findMessages(messages)
-    val toDisplay = messages.flatMap(msgMap.get)
+    val msgMap = Message.findMessages(messages map {_._1})
+    val toDisplay = messages.map(m => (msgMap.get(m._1).get, m._2))
     val jsId = "timeline_messages";
 
     OnLoad(JsCrVar(jsId, JsArray(
-        toDisplay.map(_.asJs) :_*)) &
+        toDisplay.map(m => JsObj(("message",m._1.asJs),("reason",m._2.asJs))) :_*)) &
     JsFunc("displayMessages", JsVar(jsId), jsId).cmd)
   }
   
   override def lowPriority = {
-    case UserActor.MessageReceived(msg, _) =>
-      messages = (msg.id.is :: messages).take(40)
+    case UserActor.MessageReceived(msg, r) =>
+      messages = ( (msg.id.is,r) :: messages).take(40)
       reRender(false)
       
     case Distributor.UserUpdated(_) =>

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=792682&r1=792681&r2=792682&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 Thu Jul
 9 20:49:49 2009
@@ -24,6 +24,7 @@
 import net.liftweb._
 import mapper._
 import util._
+import net.liftweb.http.js.JE._
 
 import scala.xml._
 
@@ -64,6 +65,10 @@
 
 sealed trait MailboxReason {
   def attr: MetaData
+  def asJs = attr match {
+    case Null => JsNull
+    case _ => JsObj((attr.key, Str(attr.value.toString)))
+  }
 }
 case class ResendReason(fromUserId: Long) extends MailboxReason {
   def attr = new UnprefixedAttribute("resent_from", fromUserId.toString, Null)

Modified: incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html?rev=792682&r1=792681&r2=792682&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html Thu Jul  9 20:49:49
2009
@@ -16,7 +16,7 @@
 
       function msgDateCompare(msg1, msg2)
       {
-        return parseInt(msg1.when) - parseInt(msg2.when);
+        return parseInt(msg1.message.when) - parseInt(msg2.message.when);
       }
 
       function displayMessages(msgArray, elementId)
@@ -39,7 +39,8 @@
         for (var msgIndex in msgArray)
         {
           // Marshall the data from the Comet-supplied message
-          var cometMsg = msgArray[msgIndex];
+          var cometMsg = msgArray[msgIndex].message;
+          var cometReason = msgArray[msgIndex].reason;
           var msgId = "message_"+cometMsg.id;
 
           // Only do this if the message is not already in the table
@@ -53,6 +54,8 @@
             var msgPool = '[public]';
             if (cometMsg.pool) msgPool = cometMsg.pool.name;
             var msgSource = cometMsg.source;
+            var msgReason = ""
+            for (r in cometReason) {var msgReason = r; break}
             var msgTags = jQuery(cometMsg.text).find('tags > tag').get();
             for (var tagIndex=0; tagIndex < msgTags.length; tagIndex++) {
               // Replace each tag element with the plain tag text
@@ -71,6 +74,7 @@
             newMsg.find('#body').html(msgBody);
             newMsg.find('#pool').text(msgPool);
             newMsg.find('#source').text(msgSource);
+            newMsg.find('#reason').text(msgReason);
             newMsg.find('#when').text(msgDateStr);
             for (var tagIndex=0; tagIndex < msgTags.length; tagIndex++) {
               var newTag = tagTemplate.clone(true).attr('id',msgTags[tagIndex]);
@@ -128,6 +132,7 @@
                               <th>Tags</th>
                               <th>Pool</th>
                               <th>Source</th>
+                              <th>Reason</th>
                               <th>Date</th>
                             </tr>
                           </thead>
@@ -146,6 +151,7 @@
                               </td>
                               <td id="pool">-</td>
                               <td id="source">web</td>
+                              <td id="reason">resend</td>
                               <td id="when" class="date">Jan 1, 2009 12:00</td>
                             </tr>
                             <tr id="message">
@@ -161,6 +167,7 @@
                               </td>
                               <td id="pool">PUBLIC</td>
                               <td id="source">web</td>
+                              <td id="reason"><!-- no reason --></td>
                               <td id="when" class="date">Jan 1, 2009 11:58</td>
                             </tr>
                           </tbody>



Mime
View raw message