Skip to content

Commit

Permalink
Bug fix: #24 - relative url convert break on linux when service stati…
Browse files Browse the repository at this point in the history
…c css file
  • Loading branch information
greenlaw110 committed Nov 15, 2011
1 parent 54b7d37 commit 86ba1ca
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 14 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.6k.jar" basedir="tmp/classes"/>
<jar destfile="lib/greenscript-core-1.2.6l.jar" basedir="tmp/classes"/>
<delete dir="tmp" />
</target>

Expand Down
Binary file modified java/core/lib/greenscript-core-1.2.6k.jar
Binary file not shown.
Binary file modified java/core/lib/play-greenscript.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion java/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>greenscript-core</artifactId>
<packaging>jar</packaging>
<name>GreenScript Core</name>
<version>1.2.6k</version>
<version>1.2.6l</version>
<description>A Java package to manage and process Web Resources (Javascript/CSS)</description>
<url>http://github.com/greenlaw110/greenscript</url>

Expand Down
23 changes: 22 additions & 1 deletion java/core/src/main/java/com/greenscriptool/Minimizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public String processInline(String content) {
public String processStatic(File file) {
String content = null;
try {
content = preprocess_(file, file.getPath());
content = preprocess_(file);
} catch (IOException e2) {
logger_.error("error preprocess static file: " + file.getPath());
return "";
Expand Down Expand Up @@ -657,6 +657,27 @@ private boolean postMergeLessCompile_() {
return Boolean.valueOf(System.getProperty("greenscript.lessCompile.postMerge", "false"));
}

private String preprocess_(File file) throws IOException {
String s = null;
if (lessEnabled_() && !postMergeLessCompile_()) {
try {
s = compileLess_(file);
} catch (LessException e) {
logger_.warn("error compile less file: " + file.getName() + ", error: " + e.getMessage());
}
} else {
// if (file.getName().endsWith(".coffee")) {
// try {
// s = coffee_.compile(fileToString_(file));
// } catch (JCoffeeScriptCompileException e) {
// logger_.error("error compile coffee script file", e);
// }
// }
}
if (null == s) s = fileToString_(file);
return s;
}

private String preprocess_(File file, String originalFn) throws IOException {
String s = null;
if (lessEnabled_() && !postMergeLessCompile_()) {
Expand Down
2 changes: 2 additions & 0 deletions java/play/app/controllers/greenscript/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import play.modules.greenscript.GreenScriptPlugin;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Scope.Flash;

public class Service extends Controller {

Expand All @@ -14,6 +15,7 @@ public static void getInMemoryCache(String key) {
final long l = System.currentTimeMillis();
final String etag = "\"" + l + "-" + key.hashCode() + "\"";
response.cacheFor(etag, "100d", l);
Flash.current().keep();

Map<String, Http.Header> headers = request.headers;
if (headers.containsKey("if-none-match") && headers.containsKey("if-modified-since")) {
Expand Down
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.6k
self: play -> greenscript 1.2.6l

require:
- play 1.2
Expand Down
22 changes: 13 additions & 9 deletions java/play/documentation/manual/home.textile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ h1. GreenScript module
The GreenScript module help you to manage javascript and CSS dependencies and do minimizing work in the same time.
<script type="text/javascript" src="http://www.ohloh.net/p/485839/widgets/project_users_logo.js"></script>

h2. <a>What's new for v1.2.6l</a>

* Bug fix: "relative URL convert breaks on linux when service static css file":https://github.com/greenlaw110/greenscript/issues/24

h2. <a>What's New for v1.2.6k</a>

* Fix a bug that cached content get cleared by accident
Expand All @@ -19,14 +23,14 @@ h2. <a>What's New for v1.2.6i</a>
* Bug fix: Rhino version conflict between LessEngine and YUICompressor
* Support both .css and .less extension for stylesheet files
* Enable last-modified timestamp check for resource files even greenscript.minimize is turned on.
* Fix bug: https://github.com/greenlaw110/greenscript/issues/18, e.g. support relative url path in css
* Fix bug: https://github.com/greenlaw110/greenscript/issues/19, e.g support Play.ctxPath
* Fix bug: https://github.com/greenlaw110/greenscript/issues/21 (found on v1.2.6h)
* Bug fix: https://github.com/greenlaw110/greenscript/issues/18, e.g. support relative url path in css
* Bug fix: https://github.com/greenlaw110/greenscript/issues/19, e.g support Play.ctxPath
* Bug fix: https://github.com/greenlaw110/greenscript/issues/21 (found on v1.2.6h)

h2. <a>What's New for v1.2.6</a>

* Support <a href="http://lesscss.org" >LESS</a>
* Fix bug: https://github.com/greenlaw110/greenscript/issues/18
* Bug fix: https://github.com/greenlaw110/greenscript/issues/18
* CSS file will always get merged without regarding to greenscript.minimize setting

h2. <a>What's New for v1.2.5</a>
Expand All @@ -43,8 +47,8 @@ h2. <a>What's New for v1.2.4</a>
h2. <a>What's New for v1.2.3</a>

* upgrade YUI compressor version from 2.4.2 to 2.4.6
* Fix bug: 404 error while fetching cached files when change minimize/cache setting dynamically
* Fix bug: loaded logic breaks when minimize is enabled
* Bug fix: 404 error while fetching cached files when change minimize/cache setting dynamically
* Bug fix: loaded logic breaks when minimize is enabled

h2. <a>What's New for v1.2.2</a>

Expand All @@ -60,7 +64,7 @@ h2. <a>What's New for v1.2d</a>
** Now: greenscript.dir.js=javascripts (suppose greenscript.dir.root=/public)
** Previously: greenscript.dir.css=/public/stylesheets
** Now: greenscript.dir.css=stylesheets (suppose greenscript.dir.root=/public)
* Fix bug: https://github.com/greenlaw110/greenscript/issues#issue/11
* Bug fix: https://github.com/greenlaw110/greenscript/issues#issue/11
** greenscript now support dependency management in modules (your css/js files in modules, your greenscript.conf file in moduels)
* Support '.bundle' suffix in resource dependency configuration via greenscript.conf
** E.g. js.jq.bundle=http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js,http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.js
Expand All @@ -70,7 +74,7 @@ h2. <a>What's New for v1.2d</a>

h2. <a>What's New for v1.2c</a>

* Fix bug: dependency management breaks for complicated dependencies
* Bug fix: dependency management breaks for complicated dependencies
* Support reverse dependency declaration (search for "reverse dependency declaration" in this document)

h2. <a>What's New for v1.2b</a>
Expand All @@ -79,7 +83,7 @@ h2. <a>What's New for v1.2b</a>

h2. <a>What's New for v1.2a</a>

* Fix bug: IllegalStateException thrown out when app restart (in DEV mode)
* Bug fix: IllegalStateException thrown out when app restart (in DEV mode)

h2. <a>What's New for v1.2</a>

Expand Down
13 changes: 12 additions & 1 deletion java/play/src/play/modules/greenscript/GreenScriptPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import play.mvc.Http.Request;
import play.mvc.Http.Response;
import play.mvc.Router;
import play.mvc.Scope.Flash;
import play.utils.Utils;
import play.vfs.VirtualFile;

Expand All @@ -54,6 +55,8 @@
* fix bug: https://github.com/greenlaw110/greenscript/issues/18
* fix bug: https://github.com/greenlaw110/greenscript/issues/19
* fix bug: https://github.com/greenlaw110/greenscript/issues/21
* fix bug: https://github.com/greenlaw110/greenscript/issues/23
* fix bug: https://github.com/greenlaw110/greenscript/issues/24
* @version 1.2.5, 2011-08-07
* support in-memory cache
* @version 1.2.1, 2011-01-20
Expand All @@ -63,7 +66,7 @@
*/
public class GreenScriptPlugin extends PlayPlugin {

public static final String VERSION = "1.2.6k";
public static final String VERSION = "1.2.6l";

private static String msg_(String msg, Object... args) {
return String.format("GreenScript-" + VERSION + "> %1$s",
Expand Down Expand Up @@ -264,6 +267,7 @@ public boolean serveStatic(VirtualFile file, Request request, Response response)
if ("GET".equalsIgnoreCase(request.method)) {
response.status = Http.StatusCode.NOT_MODIFIED;
response.cacheFor(etag, "100d", l);
keepFlash_();
return true;
}
}
Expand Down Expand Up @@ -308,6 +312,11 @@ public boolean serveStatic(VirtualFile file, Request request, Response response)
// return l;
// }

private void keepFlash_() {
Flash f = Flash.current();
if (f != null) f.keep();
}

private boolean processStatic_(VirtualFile file, Request req, Response resp, ResourceType type) {
/*
IRenderSession sess = type == ResourceType.JS ? jsSession() : cssSession();
Expand All @@ -328,6 +337,7 @@ private boolean processStatic_(VirtualFile file, Request req, Response resp, Res
if (eTag_) {
resp.setHeader(Names.ETAG, etag);
}
keepFlash_();
return true;
} else {
return false;
Expand All @@ -343,6 +353,7 @@ private boolean processStatic_(VirtualFile file, Request req, Response resp, Res
if (eTag_) {
resp.setHeader(Names.ETAG, etag);
}
keepFlash_();
return true;
} catch (Exception e) {
Logger.error(e, "error compress file %1$s", file.getName());
Expand Down

0 comments on commit 86ba1ca

Please sign in to comment.