You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by vd...@apache.org on 2009/11/29 23:34:26 UTC

svn commit: r885282 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/ scala/org/apache/esme/comet/ scala/org/apache/esme/lib/ webapp/info_view/ webapp/templates-hidden/

Author: vdichev
Date: Sun Nov 29 22:34:26 2009
New Revision: 885282

URL: http://svn.apache.org/viewvc?rev=885282&view=rev
Log:
ESME-101 Html template for search added.

Added:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala   (with props)
    incubator/esme/trunk/server/src/main/webapp/info_view/search.html   (with props)
    incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html   (with props)
Modified:
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.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/Timeline.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=885282&r1=885281&r2=885282&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 Nov 29 22:34:26 2009
@@ -108,7 +108,7 @@
         RewriteResponse(List("info_view", "conversation"), Map("cid" -> cid))
 
       case RewriteRequest(ParsePath("search" :: term :: Nil, "", _, _), _, _) =>
-        RewriteResponse(List("user_view", "search"), Map("term" -> term))
+        RewriteResponse(List("info_view", "search"), Map("term" -> term))
     }
 
     LiftRules.dispatch.append(UrlStore.redirectizer)
@@ -125,7 +125,6 @@
           Loc.Snippet("user_info", TagDisplay.userInfo))) ::
         Menu(Loc("about", List("static", "about"), S.?("base_menu_about"), Hidden)) ::
         Menu(Loc("tag", List("info_view", "tag"), "Tag", Hidden, Loc.Snippet("tag_display", TagDisplay.display))) ::
-        Menu(Loc("search", List("user_view", "search"), S.?("base_menu_search"), Hidden)) ::
         Menu(Loc("sign_up", List("signup"), S.?("base_menu_signup"),
           Snippet("signup", User.signupForm),
           Unless(User.loggedIn_? _, S.?("base_menu_sign_up_error")))) ::
@@ -139,7 +138,8 @@
         AuthMgr.menuItems :::
         AccessPoolMgr.menuItems :::
         StreamMgr.menuItems :::
-        ConversationMgr.menuItems
+        ConversationMgr.menuItems :::
+        SearchMgr.menuItems
 
     LiftRules.setSiteMap(SiteMap(entries: _*))
 
@@ -212,6 +212,7 @@
 
     // Dump information about session every 10 minutes
     SessionMaster.sessionWatchers = SessionInfoDumper :: SessionMaster.sessionWatchers
+    
   }
 
   private def makeUtf8(req: HTTPRequest) = {req.setCharacterEncoding("UTF-8")}

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=885282&r1=885281&r2=885282&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 Sun Nov 29 22:34:26 2009
@@ -61,7 +61,7 @@
     scheduled = false
     val msgMap = Message.findMessages(messages)
     val toDisplay = messages.flatMap(msgMap.get)
-    val jsId = "public_timeline_messages";
+    val jsId = "timeline_messages";
 
     OnLoad(JsCrVar(jsId, JsArray(
         toDisplay.map(m => JsObj(("message", m.asJs)) ) :_*)) &

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=885282&r1=885281&r2=885282&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 Sun Nov 29 22:34:26 2009
@@ -64,7 +64,7 @@
       for ((id, reason, resent) <- messages;
            msg <- msgMap.get(id))
       yield (msg, reason, resent)
-    val jsId = "timeline_messages";
+    val jsId = "personal_timeline_messages";
 
     OnLoad(JsCrVar(jsId, JsArray(
         toDisplay.map{case (msg, reason, resent) =>

Added: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala?rev=885282&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala (added)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala Sun Nov 29 22:34:26 2009
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2008-2009 WorldWide Conferencing, LLC
+ *
+ * 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.
+ */
+
+package org.apache.esme.lib
+
+import net.liftweb._
+import http._
+import SHtml._
+import js._
+import JsCmds._
+import JE._
+
+import sitemap._
+import Loc._
+
+import mapper._
+
+import util._
+import common._
+import Helpers._
+
+import model._
+
+import scala.xml._
+
+/**
+ * Manage the sitemap and related snippets for Search
+ */
+object SearchMgr {
+  def loggedIn_? = User.loggedIn_?
+
+  val ifIsLoggedIn = If(loggedIn_? _, strFuncToFailMsg(() => S.?("base_error_not_logged_in")))
+
+  val menuItems =
+  Menu(Loc("search", List("info_view", "search"), S.?("base_menu_search"), ifIsLoggedIn,
+           Loc.Snippet("displaySearch", displaySearch),
+           Loc.Snippet("searchTerm", searchTerm))) ::
+  Nil
+
+  def searchTerm(in: NodeSeq): NodeSeq = {
+    Text(S.param("term").getOrElse("no words specified"))
+  }
+  
+  def displaySearch(in: NodeSeq): NodeSeq = {
+
+    val jsId = "timeline_messages";
+    
+    {Script(
+      (for (term <- S.param("term");
+           user <- User.currentUser)
+      yield {
+
+        val msgs = Message.search(term, user.following, 50)
+        OnLoad(JsCrVar(jsId, JsArray(
+            msgs.map(m => JsObj(("message", m.asJs)) ) :_*)) &
+        JsFunc("displayMessages", JsVar(jsId), jsId).cmd)
+      }).getOrElse(Noop)
+    )}
+
+  }
+
+}

Propchange: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/SearchMgr.scala
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/esme/trunk/server/src/main/webapp/info_view/search.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/search.html?rev=885282&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/search.html (added)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/search.html Sun Nov 29 22:34:26 2009
@@ -0,0 +1,11 @@
+<lift:surround with="default" at="content">
+  <script src="/scripts/display_messages.js" type="text/javascript"/>
+  
+  Search for <lift:searchTerm/>
+  <div class="b-list">
+    <lift:displaySearch/>
+    <lift:embed what="templates-hidden/timeline"/>
+  </div>
+
+</lift:surround>
+

Propchange: incubator/esme/trunk/server/src/main/webapp/info_view/search.html
------------------------------------------------------------------------------
    svn:executable = *

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=885282&r1=885281&r2=885282&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 Sun Nov 29 22:34:26 2009
@@ -68,7 +68,7 @@
                                                         </tr>
                                                     </thead>
                                                     <lift:comet type="Timeline"/>
-                                                    <tbody id="timeline_messages">
+                                                    <tbody id="personal_timeline_messages">
                                                         <tr id="message">
                                                             <td>
                                                                 <img id="avatar" src="/images/avatar.jpg" alt="Anonymous" width="50px"/>
@@ -120,54 +120,8 @@
                                         </dt>
                                         <dd>
                                             <div class="b-list">
-                                                <table>
-                                                    <thead>
-                                                        <tr>
-                                                            <th>
-                                                                <lift:loc>ui_messages_message_label_author</lift:loc>
-                                                            </th>
-                                                            <th>
-                                                                <lift:loc>ui_messages_message_label_message</lift:loc>
-                                                            </th>
-                                                            <th>
-                                                                <lift:loc>ui_messages_message_label_tags</lift:loc>
-                                                            </th>
-                                                        </tr>
-                                                    </thead>
-                                                    <lift:comet type="PublicTimeline"/>
-                                                    <tbody id="public_timeline_messages">
-                                                        <tr id="message">
-                                                            <td>
-                                                                <img id="avatar" src="/images/avatar.jpg" alt="Anonymous" width="50px"/>
-                                                                <div id="author">
-                                                                    -
-                                                                </div>
-                                                            </td>
-                                                            <td class="message">
-                                                                <div class="outer">
-                                                                    <div class="inner clear">
-                                                                        <p class="text" id="body">
-                                                                            -
-                                                                        </p>
-                                                                    </div>
-                                                                    <div class="metainfo">
-                                                                        <span id="pool">-</span>
-                                                                        <span id="reason">-</span>
-                                                                        <span id="when" class="date">-</span>
-                                                                    </div>
-                                                                </div>
-                                                            </td>
-                                                            <td id="tags" class="tag">
-                                                                <p id="tag">
-                                                                    <a href="tag/tag1">-</a>
-                                                                </p>
-                                                                <p id="tag">
-                                                                    <a href="tag/tag2">-</a>
-                                                                </p>
-                                                            </td>
-                                                        </tr>
-                                                    </tbody>
-                                                </table>
+                                                <lift:comet type="PublicTimeline"/>
+                                                <lift:embed what="templates-hidden/timeline"/>
                                             </div>
                                         </dd>
                                     </dl>
@@ -304,7 +258,7 @@
                                     </lift:UserSnip.links>
                                 </div>
                                     <div class="bugs">
-                                        <form action="/user_view/search" class="b-primay">
+                                        <form action="/info_view/search" class="b-primay">
                                             <input style="height: 20px; background: #c9d8ea;" name="term"/>
                                           <button class="btn" onclick="javascript:form.submit();">
                                             <lift:loc>ui_messages_search</lift:loc>

Added: incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html?rev=885282&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html (added)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html Sun Nov 29 22:34:26 2009
@@ -0,0 +1,48 @@
+<table>
+    <thead>
+        <tr>
+            <th>
+                <lift:loc>ui_messages_message_label_author</lift:loc>
+            </th>
+            <th>
+                <lift:loc>ui_messages_message_label_message</lift:loc>
+            </th>
+            <th>
+                <lift:loc>ui_messages_message_label_tags</lift:loc>
+            </th>
+        </tr>
+    </thead>
+    <tbody id="timeline_messages">
+        <tr id="message">
+            <td>
+                <img id="avatar" src="/images/avatar.jpg" alt="Anonymous" width="50px"/>
+                <div id="author">
+                    -
+                </div>
+            </td>
+            <td class="message">
+                <div class="outer">
+                    <div class="inner clear">
+                        <p class="text" id="body">
+                            -
+                        </p>
+                    </div>
+                    <div class="metainfo">
+                        <span id="pool">-</span>
+                        <span id="reason">-</span>
+                        <span id="when" class="date">-</span>
+                    </div>
+                </div>
+            </td>
+            <td id="tags" class="tag">
+                <p id="tag">
+                    <a href="tag/tag1">-</a>
+                </p>
+                <p id="tag">
+                    <a href="tag/tag2">-</a>
+                </p>
+            </td>
+        </tr>
+    </tbody>
+</table>
+

Propchange: incubator/esme/trunk/server/src/main/webapp/templates-hidden/timeline.html
------------------------------------------------------------------------------
    svn:executable = *