Added simple support for RDFa - required by latest http://webid.info/spec . Also update KEYSTORE for a long life, and define BASE path in shell in an absolute way.
--- a/bin/rwsbt.sh Thu Nov 24 23:08:40 2011 +0100
+++ b/bin/rwsbt.sh Sun Nov 27 22:23:44 2011 +0100
@@ -1,6 +1,6 @@
#!/bin/bash
-export BASE=`dirname $0`/..
+BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
KS=$BASE/src/test/resources/KEYSTORE.jks
while [ $# -gt 0 ]
do
--- a/project/build.scala Thu Nov 24 23:08:40 2011 +0100
+++ b/project/build.scala Sun Nov 27 22:23:44 2011 +0100
@@ -1,7 +1,7 @@
import sbt._
import Keys._
-// some usefull libraries
+// some useful libraries
// they are pulled only if used
object Dependencies {
// val specs = "org.scala-tools.testing" %% "specs" % "1.6.9" % "test"
@@ -23,6 +23,8 @@
val slf4jSimple = "org.slf4j" % "slf4j-simple" % "1.6.4"
val antiXML = "com.codecommit" %% "anti-xml" % "0.4-SNAPSHOT" % "test"
val jena = "com.hp.hpl.jena" % "jena" % "2.6.4"
+ val rdfa = "net.rootdev" % "java-rdfa" % "0.4.2-RC2"
+ val htmlparser = "nu.validator.htmlparser" % "htmlparser" % "1.2.1"
val arq = "com.hp.hpl.jena" % "arq" % "2.8.8"
val grizzled = "org.clapper" %% "grizzled-scala" % "1.0.8" % "test"
val scalaz = "org.scalaz" %% "scalaz-core" % "6.0.3"
@@ -102,6 +104,8 @@
libraryDependencies += argot,
libraryDependencies += guava,
libraryDependencies += scalate,
+ libraryDependencies += rdfa,
+ libraryDependencies += htmlparser,
jarName in assembly := "read-write-web.jar"
)
--- a/src/main/scala/Lang.scala Thu Nov 24 23:08:40 2011 +0100
+++ b/src/main/scala/Lang.scala Sun Nov 27 22:23:44 2011 +0100
@@ -31,12 +31,16 @@
case RDFXML => "application/rdf+xml"
case TURTLE => "text/turtle"
case N3 => "text/n3"
+ case XHTML => "application/xhtml+xml"
+ case HTML => "text/html"
}
def jenaLang = this match {
case RDFXML => "RDF/XML-ABBREV"
case TURTLE => "TURTLE"
case N3 => "N3"
+ case HTML => "HTML"
+ case XHTML => "XHTML"
}
}
@@ -54,6 +58,8 @@
case "text/n3" => Some(N3)
case "text/turtle" => Some(TURTLE)
case "application/rdf+xml" => Some(RDFXML)
+ case "text/html" => Some(HTML)
+ case "text/xhtml" => Some(XHTML)
case _ => None
}
@@ -67,3 +73,7 @@
case object TURTLE extends Lang
case object N3 extends Lang
+
+case object XHTML extends Lang
+
+case object HTML extends Lang
\ No newline at end of file
--- a/src/main/scala/ReadWriteWebMain.scala Thu Nov 24 23:08:40 2011 +0100
+++ b/src/main/scala/ReadWriteWebMain.scala Sun Nov 27 22:23:44 2011 +0100
@@ -11,15 +11,10 @@
import org.clapper.argot._
import ArgotConverters._
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
-import unfiltered.scalate.Scalate
-import unfiltered.request.Path
-import org.fusesource.scalate.{Binding, TemplateEngine}
-import org.fusesource.scalate.scuery.Transformer
-import xml.XML
-import unfiltered.response.{HttpResponse, Html, Ok}
trait ReadWriteWebArgs {
val logger: Logger = LoggerFactory.getLogger(this.getClass)
+ new net.rootdev.javardfa.jena.RDFaReader //import rdfa parser
val postUsageMsg= Some("""
|PROPERTIES
@@ -78,7 +73,7 @@
object ReadWriteWebMain extends ReadWriteWebArgs {
- import unfiltered.filter.Planify
+ import unfiltered.filter.Planify
// regular Java main
def main(args: Array[String]) {
--- a/src/main/scala/WebCache.scala Thu Nov 24 23:08:40 2011 +0100
+++ b/src/main/scala/WebCache.scala Sun Nov 27 22:23:44 2011 +0100
@@ -59,7 +59,7 @@
res >:> { headers =>
val encoding = headers("Content-Type").headOption match {
case Some(mime) => Lang(mime) getOrElse Lang.default
- case None => RDFXML // it would be better to try to do a bit of guessing in this case by looking at content
+ case None => RDFXML //todo: it would be better to try to do a bit of guessing in this case by looking at content
}
val loc = headers("Content-Location").headOption match {
case Some(loc) => new URL(u,loc)
--- a/src/main/scala/auth/WebIdClaim.scala Thu Nov 24 23:08:40 2011 +0100
+++ b/src/main/scala/auth/WebIdClaim.scala Sun Nov 27 22:23:44 2011 +0100
@@ -45,7 +45,7 @@
:exponent ?e ].
}""")
- def hex(bytes: Array[Byte]): String = bytes.map("%02X" format _).mkString.stripPrefix("00")
+ def hex(bytes: Array[Byte]): String = bytes.dropWhile(_ == 0).map("%02X" format _).mkString
}
Binary file src/test/resources/KEYSTORE.jks has changed