Closed zuriar closed 10 years ago
I took the liberty to change the title a little, to make it more descriptive.
Your code could be a bit smaller and safer, if you removed the argument Option
, the return
s, and made the match
exhaustive:
def extractMediaLink(doc: io.prismic.Document, field: String): Option[String] =
doc getLink field match {
case Some(link: io.prismic.Fragment.MediaLink) => Some(link.toString())
case _ => None
}
Now I'm looking into adding support for Link.file
and Link.image
, I'll keep you updated here.
Fragment.MediaLink
is now supported; please upgrade the kit to 1.0-M9
.
Cheers!
Many thanks for the quick fix.
I have amended my SBT build to include:
// Prismic.io Maven repository resolvers += "Prismic.io kits" at "https://github.com/prismicio/repository/raw/master/maven/",
// The Scala kit
libraryDependencies += "io.prismic" %% "scala-kit" % "1.0-M9",
but get
io.prismic#scala-kit_2.10;1.0-M9: not found
on build. Is the new version actually reachable yet?
thanks Hugh
-----Original Message----- From: "Thibault Duplessis" notifications@github.com Sent: Thursday, March 20, 2014 10:57am To: "prismicio/scala-kit" scala-kit@noreply.github.com Cc: "zuriar" hugh@zuriar.com Subject: Re: [scala-kit] Support for Link.file and Link.image (#8)
Fragment.MediaLink
is now supported; please upgrade the kit to 1.0-M9
.
Cheers!
Reply to this email directly or view it on GitHub: https://github.com/prismicio/scala-kit/issues/8#issuecomment-38176762
Please paste the complete sbt output. There seems to be issue with serving the jars from raw.githubusercontent.com today.
@ornicar
SBT output when building against M9
$ ~/play-2.2.1/play compile [info] Loading project definition from /*/project [info] Set current project to**** (in build file:/***/) [info] Updating {file:/(****) [info] Resolving io.prismic#scala-kit_2.10;1.0-M9 ... [error] Server access Error: handshake alert: unrecognized_name url=https://github.com/prismicio/repository/raw/master/maven/io/prismic/scala-kit_2.10/1.0-M9/scala-kit_2.10-1.0-M9.pom [warn] module not found: io.prismic#scala-kit_2.10;1.0-M9 [warn] ==== local: tried [warn] /home/hugh/play-2.2.1/repository/local/io.prismic/scala-kit_2.10/1.0-M9/ivys/ivy.xml [warn] ==== Maven2 Local: tried [warn] file:/home/hugh/.m2/repository/io/prismic/scala-kit_2.10/1.0-M9/scala-kit_2.10-1.0-M9.pom [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/io/prismic/scala-kit_2.10/1.0-M9/scala-kit_2.10-1.0-M9.pom [warn] ==== Typesafe Releases Repository: tried [warn] http://repo.typesafe.com/typesafe/releases/io/prismic/scala-kit_2.10/1.0-M9/scala-kit_2.10-1.0-M9.pom [warn] ==== Prismic.io kits: tried [warn] https://github.com/prismicio/repository/raw/master/maven/io/prismic/scala-kit_2.10/1.0-M9/scala-kit_2.10-1.0-M9.pom [info] Resolving org.fusesource.jansi#jansi;1.4 ... [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: io.prismic#scala-kit_2.10;1.0-M9: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: sbt.ResolveException: unresolved dependency: io.prismic#scala-kit_2.10;1.0-M9: not found at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:213) at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122) at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121) at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116) at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116) at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:104) at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:51) at sbt.IvySbt$$anon$3.call(Ivy.scala:60) at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:98) at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81) at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102) at xsbt.boot.Using$.withResource(Using.scala:11) at xsbt.boot.Using$.apply(Using.scala:10) at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62) at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52) at xsbt.boot.Locks$.apply0(Locks.scala:31) at xsbt.boot.Locks$.apply(Locks.scala:28) at sbt.IvySbt.withDefaultLogger(Ivy.scala:60) at sbt.IvySbt.withIvy(Ivy.scala:101) at sbt.IvySbt.withIvy(Ivy.scala:97) at sbt.IvySbt$Module.withModule(Ivy.scala:116) at sbt.IvyActions$.update(IvyActions.scala:121) at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1144) at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1142) at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$73.apply(Defaults.scala:1165) at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$73.apply(Defaults.scala:1163) at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:35) at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1167) at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1162) at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:45) at sbt.Classpaths$.cachedUpdate(Defaults.scala:1170) at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1135) at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1113) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42) at sbt.std.Transform$$anon$4.work(System.scala:64) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18) at sbt.Execute.work(Execute.scala:244) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160) at sbt.CompletionService$$anon$2.call(CompletionService.scala:30) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) error sbt.ResolveException: unresolved dependency: io.prismic#scala-kit_2.10;1.0-M9: not found [error] Total time: 4 s, completed 20-Mar-2014 16:34:33
Things are very wrong on github side today. Try running your sbt with this flag:
sbt -Djsse.enableSNIExtension=false
I am building through play compile? Will this flag still work?
edit: I ran : $ play compile -Djsse.enableSNIExtension=false
and still got the same error
There's only way to know.
ok, the flag works on an SBT build. dunno how to get it to work from the play command
edit: turns out I am not too bright, just do:
$ play -Djsse.enableSNIExtension=false
[project] compile
and it finds and downloads the M9 build correctly. Not sure this is the best way to use SBT though? Where lies the problem?
Ok, so now M9 breaks my code which was working under M5.
It appears that ctx.api.forms(..).ref(ctx.ref).submit() has been changed from returning a Future[Seq[Document]] to a Future[Seq[Response]]
This code works fine in build M5 -
def getCollection(collectionName: Option[String] = None)(implicit ctx:Prismic.Context): Future[Seq[Document]] = {
collectionName match {
case Some(n:String) => { ctx.api.forms(n).ref(ctx.ref).submit() }
case None => { Future.successful(Nil) }
}
}
In build M9 - I get compile error -
found: scala.concurrent.Future[io.prismic.Response]] required: scala.concurrent.Future[io.prismic.Document]]
The API docs at: prismicio.github.io/scala-kit/ does not list a Response as part of io.prismic but there is one for io.prismic.core.Response (which looks low level to me).
Need to get this fixed, so please send me to the updated API docs or walk me through the changes. Thanks
There has been breaking changes since M5, as you found out. Hopeful it's pretty simple to fix on your side.
Basically, where you formerly received a Seq[Document]
, you now get a Response
. It is a paginator for a Seq[Document]
: https://github.com/prismicio/scala-kit/blob/master/src/main/scala/Api.scala#L150-L158
You can get your documents back by calling response.results
.
thank you, when will the main scala Docs be updated and improved?
I intend to give it a spin tomorrow.
in the Json a pdf is described as a Media Link but comes out as:
type: "Link.file"
In the Scala API Document has a function getLink(field:String):Option[Link] where Link is the supertype of DocumentLink, MediaLink, WebLink. However the call to doc.getLink("news-article.pdf") below does not match anything with a Some(link:io.prismic.Fragment.MediaLink)
It does work fine on a DocumentLink and a WebLink which leads me to believe that the Api has changed? Also the Json from the Prismic Browser (below) indicates that the type is now Link.File?
The same code checking for- link:io.prismic.Fragment.WebLink and .DocumentLink works fine and picks up the fragment ok.
Looking at the API browser I see the fragment is described in Json as the following (the important part is the Link.file: