esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r780346 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/Boot.scala scala/org/apache/esme/lib/AuthMgr.scala scala/org/apache/esme/view/Auth.scala webapp/auth_view/ webapp/auth_view/index.html
Date Sat, 30 May 2009 22:33:31 GMT
Author: vdichev
Date: Sat May 30 22:33:31 2009
New Revision: 780346

URL: http://svn.apache.org/viewvc?rev=780346&view=rev
Log:
Cleaned up token view to html page with binding.

Added:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AuthMgr.scala   (with props)
    incubator/esme/trunk/server/src/main/webapp/auth_view/
    incubator/esme/trunk/server/src/main/webapp/auth_view/index.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/view/Auth.scala

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=780346&r1=780345&r2=780346&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 Sat May 30 22:33:31
2009
@@ -110,8 +110,8 @@
     Menu(Loc("search", List("user_view", "search"), "Search", Hidden)) ::
     User.sitemap :::
     Track.menuItems :::
-    Auth.menuItems :::
-    ActionMgr.menuItems
+    ActionMgr.menuItems :::
+    AuthMgr.menuItems
 
     LiftRules.setSiteMap(SiteMap(entries:_*))
 

Added: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AuthMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AuthMgr.scala?rev=780346&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AuthMgr.scala (added)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AuthMgr.scala Sat May 30
22:33:31 2009
@@ -0,0 +1,108 @@
+/**
+ * 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 Helpers._
+
+import model._
+
+import scala.xml._
+
+/**
+ * Manage the sitemap and related snippets for Authentication Tokens
+ */
+object AuthMgr {
+  def loggedIn_? = User.loggedIn_?
+
+  val ifIsLoggedIn = If(loggedIn_? _, strFuncToFailMsg(() => S.?("You must be logged in")))
+
+  val menuItems =
+  Menu(Loc("authToken", List("auth_view", "index"), "Manage Tokens", ifIsLoggedIn,
+           Loc.Snippet("dispayTokens", dispayTokens),
+           Loc.Snippet("main", mainTokens))) ::
+  Nil
+
+  object updateTokens extends RequestVar[() => JsCmd](() => Noop)
+
+  def dispayTokens(in: NodeSeq): NodeSeq = {
+    // get the span name to update
+    val spanName = S.attr("the_id") openOr "TokenSpan"
+    // get the current user
+    val user = User.currentUser
+
+    // bind the dynamic content to the incoming nodeseq
+    def doRender(): NodeSeq =
+    AuthToken.findAll(By(AuthToken.user, user),
+                   OrderBy(AuthToken.id, Ascending)) match {
+      case Nil => NodeSeq.Empty
+      case xs => bind("disp", in,
+                      "item" -> 
+                      (lst => xs.flatMap(i => bind("item", lst,
+                                                   "description" -> i.description.is,
+                                                   "uniqueId" -> i.uniqueId.is,
+                                                   "revoke" -> 
+                                                   ((bt: NodeSeq) => 
+                  ajaxButton(bt, () => {i.delete_! ; updateSpan()}))
+              ))))
+    }
+
+    def updateSpan(): JsCmd = SetHtml(spanName, doRender())
+
+    updateTokens.set(updateSpan)
+    doRender()
+  }
+
+  def mainTokens(in: NodeSeq): NodeSeq = {
+    val redisplayTokens = updateTokens.is
+    val theInput = "token_input"
+    val user = User.currentUser
+    
+    def addAuthToken(desc: String): JsCmd = {
+      desc.trim match {
+        case x if x.length < 3 => S.error("Description too short")
+        case x => AuthToken.create.description(x).user(user).saveMe
+          S.notice("New token added")
+      }
+
+      redisplayTokens() & SetValById(theInput, "")
+    }
+
+    bind("main", in,
+         "token" -> text("", addAuthToken, "id" -> theInput)
+    )
+    
+  }
+
+}

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

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/Auth.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/Auth.scala?rev=780346&r1=780345&r2=780346&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/Auth.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/Auth.scala Sat May 30
22:33:31 2009
@@ -20,7 +20,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
+/*
 import net.liftweb._
 import http._
 import js._
@@ -101,4 +101,4 @@
 
     </lift:surround>
   }
-}
+}*/

Added: incubator/esme/trunk/server/src/main/webapp/auth_view/index.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/auth_view/index.html?rev=780346&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/auth_view/index.html (added)
+++ incubator/esme/trunk/server/src/main/webapp/auth_view/index.html Sat May 30 22:33:31 2009
@@ -0,0 +1,28 @@
+<lift:surround with="default" at="content">
+
+  Manage your external application authentication tokens: <br/>
+  <span id="TokenSpan">
+    <lift:ignore>
+      <!--
+      The displayTokens snippet *MUST* appear on the page before
+      the main snippet
+      -->
+    </lift:ignore>
+    <lift:dispayTokens the_id="TokenSpan">
+      <ul>
+        <disp:item>
+          <li><item:description/> token: <item:uniqueId/> <item:revoke>Revoke</item:revoke></li>
+        </disp:item>
+      </ul>
+    </lift:dispayTokens>
+  </span>
+
+  <lift:form>
+    <lift:main>
+      Create a new Authentication Token.<br />
+      Description: <main:token/>
+      <input type="submit" value="Add" />
+    </lift:main>
+  </lift:form>
+
+</lift:surround>

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



Mime
View raw message