Created
February 17, 2011 08:08
-
-
Save yesil/831280 to your computer and use it in GitHub Desktop.
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 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 _) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it proper to set date = formatter.parseDateTime(datePtr) in more method ?