golf 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/golf.gemspec +2 -0
- data/lib/golf/compiler.rb +14 -4
- data/lib/golf/rack.rb +3 -1
- data/lib/golf/version.rb +1 -1
- data/lib/golf.rb +1 -0
- data/template/config.ru +1 -1
- data/template/golfapp/components/HelloWorld/HelloWorld.html +13 -0
- data/template/golfapp/controller.js +1 -4
- data/test/data/app_error.html +60 -0
- data/test/data/components/HelloWorld/HelloWorld.html +13 -0
- data/test/data/components.js +1 -0
- data/test/data/controller.js +7 -0
- data/test/data/index.html +61 -0
- data/test/data/jquery.address.js +439 -0
- data/test/data/jquery.golf.js +942 -0
- data/test/data/jquery.js +4376 -0
- data/test/data/welcome2golf.html +50 -0
- data/test/test_compiler.rb +11 -3
- metadata +31 -4
- data/template/golfapp/components/Test/Test.html +0 -22
- data/template/golfapp/components/Test/Test.res/myfile.txt +0 -1
- data/template/golfapp/plugins/mylib.js +0 -12
data/golf.gemspec
CHANGED
@@ -11,7 +11,9 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://golf.github.com"
|
12
12
|
s.summary = %q{Component based front end JS Framework}
|
13
13
|
s.description = %q{Golf lets you write your interface in terms of reusable, simple components.}
|
14
|
+
|
14
15
|
s.add_dependency('thor')
|
16
|
+
s.add_dependency('json')
|
15
17
|
|
16
18
|
s.bindir = 'bin'
|
17
19
|
s.executables = ['golf']
|
data/lib/golf/compiler.rb
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
module Golf
|
2
2
|
class Compiler
|
3
3
|
|
4
|
-
def
|
4
|
+
def initialize(golfpath = "golfapp/components")
|
5
|
+
@golfpath = golfpath
|
5
6
|
end
|
6
7
|
|
7
|
-
def
|
8
|
-
|
8
|
+
def generate_componentsjs
|
9
|
+
component_preamble = 'jQuery.golf.components='
|
10
|
+
components = {}
|
11
|
+
if File.exists?(@golfpath) and File.directory?(@golfpath)
|
12
|
+
Dir["#{@golfpath}/**/*.html"].each do |path|
|
13
|
+
name = path.split('/').last.gsub('.html','')
|
14
|
+
html = File.read(path)
|
15
|
+
components = components.merge({ name => { "name" => name, "html" => html }})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
component_preamble << JSON.dump(components) << ';' << 'jQuery.golf.res={};jQuery.golf.plugins={};jQuery.golf.scripts={};jQuery.golf.styles={};jQuery.golf.setupComponents();'
|
9
19
|
end
|
10
|
-
|
20
|
+
|
11
21
|
end
|
12
22
|
end
|
data/lib/golf/rack.rb
CHANGED
@@ -3,11 +3,13 @@ module Golf
|
|
3
3
|
|
4
4
|
def initialize(app = nil)
|
5
5
|
@app = app if app
|
6
|
+
@compiler = Golf::Compiler.new
|
6
7
|
end
|
7
8
|
|
8
9
|
def call(env)
|
9
10
|
if env["REQUEST_METHOD"] == "GET" and env["PATH_INFO"] == "/component.js"
|
10
|
-
|
11
|
+
result = @compiler.generate_componentsjs
|
12
|
+
['200', { 'Content-Type' => 'application/javascript', 'Content-Length' => result.length.to_s}, [result]]
|
11
13
|
else
|
12
14
|
@app.call(env) if @app
|
13
15
|
end
|
data/lib/golf/version.rb
CHANGED
data/lib/golf.rb
CHANGED
data/template/config.ru
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
<style type="text/css">
|
3
|
+
* {
|
4
|
+
font-family: sans-serif;
|
5
|
+
margin: 0;
|
6
|
+
padding: 0;
|
7
|
+
color: #333;
|
8
|
+
}
|
9
|
+
|
10
|
+
h1.type {
|
11
|
+
padding: .5em 20px .5em 20px;
|
12
|
+
background: orange;
|
13
|
+
margin: 2px;
|
14
|
+
}
|
15
|
+
|
16
|
+
h3.description {
|
17
|
+
padding: .5em 20px .5em 20px;
|
18
|
+
background: yellowgreen;
|
19
|
+
margin: 2px;
|
20
|
+
}
|
21
|
+
|
22
|
+
p.message {
|
23
|
+
padding: .75em 20px .75em 20px;
|
24
|
+
background: cadetblue;
|
25
|
+
margin: 2px;
|
26
|
+
}
|
27
|
+
|
28
|
+
a, a:visited {
|
29
|
+
color: darkblue;
|
30
|
+
text-decoration: none;
|
31
|
+
}
|
32
|
+
|
33
|
+
a:hover {
|
34
|
+
color: darkblue;
|
35
|
+
text-decoration: underline;
|
36
|
+
}
|
37
|
+
|
38
|
+
code {
|
39
|
+
font-family: monospace;
|
40
|
+
font-weight: bold;
|
41
|
+
font-size: 1.18em;
|
42
|
+
padding: 0 0.20em 0 0.20em;
|
43
|
+
}
|
44
|
+
|
45
|
+
.content {
|
46
|
+
position: relative;
|
47
|
+
top: 5em;
|
48
|
+
width: 35em;
|
49
|
+
margin: 0 auto;
|
50
|
+
}
|
51
|
+
</style>
|
52
|
+
|
53
|
+
<div class="content">
|
54
|
+
<h1 class="type"/>
|
55
|
+
<h3 class="description"/>
|
56
|
+
<p class="message">
|
57
|
+
Golf server documentation:
|
58
|
+
<a href="http://golf.github.com/">http://golf.github.com</a>.
|
59
|
+
</p>
|
60
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
jQuery.golf.components={"HelloWorld":{"name":"HelloWorld","html":"<div>\n <style type=\"text/golf\">\n div.container {\n border: 1px solid red;\n }\n <\/style>\n <script type=\"text/golf\">\n\n function() {\n $(\".container\").append(\"<h1>Hello, world!<\/h1>\");\n }\n \n<\/script>\n <div class=\"container\"><\/div>\n<\/div>\n"}};jQuery.golf.res={};jQuery.golf.plugins={};jQuery.golf.scripts={};jQuery.golf.styles={};jQuery.golf.setupComponents();
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
2
|
+
<head>
|
3
|
+
<title> </title>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
5
|
+
<meta name="robots" content="noindex,nofollow"/>
|
6
|
+
<script type="text/javascript">
|
7
|
+
window.serverside = false;
|
8
|
+
window.sessionid = "";
|
9
|
+
window.servletUrl = window.location.protocol+"//"+window.location.host+window.location.pathname;
|
10
|
+
window.urlHash = "";
|
11
|
+
window.devmode = false;
|
12
|
+
window.forcebot = false;
|
13
|
+
window.forceproxy = false;
|
14
|
+
window.forceclient = false;
|
15
|
+
window.restBackends = [];
|
16
|
+
window.cloudfrontDomain = "";
|
17
|
+
if (servletUrl.match("/index\.html$"))
|
18
|
+
window.location.replace(
|
19
|
+
servletUrl.substring(0, servletUrl.length - "index.html".length));
|
20
|
+
</script>
|
21
|
+
<script type="text/javascript" src="jquery.js"></script>
|
22
|
+
<script type="text/javascript">
|
23
|
+
jQuery.golf = {};
|
24
|
+
</script>
|
25
|
+
<script type="text/javascript" src="jquery.address.js"></script>
|
26
|
+
<script type="text/javascript" src="jquery.golf.js"></script>
|
27
|
+
<script type="text/javascript" src="components.js"></script>
|
28
|
+
<script type="text/javascript" src="controller.js"></script>
|
29
|
+
<style type="text/css">
|
30
|
+
a.golfproxylink,
|
31
|
+
a.golfproxylink:link,
|
32
|
+
a.golfproxylink:visited,
|
33
|
+
a.golfproxylink:hover { color:inherit; text-decoration:inherit; }
|
34
|
+
</style>
|
35
|
+
<!-- custom head section -->
|
36
|
+
<!-- end custom head section -->
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<noscript>
|
40
|
+
<!-- custom noscript section -->
|
41
|
+
<div style="color:#222;width:25em;margin:2em auto;padding:2em;border:1px solid black;font-family:sans-serif;text-align:justify">
|
42
|
+
<div style="margin:0 auto;text-align:center;">
|
43
|
+
<h3>JavaScript proxying is disabled.</h3>
|
44
|
+
</div>
|
45
|
+
<p>It looks like your browser doesn't support JavaScript, or
|
46
|
+
maybe you've turned it off. Normally, the Golf server would
|
47
|
+
proxy the JavaScript for you and you'd still be able to access
|
48
|
+
the site. However this application is running in static mode
|
49
|
+
and proxying is disabled.</p>
|
50
|
+
|
51
|
+
<p>If you want to access this application you will need to
|
52
|
+
enable JavaScript in your browser. Check out
|
53
|
+
<a href="http://www.google.com/support/websearch/bin/answer.py?hl=en&answer=23852">Google's JavaScript page</a>
|
54
|
+
for more information on how to do this.</p>
|
55
|
+
</div>
|
56
|
+
<!-- end custom noscript section -->
|
57
|
+
</noscript>
|
58
|
+
<div class="golfbody">
|
59
|
+
</div>
|
60
|
+
</body>
|
61
|
+
</html>
|