Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed commands.py to drop in default groovy controller and test, removed old files
- Loading branch information
Showing
7 changed files
with
208 additions
and
22 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,149 @@ | |||
#{set title:'Your application is ready !' /} | |||
|
|||
#{if play.mode.toString() == 'DEV'} | |||
|
|||
#{set 'moreStyles'} | |||
<link rel="stylesheet" href="@{'/public/playmanual/manual.css'}" type="text/css" media="screen" charset="${_response_encoding}"> | |||
<link rel="stylesheet" href="@{'/public/playmanual/wiki.css'}" type="text/css" media="screen" charset="${_response_encoding}"> | |||
#{/set} | |||
|
|||
<div class="wrapper"> | |||
|
|||
<div id="docSidebar"> | |||
|
|||
<div id="logo"> | |||
<img src="@{'/public/playmanual/logo.png'}"> | |||
<h2 id="version">Play ${play.version}</h2> | |||
</div> | |||
|
|||
<h2>Browse</h2> | |||
<ul> | |||
<li id="gotoc"><a href="/@documentation/home">Local documentation</a></li> | |||
<li id="gotoc"><a href="/@api/index.html">Browse Java API</a></li> | |||
</ul> | |||
|
|||
<h2>Contents</h2> | |||
<div id="toc"></div> | |||
|
|||
#{if modules} | |||
<h2>Installed modules</h2> | |||
<ul> | |||
#{list modules, as:'module'} | |||
<li> | |||
<a href="modules/${module}/home">${module}</a> | |||
#{if apis.contains(module)} | |||
— <a href="/@api/-${module}/index.html">Browse API</a> | |||
#{/if} | |||
</li> | |||
#{/list} | |||
</ul> | |||
#{/if} | |||
|
|||
<h2>Search</h2> | |||
<p>Get help with google</p> | |||
<div id="searchBox"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="002614023023983855063:jn1mu_7bof0" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="28" style="font-size:14px"/></div></form><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></div> | |||
|
|||
</div> | |||
|
|||
<div id="pageContent"> | |||
|
|||
<div class="wikistyle"> | |||
<h1>Your new application is ready!</h1> | |||
<p> | |||
Congratulation, you've just created a new Groovy Play application. This page will help you in the few next steps. | |||
</p> | |||
<h2><a name="why">Why do you see this page?</a></h2> | |||
<p> | |||
The <strong>conf/routes</strong> file defines a route that tell play to invoke the <strong>Application.index</strong> action | |||
when a browser requests the <strong>/</strong> URI using the <strong>GET</strong> method: | |||
</p> | |||
<pre><code># Application home page | |||
GET / Application.index</code></pre> | |||
<p> | |||
So play has invoked the <strong>controllers.Application.index()</strong> method: | |||
</p> | |||
<pre><code>package controllers | |||
|
|||
import play.* | |||
import play.mvc.* | |||
|
|||
import models | |||
|
|||
class Application extends Controller { | |||
|
|||
static void index() { | |||
render() | |||
} | |||
}</code></pre> | |||
<p> | |||
Using the <strong>render()</strong> call, this action asks play to display a template. By convention play has | |||
displayed the <strong>app/views/Application/index.html</strong> template: | |||
</p> | |||
<pre><code>#{extends 'main.html' /} | |||
#{set title:'Home' /} | |||
|
|||
#{welcome /}</code></pre> | |||
<p> | |||
This template extends the <strong>app/views/main.html</strong>, and uses the <strong>#{welcome /}</strong> tag to display this | |||
welcome page. | |||
</p> | |||
<h2><a name="ide">Need to set up a Java IDE?</a></h2> | |||
<p> | |||
You can start right now to hack your application using any text editor. Any changes will be automatically realoaded at the | |||
next page refresh, including modifications made to Java sources files. | |||
</p> | |||
<p> | |||
If you want to set up your application in <strong>Eclipse</strong>, <strong>Netbeans</strong> or any other Java IDE, check | |||
the <a href="/@documentation/ide">Setting up your preferred IDE</a> page. | |||
</p> | |||
<h2><a name="db">Need to connect to a database?</a></h2> | |||
<p> | |||
You can quickly set up a developement database (either in memory or written to the filesystem), by adding one of these | |||
lines to the <strong>conf/application.conf</strong> file: | |||
</p> | |||
<pre><code># For a transient in memory database (H2 in memory) | |||
db=mem | |||
|
|||
# for a simple file written database (H2 file stored) | |||
db=fs</code></pre> | |||
<p> | |||
If you want to connect to an existing <strong>MySQL5 server</strong>, use: | |||
</p> | |||
<pre><code>db=mysql:user:pwd@database_name</code></pre> | |||
<p> | |||
If you need to connect to another JDBC compliant database, first add the corresponding driver library to the | |||
<strong>lib/</strong> directory of your application, and add these lines to the <strong>conf/application.conf</strong> file: | |||
</p> | |||
<pre><code>db.url=jdbc:postgresql:database_name | |||
db.driver=org.postgresql.Driver | |||
db.user=root | |||
db.pass=secret</code></pre> | |||
<h2><a name="doc">Need more help?</a></h2> | |||
<p> | |||
When your application run in <strong>DEV</strong> mode, you can access directly the current documentation at the | |||
<a href="/@documentation">/@documentation</a> URL or go to <a href="http://www.playframework.org">http://www.playframework.org</a>. | |||
</p> | |||
<p> | |||
For specific help with the Groovy plugin, please head to the <a href='http://github.com/clarkdave/play-groovy'>project page</a>. Bug reports and fixes are welcome! | |||
</p> | |||
<p> | |||
The <a href="http://groups.google.com/group/play-framework">Play Google Group</a> is where Play users come to seek help, announce projects, and discuss. | |||
If you don't have any google account, you can still join the mailing list sending an email to | |||
<br/><strong>play-framework+subscribe@googlegroups.com</strong>. | |||
</p> | |||
</div> | |||
</div> | |||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
<script type="text/javascript" src="@{'/public/playmanual/jquery-1.3.2.min.js'}"></script> | |||
<script type="text/javascript" src="@{'/public/playmanual/navigation.js'}"></script> | |||
|
|||
#{/if} | |||
#{else} | |||
<h1>Your application is ready!</h1> | |||
#{/else} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,35 +1,59 @@ | |||
# Here you can create play commands that are specific to the module, and extend existing commands | # groovy | ||
import sys | |||
import inspect | |||
import os | |||
import subprocess | |||
import shutil | |||
|
|
||
MODULE = 'groovy' | from play.utils import * | ||
|
|
||
# Commands that are specific to your module | MODULE = 'groovy' | ||
|
|
||
COMMANDS = ['groovy:hello'] | COMMANDS = ['groovy:console'] | ||
|
|
||
def execute(**kargs): | def execute(**kargs): | ||
command = kargs.get("command") | command = kargs.get("command") | ||
app = kargs.get("app") | app = kargs.get("app") | ||
args = kargs.get("args") | args = kargs.get("args") | ||
env = kargs.get("env") | env = kargs.get("env") | ||
|
|
||
if command == "groovy:hello": | if command == "groovy:console": | ||
print "~ Hello" | # add precompiled classes to classpath | ||
cp_args = app.cp_args() + ":" + os.path.normpath(os.path.join(app.path,'tmp', 'classes')) | |||
# replace last element with the console app | |||
java_cmd = app.java_cmd(args, cp_args) | |||
java_cmd[len(java_cmd)-2] = "play.console.Console" | |||
java_cmd.insert(2, '-Xmx512M') | |||
subprocess.call(java_cmd, env=os.environ) | |||
|
|
||
|
|
||
# This will be executed before any command (new, run...) | |||
def before(**kargs): | def before(**kargs): | ||
command = kargs.get("command") | command = kargs.get("command") | ||
app = kargs.get("app") | app = kargs.get("app") | ||
args = kargs.get("args") | args = kargs.get("args") | ||
env = kargs.get("env") | env = kargs.get("env") | ||
|
|
||
|
|
||
# This will be executed after any command (new, run...) | |||
def after(**kargs): | def after(**kargs): | ||
command = kargs.get("command") | command = kargs.get("command") | ||
app = kargs.get("app") | app = kargs.get("app") | ||
args = kargs.get("args") | args = kargs.get("args") | ||
env = kargs.get("env") | env = kargs.get("env") | ||
|
|
||
if command == "new": | if command == "new": | ||
pass | #shutil.rmtree(os.path.join(app.path, 'app/controllers')) | ||
#shutil.rmtree(os.path.join(app.path, 'app/models')) | |||
#shutil.rmtree(os.path.join(app.path, 'app/views/errors')) | |||
os.remove(os.path.join(app.path, 'app/controllers/Application.java')) | |||
os.remove(os.path.join(app.path, 'test/BasicTest.java')) | |||
os.remove(os.path.join(app.path, 'test/ApplicationTest.java')) | |||
module_dir = inspect.getfile(inspect.currentframe()).replace("commands.py", "") | |||
shutil.copyfile(os.path.join(module_dir, 'resources', 'Application.groovy'), os.path.join(app.path, 'app/controllers', 'Application.groovy')) | |||
shutil.copyfile(os.path.join(module_dir, 'resources', 'Tests.groovy'), os.path.join(app.path, 'test', 'Tests.groovy')) | |||
ac = open(os.path.join(app.path, 'conf/application.conf'), 'r') | |||
conf = ac.read() | |||
ac = open(os.path.join(app.path, 'conf/application.conf'), 'w') | |||
ac.write(conf) | |||
|
|||
# TODO: set up eclipsify and stuff |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
package controllers | |||
|
|||
import play.* | |||
import play.mvc.* | |||
|
|||
import models.* | |||
|
|||
class Application extends Controller { | |||
|
|||
static void index() { | |||
render() | |||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
import play.test.* | |||
import models.* | |||
|
|||
class BasicTest extends SpockTest { | |||
|
|||
'run this pointless test'() { | |||
when: | |||
def hello = 1 | |||
|
|||
then: | |||
hello == 1 | |||
} |