Skip to content

Commit

Permalink
Merge branch 'master' into lift_30
Browse files Browse the repository at this point in the history
Conflicts:
	build.sbt
	core/markdown/src/main/scala/net/liftweb/markdown/BaseParsers.scala
	core/markdown/src/test/scala/net/liftweb/markdown/LineTokenizerTest.scala
	core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
	core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala
	core/util/src/test/scala/net/liftweb/util/TimeHelpersSpec.scala
	core/util/src/test/scala/net/liftweb/util/VCardParserSpec.scala
	persistence/mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala
	persistence/mongodb/src/main/scala/net/liftweb/mongodb/Mongo.scala
	persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoDirectSpec.scala
	persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoDocumentExamplesSpec.scala
	persistence/record/src/test/scala/net/liftweb/record/RecordSpec.scala
	project/Build.scala
	project/Dependencies.scala
	web/webkit/src/main/scala/net/liftweb/http/CometActor.scala
	web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala
	web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
  • Loading branch information
Shadowfiend committed Jun 20, 2014
2 parents aa429b2 + 33c1b26 commit 6de5cd2
Show file tree
Hide file tree
Showing 80 changed files with 1,500 additions and 510 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -56,3 +56,5 @@ project/plugins/project
# Pax Runner (for easy OSGi launching)
runner

# ignore the sbt launcher
project/sbt-launch*
11 changes: 8 additions & 3 deletions build.sbt
Expand Up @@ -14,9 +14,9 @@ organizationName in ThisBuild := "WorldWide Conferencing, LLC"

scalaVersion in ThisBuild := "2.10.4"

crossScalaVersions in ThisBuild := Seq("2.10.0")
crossScalaVersions in ThisBuild := Seq("2.10.4")

libraryDependencies in ThisBuild <++= scalaVersion {sv => Seq(specs2(sv), scalacheck) }
libraryDependencies in ThisBuild <++= scalaVersion {sv => Seq(specs2(sv), scalacheck, scalatest(sv)) }

// Settings for Sonatype compliance
pomIncludeRepository in ThisBuild := { _ => false }
Expand All @@ -25,8 +25,13 @@ publishTo in ThisBuild <<= isSnapshot(if (_) Some(Opts.resolver.sonat

scmInfo in ThisBuild := Some(ScmInfo(url("https://github.com/lift/framework"), "scm:git:https://github.com/lift/framework.git"))

pomExtra in ThisBuild ~= (_ ++ {Developers.toXml})
pomExtra in ThisBuild := Developers.toXml

credentials in ThisBuild <+= state map { s => Credentials(BuildPaths.getGlobalSettingsDirectory(s, BuildPaths.getGlobalBase(s)) / ".credentials") }

initialize <<= (name, version, scalaVersion) apply printLogo

resolvers in ThisBuild ++= Seq(
"snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"releases" at "https://oss.sonatype.org/content/repositories/releases"
)
12 changes: 12 additions & 0 deletions contributors.md
Expand Up @@ -209,3 +209,15 @@ Robert Freytag

### Email: ###
robertfreytag+lift at gmail .. com

### Name: ###
Mikhail Limansky

### Email: ###
mike.limansky at gmail dot com

### Name: ###
Aleksey Izmailov

### Email: ###
izmailoff at gmail dot com
Expand Up @@ -19,13 +19,14 @@ package common

import xml.{NodeSeq, Text}

import org.specs2.matcher.XmlMatchers
import org.specs2.mutable.Specification


/**
* System under specification for Conversions.
*/
class ConversionsSpec extends Specification {
class ConversionsSpec extends Specification with XmlMatchers {

"A StringOrNodeSeq" should {

Expand Down
Expand Up @@ -28,23 +28,25 @@ import org.scalatest.junit.JUnitRunner
* Tests the Line Tokenizer that prepares input for parsing.
*/
@RunWith(classOf[JUnitRunner])
class LineTokenizerTest extends LineTokenizer with FlatSpec with ShouldMatchers {
class LineTokenizerTest extends FlatSpec with ShouldMatchers {

val tokenizer = new LineTokenizer

"The LineTokenizer" should "split input lines correctly" in {
splitLines("line1\nline2\n") should equal (List("line1", "line2"))
splitLines("line1\nline2 no nl") should equal (List("line1", "line2 no nl"))
splitLines("test1\n\ntest2\n") should equal (List("test1", "", "test2"))
splitLines("test1\n\ntest2\n\n") should equal (List("test1", "", "test2"))
splitLines("\n\n") should equal (Nil)
splitLines("\n") should equal (Nil)
splitLines("") should equal (List(""))
tokenizer.splitLines("line1\nline2\n") should equal (List("line1", "line2"))
tokenizer.splitLines("line1\nline2 no nl") should equal (List("line1", "line2 no nl"))
tokenizer.splitLines("test1\n\ntest2\n") should equal (List("test1", "", "test2"))
tokenizer.splitLines("test1\n\ntest2\n\n") should equal (List("test1", "", "test2"))
tokenizer.splitLines("\n\n") should equal (Nil)
tokenizer.splitLines("\n") should equal (Nil)
tokenizer.splitLines("") should equal (List(""))
}

it should "preprocess the input correctly" in {
tokenize("[foo]: http://example.com/ \"Optional Title Here\"") should equal(
tokenizer.tokenize("[foo]: http://example.com/ \"Optional Title Here\"") should equal(
(new MarkdownLineReader(List(), Map( "foo"->new LinkDefinition("foo", "http://example.com/", Some("Optional Title Here")) )) ) )

tokenize(
tokenizer.tokenize(
"""[Baz]: http://foo.bar
'Title next line'
some text
Expand All @@ -68,8 +70,8 @@ new OtherLine("more text")

it should "parse different line types" in {
def p(line:String) = {
lineToken(new LineReader(Seq(line))) match {
case Success(result, _) => result
tokenizer.lineToken(new LineReader(Seq(line))) match {
case tokenizer.Success(result, _) => result
case _ => fail("Line tokenization failed.")
}
}
Expand Down
87 changes: 59 additions & 28 deletions core/util/src/main/scala/net/liftweb/util/Mailer.scala
Expand Up @@ -286,38 +286,69 @@ trait Mailer extends SimpleInjector {
*/
protected def buildMailBody(tab: MailBodyType): BodyPart = {
val bp = new MimeBodyPart
tab match {
case PlainMailBodyType(txt) => bp.setText(txt, "UTF-8")
case PlainPlusBodyType(txt, charset) => bp.setText(txt, charset)
case XHTMLMailBodyType(html) => bp.setContent(encodeHtmlBodyPart(html), "text/html; charset=" + charSet)

case XHTMLPlusImages(html, img@_*) =>
val html_mp = new MimeMultipart("related")
val bp2 = new MimeBodyPart
bp2.setContent(encodeHtmlBodyPart(html), "text/html; charset=" + charSet)
html_mp.addBodyPart(bp2)
img.foreach {
i =>
val rel_bpi = new MimeBodyPart
rel_bpi.setFileName(i.name)
rel_bpi.setContentID(i.name)
rel_bpi.setDisposition(if (!i.attachment) "inline" else "attachment")
rel_bpi.setDataHandler(new javax.activation.DataHandler(new javax.activation.DataSource {
def getContentType = i.mimeType

def getInputStream = new java.io.ByteArrayInputStream(i.bytes)

def getName = i.name

def getOutputStream = throw new java.io.IOException("Unable to write to item")
}))
html_mp.addBodyPart(rel_bpi)
}
bp.setContent(html_mp)

tab match {
case PlainMailBodyType(txt) =>
bp.setText(txt, "UTF-8")

case PlainPlusBodyType(txt, charset) =>
bp.setText(txt, charset)

case XHTMLMailBodyType(html) =>
bp.setContent(encodeHtmlBodyPart(html), "text/html; charset=" + charSet)

case XHTMLPlusImages(html, img@_*) =>
val (attachments, images) = img.partition(_.attachment)
val relatedMultipart = new MimeMultipart("related")

val htmlBodyPart = new MimeBodyPart
htmlBodyPart.setContent(encodeHtmlBodyPart(html), "text/html; charset=" + charSet)
relatedMultipart.addBodyPart(htmlBodyPart)

images.foreach { image =>
relatedMultipart.addBodyPart(buildAttachment(image))
}

if (attachments.isEmpty) {
bp.setContent(relatedMultipart)
} else {
// Some old versions of Exchange server will not behave correclty without
// a mixed multipart wrapping file attachments. This appears to be linked to
// specific versions of Exchange and Outlook. See the discussion at
// https://github.com/lift/framework/pull/1569 for more details.
val mixedMultipart = new MimeMultipart("mixed")

val relatedMultipartBodypart = new MimeBodyPart
relatedMultipartBodypart.setContent(relatedMultipart)
mixedMultipart.addBodyPart(relatedMultipartBodypart)

attachments.foreach { attachment =>
mixedMultipart.addBodyPart(buildAttachment(attachment))
}

bp.setContent(mixedMultipart)
}
}

bp
}

private def buildAttachment(holder: PlusImageHolder) = {
val part = new MimeBodyPart

part.setFileName(holder.name)
part.setContentID(holder.name)
part.setDisposition(if (holder.attachment) Part.ATTACHMENT else Part.INLINE)
part.setDataHandler(new javax.activation.DataHandler(new javax.activation.DataSource {
def getContentType = holder.mimeType
def getInputStream = new java.io.ByteArrayInputStream(holder.bytes)
def getName = holder.name
def getOutputStream = throw new java.io.IOException("Unable to write to item")
}))

part
}


/**
* Asynchronously send an email.
Expand Down
9 changes: 9 additions & 0 deletions core/util/src/main/scala/net/liftweb/util/Maker.scala
Expand Up @@ -131,12 +131,21 @@ trait StackableMaker[T] extends Maker[T] {
case x => x
}

/**
* Changes to the stack of Makers made by this method are thread-local!
*/
def doWith[F](value: T)(f: => F): F =
doWith(PValueHolder(Maker(value)))(f)

/**
* Changes to the stack of Makers made by this method are thread-local!
*/
def doWith[F](vFunc: () => T)(f: => F): F =
doWith(PValueHolder(Maker(vFunc)))(f)

/**
* Changes to the stack of Makers made by this method are thread-local!
*/
def doWith[F](addl: PValueHolder[Maker[T]])(f: => F): F = {
val old = _stack.get()
_stack.set(addl :: stack)
Expand Down
85 changes: 85 additions & 0 deletions core/util/src/main/scala/net/liftweb/util/Position.scala
@@ -0,0 +1,85 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */

package scala
package io

/** The object Position provides convenience methods to encode
* line and column number in one single integer. The encoded line
* (column) numbers range from 0 to `LINE_MASK` (`COLUMN_MASK`),
* where `0` indicates that the line (column) is undefined and
* `1` represents the first line (column).
*
* Line (Column) numbers greater than `LINE_MASK` (`COLUMN_MASK`) are
* replaced by `LINE_MASK` (`COLUMN_MASK`). Furthermore, if the encoded
* line number is `LINE_MASK`, the column number is always set to 0.
*
* The following properties hold:
*
* the undefined position is 0: `encode(0,0) == 0`
* encodings are non-negative : `encode(line,column) >= 0`
* position order is preserved:
* {{{
* (line1 <= line2) || (line1 == line2 && column1 <= column2)
* }}}
* implies
* {{{
* encode(line1,column1) <= encode(line2,column2)
* }}}
* @author Burak Emir (translated from work by Matthias Zenger and others)
*/

/**
* This was made private in scala 2.11.0 but there is no alternative for us to use, so here, copy/paste for now.
*/

@deprecated("This class will be removed.", "2.10.0")
abstract class Position {
/** Definable behavior for overflow conditions.
*/
def checkInput(line: Int, column: Int): Unit

/** Number of bits used to encode the line number */
final val LINE_BITS = 20
/** Number of bits used to encode the column number */
final val COLUMN_BITS = 31 - LINE_BITS // no negatives => 31
/** Mask to decode the line number */
final val LINE_MASK = (1 << LINE_BITS) - 1
/** Mask to decode the column number */
final val COLUMN_MASK = (1 << COLUMN_BITS) - 1

/** Encodes a position into a single integer. */
final def encode(line: Int, column: Int): Int = {
checkInput(line, column)

if (line >= LINE_MASK)
LINE_MASK << COLUMN_BITS
else
(line << COLUMN_BITS) | scala.math.min(COLUMN_MASK, column)
}

/** Returns the line number of the encoded position. */
final def line(pos: Int): Int = (pos >> COLUMN_BITS) & LINE_MASK

/** Returns the column number of the encoded position. */
final def column(pos: Int): Int = pos & COLUMN_MASK

/** Returns a string representation of the encoded position. */
def toString(pos: Int): String = line(pos) + ":" + column(pos)
}

object Position extends Position {
def checkInput(line: Int, column: Int) {
if (line < 0)
throw new IllegalArgumentException(line + " < 0")
if ((line == 0) && (column != 0))
throw new IllegalArgumentException(line + "," + column + " not allowed")
if (column < 0)
throw new IllegalArgumentException(line + "," + column + " not allowed")
}
}
Expand Up @@ -165,7 +165,7 @@ object BasicTypesHelpersSpec extends Specification with DataTables {

"put a guard around a partial function" in {
val pf1: PartialFunction[String, Unit] = {
case s if s.startsWith("s") => true
case s if s.startsWith("s") =>
}

val pf2: PartialFunction[String, Boolean] = {
Expand Down
Expand Up @@ -21,13 +21,14 @@ import java.util.Locale

import xml.NodeSeq

import org.specs2.matcher.XmlMatchers
import org.specs2.mutable.Specification


/**
* Systems under specification for BundleBuilder.
*/
object BundleBuilderSpec extends Specification {
object BundleBuilderSpec extends Specification with XmlMatchers {
"BundleBuilder Specification".title

"BundleBuilder" should {
Expand Down
Expand Up @@ -106,6 +106,8 @@ object CombParserHelpersSpec extends Specification with ScalaCheck {
result.get.toString must_== "()"
result.next.atEnd must beTrue
}

success
}
val parserA = elem("a", (c: Char) => c == 'a')
val parserB = elem("b", (c: Char) => c == 'b')
Expand Down
Expand Up @@ -17,6 +17,7 @@
package net.liftweb
package util

import org.specs2.matcher.XmlMatchers
import org.specs2.mutable.Specification

import common._
Expand All @@ -27,7 +28,7 @@ import Helpers._
/**
* Systems under specification for CSS Selector.
*/
object CssSelectorSpec extends Specification {
object CssSelectorSpec extends Specification with XmlMatchers {
"CSS Selector Specification".title

"CssSelector" should {
Expand Down Expand Up @@ -227,7 +228,7 @@ object CssSelectorSpec extends Specification {

}

object CssBindHelpersSpec extends Specification {
object CssBindHelpersSpec extends Specification with XmlMatchers {

"css bind helpers" should {
"clear clearable" in {
Expand Down
Expand Up @@ -65,10 +65,7 @@ object Html5ParserSpec extends Specification with PendingUntilFixed with Html5Pa

"fail to parse invalid page type3" in {
val parsed = parse(page3)
parsed match {
case _: Failure => true must_== true
case _ => failure("succeeded parsing invalid page")
}
parsed must beAnInstanceOf[Failure]
}.pendingUntilFixed

case _ =>
Expand Down

0 comments on commit 6de5cd2

Please sign in to comment.