golf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gitignore +10 -0
  2. data/Gemfile +6 -0
  3. data/Gemfile.lock +21 -0
  4. data/Rakefile +12 -0
  5. data/bin/golf +8 -0
  6. data/golf-java/README.markdown +41 -0
  7. data/golf-java/THANKS.markdown +14 -0
  8. data/golf-java/build/classes.zip +0 -0
  9. data/golf-java/build/com/thinkminimo/golf/GolfResource$MimeMapping$MimeMappingSingleton.class +0 -0
  10. data/golf-java/build/com/thinkminimo/golf/GolfResource$MimeMapping.class +0 -0
  11. data/golf-java/build/com/thinkminimo/golf/GolfResource.class +0 -0
  12. data/golf-java/build/com/thinkminimo/golf/GolfServlet$1.class +0 -0
  13. data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfContext.class +0 -0
  14. data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfParams.class +0 -0
  15. data/golf-java/build/com/thinkminimo/golf/GolfServlet$GolfSession.class +0 -0
  16. data/golf-java/build/com/thinkminimo/golf/GolfServlet$PermanentRedirectException.class +0 -0
  17. data/golf-java/build/com/thinkminimo/golf/GolfServlet$RedirectException.class +0 -0
  18. data/golf-java/build/com/thinkminimo/golf/GolfServlet$StoredJSVM.class +0 -0
  19. data/golf-java/build/com/thinkminimo/golf/GolfServlet.class +0 -0
  20. data/golf-java/build/com/thinkminimo/golf/JsonpTunnel.class +0 -0
  21. data/golf-java/build/com/thinkminimo/golf/Main$1.class +0 -0
  22. data/golf-java/build/com/thinkminimo/golf/Main$RingList.class +0 -0
  23. data/golf-java/build/com/thinkminimo/golf/Main.class +0 -0
  24. data/golf-java/build/com/thinkminimo/golf/ProxyServlet.class +0 -0
  25. data/golf-java/build/com/yahoo/platform/yui/compressor/CssCompressor.class +0 -0
  26. data/golf-java/build/com/yahoo/platform/yui/compressor/JarClassLoader.class +0 -0
  27. data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptCompressor.class +0 -0
  28. data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.class +0 -0
  29. data/golf-java/build/com/yahoo/platform/yui/compressor/JavaScriptToken.class +0 -0
  30. data/golf-java/build/com/yahoo/platform/yui/compressor/ScriptOrFnScope.class +0 -0
  31. data/golf-java/build/depends.zip +0 -0
  32. data/golf-java/build/golf +2 -0
  33. data/golf-java/build/org/json/JSONArray.class +0 -0
  34. data/golf-java/build/org/json/JSONException.class +0 -0
  35. data/golf-java/build/org/json/JSONObject$1.class +0 -0
  36. data/golf-java/build/org/json/JSONObject$Null.class +0 -0
  37. data/golf-java/build/org/json/JSONObject.class +0 -0
  38. data/golf-java/build/org/json/JSONString.class +0 -0
  39. data/golf-java/build/org/json/JSONStringer.class +0 -0
  40. data/golf-java/build/org/json/JSONTokener.class +0 -0
  41. data/golf-java/build/org/json/JSONWriter.class +0 -0
  42. data/golf-java/build/resources.zip +0 -0
  43. data/golf-java/build.xml +174 -0
  44. data/golf-java/dist/golf.zip +0 -0
  45. data/golf-java/lib/ant-launcher.jar +0 -0
  46. data/golf-java/lib/ant.jar +0 -0
  47. data/golf-java/lib/commons-codec-1.4.jar +0 -0
  48. data/golf-java/lib/commons-collections-3.2.1.jar +0 -0
  49. data/golf-java/lib/commons-fileupload-1.2.1.jar +0 -0
  50. data/golf-java/lib/commons-httpclient-3.1.jar +0 -0
  51. data/golf-java/lib/commons-io-1.4.jar +0 -0
  52. data/golf-java/lib/commons-lang-2.4.jar +0 -0
  53. data/golf-java/lib/commons-logging-1.1.1.jar +0 -0
  54. data/golf-java/lib/cssparser-0.9.5.jar +0 -0
  55. data/golf-java/lib/getopt-0.1-dev.jar +0 -0
  56. data/golf-java/lib/htmlunit-2.6.jar +0 -0
  57. data/golf-java/lib/htmlunit-core-js-2.6.jar +0 -0
  58. data/golf-java/lib/java-xmlbuilder-1.jar +0 -0
  59. data/golf-java/lib/jets3t-0.7.0.jar +0 -0
  60. data/golf-java/lib/jetty-6.1.15.jar +0 -0
  61. data/golf-java/lib/jetty-util-6.1.15.jar +0 -0
  62. data/golf-java/lib/log4j-1.2.15.jar +0 -0
  63. data/golf-java/lib/nekohtml-1.9.13.jar +0 -0
  64. data/golf-java/lib/sac-1.3.jar +0 -0
  65. data/golf-java/lib/serializer-2.7.1.jar +0 -0
  66. data/golf-java/lib/servlet-api-2.5-20081211.jar +0 -0
  67. data/golf-java/lib/xalan-2.7.1.jar +0 -0
  68. data/golf-java/lib/xercesImpl-2.9.1.jar +0 -0
  69. data/golf-java/lib/xml-apis-1.3.04.jar +0 -0
  70. data/golf-java/resources/app_error.html +60 -0
  71. data/golf-java/resources/error.html +29 -0
  72. data/golf-java/resources/forcebot.txt +0 -0
  73. data/golf-java/resources/forceclient.txt +0 -0
  74. data/golf-java/resources/forceproxy.txt +0 -0
  75. data/golf-java/resources/head.html +0 -0
  76. data/golf-java/resources/jquery.address.js +439 -0
  77. data/golf-java/resources/jquery.golf.js +945 -0
  78. data/golf-java/resources/jquery.js +4376 -0
  79. data/golf-java/resources/jsdetect.html +23 -0
  80. data/golf-java/resources/loading.gif +0 -0
  81. data/golf-java/resources/new.html +45 -0
  82. data/golf-java/resources/new.static.html +45 -0
  83. data/golf-java/resources/noscript.forceclient.html +11 -0
  84. data/golf-java/resources/noscript.html +18 -0
  85. data/golf-java/resources/noscript.static.html +15 -0
  86. data/golf-java/resources/project.xml +21 -0
  87. data/golf-java/resources/proxy_project.xml +11 -0
  88. data/golf-java/resources/proxy_web.xml +40 -0
  89. data/golf-java/resources/static_project.xml +37 -0
  90. data/golf-java/resources/version +1 -0
  91. data/golf-java/resources/web.xml +36 -0
  92. data/golf-java/resources/welcome2golf.html +50 -0
  93. data/golf-java/src/com/thinkminimo/golf/GolfResource.java +582 -0
  94. data/golf-java/src/com/thinkminimo/golf/GolfServlet.java +1055 -0
  95. data/golf-java/src/com/thinkminimo/golf/JsonpTunnel.java +86 -0
  96. data/golf-java/src/com/thinkminimo/golf/Main.java +1299 -0
  97. data/golf-java/src/com/thinkminimo/golf/ProxyServlet.java +577 -0
  98. data/golf-java/src/com/yahoo/platform/yui/compressor/CssCompressor.java +188 -0
  99. data/golf-java/src/com/yahoo/platform/yui/compressor/JarClassLoader.java +158 -0
  100. data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java +1281 -0
  101. data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java +55 -0
  102. data/golf-java/src/com/yahoo/platform/yui/compressor/JavaScriptToken.java +28 -0
  103. data/golf-java/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java +160 -0
  104. data/golf-java/src/org/json/JSONArray.java +934 -0
  105. data/golf-java/src/org/json/JSONException.java +27 -0
  106. data/golf-java/src/org/json/JSONObject.java +1550 -0
  107. data/golf-java/src/org/json/JSONString.java +18 -0
  108. data/golf-java/src/org/json/JSONStringer.java +78 -0
  109. data/golf-java/src/org/json/JSONTokener.java +422 -0
  110. data/golf-java/src/org/json/JSONWriter.java +323 -0
  111. data/golf-java/test/client/golftest/README.markdown +3 -0
  112. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.css +114 -0
  113. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.html +17 -0
  114. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.js +81 -0
  115. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/asc.gif +0 -0
  116. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/bg.gif +0 -0
  117. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/desc.gif +0 -0
  118. data/golf-java/test/client/golftest/components/com/thinkminimo/golf/test/Harness.res/test/test.html +1 -0
  119. data/golf-java/test/client/golftest/controller.js +131 -0
  120. data/golf-java/test/client/golftest/forceclient.txt +0 -0
  121. data/golf-java/test/client/golftest/forceproxy.txt +0 -0
  122. data/golf-java/test/client/golftest/head.html +1 -0
  123. data/golf-java/test/client/golftest/scripts/jquery.tablesort.js +75 -0
  124. data/golf-java/test/client/golftest/styles/style.css +18 -0
  125. data/golf-java/test/client/golftest/test/test.html +1 -0
  126. data/golf.gemspec +24 -0
  127. data/lib/golf/cli.rb +32 -0
  128. data/lib/golf/compiler.rb +12 -0
  129. data/lib/golf/rack.rb +17 -0
  130. data/lib/golf/version.rb +3 -0
  131. data/lib/golf.rb +6 -0
  132. data/template/Gemfile +5 -0
  133. data/template/config.ru +7 -0
  134. data/template/golfapp/components/Test/Test.html +22 -0
  135. data/template/golfapp/components/Test/Test.res/myfile.txt +1 -0
  136. data/template/golfapp/controller.js +10 -0
  137. data/template/golfapp/plugins/mylib.js +12 -0
  138. data/test/test_compiler.rb +10 -0
  139. data/test/test_helper.rb +6 -0
  140. data/test/test_rack.rb +17 -0
  141. metadata +208 -0
@@ -0,0 +1,55 @@
1
+ /*
2
+ * YUI Compressor
3
+ * Author: Julien Lecomte <jlecomte@yahoo-inc.com>
4
+ * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
5
+ * Code licensed under the BSD License:
6
+ * http://developer.yahoo.net/yui/license.txt
7
+ */
8
+
9
+ package com.yahoo.platform.yui.compressor;
10
+
11
+ import net.sourceforge.htmlunit.corejs.javascript.Token;
12
+
13
+ /**
14
+ * JavaScriptIdentifier represents a variable/function identifier.
15
+ */
16
+ class JavaScriptIdentifier extends JavaScriptToken {
17
+
18
+ private int refcount = 0;
19
+ private String mungedValue;
20
+ private ScriptOrFnScope declaredScope;
21
+ private boolean markedForMunging = true;
22
+
23
+ JavaScriptIdentifier(String value, ScriptOrFnScope declaredScope) {
24
+ super(Token.NAME, value);
25
+ this.declaredScope = declaredScope;
26
+ }
27
+
28
+ ScriptOrFnScope getDeclaredScope() {
29
+ return declaredScope;
30
+ }
31
+
32
+ void setMungedValue(String value) {
33
+ mungedValue = value;
34
+ }
35
+
36
+ String getMungedValue() {
37
+ return mungedValue;
38
+ }
39
+
40
+ void preventMunging() {
41
+ markedForMunging = false;
42
+ }
43
+
44
+ boolean isMarkedForMunging() {
45
+ return markedForMunging;
46
+ }
47
+
48
+ void incrementRefcount() {
49
+ refcount++;
50
+ }
51
+
52
+ int getRefcount() {
53
+ return refcount;
54
+ }
55
+ }
@@ -0,0 +1,28 @@
1
+ /*
2
+ * YUI Compressor
3
+ * Author: Julien Lecomte <jlecomte@yahoo-inc.com>
4
+ * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
5
+ * Code licensed under the BSD License:
6
+ * http://developer.yahoo.net/yui/license.txt
7
+ */
8
+
9
+ package com.yahoo.platform.yui.compressor;
10
+
11
+ public class JavaScriptToken {
12
+
13
+ private int type;
14
+ private String value;
15
+
16
+ JavaScriptToken(int type, String value) {
17
+ this.type = type;
18
+ this.value = value;
19
+ }
20
+
21
+ int getType() {
22
+ return type;
23
+ }
24
+
25
+ String getValue() {
26
+ return value;
27
+ }
28
+ }
@@ -0,0 +1,160 @@
1
+ /*
2
+ * YUI Compressor
3
+ * Author: Julien Lecomte <jlecomte@yahoo-inc.com>
4
+ * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
5
+ * Code licensed under the BSD License:
6
+ * http://developer.yahoo.net/yui/license.txt
7
+ */
8
+
9
+ package com.yahoo.platform.yui.compressor;
10
+
11
+ import java.util.ArrayList;
12
+ import java.util.Enumeration;
13
+ import java.util.Hashtable;
14
+
15
+ class ScriptOrFnScope {
16
+
17
+ private int braceNesting;
18
+ private ScriptOrFnScope parentScope;
19
+ private ArrayList subScopes;
20
+ private Hashtable identifiers = new Hashtable();
21
+ private Hashtable hints = new Hashtable();
22
+ private boolean markedForMunging = true;
23
+ private int varcount = 0;
24
+
25
+ ScriptOrFnScope(int braceNesting, ScriptOrFnScope parentScope) {
26
+ this.braceNesting = braceNesting;
27
+ this.parentScope = parentScope;
28
+ this.subScopes = new ArrayList();
29
+ if (parentScope != null) {
30
+ parentScope.subScopes.add(this);
31
+ }
32
+ }
33
+
34
+ int getBraceNesting() {
35
+ return braceNesting;
36
+ }
37
+
38
+ ScriptOrFnScope getParentScope() {
39
+ return parentScope;
40
+ }
41
+
42
+ JavaScriptIdentifier declareIdentifier(String symbol) {
43
+ JavaScriptIdentifier identifier = (JavaScriptIdentifier) identifiers.get(symbol);
44
+ if (identifier == null) {
45
+ identifier = new JavaScriptIdentifier(symbol, this);
46
+ identifiers.put(symbol, identifier);
47
+ }
48
+ return identifier;
49
+ }
50
+
51
+ JavaScriptIdentifier getIdentifier(String symbol) {
52
+ return (JavaScriptIdentifier) identifiers.get(symbol);
53
+ }
54
+
55
+ void addHint(String variableName, String variableType) {
56
+ hints.put(variableName, variableType);
57
+ }
58
+
59
+ void preventMunging() {
60
+ if (parentScope != null) {
61
+ // The symbols in the global scope don't get munged,
62
+ // but the sub-scopes it contains do get munged.
63
+ markedForMunging = false;
64
+ }
65
+ }
66
+
67
+ private ArrayList getUsedSymbols() {
68
+ ArrayList result = new ArrayList();
69
+ Enumeration elements = identifiers.elements();
70
+ while (elements.hasMoreElements()) {
71
+ JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.nextElement();
72
+ String mungedValue = identifier.getMungedValue();
73
+ if (mungedValue == null) {
74
+ mungedValue = identifier.getValue();
75
+ }
76
+ result.add(mungedValue);
77
+ }
78
+ return result;
79
+ }
80
+
81
+ private ArrayList getAllUsedSymbols() {
82
+ ArrayList result = new ArrayList();
83
+ ScriptOrFnScope scope = this;
84
+ while (scope != null) {
85
+ result.addAll(scope.getUsedSymbols());
86
+ scope = scope.parentScope;
87
+ }
88
+ return result;
89
+ }
90
+
91
+ int incrementVarCount() {
92
+ varcount++;
93
+ return varcount;
94
+ }
95
+
96
+ void munge() {
97
+
98
+ if (!markedForMunging) {
99
+ // Stop right here if this scope was flagged as unsafe for munging.
100
+ return;
101
+ }
102
+
103
+ int pickFromSet = 1;
104
+
105
+ // Do not munge symbols in the global scope!
106
+ if (parentScope != null) {
107
+
108
+ ArrayList freeSymbols = new ArrayList();
109
+
110
+ freeSymbols.addAll(JavaScriptCompressor.ones);
111
+ freeSymbols.removeAll(getAllUsedSymbols());
112
+ if (freeSymbols.size() == 0) {
113
+ pickFromSet = 2;
114
+ freeSymbols.addAll(JavaScriptCompressor.twos);
115
+ freeSymbols.removeAll(getAllUsedSymbols());
116
+ }
117
+ if (freeSymbols.size() == 0) {
118
+ pickFromSet = 3;
119
+ freeSymbols.addAll(JavaScriptCompressor.threes);
120
+ freeSymbols.removeAll(getAllUsedSymbols());
121
+ }
122
+ if (freeSymbols.size() == 0) {
123
+ throw new IllegalStateException("The YUI Compressor ran out of symbols. Aborting...");
124
+ }
125
+
126
+ Enumeration elements = identifiers.elements();
127
+ while (elements.hasMoreElements()) {
128
+ if (freeSymbols.size() == 0) {
129
+ pickFromSet++;
130
+ if (pickFromSet == 2) {
131
+ freeSymbols.addAll(JavaScriptCompressor.twos);
132
+ } else if (pickFromSet == 3) {
133
+ freeSymbols.addAll(JavaScriptCompressor.threes);
134
+ } else {
135
+ throw new IllegalStateException("The YUI Compressor ran out of symbols. Aborting...");
136
+ }
137
+ // It is essential to remove the symbols already used in
138
+ // the containing scopes, or some of the variables declared
139
+ // in the containing scopes will be redeclared, which can
140
+ // lead to errors.
141
+ freeSymbols.removeAll(getAllUsedSymbols());
142
+ }
143
+
144
+ String mungedValue;
145
+ JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.nextElement();
146
+ if (identifier.isMarkedForMunging()) {
147
+ mungedValue = (String) freeSymbols.remove(0);
148
+ } else {
149
+ mungedValue = identifier.getValue();
150
+ }
151
+ identifier.setMungedValue(mungedValue);
152
+ }
153
+ }
154
+
155
+ for (int i = 0; i < subScopes.size(); i++) {
156
+ ScriptOrFnScope scope = (ScriptOrFnScope) subScopes.get(i);
157
+ scope.munge();
158
+ }
159
+ }
160
+ }