Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#526] Added cheat sheet support to standard docviewer module
Each cheat sheet could be accessed via url '@documentation/cheatsheets/{category}'
- Loading branch information
1 parent
ab6642a
commit e0c7b18
Showing
32 changed files
with
978 additions
and
2 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
documentation/cheatsheets/commandLine/ch25-CommandLinePlayCommand.textile
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,85 @@ | ||
h2. Command line - play command | ||
|
||
*classpath* | ||
Display the computed classpath | ||
|
||
*id* | ||
Define the framework ID, used for multi environment config | ||
|
||
*secret* | ||
Generate a new secret key, used for encryption | ||
|
||
*install* | ||
Install a module | ||
|
||
*list-modules* | ||
List modules available from the central modules repository | ||
|
||
*modules* | ||
Display the computed modules list | ||
|
||
*new* | ||
Create a new application | ||
|
||
*new-module* | ||
Create a module | ||
|
||
*build-module* | ||
Build and package a module | ||
|
||
*eclipsify* | ||
Create all Eclipse configuration files | ||
|
||
*netbeansify* | ||
Create all NetBeans configuration files | ||
|
||
*idealize* | ||
Create all IntelliJ Idea configuration files | ||
|
||
*javadoc* | ||
Generate your application Javadoc | ||
|
||
*auto-test* | ||
Automatically run all application tests | ||
|
||
*clean* | ||
Delete temporary files (including the bytecode cache) | ||
|
||
*test* | ||
Run the application in test mode in the current shell | ||
|
||
*precompile* | ||
Precompile all Java sources and templates to speed up | ||
application start-up | ||
|
||
*war* | ||
Export the application as a standalone WAR archive | ||
|
||
*run* | ||
Run the application in the current shell | ||
|
||
*start* | ||
Start the application in the background | ||
|
||
*stop* | ||
Stop the running application | ||
|
||
*restart* | ||
Restart the running application | ||
|
||
*status* | ||
Display the running application's status | ||
|
||
*out* | ||
Follow logs/system.out file | ||
|
||
*pid* | ||
Show the PID of the running application | ||
|
||
*check* | ||
Check for a release newer than the current one | ||
|
||
*help* | ||
Display help on a specific command | ||
|
||
|
27 changes: 27 additions & 0 deletions
27
documentation/cheatsheets/controllers/ch01-ControllerActionSmartbinding.textile
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,27 @@ | ||
h2. Controller.action - Smart binding | ||
|
||
*==Controller/link?i=32&n=patrick==* | ||
==public static void link(int i, String n)== | ||
==public static void link(Integer i, String n)== | ||
==public static void link(Long i, String n)== | ||
|
||
*==Controller/show?id[0]=1&id[1]=2&id[2]=3&id[3]=4==* | ||
==public static void show(Long[] id)== | ||
==public static void show(List<Long> id)== | ||
==public static void show(Set<Long> id)== | ||
|
||
*==Controller/get?date=02-18-1972==* | ||
==public static void get(@As("MM-dd-yyyy") Date date)== | ||
|
||
*==(@As(binder=MyCustomStringBinder.class))==* | ||
Custom parameter binder | ||
|
||
*Send File as multipart/form-data encoded post request* | ||
public static void create(String comment, File attachment) | ||
|
||
*==?client.name=paul&client.email=contact@crionics.com==* | ||
public static void create(Client client) POJO binding | ||
|
||
*@NoBinding* | ||
Marks a non bindable field | ||
|
20 changes: 20 additions & 0 deletions
20
documentation/cheatsheets/controllers/ch02-ControllerActionValidation.textile
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,20 @@ | ||
h2. Controller.action - Validation | ||
|
||
*==@Required String lastname==* | ||
*==@IsTrue String agree==* | ||
*==@Max(7500) Integer wordCount==* | ||
*==@Min(18) Long age==* | ||
*==@MaxSize(2083) String value==* | ||
*==@MinSize(42) String value==* | ||
*==@Email String address==* | ||
*==@Equals("passwordConfirmation") String password==* | ||
*==@InFuture String dueDate==* | ||
*==@InFuture("1979-12-31") String birthDate==* | ||
*==@Match("[A-Z]{3}") String abbreviation==* | ||
*==@Match("(directDebit|creditCard|onReceipt)")==* | ||
*==@Past String actualDepartureDate==* | ||
*==@Past("1980-01-01") String birthDate==* | ||
*==@Range(min = 17500, max = 40000) String wordCount==* | ||
*==@URL String address==* | ||
*==@Valid Person person==* | ||
Pojo validation - class Person needs validation annotations |
28 changes: 28 additions & 0 deletions
28
documentation/cheatsheets/controllers/ch03-ControllerSessionManagement.textile
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,28 @@ | ||
h2. Controller - Session Management | ||
|
||
*WARNING: Play Session is NOT the J2EE session* | ||
session and flash use cookies! 4kb limit/20 cookies max | ||
|
||
*session.getId();* | ||
Returns the session Id - in most cases: a must have! | ||
|
||
*session.put(String key, String value);* | ||
*session.get("user_flag");* | ||
Values are limited to Strings, 4kb max | ||
|
||
*flash.put(String key, String value);* | ||
*flash.get(String key);* | ||
Flash entries are discarded at end of next call | ||
|
||
*Cache.set("key_" + id, product, "30mn");* | ||
Set cache value for 30 minutes | ||
|
||
*Cache.get("key_" + id, Product.class);* | ||
Get cache value, may return null | ||
|
||
*Cache.delete("key_" + id);* | ||
Non blocking cache delete | ||
|
||
*Cache.safeDelete("key_" + id);* | ||
Blocking cache delete | ||
|
23 changes: 23 additions & 0 deletions
23
documentation/cheatsheets/controllers/ch04-ControllerActionRedirection.textile
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 @@ | ||
h2. Controller.action - Redirection | ||
|
||
*render(params...);* | ||
Renders template with given parameters, text/html | ||
|
||
*renderXML(params...);* | ||
Renders parameters as application/xml | ||
|
||
*renderJson(params...);* | ||
Renders parameters as application/json | ||
|
||
*renderText(params...);* | ||
Renders parameters as text/plain | ||
|
||
*renderTemplate("Clients/showClient.html", id, client);* | ||
Bypasses default template | ||
|
||
*redirect("http://www.crionics.com");* | ||
Http redirect to the given URL | ||
|
||
*From an action, calling another Controller.action()* | ||
The framework transparently generates a REDIRECT! | ||
|
7 changes: 7 additions & 0 deletions
7
documentation/cheatsheets/controllers/ch05-ControllerJobs.textile
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,7 @@ | ||
h2. Controller - Jobs | ||
|
||
*==@OnApplicationStart==* | ||
*==@On("0 0 12 ∗ ∗ ?")==* | ||
*==@Every("1h")==* | ||
==public class Bootstrap extends Job {public void doJob() {...} }== | ||
|
14 changes: 14 additions & 0 deletions
14
documentation/cheatsheets/controllers/ch06-ControllerInterceptions.textile
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,14 @@ | ||
h2. Controller - Interceptions | ||
|
||
*==@Before ➟ action ➟ @After ➟ template ➟ @Finally==* | ||
Interceptions evaluation order | ||
|
||
*==@Before static void checkAuthentification()==* | ||
*==@After static void log()==* | ||
*==@Finally static void audit()==* | ||
You get the idea | ||
|
||
*==@With(Secure.class)==* | ||
*==public class Admin extends Application==* | ||
Custom interceptors at the controller scope | ||
|
16 changes: 16 additions & 0 deletions
16
documentation/cheatsheets/controllers/ch07-ControllerActionOthers.textile
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,16 @@ | ||
h2. Controller.action - Others | ||
|
||
*==Logger.info("Action executed ...");==* | ||
*==Logger.debug("A log message");==* | ||
*==Logger.error(ex, "Oops");==* | ||
Logging configuration lives in application.conf | ||
|
||
*==@CacheFor("1h") public static void index() { ... }==* | ||
Caches the result of the action for 1h | ||
|
||
*==Play.configuration.getProperty("blog.title");==* | ||
Access to the configuration file | ||
|
||
*==Query query = JPA.em().createQuery(“query”);==* | ||
Access the persistence manager | ||
|
58 changes: 58 additions & 0 deletions
58
documentation/cheatsheets/controllers/ch08-ControllerLibraries.textile
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,58 @@ | ||
h2. Controller - Libraries | ||
|
||
*==WS.url(“http://s.com/posts”).get().toJSON();==* | ||
HTTP get request to JSON | ||
|
||
*==WS.url(“http://s.com/”).post().toXML();==* | ||
HTTP post request to XML | ||
|
||
*==XML.getDocument(String);==* | ||
String to XML | ||
|
||
*==XML.serialize(Document);==* | ||
XML to String | ||
|
||
*==XPath.selectNodes(String xpath, Object node);==* | ||
XPath expression evaluator | ||
|
||
*==Files.copy(File,File);==* | ||
File copy | ||
|
||
*==Files.copyDir(File,File);==* | ||
Recursive directory copy | ||
|
||
*==Files.delete(File);==* | ||
*==Files.deleteDirectory(File);==* | ||
Deletes file/directory | ||
|
||
*==IO.readLines(File);==* | ||
*==IO.readContentAsString(File);==* | ||
*==IO.readContent(File);==* | ||
*==IO.write(byte[],File);==* | ||
Read/Write file contents | ||
|
||
*==Images.crop(File orig,File to, int x1, int y1, int x2, int y2);==* | ||
*==Images.resize(File orig, File to, int w, int h);==* | ||
*==Images.toBase64(File image);==* | ||
Handy methods! | ||
|
||
*==Crypto.encryptAES(String);==* | ||
*==Crypto.decryptAES(String);==* | ||
Encryption using the application secret key | ||
|
||
*==Crypto.passwordHash(String);==* | ||
Create an MD5 password hash | ||
|
||
*==Codec.UUID();==* | ||
Generates unique IDs | ||
|
||
*==Codec.byteToHexString(byte[] bytes);==* | ||
Write a byte array as hexadecimal String | ||
|
||
*==Codec.encodeBASE64(byte[] value);==* | ||
*==Codec.decodeBASE64(String base64);==* | ||
Encode/Decode a base64 value | ||
|
||
*==Codec.hexSHA1(String);==* | ||
Build a hexadecimal SHA1 hash for a String | ||
|
33 changes: 33 additions & 0 deletions
33
documentation/cheatsheets/model/ch14-ModelActionQueries.textile
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 @@ | ||
h2. Model.action - Queries | ||
|
||
*==Query query = JPA.em().createQuery(“jpql_query”);==* | ||
Access the persistence manager | ||
|
||
*==Post post = Post.findById(id);==* | ||
*==List<Post> posts = Post.findAll();==* | ||
Finder methods | ||
|
||
*==post.save();==* | ||
Saves the object to the persistent store | ||
|
||
*==boolean post.validateAndSave();==* | ||
true if object validates and saved, see validation annotations | ||
|
||
*==List<Post> posts = Post.all().from(50).fetch(100);==* | ||
Read records 50 to 100, if any | ||
|
||
*==Post.find("select p from Post p, Comment c where c.post==* | ||
*=== p and c.subject like ?", "%hop%");==* | ||
Parametrized lookup using a join | ||
|
||
*==long userCount = Post.count("author=?", connectedUser);==* | ||
*==long postCount = Post.count();==* | ||
Counting records | ||
|
||
*==JPAPlugin.startTx(boolean readonly);==* | ||
*==JPAPlugin.closeTx(boolean rollback);==* | ||
Custom transaction control methods | ||
|
||
*==JPA.setRollbackOnly();==* | ||
Forces a transaction rollback | ||
|
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,20 @@ | ||
h2. Model - Basics | ||
|
||
*==@Entity(name=”sql_tbl”) public class Post extends Model==* | ||
Specifies that the class is persistent | ||
|
||
*==@Embedded==* | ||
Defines this field as being embedded | ||
|
||
*==@EmbeddedId==* | ||
Defines this field as being (part of) the identity for the class, | ||
and being embedded into this class | ||
|
||
*==@Embeddable==* | ||
Specifies that the class is persistent embedded in another | ||
persistent class | ||
|
||
*==@MappedSuperclass==* | ||
Specifies that this class contains persistent information to be | ||
mapped in a child | ||
|
14 changes: 14 additions & 0 deletions
14
documentation/cheatsheets/model/ch16-ModelGenerators.textile
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,14 @@ | ||
h2. Model - Generators | ||
|
||
*==@GeneratedValue(strategy = [NONE, TABLE, SEQUENCE,==* | ||
*==IDENTITY, AUTO])==* | ||
Used to generate auto indexes | ||
|
||
*==@SequenceGenerator==* | ||
Defines a generator of values using sequences in the | ||
datastore for use with persistent entities | ||
|
||
*==@TableGenerator==* | ||
Defines a generator of sequences using a table in the | ||
datastore for use with persistent entities | ||
|
33 changes: 33 additions & 0 deletions
33
documentation/cheatsheets/model/ch17-ModelRelationalMapping.textile
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 @@ | ||
h2. Model - Relational mapping | ||
|
||
*==@Table(name=”sql_tbl”, catalog=””, schema=””)==* | ||
Defines the table where this class will be stored | ||
|
||
*==@Id==* | ||
Defines this field as being (part of) the identity for the class | ||
|
||
*==@Version==* | ||
Defines this field as storing the version for the class | ||
|
||
*==@Basic==* | ||
Defines this field as being persistent, can be omitted | ||
|
||
*==@Transient==* | ||
Defines this field as being transient (not persisted) | ||
|
||
*==@Lob(fetch=[LAZY, EAGER], type=[BLOB,CLOB])==* | ||
Defines this field as being stored as a large object | ||
|
||
*==@UniqueConstraint(primary=false, String columns[])==* | ||
Used to define secondary indexes | ||
|
||
*==@Temporal(DATE,TIME,TIMESTAMP)==* | ||
Should only be used on java.util.Date and Calendar fields | ||
|
||
*==@Enumerated(ORDINAL, STRING)==* | ||
Defines this field as storing an enumerated class | ||
|
||
*==@Column(name=”sql_column_name”)==* | ||
Should the table column name be different from the field name | ||
|
||
|
Oops, something went wrong.