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
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cmd: |
# Clone generated docs so that we can run some integration tests
git clone -o origin https://github.com/playframework/play-generated-docs.git $PWD/data/generated
sbt ++$MATRIX_SCALA test
sbt ++$MATRIX_SCALA scalafmtSbtCheck scalafmtCheckAll test

finish:
name: Finish
Expand Down
7 changes: 4 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
align = more
runner.dialect = Scala3
align.preset = more
assumeStandardLibraryStripMargin = true
danglingParentheses = true
docstrings = JavaDoc
danglingParentheses.preset = true
docstrings.style = keep
maxColumn = 112
project.git = true
rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifiers, PreferCurlyFors ]
Expand Down
2 changes: 1 addition & 1 deletion app/actors/DocumentationActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class DocumentationActor(
* Get the translation context for the given language and version.
*/
def translationContext(lang: Lang, version: Version, translation: Translation): TranslationContext = {
val isDefault = lang == documentation.defaultLang
val isDefault = lang == documentation.defaultLang
val defaultAlternative = AlternateTranslation(
documentation.defaultLang,
true,
Expand Down
2 changes: 1 addition & 1 deletion app/actors/DocumentationLoadingActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object DocumentationLoadingActor {
val sheets = sortedSheets.flatMap { file =>
repo.loadFile(s"cheatsheets/$category/$file")(is => Textile.toHTML(IOUtils.toString(is, "utf-8")))
}
val title = CheatSheetHelper.getCategoryTitle(category)
val title = CheatSheetHelper.getCategoryTitle(category)
val otherCategories = CheatSheetHelper
.listCategoriesAndTitles(
repo
Expand Down
12 changes: 6 additions & 6 deletions app/actors/DocumentationPollingActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class DocumentationPollingActor(
old.flatMap(_.default.byVersion.get(version)) match {
// The version hasn't changed, don't rescan
case Some(same: TranslationVersion) if same.cacheId == newCacheId => same
case _ =>
case _ =>
implicit val lang = repos.default.config.lang

if (old.isDefined) {
Expand All @@ -144,15 +144,15 @@ class DocumentationPollingActor(
// Now for each translation
val translations = repos.translations.map { t =>
// Parse all the versions from tags, branches and the main version
val gitTags = parseVersionsFromRefs(t.repo.allTags).map(v => (v._1, v._2, v._1.name))
val gitTags = parseVersionsFromRefs(t.repo.allTags).map(v => (v._1, v._2, v._1.name))
val gitBranches = parseVersionsFromRefs(
t.repo.allBranches
.filter(_._1.matches("""\d+\.\d+\.x""")),
).map(v => (v._1, v._2, v._1.name))
val mainVersion = determineMainVersion(t).map(v => (v._1, v._2, "main"))

implicit val lang = t.config.lang
val versions = versionsToTranslations(
val versions = versionsToTranslations(
t.repo,
gitTags ++ gitBranches ++ mainVersion,
defaultTranslation,
Expand Down Expand Up @@ -184,8 +184,8 @@ class DocumentationPollingActor(
.sortBy(_._1)
.reverse
.map { version =>
val baseRepo = repo.fileRepoForHash(version._2)
val aggregateVersion = aggregate.byVersion.get(version._1)
val baseRepo = repo.fileRepoForHash(version._2)
val aggregateVersion = aggregate.byVersion.get(version._1)
val (fileRepo, cacheId) =
aggregateVersion.fold(baseRepo -> xorHashes(version._2.name, utils.SiteVersion.hash)) { default =>
new AggregateFileRepository(Seq(baseRepo, default.repo)) ->
Expand All @@ -195,7 +195,7 @@ class DocumentationPollingActor(
old.flatMap(_.byVersion.get(version._1)) match {
// The version hasn't changed, don't rescan
case Some(same: TranslationVersion) if same.cacheId == cacheId => same
case _ =>
case _ =>
val playDoc = new PlayDoc(
markdownRepository = fileRepo,
codeRepository = fileRepo,
Expand Down
33 changes: 19 additions & 14 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ class Application @Inject() (

}
.orElse {
if(version.isEmpty ||
if (
version.isEmpty ||
(version.exists(_.startsWith("2.")) && !version.contains(releases.latest2.version)) ||
(version.exists(_.startsWith("3.")) && !version.contains(releases.latest3.version))) {
(version.exists(_.startsWith("3.")) && !version.contains(releases.latest3.version))
) {
Some(
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>.""",
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 All @@ -76,15 +81,15 @@ class Application @Inject() (

def widget(version: Option[String]) = Action.async { request =>
Future.successful(
Ok(views.html.widget(news(version)))
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 =>
Future.successful(
MovedPermanently(routes.Application.gettingStarted.path)
MovedPermanently(routes.Application.gettingStarted.path),
)
}

Expand All @@ -106,7 +111,7 @@ class Application @Inject() (
def allreleases(platform: Option[String] = None) = Action.async { implicit request =>
val selectedPlatform = Platform(platform.orElse(request.headers.get("User-Agent")))
Future.successful(
Ok(html.allreleases(releases, selectedPlatform))
Ok(html.allreleases(releases, selectedPlatform)),
)
}

Expand Down Expand Up @@ -161,24 +166,24 @@ class Application @Inject() (
page match {
case Some(content) =>
Future.successful(
Ok(template(request)(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000")
Ok(template(request)(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000"),
)
case None =>
Future.successful(
notFound
notFound,
)
}
}

def getInvolved = Action.async { implicit request =>
Future.successful(
Ok(html.getInvolved())
Ok(html.getInvolved()),
)
}

def sponsors = Action.async { implicit request =>
Future.successful(
Ok(html.sponsors())
Ok(html.sponsors()),
)
}

Expand All @@ -197,15 +202,15 @@ class Application @Inject() (
.replace("-released", "")
.replace("-", ".")
Future.successful(
MovedPermanently(s"https://github.com/playframework/playframework/releases/tag/$version")
MovedPermanently(s"https://github.com/playframework/playframework/releases/tag/$version"),
)
} else if (route.endsWith("/")) {
Future.successful(
MovedPermanently("/" + request.path.take(request.path.length - 1).dropWhile(_ == '/'))
MovedPermanently("/" + request.path.take(request.path.length - 1).dropWhile(_ == '/')),
)
} else {
Future.successful(
notFound
notFound,
)
}
}
Expand Down Expand Up @@ -244,7 +249,7 @@ class Application @Inject() (
val sections = byVersion.map { case (v, p) =>
val TutorialKeyword = "tutorial" // this MUST be in the project keywords for this to work
val SeedKeyword = "seed"
val tutorials = p
val tutorials = p
.filter(e => e.keywords.contains(TutorialKeyword) && !e.hasParams)
.groupBy(byLanguage)
.view
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/Blog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class Blog @Inject() (

def index() = Action.async { implicit request =>
Future.successful(
Ok(html.blog.index(blogName))
Ok(html.blog.index(blogName)),
)
}

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

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

def ossPledgeLaunch() = Action.async { implicit request =>
Future.successful(
Ok(html.blog.ossPledgeLaunch(blogName, "Celebrating the Launch of the Open Source Pledge"))
Ok(html.blog.ossPledgeLaunch(blogName, "Celebrating the Launch of the Open Source Pledge")),
)
}
}
14 changes: 7 additions & 7 deletions app/controllers/Modules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
case Accepts.Json() =>
import Module.modulesWrites
Ok(Json.toJson(moduleDao.findEverything()))
}
},
)
}

def download(name: String, version: String) = Action.async { implicit request =>
modulesLookup.findModule(name, version) match {
case Some(zip) =>
Future.successful(
Ok.sendFile(zip)
Ok.sendFile(zip),
)
case None =>
Future.successful(
PageNotFound
PageNotFound,
)
}
}
Expand All @@ -46,11 +46,11 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
modulesLookup.loadModuleDocumentation(name, version, page) match {
case Some(content) =>
Future.successful(
Ok(views.html.modules.documentation(name, content))
Ok(views.html.modules.documentation(name, content)),
)
case None =>
Future.successful(
PageNotFound
PageNotFound,
)
}
}
Expand All @@ -59,11 +59,11 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
moduleDao.findById(name) match {
case Some((module, releases)) =>
Future.successful(
Ok(views.html.modules.show(module, releases))
Ok(views.html.modules.show(module, releases)),
)
case None =>
Future.successful(
PageNotFound
PageNotFound,
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/Outreachy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class Outreachy @Inject() (components: ControllerComponents)(implicit
reverseRouter: documentation.ReverseRouter,
) extends AbstractController(components) {

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

def round10 = Action.async { implicit req =>
Future.successful(
Ok(views.html.outreachy.round10())
Ok(views.html.outreachy.round10()),
)
}

def round15 = Action.async { implicit req =>
Future.successful(
Ok(views.html.outreachy.round15())
Ok(views.html.outreachy.round15()),
)
}
}
8 changes: 4 additions & 4 deletions app/controllers/Security.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ class Security @Inject() (environment: Environment, val controllerComponents: Co
"Play Framework Security Advisory",
Html(Markdown.toHtml(content, link => (link, link))),
),
).withHeaders(CACHE_CONTROL -> "max-age=10000")
).withHeaders(CACHE_CONTROL -> "max-age=10000"),
)
} finally {
is.close()
}
}
.getOrElse(
Future.successful(
notFound
)
notFound,
),
)
}
}

def index = Action.async { implicit req =>
Future.successful(
Ok(views.html.vulnerabilities()).withHeaders(CACHE_CONTROL -> "max-age=1000")
Ok(views.html.vulnerabilities()).withHeaders(CACHE_CONTROL -> "max-age=1000"),
)
}

Expand Down
Loading
Loading