-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1180 from gliderlabs/master
Release 0.9.0
- Loading branch information
Showing
34 changed files
with
421 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v247 | ||
v248 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ENERGY=20 GeV |
46 changes: 46 additions & 0 deletions
46
...packs/buildpack-scala/tests/scala/.g8/form/app/controllers/$model__Camel$Controller.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package controllers | ||
|
||
import javax.inject._ | ||
import play.api.mvc._ | ||
|
||
import play.api.data._ | ||
import play.api.data.Forms._ | ||
|
||
case class $model;format="Camel"$Data(name: String, age: Int) | ||
|
||
// NOTE: Add the following to conf/routes to enable compilation of this class: | ||
/* | ||
GET /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Get() | ||
POST /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Post() | ||
*/ | ||
|
||
/** | ||
* $model;format="Camel"$ form controller for Play Scala | ||
*/ | ||
class $model;format="Camel"$Controller @Inject()(mcc: MessagesControllerComponents) extends MessagesAbstractController(mcc) { | ||
|
||
val $model;format="camel"$Form = Form( | ||
mapping( | ||
"name" -> text, | ||
"age" -> number | ||
)($model;format="Camel"$Data.apply)($model;format="Camel"$Data.unapply) | ||
) | ||
|
||
def $model;format="camel"$Get() = Action { implicit request: MessagesRequest[AnyContent] => | ||
Ok(views.html.$model;format="camel"$.form($model;format="camel"$Form)) | ||
} | ||
|
||
def $model;format="camel"$Post() = Action { implicit request: MessagesRequest[AnyContent] => | ||
$model;format="camel"$Form.bindFromRequest().fold( | ||
formWithErrors => { | ||
// binding failure, you retrieve the form containing errors: | ||
BadRequest(views.html.$model;format="camel"$.form(formWithErrors)) | ||
}, | ||
$model;format="camel"$Data => { | ||
/* binding success, you get the actual value. */ | ||
/* flashing uses a short lived cookie */ | ||
Redirect(routes.$model;format="Camel"$Controller.$model;format="camel"$Get()).flashing("success" -> ("Successful " + $model;format="camel"$Data.toString)) | ||
} | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
buildpacks/buildpack-scala/tests/scala/.g8/form/app/views/$model__camel$/form.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@($model;format="camel"$Form: Form[$model;format="Camel"$Data])(implicit request: MessagesRequestHeader) | ||
|
||
<h1>$model;format="camel"$ form</h1> | ||
|
||
@request.flash.get("success").getOrElse("") | ||
|
||
@helper.form(action = routes.$model;format="Camel"$Controller.$model;format="camel"$Post()) { | ||
@helper.CSRF.formField | ||
@helper.inputText($model;format="camel"$Form("name")) | ||
@helper.inputText($model;format="camel"$Form("age")) | ||
<input type="submit" value="submit"/> | ||
} |
2 changes: 2 additions & 0 deletions
2
buildpacks/buildpack-scala/tests/scala/.g8/form/default.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
description = Generates a Controller with form handling | ||
model = user |
71 changes: 71 additions & 0 deletions
71
.../buildpack-scala/tests/scala/.g8/form/test/controllers/$model__Camel$ControllerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package controllers | ||
|
||
import play.api.mvc._ | ||
import play.api.i18n._ | ||
import org.scalatestplus.play._ | ||
import org.scalatestplus.play.guice.GuiceOneAppPerTest | ||
import play.api.http.FileMimeTypes | ||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import play.api.test.CSRFTokenHelper._ | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
/** | ||
* $model;format="Camel"$ form controller specs | ||
*/ | ||
class $model;format="Camel"$ControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting { | ||
|
||
// Provide stubs for components based off Helpers.stubControllerComponents() | ||
class StubComponents(cc:ControllerComponents = stubControllerComponents()) extends MessagesControllerComponents { | ||
override val parsers: PlayBodyParsers = cc.parsers | ||
override val messagesApi: MessagesApi = cc.messagesApi | ||
override val langs: Langs = cc.langs | ||
override val fileMimeTypes: FileMimeTypes = cc.fileMimeTypes | ||
override val executionContext: ExecutionContext = cc.executionContext | ||
override val actionBuilder: ActionBuilder[Request, AnyContent] = cc.actionBuilder | ||
override val messagesActionBuilder: MessagesActionBuilder = new DefaultMessagesActionBuilderImpl(parsers.default, messagesApi)(executionContext) | ||
} | ||
|
||
"$model;format="Camel"$Controller GET" should { | ||
|
||
"render the index page from a new instance of controller" in { | ||
val controller = new $model;format="Camel"$Controller(new StubComponents()) | ||
val request = FakeRequest().withCSRFToken | ||
val home = controller.$model;format="camel"$Get().apply(request) | ||
|
||
status(home) mustBe OK | ||
contentType(home) mustBe Some("text/html") | ||
} | ||
|
||
"render the index page from the application" in { | ||
val controller = inject[$model;format="Camel"$Controller] | ||
val request = FakeRequest().withCSRFToken | ||
val home = controller.$model;format="camel"$Get().apply(request) | ||
|
||
status(home) mustBe OK | ||
contentType(home) mustBe Some("text/html") | ||
} | ||
|
||
"render the index page from the router" in { | ||
val request = CSRFTokenHelper.addCSRFToken(FakeRequest(GET, "/$model;format="camel"$")) | ||
val home = route(app, request).get | ||
|
||
status(home) mustBe OK | ||
contentType(home) mustBe Some("text/html") | ||
} | ||
} | ||
|
||
"$model;format="Camel"$Controller POST" should { | ||
"process form" in { | ||
val request = { | ||
FakeRequest(POST, "/$model;format="camel"$") | ||
.withFormUrlEncodedBody("name" -> "play", "age" -> "4") | ||
} | ||
val home = route(app, request).get | ||
status(home) mustBe SEE_OTHER | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Note: Delete this file if you are copying the code in this repository into your own project. | ||
|
||
* @heroku/languages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
logs | ||
target | ||
/.bsp | ||
/.idea | ||
/.idea_modules | ||
/.classpath | ||
/.project | ||
/.settings | ||
/RUNNING_PID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Salesforce, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: target/universal/stage/bin/hello | ||
web: target/universal/stage/bin/scala-getting-started -Dhttp.port=${PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: target\universal\stage\bin\scala-getting-started.bat -Dhttp.port=${PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Scala: Getting Started | ||
|
||
A barebones Scala app, which can easily be deployed to Heroku. | ||
|
||
## Deploying to Heroku | ||
|
||
Using resources for this example app counts towards your usage. [Delete your app](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-apps-destroy) and [database](https://devcenter.heroku.com/articles/heroku-postgresql#removing-the-add-on) as soon as you are done experimenting to control costs. | ||
|
||
By default, apps use Eco dynos if you are subscribed to Eco. Otherwise, it defaults to Basic dynos. The Eco dynos plan is shared across all Eco dynos in your account and is recommended if you plan on deploying many small apps to Heroku. Learn more about our low-cost plans [here](https://blog.heroku.com/new-low-cost-plans). | ||
|
||
Eligible students can apply for platform credits through our new [Heroku for GitHub Students program](https://blog.heroku.com/github-student-developer-program). | ||
|
||
This application supports the [Getting Started with Scala on Heroku](https://devcenter.heroku.com/articles/getting-started-with-scala) article - check it out for instructions on how to deploy this app to Heroku and also run it locally. | ||
|
||
Alternatively, you can deploy it using this Heroku Button: | ||
|
||
[](https://heroku.com/deploy) | ||
|
||
For more information about using Scala on Heroku, see these Dev Center articles: | ||
|
||
- [Scala on Heroku](https://devcenter.heroku.com/categories/scala) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Start on Heroku: Scala", | ||
"description": "A barebones Scala app, which can easily be deployed to Heroku.", | ||
"addons": ["heroku-postgresql"] | ||
} |
33 changes: 33 additions & 0 deletions
33
buildpacks/buildpack-scala/tests/scala/app/controllers/Application.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package controllers | ||
|
||
import javax.inject._ | ||
import play.api._ | ||
import play.api.db.Database | ||
import play.api.mvc._ | ||
|
||
@Singleton | ||
class Application @Inject()(val controllerComponents: ControllerComponents, val database: Database) extends BaseController { | ||
|
||
def index(): Action[AnyContent] = Action { implicit request: Request[AnyContent] => | ||
Ok("scala") | ||
} | ||
|
||
def db(): Action[AnyContent] = Action { implicit request: Request[AnyContent] => | ||
// In this getting started app, we don't use a custom execution context to keep the code and configuration simple. | ||
// For real-world apps, consult the Play documentation on how to configure custom contexts and how to use them: | ||
// https://www.playframework.com/documentation/2.8.19/AccessingAnSQLDatabase#Using-a-CustomExecutionContext | ||
database.withConnection { connection => | ||
val statement = connection.createStatement() | ||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS ticks (tick timestamp)") | ||
statement.executeUpdate("INSERT INTO ticks VALUES (now())") | ||
|
||
val output = new StringBuilder(); | ||
val resultSet = statement.executeQuery("SELECT tick FROM ticks") | ||
while (resultSet.next()) { | ||
output.append("Read from DB: " + resultSet.getTimestamp("tick") + "\n") | ||
} | ||
|
||
Ok(output.toString()) | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
buildpacks/buildpack-scala/tests/scala/app/views/index.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@() | ||
@main { | ||
scala | ||
} |
2 changes: 2 additions & 0 deletions
2
buildpacks/buildpack-scala/tests/scala/app/views/main.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@(content: Html) | ||
@content |
33 changes: 33 additions & 0 deletions
33
buildpacks/buildpack-scala/tests/scala/app/views/nav.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<nav class="navbar navbar-default navbar-static-top navbar-inverse"> | ||
<div class="container"> | ||
<ul class="nav navbar-nav"> | ||
<li class="active"> | ||
<a href="/"><span class="glyphicon glyphicon-home"></span> Home</a> | ||
</li> | ||
<li> | ||
<a href="https://devcenter.heroku.com/articles/how-heroku-works"><span class="glyphicon glyphicon-user"></span> How Heroku Works</a> | ||
</li> | ||
<li class="dropdown"> | ||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-info-sign"></span> Getting Started Guides <span class="caret"></span></a> | ||
<ul class="dropdown-menu" role="menu"> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-ruby">Getting Started with Ruby on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs">Getting Started with Node on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-php">Getting Started with PHP on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-python">Getting Started with Python on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-scala">Getting Started with Java on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-go">Getting Started with Go on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-clojure">Getting Started with Clojure on Heroku</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-scala">Getting Started with Scala on Heroku</a></li> | ||
<li class="divider"></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-heroku-and-connect-without-local-dev">Getting Started on Heroku with Heroku Connect</a></li> | ||
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-jruby">Getting Started with Ruby on Heroku (Microsoft Windows)</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<ul class="nav navbar-nav navbar-right"> | ||
<li class="navbar-right"> | ||
<a href="https://devcenter.heroku.com"><span class="glyphicon glyphicon-book"></span> Heroku Dev Center</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
import NativePackagerKeys._ | ||
name := """scala-getting-started""" | ||
organization := "com.heroku" | ||
|
||
packageArchetype.java_application | ||
version := "1.0-SNAPSHOT" | ||
|
||
name := "hello" | ||
lazy val root = (project in file(".")).enablePlugins(PlayScala) | ||
|
||
version := "1.0" | ||
|
||
scalaVersion := "2.10.4" | ||
|
||
mainClass in Compile := Some("Web") | ||
scalaVersion := "2.13.10" | ||
|
||
libraryDependencies += guice | ||
libraryDependencies += jdbc | ||
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test | ||
libraryDependencies ++= Seq( | ||
"com.twitter" % "finagle-http_2.10" % "6.18.0" | ||
"com.google.inject" % "guice" % "5.1.0", | ||
"com.google.inject.extensions" % "guice-assistedinject" % "5.1.0", | ||
"org.postgresql" % "postgresql" % "42.6.0" | ||
) | ||
|
||
// Adds additional packages into Twirl | ||
//TwirlKeys.templateImports += "com.heroku.controllers._" | ||
|
||
// Adds additional packages into conf/routes | ||
// play.sbt.routes.RoutesKeys.routesImport += "com.heroku.binders._" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import mill._ | ||
import $ivy.`com.lihaoyi::mill-contrib-playlib:`, mill.playlib._ | ||
|
||
object scalagettingstarted extends PlayModule with SingleModule { | ||
|
||
def scalaVersion = "2.13.10" | ||
def playVersion = "2.8.19" | ||
def twirlVersion = "1.5.1" | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
buildpacks/buildpack-scala/tests/scala/conf/application.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://www.playframework.com/documentation/latest/Configuration | ||
|
||
# Allows all hosts to be valid hosts for requests to this app. This is necessary since this getting started guide | ||
# makes users deploy their own app of which we don't know the hostname in advance. For production apps, set this | ||
# to the correct host of your application. | ||
# More info: https://www.playframework.com/documentation/2.8.x/AllowedHostsFilter | ||
play.filters.hosts { | ||
allowed = ["."] | ||
} | ||
|
||
# Sets the secret key if the APPLICATION_SECRET environment variable isn't set. It is recommended to set the | ||
# application secret for production apps via heroku config:set on the command line. | ||
# More info: https://www.playframework.com/documentation/2.8.x/ApplicationSecret | ||
play.http.secret.key = "YWRmNTNmZDYtMTE5NS00MTc1LWI4YmMtMGU3ZmY2NTE1NDI0Cg==" | ||
play.http.secret.key = ${?APPLICATION_SECRET} | ||
|
||
# Default to "jdbc:postgresql://example.com:5432/database" so that the application at least starts up when | ||
# JDBC_DATABASE_URL is not set. We use this here to reduce friction when newcomers work with this getting started | ||
# application. Production applications should not have a default like this, especially not ones that have credentials | ||
# in them! | ||
db.default.url = "jdbc:postgresql://example.com:5432/database" | ||
db.default.url = ${?JDBC_DATABASE_URL} | ||
db.default.driver = org.postgresql.Driver |
Oops, something went wrong.