Skip to content
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
33 changes: 15 additions & 18 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ class Application @Inject() (
message.toSeq.map(Html.apply)
}

def index = Action.async { implicit request =>
def index = Action.async { case given Request[AnyContent] =>
membersSummariser.fetchMembers.map { members =>
Ok(html.index(members, releases))
}
}

def widget(version: Option[String]) = Action.async { request =>
def widget(version: Option[String]) = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(views.html.widget(news(version))),
)
}

// This used to be the download/getting-started page. We are keeping
// the URL for SEO purposes only.
def download = Action.async { implicit request =>
def download = Action.async { case given Request[AnyContent] =>
Future.successful(
MovedPermanently(routes.Application.gettingStarted.path),
)
}

def gettingStarted = Action.async { implicit request =>
def gettingStarted = Action.async { case given Request[AnyContent] =>
exampleProjectsService.cached() match {
case Some(cached) =>
val examples = toExamples(cached)
Expand All @@ -108,8 +108,8 @@ class Application @Inject() (
}
}

def allreleases(platform: Option[String] = None) = Action.async { implicit request =>
val selectedPlatform = Platform(platform.orElse(request.headers.get("User-Agent")))
def allreleases(platform: Option[String] = None) = Action.async { case given Request[AnyContent] =>
val selectedPlatform = Platform(platform.orElse(summon[Request[AnyContent]].headers.get("User-Agent")))
Future.successful(
Ok(html.allreleases(releases, selectedPlatform)),
)
Expand All @@ -118,9 +118,7 @@ class Application @Inject() (
def changelog =
markdownAction(
"public/markdown/changelog.md",
{ implicit request =>
views.html.changelog(_)
},
views.html.changelog(_),
)

def conduct = Action {
Expand All @@ -130,17 +128,15 @@ class Application @Inject() (
def communityProcess =
markdownAction(
"public/markdown/community-process.md",
{ implicit request => markdown =>
views.html.markdownPage("Community process", markdown)
},
markdown => views.html.markdownPage("Community process", markdown),
)

def contributing = Action {
Redirect("https://github.com/playframework/.github/blob/main/CONTRIBUTING.md")
}

def markdownAction(markdownFile: String, template: RequestHeader => Html => Html) = Action.async {
implicit request =>
def markdownAction(markdownFile: String, template: RequestHeader ?=> Html => Html) = Action.async {
case given RequestHeader =>
def readInputStream(is: InputStream): String =
try {
IOUtils.toString(is, "utf-8")
Expand All @@ -166,7 +162,7 @@ class Application @Inject() (
page match {
case Some(content) =>
Future.successful(
Ok(template(request)(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000"),
Ok(template(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000"),
)
case None =>
Future.successful(
Expand All @@ -175,13 +171,13 @@ class Application @Inject() (
}
}

def getInvolved = Action.async { implicit request =>
def getInvolved = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.getInvolved()),
)
}

def sponsors = Action.async { implicit request =>
def sponsors = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.sponsors()),
)
Expand All @@ -192,7 +188,8 @@ class Application @Inject() (
MovedPermanently(url)
}

def onHandlerNotFound(route: String) = Action.async { implicit request =>
def onHandlerNotFound(route: String) = Action.async { case given Request[AnyContent] =>
val request = summon[Request[AnyContent]]
if (
route.startsWith("play-") && route.endsWith("-released") && !route
.contains("-rc") && !route.contains("-m")
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/Blog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ class Blog @Inject() (

val blogName = "Play Framework Blog"

def index() = Action.async { implicit request =>
def index() = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.blog.index(blogName)),
)
}

def graal() = Action.async { implicit request =>
def graal() = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.blog.graal(blogName, "Running Play on GraalVM")),
)
}

def socketio() = Action.async { implicit request =>
def socketio() = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.blog.socketio(blogName, "Play socket.io support")),
)
}

def ossPledgeLaunch() = Action.async { implicit request =>
def ossPledgeLaunch() = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(html.blog.ossPledgeLaunch(blogName, "Celebrating the Launch of the Open Source Pledge")),
)
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/Code.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package controllers
import javax.inject.Inject

import play.api.mvc.AbstractController
import play.api.mvc.AnyContent
import play.api.mvc.ControllerComponents
import play.api.mvc.Request
import services.github.ContributorsSummariser

import scala.concurrent.ExecutionContext

class Code @Inject() (contributorsSummariser: ContributorsSummariser, components: ControllerComponents)(implicit
class Code @Inject() (contributorsSummariser: ContributorsSummariser, components: ControllerComponents)(using
executionContext: ExecutionContext,
reverseRouter: documentation.ReverseRouter,
) extends AbstractController(components) {

def index = Action.async { implicit req =>
def index = Action.async { case given Request[AnyContent] =>
contributorsSummariser.fetchContributors.map { contributors =>
Ok(views.html.code(contributors))
}
Expand Down
31 changes: 16 additions & 15 deletions app/controllers/Modules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
reverseRouter: documentation.ReverseRouter,
) extends AbstractController(components) {

def index(keyword: String) = Action.async { implicit request =>
def index(keyword: String) = Action.async { case given Request[AnyContent] =>
Future.successful(
render {
case Accepts.Html() =>
Expand All @@ -29,7 +29,7 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
)
}

def download(name: String, version: String) = Action.async { implicit request =>
def download(name: String, version: String) = Action.async { case given Request[AnyContent] =>
modulesLookup.findModule(name, version) match {
case Some(zip) =>
Future.successful(
Expand All @@ -42,20 +42,21 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
}
}

def documentation(name: String, version: String, page: String) = Action.async { implicit request =>
modulesLookup.loadModuleDocumentation(name, version, page) match {
case Some(content) =>
Future.successful(
Ok(views.html.modules.documentation(name, content)),
)
case None =>
Future.successful(
PageNotFound,
)
}
def documentation(name: String, version: String, page: String) = Action.async {
case given Request[AnyContent] =>
modulesLookup.loadModuleDocumentation(name, version, page) match {
case Some(content) =>
Future.successful(
Ok(views.html.modules.documentation(name, content)),
)
case None =>
Future.successful(
PageNotFound,
)
}
}

def show(name: String) = Action.async { implicit request =>
def show(name: String) = Action.async { case given Request[AnyContent] =>
moduleDao.findById(name) match {
case Some((module, releases)) =>
Future.successful(
Expand All @@ -68,7 +69,7 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
}
}

def dependencies(name: String, version: String) = Action.async { implicit request =>
def dependencies(name: String, version: String) = Action.async { case given Request[AnyContent] =>
modulesLookup.findDependencies(name, version) match {
case Some(yml) =>
Future.successful(Ok(yml))
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/Outreachy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package controllers
import javax.inject.Inject

import play.api.mvc.AbstractController
import play.api.mvc.AnyContent
import play.api.mvc.ControllerComponents
import play.api.mvc.Request

import scala.concurrent.Future

Expand All @@ -16,13 +18,13 @@ class Outreachy @Inject() (components: ControllerComponents)(using

// def outreachy = Action(Redirect(routes.Outreachy.round15))

def round10 = Action.async { implicit req =>
def round10 = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(views.html.outreachy.round10()),
)
}

def round15 = Action.async { implicit req =>
def round15 = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(views.html.outreachy.round15()),
)
Expand Down
8 changes: 5 additions & 3 deletions app/controllers/Security.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package controllers
import javax.inject.Inject
import javax.inject.Singleton

import play.api.mvc.AnyContent
import play.api.mvc.BaseController
import play.api.mvc.ControllerComponents
import play.api.mvc.Request
import play.api.Environment
import play.twirl.api.Html
import utils.Markdown
Expand All @@ -13,12 +15,12 @@ import java.io.File
import scala.concurrent.Future

@Singleton
class Security @Inject() (environment: Environment, val controllerComponents: ControllerComponents)(implicit
class Security @Inject() (environment: Environment, val controllerComponents: ControllerComponents)(using
val reverseRouter: documentation.ReverseRouter,
) extends BaseController
with Common {

def vulnerability(name: String) = Action.async { implicit req =>
def vulnerability(name: String) = Action.async { case given Request[AnyContent] =>
val path = "public/markdown/vulnerabilities/" + name

// protect against dot dots
Expand Down Expand Up @@ -51,7 +53,7 @@ class Security @Inject() (environment: Environment, val controllerComponents: Co
}
}

def index = Action.async { implicit req =>
def index = Action.async { case given Request[AnyContent] =>
Future.successful(
Ok(views.html.vulnerabilities()).withHeaders(CACHE_CONTROL -> "max-age=1000"),
)
Expand Down
Loading
Loading