Skip to content

Instantly share code, notes, and snippets.

@yesil
Created February 17, 2011 08:08
Show Gist options
  • Save yesil/831280 to your computer and use it in GitHub Desktop.
Save yesil/831280 to your computer and use it in GitHub Desktop.
class Ads {
val formatter = ISODateTimeFormat.dateTime()
var date:DateTime = new DateTime
lazy val mongoColl = MongoConnection()("abc")("ads")
def list = {
val q = MongoDBObject("published" -> MongoDBObject("$lt" -> date))
val la = S.findCookie("latitude")
val lo = S.findCookie("longitude")
if(!la.isEmpty && !lo.isEmpty){
val latitude = la.open_!.value
val longitude = lo.open_!.value
if(!latitude.isEmpty && !longitude.isEmpty) {
val latitudeStr = latitude.open_!
val longitudeStr = longitude.open_!
q+=("location" -> MongoDBObject("$near" -> (latitudeStr.toFloat,longitudeStr.toFloat)))
}
}
val coll = mongoColl.find(q).limit(10).sort(Map("published" -> -1)).toList
if(coll.size>0) S.appendJs(JsRaw("datePtr = '%s'".format(coll.last.get("published").toString)))
/**
".ad" #> coll.map(ad =>
.
.
) */
}
def more(datePtr:String) = {
date = formatter.parseDateTime(datePtr)
AppendHtml ("ads", <lift:embed what="ad"></lift:embed>)
}
def ajax = "#more" #> SHtml.ajaxButton (Text ("More"), JsVar("datePtr"), more _)
}
@yesil
Copy link
Author

yesil commented Feb 17, 2011

Is it proper to set date = formatter.parseDateTime(datePtr) in more method ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment