Skip to content

Commit

Permalink
fix bug #30, add tags for rythm template engine
Browse files Browse the repository at this point in the history
  • Loading branch information
greenlaw110 committed Jan 30, 2012
1 parent 13d45f1 commit 473c2fc
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 3 deletions.
2 changes: 1 addition & 1 deletion java/core/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<copy todir="tmp/classes">
<fileset dir="src"/>
</copy>
<jar destfile="lib/greenscript-core-1.2.4b.jar" basedir="tmp/classes"/>
<jar destfile="lib/greenscript-core-1.2.7.jar" basedir="tmp/classes"/>
<delete dir="tmp" />
</target>

Expand Down
Binary file added java/core/lib/commons-lang-2.6.jar
Binary file not shown.
Binary file not shown.
Binary file modified java/core/lib/play-greenscript.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions java/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ private File f_(String fn) {

public File createTempFile(String extension) {
try {
if (!r_.isDirectory() && !r_.mkdir()) {
throw new RuntimeException("cannot create temporary directory for: " + r_);
}
return File.createTempFile("gstmp", extension, r_);
} catch (IOException e) {
String msg = "Error create temp file";
Expand Down
2 changes: 2 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/closeTag_.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@args String type;
@if ("js".equalsIgnoreCase(type)) </script> @ else if ("css".equalsIgnoreCase(type)) </style> @
10 changes: 10 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/css.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority;

@{
if (null == nameList) nameList = _getAs("arg", String.class);
String cacheKey = nameList + output + all + deps + media + browser + id + charset + priority;
}@

@cacheOnProd(cacheKey, "1h") <<
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "css")
@
47 changes: 47 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/gs_.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@import play.modules.greenscript.GreenScriptPlugin;
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority = 0, String type;
@{
final com.greenscriptool.RenderSession sm = (com.greenscriptool.RenderSession)GreenScriptPlugin.session(type);
if (null != nameList) {
sm.declare(nameList, media, browser);
}
_logger.info("aaa");

all = all || "all".equals(output);
deps = deps || "deps".equals(output);

boolean _output = all || deps || ((null != output) && ((output instanceof Boolean) ? (Boolean)output : !"false".equals(output.toString())));
}@

@if (_output)
@if (all)
@// default browser with default media
@greenscript.output_(nameList, deps = deps, all = all, media = null, browser = null, id = id, charset = charset, type = type, sm = sm)

@// default browser with non-default media
@each String med: sm.getMedias(null)
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = null, id = id, charset = charset, type = type, sm = sm)
@

@// non-default browsers
@each String bro: sm.getBrowsers()
@each String med: sm.getMedias(bro)
@greenscript.output_(nameList, deps = deps, all = all, media = med, browser = bro, id = id, charset = charset, type = type, sm = sm)
@
@
@ else
@greenscript.output_(nameList, deps = deps, all = all, media = media, browser = browser, id = id, charset = charset, type = type, sm = sm)
@
@

@// handle inline code

@if (null != _body)
@if (_output)
@greenscript.openTag_(type)
@_body.build()
@greenscript.closeTag_(type)
@ else
@{ sm.declareInline(_body.toString(), priority); }@
@
@
4 changes: 4 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/importCss.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import play.modules.greenscript.GreenScriptPlugin;
@args String nameList;

@GreenScriptPlugin.lessImport(nameList)
10 changes: 10 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, int priority;

@{
if (null == nameList) nameList = _getAs("arg", String.class);
String cacheKey = nameList + output + all + deps + media + browser + id + charset + priority;
}@

@cacheOnProd(cacheKey, "1h") <<
@greenscript.gs_(nameList = nameList, output = output, all = all, deps = deps, media = media, browser = browser, id = id, charset = charset, priority = priority, type = "js")
@
7 changes: 7 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/openTag_.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@args String type

@if ("js".equalsIgnoreCase(type))
<script type="text/javascript">
@ else if ("css".equalsIgnoreCase(type))
<style type="text/css">
@
21 changes: 21 additions & 0 deletions java/play/app/views/tags/rythm/greenscript/output_.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@args String nameList, Object output, boolean all, boolean deps, String media, String browser, String id, String charset, String type, com.greenscriptool.RenderSession sm;

@if (!sm.isDefault(browser))

<!--[if @browser]>
@
@each String sUrl: sm.output(nameList, deps, all, media, browser)
@if("css".equals(type))
<link rel="stylesheet" type="text/css" media="@media" href="@sUrl"/>
@ else
<script type="text/javascript" src="@sUrl" @if (null != id && !"".equals(id)) id="@id" @ @if (null != charset && !"".equals(charset)) charset="@charset" @></script>
@
@
@if (!sm.isDefault(browser))
<![endif]-->
@

@{ String inline = all ? sm.outputInline().trim() : null; }@
@if (null != inline && !"".equals(inline))
@greenscript.openTag_(type) @inline.raw() @greenscript.closeTag_(type)
@
2 changes: 1 addition & 1 deletion java/play/conf/dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: play -> greenscript 1.2.4b
self: play -> greenscript 1.2.7

require:
- play [1.2,)
Expand Down
5 changes: 4 additions & 1 deletion java/play/src/play/modules/greenscript/GreenScriptPlugin.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
* Define a Playframework plugin
*
* @author [email protected]
* @version 1.2.7 2012-01-31
* fix bug: https://github.com/greenlaw110/greenscript/issues/30
* Add tags for rythm engine
* @version 1.2.6, 2011-09-04
* support LESS,
* fix bug: https://github.com/greenlaw110/greenscript/issues/18
Expand All @@ -71,7 +74,7 @@
*/
public class GreenScriptPlugin extends PlayPlugin {

public static final String VERSION = "1.2.6m";
public static final String VERSION = "1.2.7";

private static String msg_(String msg, Object... args) {
return String.format("GreenScript-" + VERSION + "> %1$s",
Expand Down

0 comments on commit 473c2fc

Please sign in to comment.