Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Play 2.9 and 3.0 and make app handle both versions in parallel #557

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class Application @Inject() (

}
.orElse {
if (!version.contains(releases.latest.version)) {
if(version.isEmpty ||
(version.exists(_.startsWith("2.")) && !version.contains(releases.latest2.version)) ||
(version.exists(_.startsWith("3.")) && !version.contains(releases.latest3.version))) {
Some(
s"""Play framework ${releases.latest.version} is out! Check it out <a href="${routes.Application.download}">here</a>.""",
s"""Play framework ${if(version.isEmpty || version.exists(_.startsWith("3."))) releases.latest3.version else releases.latest2.version} is out! Check it out <a href="${routes.Application.download}">here</a>.""",
)
} else {
None
Expand Down
10 changes: 7 additions & 3 deletions app/controllers/documentation/DocumentationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class DocumentationController @Inject() (
}

def page(lang: Option[Lang], v: String, page: String) = VersionAction(v) { (actor, version) => implicit req =>
val linkFuture = canonicalLinkHeader(page)
val linkFuture = canonicalLinkHeader(page, version)
val resultFuture =
actorRequest(actor, page, replyTo => RenderPage(lang, version, etag(req), page, replyTo)) {
case RenderedPage(html, sidebarHtml, breadcrumbsHtml, source, context, cacheId) =>
Expand Down Expand Up @@ -321,8 +321,12 @@ class DocumentationController @Inject() (
}
}

private def canonicalLinkHeader(page: String) = {
val Array(epoch, major, minor) = releases.latest.version.split("\\.", 4)
private def canonicalLinkHeader(page: String, version: Version) = {
val playRelease = version.era match {
case 3 => releases.latest3
case _ => releases.latest2
}
val Array(epoch, major, minor) = playRelease.version.split("\\.", 4)
val latestVersion = Version.parse(s"$epoch.$major.x").get
documentationActor
.ask[Response[PageExists]](replyTo => QueryPageExists(None, latestVersion, None, page, replyTo))
Expand Down
2 changes: 1 addition & 1 deletion app/models/Releases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object PlayRelease {
implicit val releaseReads: Reads[PlayRelease] = Json.reads[PlayRelease]
}

case class PlayReleases(latest: PlayRelease, development: Seq[PlayRelease], previous: Seq[PlayRelease])
case class PlayReleases(latest3: PlayRelease, latest2: PlayRelease, development: Seq[PlayRelease], previous: Seq[PlayRelease])

object PlayReleases {
implicit val playReleasesReads: Reads[PlayReleases] = Json.reads[PlayReleases]
Expand Down
2 changes: 1 addition & 1 deletion app/services/releases/ReleasesModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PlayReleasesProvider @Inject() (environment: Environment) extends Provider
is.close()
}
}
.getOrElse(PlayReleases(PlayRelease("unknown", None, Some("unknown"), None, None), Nil, Nil))
.getOrElse(PlayReleases(PlayRelease("unknown", None, Some("unknown"), None, None), PlayRelease("unknown", None, Some("unknown"), None, None), Nil, Nil))
}

override def get(): PlayReleases = releases
Expand Down
4 changes: 2 additions & 2 deletions app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>
<div id="actions">
<div id="start">
<h2>Get Started</h2>
<a href="@routes.Application.download" class="button">Try Play <br> @releases.latest.version@for(name <- releases.latest.name){ "@name"}</a>
<a href="@routes.Application.download" class="button">Try Play <br> @releases.latest3.version or @releases.latest2.version@for(name <- releases.latest2.name){ "@name"}</a>
<p>
or <a href="@routes.Application.allreleases()">browse all versions</a>
</p>
Expand All @@ -33,7 +33,7 @@ <h2>Get Started</h2>
<div id="docs">
<h2>Read the Docs</h2>

<a href="@reverseRouter.index(None)" class="button">Documentation <br> @releases.latest.version@for(name <- releases.latest.name){ "@name"}</a>
<a href="@reverseRouter.index(None)" class="button">Documentation <br> @releases.latest3.version or @releases.latest2.version@for(name <- releases.latest2.name){ "@name"}</a>
<p>
or go to <a href="@reverseRouter.latest(None, "JavaHome")">Java docs</a> or <a href="@reverseRouter.latest(None, "ScalaHome")">Scala docs</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ opencollective.slug = "playframework"

# apiUrl not used currently, we use local json files in conf/playSamples_x.x.x.json currently
#examples.apiUrl = "https://example.lightbend.com/v1/api/templates"
examples.playVersions = [ "2.8.x" ]
examples.playVersions = [ "3.0.x", "2.9.x" ]
examples.cache.ttl = 1 hour

documentation.home=testdocs
Expand Down
18 changes: 11 additions & 7 deletions conf/playReleases.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"latest": {
"version": "2.8.20",
"date": "Jul 18 2023"
"latest3": {
"version": "3.0.0",
"date": "Oct 25 2023"
},
"latest2": {
"version": "2.9.0",
"date": "Oct 25 2023"
},
"development": [
{
"version": "2.9.0-RC2",
"date": "Sep 19 2023"
}
],
"previous": [
{
"version": "2.8.20",
"date": "Jul 18 2023"
},
{
"version": "2.8.19",
"date": "Jan 13 2023"
Expand Down
18 changes: 18 additions & 0 deletions public/markdown/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## Play 3.0.0

*Released 25 October 2023

[Highlights](https://playframework.com/documentation/3.0.x/Highlights30)
[Migration Guide](https://playframework.com/documentation/3.0.x/Migration30)
[All changes](https://github.com/playframework/playframework/compare/2.9.0...3.0.0/)
[GitHub milestone](https://github.com/playframework/playframework/milestone/129?closed=1)

## Play 2.9.0

*Released 25 October 2023

[Highlights](https://playframework.com/documentation/2.9.x/Highlights29)
[Migration Guide](https://playframework.com/documentation/2.9.x/Migration29)
[All changes](https://github.com/playframework/playframework/compare/2.8.0...2.9.0/)
[GitHub milestone](https://github.com/playframework/playframework/milestone/105?closed=1)

## Play 2.8.20

*Released 18 July 2023
Expand Down
Loading