This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sitemap = SiteMap( | |
Menu("Home") / "index" >> LocGroup("public"), | |
Menu("Search") / "search" >> LocGroup("public"), | |
Menu("History") / "history" >> LocGroup("public"), | |
Menu("Auctions") / "auctions" >> LocGroup("public"), | |
Menu("Auction Detail") / "auction" >> LocGroup("public"), | |
// admin | |
Menu("Admin") / "admin" / "index" >> LocGroup("admin"), | |
Menu("Suppliers") / "admin" / "suppliers" >> LocGroup("admin") submenus(Supplier.menus : _*), | |
Menu("Auction Admin") / "admin" / "auctions" >> LocGroup("admin") submenus(Auction.menus : _*), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def submit: JsCmd = { | |
for(amountString <- amountBox ?~ "Amount not entered"; | |
amount <- tryo(BigDecimal(amountString).longValue) ?~! "Amount not a number" | |
) yield ( | |
tryo(new Bid().auction(auction).customer(Customer.currentUser).amount(amount).save) | |
) match { | |
case Full(x) => S.notice("Great, your bid was accepted!") | |
case Failure(msg, _, _) => S.error(msg) | |
case _ => S.warning("Unable to place bid at this time.") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bid(xhtml: NodeSeq): NodeSeq = { | |
var amountBox: Box[String] = Empty | |
def submit = { | |
for(as <- amountBox ?~ "Amount not entered"; | |
amount <- tryo(BigDecimal(as).longValue) ?~! "Amount not a number" | |
) yield { | |
new Bid().auction(auction).customer(Customer.currentUser).amount(amount).save | |
} | |
} match { | |
case Full(x) => S.notice("Great, your bid was accepted!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bid(xhtml: NodeSeq): NodeSeq = { | |
var amountBox: Box[String] = Empty | |
def submit = { | |
for(ass <- amountBox ?~ "Amount not entered"; | |
amo <- tryo(BigDecimal(ass).doubleValue) ?~! "Amount not a number"; | |
auc <- auction; | |
vld <- tryo(amo).filter(_ >= auc.nextAmount) ?~ "Less that required amount!" | |
) yield { | |
new Bid().auction(auction).customer(Customer.currentUser).amount(amo).save | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Details extends StatefulSnippet with AuctionHelpers with Loggable { | |
val dispatch: DispatchIt = { | |
case "show" => show _ | |
case "bid" => bid _ | |
} | |
val currentAmountSpan = "current_amount" | |
val nextAmountSpan = "next_amount" | |
val amountInputId = "amount" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val xml = | |
{ if(S.errors.isEmpty) Nil else List(MsgsErrorMeta.get, f(S.errors), S.??("msg.error"), LiftRules.noticesContainerId + "_error") } ++ | |
{ if(S.warnings.isEmpty) Nil else List((MsgsWarningMeta.get, f(S.warnings), S.??("msg.warning"), LiftRules.noticesContainerId + "_warn")) } ++ | |
{ if (S.notices.isEmpty) Nil else List((MsgsNoticeMeta.get, f(S.notices), S.??("msg.notice"), LiftRules.noticesContainerId + "_notice")) } flatMap { | |
msg => msg._1 match { | |
case Full(meta) => <div id={msg._4}>{func(msg._2 _, meta.title openOr "", | |
meta.cssClass.map(new UnprefixedAttribute("class", _, Null)) openOr Null)}</div> | |
case _ => <div id={msg._4}>{func(msg._2 _, msg._3, Null)}</div> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] /Users/timperrett/repositories/lift/lift-framework/framework/lift-persistence/lift-squeryl-record/src/main/scala:-1: info: compiling | |
[INFO] Compiling 4 source files to /Users/timperrett/repositories/lift/lift-framework/framework/lift-persistence/lift-squeryl-record/target/classes at 1279630839609 | |
[ERROR] /Users/timperrett/repositories/lift/lift-framework/framework/lift-persistence/lift-squeryl-record/src/main/scala/net/liftweb/squerylrecord/RecordTypeMode.scala:35: error: not found: type StringExpression | |
[INFO] new SelectElementReference[Option[StringType]](FieldReferenceLinker.takeLastAccessedFieldReference.get)(createOutMapperStringTypeOption) with StringExpression[Option[StringType]] | |
[INFO] ^ | |
[ERROR] /Users/timperrett/repositories/lift/lift-framework/framework/lift-persistence/lift-squeryl-record/src/main/scala/net/liftweb/squerylrecord/RecordTypeMode. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LiftRules.dispatch.append { | |
case r@Req("some" :: "path" :: Nil,"",GetRequest) => { | |
val accept = in.headers("accept") | |
(accept.find(_.toLowerCase.indexOf("text/xml") >= 0).isDefined || | |
((in.path.suffix equalsIgnoreCase "xml") && (accept.isEmpty || | |
accept.find(_.toLowerCase.indexOf("*/*") >= 0).isDefined))) | |
? Full(XmlResponse(...)) | Full(JsonReponse(...)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalala.Scalala._; | |
import scalala.tensor._; | |
import scalala.tensor.dense_; | |
object KMeans { | |
// Returns the centers of the k clusters, and the clusters themselves | |
def cluster(data: Seq[Vector], k: Int): Seq[Vector] = { | |
var means = data.take(k); | |
var converged = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Book(publisher: String, title: String) | |
object Bookshop { | |
val stock = List( | |
Book("Bloomsbury", "Harry Potter and the Deathly Hallows"), | |
Book("Bloomsbury", "Harry Potter and the Goblet of Fire"), | |
Book("Manning", "Scala in Depth"), | |
Book("Manning", "Lift in Action") | |
) | |
} |