Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 10 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
2  LICENSE
View
@@ -1,4 +1,4 @@
-Copyright 2013 Typesafe, Inc.
+Copyright 2013 Tuplejump.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
8 activator.properties
View
@@ -1,4 +1,4 @@
-name=hello-play-scala
-title=Hello Play Framework (Scala Only)
-description=Play Framework is the High Velocity Web Framework for Java and Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource comsumption (CPU, memory, threads) for highly-scalable applications. This app will teach you how to start building Play 2.1 apps with Scala.
-tags=Basics,play,scala,starter
+name=play-yeoman
+title=Play (Scala) with play-yeoman
+description=Play application with play-yeoman plugin. Can be used as base for any web applications. Provides ability to use yo, bower and grunt commands on the sbt command line. More details here - https://github.com/tuplejump/play-yeoman
+tags=Basics,playframework,scala,starter,yeoman,angularjs
4 build.sbt
View
@@ -1,4 +1,5 @@
import play.Project._
+import com.tuplejump.sbt.yeoman.Yeoman
name := "hello-play-scala"
@@ -10,3 +11,6 @@ libraryDependencies ++= Seq(
)
playScalaSettings
+
+Yeoman.yeomanSettings
+
8 conf/routes
View
@@ -2,7 +2,13 @@
# This file defines all application routes (Higher priority routes first)
# ~~~~
-GET / controllers.Application.index()
+#GET / controllers.Application.index()
+
+GET / com.tuplejump.playYeoman.Yeoman.redirectRoot(base="/ui/")
+
+GET /ui com.tuplejump.playYeoman.Yeoman.index
+
+-> /ui/ yeoman.Routes
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
3  project/plugins.sbt
View
@@ -6,3 +6,6 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")
+
+//Use the play-yeoman plugin to get yeoman support in the play console
+addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.6.4")
94 tutorial/index.html
View
@@ -1,96 +1,54 @@
<html>
<head>
- <title>Hello Play Framework - Activator Template</title>
+ <title>Play (Scala) App with play-yeoman - Activator Template</title>
</head>
<body>
<div>
- <p>You've just created a simple Play Framework application! Now lets explore the code and make some changes.</p>
-
- <h2> View the App</h2>
-
+ <p>You've just created a simple Play Framework application with play-yeoman plugin configured.</p>
+
+ <h3>Prerequisites</h3>
+
<p>
- Once the application has been compiled and the server started, your application can be accessed at: <a href="http://localhost:9000" target="_blank">http://localhost:9000</a><br/>
- Check in <a href="#run" class="shortcut">Run</a> to see the server status.<br/>
- When you make an HTTP request to that URL, the Play server figures out what code to execute which will handle the request and return a response. In this application the request handler for requests to the root URL (e.g. "/") are handled by a Java Controller. You can use Java and Scala to create your controllers.<br/>
- Controllers asynchronously return HTTP responses of any content type (i.e. HTML, JSON, binary).
+ You need to have npm, bower, yeoman and grunt installed before doing anything else. Please follow the instructions at <a href="http://yeoman.io/">yeoman.io</a> to get started.
</p>
-</div>
-<div>
- <h2>UNDER CONSTRUCTION</h2>
-</div>
-<!--
-<div>
- <h2> Code Overview</h2>
- <p>A Play application has very few required files. This example tries to illustrate a number of key concepts in Play so it has a handful of files to explain. The <a href="#code/app" class="shortcut">app</a> directory contains the application's source code, including Java, Scala, server-side templates, and server-side compiled assets for the browser (e.g. JavaScript, CoffeeScript, LESS). The <a href="#code/conf" class="shortcut">conf</a> directory contains the <a href="#code/conf/application.conf" class="shortcut">application.conf</a> config file and the <a href="#code/conf/routes" class="shortcut">routes</a> file</a>. The <a href="#code/project" class="shortcut">project</a> directory contains the SBT build information for the app. The default place for static assets (e.g. images, HTML, CSS, JavaScript) is the <a href="#code/public" class="shortcut">public</a> directory. Unit, functional, and integration tests (Java and Scala) go in the <a href="#code/test" class="shortcut">test</a> directory.</p>
-</div>
-<div>
- <h2> HTTP Routing</h2>
+ <h3>Initialize the application</h3>
<p>
- The <a href="#code/conf/routes" class="shortcut">routes</a> file contains mappings between HTTP request verbs &amp; paths and the code that controller method that handles the requests. Route paths can be parametrized to support RESTful style URLs. The following mapping will handle HTTP GET requests to "/" using the <strong>controllers.Application.index</strong> method:
- <pre><code>GET / controllers.Application.index</code></pre>
- You can try out the routing by first making a request to an unmatched route, like: <a href="http://localhost:9000/foo" target="_blank">http://localhost:9000/foo</a><br/>
- This should produce an error because there isn't a route that matches the request.
- Then edit the <a href="#code/conf/routes" class="shortcut">routes</a> to include a new route:
- <pre><code>GET /foo controllers.Application.index</code></pre>
- Now retry the request and you should see the default index page.<br/>
- By default the routes are compiled by Play so that they can be used in a type-safe way. This prevents issues caused by incorrect URL usages.
+ Before you start building the application, use yeoman generator on the SBT console to create your web application. <br/>
+ For example to create an agular web application use,
+ <quote>
+ sbt> yo angular
+ </quote>
</p>
-</div>
-<div>
- <h2> Controllers</h2>
-
+
+ <h3>Run the application</h3>
+
<p>
- HTTP GET requests to <a href="http://localhost:9000/" target="_blank">http://localhost:9000/</a> are handled by the index method defined in the <a href="#code/app/controllers/Application.java" class="shortcut">Application.java</a> file. This static method returns a <strong>Result</strong> which in this case consists of a server-side rendered template and an HTTP 200 response which is represented by the <strong>ok</strong> method call. You can also use non-static methods along with Dependency Injection frameworks like Spring, Guice, and CDI.<br/>
- You can change the "Hello Play Framework" string in <a href="#code/app/controllers/Application.java" class="shortcut">Application.java</a> a different value, like "Hello from Play", then save the file and reload <a href="http://localhost:9000/" target="_blank">the index page</a> in your browser. Play will automatically recompile the controller and you should immediately see your changes.<br/>
- If your changes result in a compile error you will see the error in your browser (after a refresh) and in the <a href="#compile" class="shortcut">Compile Plugin</a>. Try it by removing one of the double-quotes in the <strong>index</strong> method's string, save the file, and reload the index page. Fix the error before you continue.<br/>
+ To run the application, you can use the standard play run command. This will run grunt and build the web app.<br/>
+ <quote>
+ sbt> run
+ </quote>
+
</p>
-</div>
-<div>
- <h2> Templates</h2>
- <p>
- The <strong>Application.index</strong> method uses a template which is compiled by Play into a function. The source is in the <a href="#code/app/views/index.scala.html" class="shortcut">index.scala.html</a> file and is available by calling the <strong>views.html.index.render</strong> function. This template takes a parameter of a <strong>String</strong> so the compiled function also takes a <strong>String</strong> parameter. The default templating language in Play is Scala, but a number of other templating languages (like Java, Groovy, and Dust) can also be plugged in.<br/>
- The <a href="#code/app/views/index.scala.html" class="shortcut">index template</a> uses the <a href="#code/app/views/main.scala.html" class="shortcut">main template</a> by calling the <strong>main</strong> function with the required parameters.<br/>
- Notice that the templates do not use hard-coded URLs and instead use Play's reverse routing, like:
- <pre><code>@routes.Assets.at("images/favicon.png")</code></pre>
- This provides a type-safe way to specify URLs in an application. If the URL to a file changes, then automatically, the new value will be used throughout all of the URL references. You can use the reverse router anywhere in your code, like redirects in controllers.<br/>
- Like controllers (and all source code in Play) you can make changes to templates which triggers a recompile. Then simply refresh the page to see the changes. Try it out by making a change to the <a href="#code/app/views/index.scala.html" class="shortcut">index template</a>, saving the file, and then refreshing the <a href="http://localhost:9000/" target="_blank">index page</a> in your browser.
- </p>
-</div>
-<div>
- <h2> Static Assets</h2>
+ <h3>View the App</h3>
<p>
- This application has a route to handle loading static assets from the <a href="#code/public" class="shortcut">public</a> directory:
- <pre><code>GET /assets/*file controllers.Assets.at(path="/public", file)</code></pre>
- A request to <a href="http://localhost:9000/assets/images/favicon.png" target="_blank">http://localhost:9000/assets/images/favicon.png</a> will use this route to find the <a href="#code/public/images/favicon.png" class="shortcut">favicon.png</a> file in the <strong>public/images</strong> directory.<br/>
- You can put any static assets into the public directory and have them accessible in this way.
- </p>
-</div>
-<div>
- <h2> Test the App</h2>
-
- <p>
- This application includes a number of tests which are automatically run after each successful compile. You can see the test results in the <a href="#test" class="shortcut">Test plugin</a>. Due to changes that you may have made to your application source code, some of the tests might now be failing. The source for the tests is located in the <a href="#code/test" class="shortcut">test</a> directory. The <a href="#code/test/ApplicationTest.java" class="shortcut">test/ApplicationTest.java</a> Java class contains a number of unit and functional tests for the <strong>Application</strong>. The <a href="#code/test/IntegrationTest.java" class="shortcut">IntegrationTest.java</a> file contains an test which uses Solenium to test the actual UI in a browser. The default testing framework for Java in Play is JUnit, but you can plug any testing framework in.<br/>
- If you modify a test and save the changes, then the tests will automatically be re-run.
+ Once the application has been compiled and the server started, your application can be accessed at: <a href="http://localhost:9000" target="_blank">http://localhost:9000</a><br/>
+ Check in <a href="#run" class="shortcut">Run</a> to see the server status.<br/>
</p>
</div>
<div>
- <h2> SBT Build</h2>
-
- <p>
- SBT is the build system underneath Play applications. It is responsible for resolving dependencies, compiling the project, running the tests, etc. The primary build definition file is the <a href="#code/project/Build.scala" class="shortcut">Build.scala</a> file. In that file you will see a comma-seperated list of dependencies which can be modified to suit your needs. Play includes a number of libraries which can selectively be turned on/off. For instance if you want to use JPA with Play, uncomment the <strong>javaJpa</strong> dependency. You can also add your own dependencies in the SBT form:
- <pre><code>"group" % "artifact" % "version"</code></pre>
- </p>
+ <h2>UNDER CONSTRUCTION</h2>
</div>
--->
<div>
<h2> Further Learning</h2>
<p>
The <a href="http://www.playframework.com/documentation" target="_blank">Play Documentation</a> contains much more exhaustive details and also covers a number of other topics which haven't been addressed in this tutorial.<br/>
+ For learning more about yeoman, checkout the website <a href="http://yeoman.io/" target="_blank">here</a>.<br/>
+ More information and documentation for play-yeoman plugin can be found <a href="https://github.com/tuplejump/play-yeoman" target="_blank">here</a>.<br/>
<a href="http://stackoverflow.com" target="_blank">StackOverflow</a> is a great place ask questions about Play.<br/>
<a href="http://groups.google.com/group/play-framework" target="_blank">The play-framework</a> Google Group is a great place to discuss Play.<br/>
</p>

No commit comments for this range

Something went wrong with that request. Please try again.