incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r988345 - in /incubator/esme/trunk/server/src/main: scala/org/apache/esme/lib/StreamMgr.scala webapp/info_view/streams.html
Date Mon, 23 Aug 2010 22:52:49 GMT
Author: esjewett
Date: Mon Aug 23 22:52:49 2010
New Revision: 988345

URL: http://svn.apache.org/viewvc?rev=988345&view=rev
Log:
[ESME-259] Refactor StreamMgr.scala to remove snippet order requirement by moving initialization
code out of the individual snippets, then re-ordered streams.html so that HTML is in order
it appears on the page.

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
    incubator/esme/trunk/server/src/main/webapp/info_view/streams.html

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala?rev=988345&r1=988344&r2=988345&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala Mon Aug
23 22:52:49 2010
@@ -64,75 +64,80 @@ object StreamMgr {
   object resenderId extends RequestVar[Long](AnyResender)
   object filterResent_? extends RequestVar[Boolean](false)
   object poolId extends RequestVar[Long](PublicPool)
-  object filterPools_? extends RequestVar[Boolean](false)
-
-  def displayStream(in: NodeSeq): NodeSeq = {
-    // get the span name to update
-    val spanName = S.attr("the_id") openOr "StreamSpan"
+  object filterPools_? extends RequestVar[Boolean](false)  
+  object spanName extends RequestVar[String]("StreamSpan")     
+  object displayStreamNodes extends RequestVar[NodeSeq](Text(""))  
+  
+  def updateSpan(): JsCmd = SetHtml(spanName, doRender(displayStreamNodes))    
+  
+  // bind the dynamic content to the incoming nodeseq
+  def doRender(in: NodeSeq): NodeSeq = {   
     // get the current user
     val user = User.currentUser
-
-    // bind the dynamic content to the incoming nodeseq
-    def doRender(): NodeSeq = {
-      val resentQuery = 
-      if (filterResent_?.is == false) Nil
-      else {
-        val queryParam = resenderId.is match {
-          case AnyResender => NotBy(Mailbox.resentBy, Empty)
-          case id => By(Mailbox.resentBy, id)
-        }
-        List(In(Message.id,Mailbox.message,By(Mailbox.user, user), queryParam))
+  
+    val resentQuery = 
+    if (filterResent_?.is == false) Nil
+    else {
+      val queryParam = resenderId.is match {
+        case AnyResender => NotBy(Mailbox.resentBy, Empty)
+        case id => By(Mailbox.resentBy, id)
       }
-      
-      val poolsQuery = 
-      if (filterPools_?.is == false) Nil
-      else List(poolId.is match {
-        case PublicPool => By(Message.pool, Empty)
-        case id => By(Message.pool, id)
-      })
-      
-      val query = poolsQuery :::
-                  resentQuery :::
-                  List[QueryParam[Message]](OrderBy(Message.id, Descending), MaxRows(10))

+      List(In(Message.id,Mailbox.message,By(Mailbox.user, user), queryParam))
+    }
+    
+    val poolsQuery = 
+    if (filterPools_?.is == false) Nil
+    else List(poolId.is match {
+      case PublicPool => By(Message.pool, Empty)
+      case id => By(Message.pool, id)
+    })
+    
+    val query = poolsQuery :::
+                resentQuery :::
+                List[QueryParam[Message]](OrderBy(Message.id, Descending), MaxRows(10)) 
+       
+    def profileImage(u: User): NodeSeq = {
+        var imageUrl = u.imageUrl.toString
+        if (imageUrl.length > 0) 
+          <img width="30px" src={imageUrl}/>
+        else
+           <img width="30px" src="/images/avatar.jpg"/>
+     }
          
-      def profileImage(u: User): NodeSeq = {
-          var imageUrl = u.imageUrl.toString
-          if (imageUrl.length > 0) 
-            <img width="30px" src={imageUrl}/>
-          else
-             <img width="30px" src="/images/avatar.jpg"/>
-       }
-           
-      //XXX copy from lib.UserMgr
-      def nicknameWithProfileLink(u: User): NodeSeq = {
-    		  <a href={"/user/" + urlEncode(u.nickname.is)}>{u.niceName}</a>
-      	}
-      	
-      val dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm")
-          
+    //XXX copy from lib.UserMgr
+    def nicknameWithProfileLink(u: User): NodeSeq = {
+  		  <a href={"/user/" + urlEncode(u.nickname.is)}>{u.niceName}</a>
+    	}
+    	
+    val dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm")
         
-      Message.findAll(query: _*) match {
-        case Nil => NodeSeq.Empty
-        case xs => bind("disp", in,
-                        "item" -> 
-                        (lst => xs.flatMap(i => bind("item", lst,
-                                                     "author" -> i.author.obj.map(nicknameWithProfileLink).openOr(Text("")),
-                                                     "imageUrl" -> i.author.obj.map(profileImage).openOr(Text("")),
-                                                     "text" -> i.getBody,
-                                                     "date" -> dateFormatter.format(i.getWhen)
-                ))))
-      }
+      
+    Message.findAll(query: _*) match {
+      case Nil => NodeSeq.Empty
+      case xs => bind("disp", in,
+                      "item" -> 
+                      (lst => xs.flatMap(i => bind("item", lst,
+                                                   "author" -> i.author.obj.map(nicknameWithProfileLink).openOr(Text("")),
+                                                   "imageUrl" -> i.author.obj.map(profileImage).openOr(Text("")),
+                                                   "text" -> i.getBody,
+                                                   "date" -> dateFormatter.format(i.getWhen)
+              ))))
     }
-    def updateSpan(): JsCmd = SetHtml(spanName, doRender())
+  }  
+  
 
-    updateStream.set(updateSpan)
-    doRender()
+  def displayStream(in: NodeSeq): NodeSeq = {    
+      
+    updateStream.set(updateSpan)    
+    displayStreamNodes.set(in)                               
+  
+    doRender(in)
   }
 
-  def streamFilters(in: NodeSeq): NodeSeq = {
+  def streamFilters(in: NodeSeq): NodeSeq = {   
+  
     import org.apache.esme.model.AccessPool
-    import net.liftweb.common.Empty
-    val redisplayStream = updateStream.is
+    import net.liftweb.common.Empty              
     val resenderInput = "resender_input"
     val poolInput = "pool_input"
     val filterResentInput = "filter_resent_input"
@@ -162,7 +167,7 @@ object StreamMgr {
       poolId.set(pool)
       filterResent_?.set(filterResent)
       filterPools_?.set(filterPools)
-      redisplayStream()
+      updateStream()
     }
 
     /*
@@ -212,5 +217,4 @@ object StreamMgr {
                                        "id" -> filterPoolsInput)
     )
   }
-
 }

Modified: incubator/esme/trunk/server/src/main/webapp/info_view/streams.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/streams.html?rev=988345&r1=988344&r2=988345&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/streams.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/streams.html Mon Aug 23 22:52:49
2010
@@ -17,82 +17,63 @@
  under the License.                                           *
 -->
 <lift:surround with="base" at="left">
-    <link rel="stylesheet" type="text/css" href="../style/style.css"/>
-    <lift:TableSorterSnip/>
-    <div id="back-header">
-      <h1><b><lift:loc>ui_streams_manage</lift:loc></b></h1>
+  <link rel="stylesheet" type="text/css" href="../style/style.css"/>
+  <lift:TableSorterSnip/>
+  <div id="back-header">
+    <h1><b><lift:loc>ui_streams_manage</lift:loc></b></h1>
      
-	<!---CONTENT BOX-->
-	<div class="container-streams">
-	
-	<div class ="stream_body">
-        <table id="esme-table" class="tablesorter">        
-            <thead>
-                <tr>
-                    <th>
-                    </th>
-                    <th>
-                        <lift:loc>ui_user_list_nickname</lift:loc>
-                    </th>
-                    <th>
-                        <lift:loc>ui_user_list_last_message</lift:loc>
-                    </th>
-                    <th>
-                        <lift:loc>ui_user_list_last_message_date</lift:loc>
-                    </th>
-                </tr>
-            </thead>
-            <tbody id="StreamSpan">         
-                <lift:displayStream>                  
-                    <disp:item>
-                        <tr class="user_row">
-                            <td>
-                                <item:imageUrl/>
-                            </td>
-                            <td>
-	                    <div class="user_name">
-                                	<item:author/>
-			    </div>
-                            </td>
-                            <td class="user_message">
-                                <item:text/>
-                            </td>
-                            <td>
-                                <item:date/>
-                            </td>
-                        </tr>
-                    </disp:item>
-                   
-                </lift:displayStream>
-                 
-            </tbody>
-        </table>
-       </div>
-		
-		<div class="StreamUI">
-			<lift:streamFilters>
+	  <!---CONTENT BOX-->
+	  <div class="container-streams">  
+	    <div class="StreamUI">
+			  <lift:streamFilters>
 					<table class="tablesorter" >
-					<thead>
-						<tr>
-							<th class="tipelement" title="These are users that you follow">
-								 <lift:loc>ui_streams_filter_resender</lift:loc> <main:resent/>
-							</th>
-							<th align="center" class="tipelement" title="Filter by messages that have been
resent by those you follow. ">
-								 <lift:loc>ui_streams_resent_active</lift:loc> <main:filterResent/>
-							</th>
-							<th class="tipelement" title="These are pools in which you are a member">
-								<lift:loc>ui_streams_filter_pool</lift:loc> <main:pools/> 
-							</th>
-							<th align="center">
-								<lift:loc>ui_streams_pool_active</lift:loc> <main:filterPools/>
-							</th>
-						</tr>
-						 </thead>
+					  <thead>
+						  <tr>
+							  <th class="tipelement" title="These are users that you follow">
+								  <lift:loc>ui_streams_filter_resender</lift:loc> <main:resent/>
+							  </th>
+							  <th align="center" class="tipelement" title="Filter by messages that have been
resent by those you follow. ">
+								  <lift:loc>ui_streams_resent_active</lift:loc> <main:filterResent/>
+							  </th>
+							  <th class="tipelement" title="These are pools in which you are a member">
+								  <lift:loc>ui_streams_filter_pool</lift:loc> <main:pools/> 
+							  </th>
+							  <th align="center">
+								  <lift:loc>ui_streams_pool_active</lift:loc> <main:filterPools/>
+							  </th>
+						  </tr>
+						</thead>
 					</table>
 				</lift:streamFilters>
-		</div>		
-
-	</div>
-	</div>
-	<!-- End demo -->
+		  </div>
+	    <div class ="stream_body">  
+        <table id="esme-table" class="tablesorter">        
+          <thead>
+            <tr>
+              <th></th>
+              <th><lift:loc>ui_user_list_nickname</lift:loc></th>
+              <th><lift:loc>ui_user_list_last_message</lift:loc></th>
+              <th><lift:loc>ui_user_list_last_message_date</lift:loc></th>
+            </tr>
+          </thead>              
+          <tbody id="StreamSpan">         
+            <lift:displayStream>                  
+              <disp:item>
+                <tr class="user_row">
+                  <td><item:imageUrl/></td>
+                  <td>
+                    <div class="user_name">
+                      <item:author/>
+                    </div>
+                  </td>
+                  <td class="user_message"><item:text/></td>
+                  <td><item:date/></td>
+                </tr>
+              </disp:item>
+            </lift:displayStream>
+          </tbody>
+        </table>
+      </div>
+	  </div>
+	</div>           
 </lift:surround>
\ No newline at end of file



Mime
View raw message