Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes #953 -- adds headers to Mailer. Closes #993 sitemap global par…

…ams no longer cached. Closes #989 -- formGroup for onSubmit same as submit and button.  Closes #962 -- allows for separate subclasses of ProtoUser.  Closes #979 -- allows for global LocParams in ProtoUser
  • Loading branch information...
commit afb026038e4cc88df213d9a372c7e75bc5161c7f 1 parent 95f2dc6
@dpp dpp authored
View
33 core/util/src/main/scala/net/liftweb/util/Mailer.scala
@@ -37,36 +37,40 @@ protected trait MailerImpl extends SimpleInjector {
private val logger = Logger(classOf[MailerImpl])
sealed abstract class MailTypes
+ /**
+ * Add message headers to outgoing messages
+ */
+ final case class MessageHeader(name: String, value: String) extends MailTypes
sealed abstract class MailBodyType extends MailTypes
- case class PlusImageHolder(name: String, mimeType: String, bytes: Array[Byte])
+ final case class PlusImageHolder(name: String, mimeType: String, bytes: Array[Byte])
/**
* Represents a text/plain mail body. The given text will
* be encoded as UTF-8 when sent.
*/
- case class PlainMailBodyType(text: String) extends MailBodyType
+ final case class PlainMailBodyType(text: String) extends MailBodyType
/**
* Represents a text/plain mail body that is encoded with the
* specified charset
*/
- case class PlainPlusBodyType(text: String, charset: String) extends MailBodyType
+ final case class PlainPlusBodyType(text: String, charset: String) extends MailBodyType
- case class XHTMLMailBodyType(text: NodeSeq) extends MailBodyType
- case class XHTMLPlusImages(text: NodeSeq, items: PlusImageHolder*) extends MailBodyType
+ final case class XHTMLMailBodyType(text: NodeSeq) extends MailBodyType
+ final case class XHTMLPlusImages(text: NodeSeq, items: PlusImageHolder*) extends MailBodyType
sealed abstract class RoutingType extends MailTypes
sealed abstract class AddressType(val adr: String) extends RoutingType
- case class From(address: String) extends AddressType(address)
- case class To(address: String) extends AddressType(address)
- case class CC(address: String) extends AddressType(address)
- case class Subject(subject: String) extends RoutingType
- case class BCC(address: String) extends AddressType(address)
- case class ReplyTo(address: String) extends AddressType(address)
+ final case class From(address: String) extends AddressType(address)
+ final case class To(address: String) extends AddressType(address)
+ final case class CC(address: String) extends AddressType(address)
+ final case class Subject(subject: String) extends RoutingType
+ final case class BCC(address: String) extends AddressType(address)
+ final case class ReplyTo(address: String) extends AddressType(address)
implicit def xmlToMailBodyType(html: NodeSeq): MailBodyType = XHTMLMailBodyType(html)
- case class MessageInfo(from: From, subject: Subject, info: List[MailTypes])
+ final case class MessageInfo(from: From, subject: Subject, info: List[MailTypes])
implicit def addressToAddress(in: AddressType): Address = new InternetAddress(in.adr)
@@ -221,6 +225,11 @@ protected trait MailerImpl extends SimpleInjector {
// message.setReplyTo(filter[MailTypes, ReplyTo](info, {case x @ ReplyTo(_) => Some(x); case _ => None}))
message.setReplyTo(info.flatMap {case x: ReplyTo => Some[ReplyTo](x) case _ => None})
message.setSubject(subject.subject)
+ info.foreach {
+ case MessageHeader(name, value) => message.addHeader(name, value)
+ case _ =>
+ }
+
val bodyTypes = info.flatMap {case x: MailBodyType => Some[MailBodyType](x); case _ => None}
bodyTypes match {
case PlainMailBodyType(txt) :: Nil =>
View
47 persistence/proto/src/main/scala/net/liftweb/proto/ProtoUser.scala
@@ -216,7 +216,9 @@ trait ProtoUser {
def homePage = "/"
- object loginRedirect extends SessionVar[Box[String]](Empty)
+ object loginRedirect extends SessionVar[Box[String]](Empty) {
+ override lazy val __nameSalt = Helpers.nextFuncName
+ }
@@ -264,7 +266,14 @@ trait ProtoUser {
* The menu item for login (make this "Empty" to disable)
*/
def loginMenuLoc: Box[Menu] =
- Full(Menu(Loc("Login", loginPath, S.??("login"), loginMenuLocParams)))
+ Full(Menu(Loc("Login", loginPath, S.??("login"), loginMenuLocParams ::: globalUserLocParams)))
+
+
+ /**
+ * If you want to include a LocParam (e.g. LocGroup) on all the
+ * User menus, add them here
+ */
+ protected def globalUserLocParams: List[LocParam[Unit]] = Nil
/**
* The LocParams for the menu item for login.
@@ -279,7 +288,7 @@ trait ProtoUser {
* The menu item for logout (make this "Empty" to disable)
*/
def logoutMenuLoc: Box[Menu] =
- Full(Menu(Loc("Logout", logoutPath, S.??("logout"), logoutMenuLocParams)))
+ Full(Menu(Loc("Logout", logoutPath, S.??("logout"), logoutMenuLocParams ::: globalUserLocParams)))
/**
* The LocParams for the menu item for logout.
@@ -294,7 +303,7 @@ trait ProtoUser {
* The menu item for creating the user/sign up (make this "Empty" to disable)
*/
def createUserMenuLoc: Box[Menu] =
- Full(Menu(Loc("CreateUser", signUpPath, S.??("sign.up"), createUserMenuLocParams)))
+ Full(Menu(Loc("CreateUser", signUpPath, S.??("sign.up"), createUserMenuLocParams ::: globalUserLocParams)))
/**
* The LocParams for the menu item for creating the user/sign up.
@@ -309,7 +318,7 @@ trait ProtoUser {
* The menu item for lost password (make this "Empty" to disable)
*/
def lostPasswordMenuLoc: Box[Menu] =
- Full(Menu(Loc("LostPassword", lostPasswordPath, S.??("lost.password"), lostPasswordMenuLocParams))) // not logged in
+ Full(Menu(Loc("LostPassword", lostPasswordPath, S.??("lost.password"), lostPasswordMenuLocParams ::: globalUserLocParams))) // not logged in
/**
* The LocParams for the menu item for lost password.
@@ -324,7 +333,7 @@ trait ProtoUser {
* The menu item for resetting the password (make this "Empty" to disable)
*/
def resetPasswordMenuLoc: Box[Menu] =
- Full(Menu(Loc("ResetPassword", (passwordResetPath, true), S.??("reset.password"), resetPasswordMenuLocParams))) //not Logged in
+ Full(Menu(Loc("ResetPassword", (passwordResetPath, true), S.??("reset.password"), resetPasswordMenuLocParams ::: globalUserLocParams))) //not Logged in
/**
* The LocParams for the menu item for resetting the password.
@@ -340,7 +349,7 @@ trait ProtoUser {
* The menu item for editing the user (make this "Empty" to disable)
*/
def editUserMenuLoc: Box[Menu] =
- Full(Menu(Loc("EditUser", editPath, S.??("edit.user"), editUserMenuLocParams)))
+ Full(Menu(Loc("EditUser", editPath, S.??("edit.user"), editUserMenuLocParams ::: globalUserLocParams)))
/**
* The LocParams for the menu item for editing the user.
@@ -355,7 +364,7 @@ trait ProtoUser {
* The menu item for changing password (make this "Empty" to disable)
*/
def changePasswordMenuLoc: Box[Menu] =
- Full(Menu(Loc("ChangePassword", changePasswordPath, S.??("change.password"), changePasswordMenuLocParams)))
+ Full(Menu(Loc("ChangePassword", changePasswordPath, S.??("change.password"), changePasswordMenuLocParams ::: globalUserLocParams)))
/**
* The LocParams for the menu item for changing password.
@@ -370,7 +379,7 @@ trait ProtoUser {
* The menu item for validating a user (make this "Empty" to disable)
*/
def validateUserMenuLoc: Box[Menu] =
- Full(Menu(Loc("ValidateUser", (validateUserPath, true), S.??("validate.user"), validateUserMenuLocParams)))
+ Full(Menu(Loc("ValidateUser", (validateUserPath, true), S.??("validate.user"), validateUserMenuLocParams ::: globalUserLocParams)))
/**
* The LocParams for the menu item for validating a user.
@@ -498,11 +507,17 @@ trait ProtoUser {
S.session.foreach(_.destroySession())
}
- private object curUserId extends SessionVar[Box[String]](Empty)
+ private object curUserId extends SessionVar[Box[String]](Empty) {
+ override lazy val __nameSalt = Helpers.nextFuncName
+ }
+
def currentUserId: Box[String] = curUserId.is
- private object curUser extends RequestVar[Box[TheUserType]](currentUserId.flatMap(userFromStringId)) with CleanRequestVarOnSessionTransition
+ private object curUser extends RequestVar[Box[TheUserType]](currentUserId.flatMap(userFromStringId)) with CleanRequestVarOnSessionTransition {
+ override lazy val __nameSalt = Helpers.nextFuncName
+ }
+
/**
* Given a String representing the User ID, find the user
@@ -570,7 +585,10 @@ trait ProtoUser {
resetLink: String):
List[MailBodyType] = List(xmlToMailBodyType(signupMailBody(user, resetLink)))
- protected object signupFunc extends RequestVar[Box[() => NodeSeq]](Empty)
+ protected object signupFunc extends RequestVar[Box[() => NodeSeq]](Empty) {
+ override lazy val __nameSalt = Helpers.nextFuncName
+ }
+
/**
* Override this method to do something else after the user signs up
@@ -892,7 +910,10 @@ trait ProtoUser {
</form>)
}
- object editFunc extends RequestVar[Box[() => NodeSeq]](Empty)
+ object editFunc extends RequestVar[Box[() => NodeSeq]](Empty) {
+ override lazy val __nameSalt = Helpers.nextFuncName
+ }
+
/**
* If there's any mutation to do to the user on retrieval for
View
14 web/webkit/src/main/scala/net/liftweb/http/SHtml.scala
@@ -1184,7 +1184,11 @@ trait SHtml {
case Group(g) => runNodes(g)
// button
case e: Elem if e.label == "button" =>
- fmapFunc(func) {dupWithName(e, _)}
+ _formGroup.is match {
+ case Empty =>
+ formGroup(1)(fmapFunc(func) {dupWithName(e, _)})
+ case _ => fmapFunc(func) {dupWithName(e, _)}
+ }
// textarea
case e: Elem if e.label == "textarea" =>
@@ -1223,6 +1227,14 @@ trait SHtml {
}
}
+ // submit
+ case e: Elem if e.label == "input" && e.attribute("type").map(_.text) == Some("submit") =>
+ _formGroup.is match {
+ case Empty =>
+ formGroup(1)(fmapFunc(func) {dupWithName(e, _)})
+ case _ => fmapFunc(func) {dupWithName(e, _)}
+ }
+
// generic input
case e: Elem if e.label == "input" =>
fmapFunc(func) {dupWithName(e, _)}
View
2  web/webkit/src/main/scala/net/liftweb/sitemap/Loc.scala
@@ -109,7 +109,7 @@ trait Loc[T] {
def params: List[Loc.LocParam[T]]
- lazy val allParams: List[Loc.AnyLocParam] =
+ def allParams: List[Loc.AnyLocParam] =
(params.asInstanceOf[List[Loc.AnyLocParam]]) :::
parentParams :::
siteMap.globalParams
Please sign in to comment.
Something went wrong with that request. Please try again.