Skip to content

Commit 11a37fd

Browse files
rstentodwijnand
authored andcommitted
WIP change Try play page example from starter project to tutorials (#231)
@dwijnand, @ignasi35, The objective of this is to change the recommended example (Follow the Hello World Tutorial) on the https://www.playframework.com/getting-started page to point to the correct Hello World Tutorial examples. In addition, I made some edits to simplify and clarify the page. The changes I made look good when I build the web pages except, they do not display the links to download the Hello World Tutorials from Tech Hub: ![image](https://user-images.githubusercontent.com/22889339/47935183-29f6b300-de9f-11e8-9082-864f36208e07.png) No links appear here. Maybe it needs to be live to pull in the links from the example-code-service? If not, could you take a look at the Application controller, I might have made a mistake while switching out the starters examples for tutorials. For your reference, on Tech Hub, the play-templates.conf file defines them like this: ```hocon tutorials = [ { display-name = "Play Scala Hello World Tutorial" name = "play-scala-hello-world-tutorial" url = "git@github.com:playframework/play-scala-hello-world-tutorial.git" github-repo = "playframework/play-scala-hello-world-tutorial" branch = "2.6.x" keywords = [ "play", "scala", "tutorial", "hello-world", "2.6.x" ] "featured": { "play": 0 }, summary = "Play Hello World tutorial in Scala" description = "This tutorial introduces Play Framework, describes how Play web applications work, and walks you through steps to create page that displays a Hello World greeting." }, { display-name = "Play Java Hello World Tutorial" name = "play-java-hello-world-tutorial" url = "git@github.com:playframework/play-java-hello-world-tutorial.git" github-repo = "playframework/play-java-hello-world-tutorial" branch = "2.6.x" keywords = [ "play", "java", "tutorial", "hello-world", "2.6.x" ] summary = "Play Hello World tutorial in Java" description = "This tutorial introduces Play Framework, describes how Play web applications work, and walks you through steps to create page that displays a Hello World greeting." } ] ```
1 parent d44a385 commit 11a37fd

2 files changed

Lines changed: 29 additions & 23 deletions

File tree

app/controllers/Application.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,28 +200,28 @@ class Application @Inject() (
200200
}
201201

202202
val sections = byVersion.map { case (v, p) =>
203-
val StarterKeyword = "starter" // this MUST be in the project keywords for this to work
203+
val TutorialKeyword = "tutorial" // this MUST be in the project keywords for this to work
204204
val SeedKeyword = "seed"
205-
val starters = p.filter(e => e.keywords.contains(StarterKeyword) && !e.hasParams)
205+
val tutorials = p.filter(e => e.keywords.contains(TutorialKeyword) && !e.hasParams)
206206
.groupBy(byLanguage)
207207
.mapValues(_.sortBy(_.displayName))
208208

209-
val examples = p.filter(e => !e.keywords.contains(StarterKeyword) && !e.hasParams)
209+
val examples = p.filter(e => !e.keywords.contains(TutorialKeyword) && !e.hasParams)
210210
.groupBy(byLanguage)
211211
.mapValues(_.sortBy(_.displayName))
212212

213213
val seeds = p.filter(e => e.hasParams && e.keywords.contains(SeedKeyword))
214214
.groupBy(byLanguage)
215215
.mapValues(_.sortBy(_.displayName))
216216

217-
v -> PlayExampleSection(starters, seeds, examples)
217+
v -> PlayExampleSection(tutorials, seeds, examples)
218218
}
219219
PlayExamples(sections)
220220
}
221221
}
222222

223223
case class PlayExamples(sections: Seq[(String, PlayExampleSection)])
224224

225-
case class PlayExampleSection(starters: Map[String, Seq[ExampleProject]],
225+
case class PlayExampleSection(tutorials: Map[String, Seq[ExampleProject]],
226226
seeds: Map[String, Seq[ExampleProject]],
227227
examples: Map[String, Seq[ExampleProject]])

app/views/gettingStarted.scala.html

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,57 @@ <h1>Getting Started with Play Framework</h1>
2020

2121
<div class="try-section">
2222
<h2>New to Play?</h2>
23-
<p>Start with <a href="@controllers.documentation.ReverseRouter.latest(None)">our documentation</a> or the <a href="@controllers.documentation.ReverseRouter.latest(None, "HelloWorldTutorial")">Hello World Tutorial</a>.</p>
24-
2523
<div class="try-option">
2624
<h3><span>&raquo;</span> Learn whether Play Framework is right for your project</h3>
2725
<div class="try-option-content">
2826
<ul>
29-
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Introduction")">Introduction to Play</a></li>
30-
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Requirements")">Requirements for using Play</a></li>
31-
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Philosophy")">Our philosophy</a></li>
27+
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Introduction")" target="_blank">Introduction to Play</a></li>
28+
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Philosophy")" target="_blank">Our philosophy</a></li>
29+
<li><a href="@controllers.documentation.ReverseRouter.latest(None, "Requirements")" target="_blank">Requirements for using Play</a></li>
3230
</ul>
3331
</div>
3432
</div>
35-
3633
<div class="try-option">
37-
<h3><span>&raquo;</span> Follow the Hello World Tutorial</h3>
34+
<h3><span>&raquo;</span> Try the Hello World Tutorial</h3>
3835
<div class="try-option-content">
39-
<p>Play requires Java 8 or higher. You can check your version with the <code>java -version</code> command or install it from <a href="//www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noopener">Oracle's site</a>. See details about <a href="@controllers.documentation.ReverseRouter.latest(None, "Requirements")">Play's system requirement</a>.</p>
40-
<p>First, download the starter project:</p>
36+
<p>The Java and Scala Hello World projects are self-contained tutorials that include a distribution of the sbt build tool.</p>
37+
<p>Play requires Java 8 or higher. Check your version with the <code>java -version</code> command and if needed, install it from <a href="//www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noopener">Oracle's site</a>.</p>
38+
<p>To try the tutorial, first download the Java or Scala project:</p>
4139
<table>
4240
@examples.sections.map { case (version, section) =>
4341
<tbody>
44-
<tr><th><h4>Play @version Starter Projects</h4></th></tr>
45-
@section.starters.getOrElse("java", Seq.empty).map { (project) =>
42+
<tr><th><h4>Play @version Hello World Projects</h4></th></tr>
43+
@section.tutorials.getOrElse("java", Seq.empty).map { (project) =>
4644
@renderProject(project)
4745
}
48-
@section.starters.getOrElse("scala", Seq.empty).map { (project) =>
46+
@section.tutorials.getOrElse("scala", Seq.empty).map { (project) =>
4947
@renderProject(project)
5048
}
5149
</tbody>
5250
}
5351
</table>
54-
<p>Then, unzip the project in a convenient location and follow the directions in the <code>README.md</code> file to build and run the tutorial.</p>
52+
<p>To run the tutorial:</p>
53+
<ol>
54+
<li>Unzip the project in a convenient location.</li>
55+
<li>In a command window, change to the top-level project directory.</li>
56+
<li>Enter <code>sbt run</code>.</li>
57+
<li>After the message <code>Server started, ...</code> displays, enter the following URL in a browser: <http://localhost:9000>
58+
<p>The tutorial welcome page displays.</p></li>
59+
<ol>
5560
</div>
5661
</div>
5762
</div>
5863

5964
<div class="try-section">
6065
<h2>Already know a bit about Play?</h2>
61-
<p>Check out our <a href="//developer.lightbend.com/start/?group=play">example projects for Java or Scala</a>. The downloadable zip files include everything you need, including <a href="//www.scala-sbt.org/index.html">sbt</a>, Play Framework, and an HTTP server. Examples also support <a href="//docs.gradle.org/current/userguide/play_plugin.html">Gradle</a>. You can also create a Play project from the command line using a template if you have sbt installed already.</p>
62-
<p>Play requires Java 8 or higher. You can check your version with the <code>java -version</code> command or install it from <a href="//www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noopener">Oracle's site</a>. See details about the <a href="@controllers.documentation.ReverseRouter.latest(None, "Requirements")">requirements to work with Play</a>.</p>
63-
66+
<p>Lightbend Tech Hub offers a variety of Play example projects for Java and Scala that are focused on a particular use case. The downloadable zip files include everything you need, including <a href="//www.scala-sbt.org/index.html">sbt</a>, Play Framework, and an HTTP server. The examples also support <a href="//docs.gradle.org/current/userguide/play_plugin.html">Gradle</a>.</p>
67+
<p>If you are ready to start your own project and have sbt installed, you can create a Play project from the command line.</p>
6468
<div class="try-option">
6569
<h3><span>&raquo;</span> Try a focused example</h3>
6670
<div class="try-option-content">
6771
<p>Follow these steps to try an example project:</p>
6872
<ol>
73+
<li>Check that your Java version is 8 or higher with the <code>java -version</code> command and if needed, install it from <a href="//www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noopener">Oracle's site</a>.
6974
<li>Choose an example from <a href="https://developer.lightbend.com/start/?group=play">Lightbend's Tech Hub</a>.</li>
7075
<li>Click "CREATE A PROJECT FOR ME" to download the zipped project.</li>
7176
<li>Unzip the project in a convenient location.</li>
@@ -87,7 +92,7 @@ <h3><span>&raquo;</span> Try a focused example</h3>
8792
<div class="try-option">
8893
<h3><span>&raquo;</span> Create a Play Java or Scala project using <code>sbt new</code></h3>
8994
<div class="try-option-content">
90-
<p>In a command window, enter one of the following lines to create a new project:</p>
95+
<p>In a command window, enter one of the following and respond to the prompts to create a new project:</p>
9196

9297
<h4>Java seed template</h4>
9398
<pre>sbt new playframework/play-java-seed.g8</pre>
@@ -97,7 +102,8 @@ <h4>Scala seed template</h4>
97102

98103
<p>After the template creates the project:</p>
99104
<ol>
100-
<li>Enter <code>sbt run</code> command to download dependencies and start the system.</li>
105+
<li>Change into the top level project directory.</li>
106+
<li>Enter <code>sbt run</code> to download dependencies and start the system.</li>
101107
<li>In a browser, enter <a href="http://localhost:9000">http://localhost:9000</a> to view the welcome page.</li>
102108
</ol>
103109
</div>

0 commit comments

Comments
 (0)