darthapo-stratus 0.2
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/Changelog +3 -0
- data/Manifest +87 -0
- data/Rakefile +82 -0
- data/Readme.markdown +15 -0
- data/bin/stratus +8 -0
- data/lib/stratus/cli.rb +206 -0
- data/lib/stratus/filters.rb +73 -0
- data/lib/stratus/generator/builder.rb +147 -0
- data/lib/stratus/generator/context.rb +39 -0
- data/lib/stratus/generator/renderer.rb +100 -0
- data/lib/stratus/generator/scanner.rb +75 -0
- data/lib/stratus/generator.rb +12 -0
- data/lib/stratus/resources/attachment.rb +41 -0
- data/lib/stratus/resources/base.rb +257 -0
- data/lib/stratus/resources/content.rb +17 -0
- data/lib/stratus/resources/hash_db.rb +128 -0
- data/lib/stratus/resources/layout.rb +18 -0
- data/lib/stratus/resources/template.rb +22 -0
- data/lib/stratus/resources.rb +75 -0
- data/lib/stratus/settings.rb +19 -0
- data/lib/stratus/tags/markdown.rb +19 -0
- data/lib/stratus/tags/textile.rb +19 -0
- data/lib/stratus/tags.rb +3 -0
- data/lib/stratus/tasks/app/boilerplate/StratusSite +25 -0
- data/lib/stratus/tasks/app/boilerplate/config/defaults/page.default.html +10 -0
- data/lib/stratus/tasks/app/boilerplate/config/defaults/post.default.html +10 -0
- data/lib/stratus/tasks/app/boilerplate/config/site.yaml +16 -0
- data/lib/stratus/tasks/app/boilerplate/content/pages/home/index.html +35 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/styles/main.css +12 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/templates/layouts/main.html +31 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/templates/objects/page.html +7 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/templates/objects/page.index.html +10 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/templates/objects/post.html +22 -0
- data/lib/stratus/tasks/app/boilerplate/themes/default/templates/objects/post.index.html +10 -0
- data/lib/stratus/tasks/app/site.rake +68 -0
- data/lib/stratus/tasks/shared/system.rake +16 -0
- data/lib/stratus/tasks/site/new.rake +108 -0
- data/lib/stratus/tasks/site/site.rake +21 -0
- data/lib/stratus/tasks/site/theme.rake +13 -0
- data/lib/stratus.rb +62 -0
- data/stratus.gemspec +31 -0
- data/test/fixtures/site/StratusSite +26 -0
- data/test/fixtures/site/config/defaults/article.default.html +7 -0
- data/test/fixtures/site/config/defaults/content.default.html +7 -0
- data/test/fixtures/site/config/defaults/page.default.html +10 -0
- data/test/fixtures/site/config/defaults/post.default.html +10 -0
- data/test/fixtures/site/config/site.yaml +25 -0
- data/test/fixtures/site/content/articles/001_im-the-title/index.html +10 -0
- data/test/fixtures/site/content/pages/about/index.html +7 -0
- data/test/fixtures/site/content/pages/home/index.html +37 -0
- data/test/fixtures/site/content/pages/projects/index.html +6 -0
- data/test/fixtures/site/content/posts/001_new-blog/dom.js +123 -0
- data/test/fixtures/site/content/posts/001_new-blog/index.html +24 -0
- data/test/fixtures/site/content/posts/001_new-blog/old.html +18 -0
- data/test/fixtures/site/content/posts/002_fun-for-the-whole-family/index.html +12 -0
- data/test/fixtures/site/content/posts/002_fun-for-the-whole-family/snippet_one.rb +5 -0
- data/test/fixtures/site/content/posts/003_life-is-quite-fun-really/index.html +12 -0
- data/test/fixtures/site/themes/default/scripts/code_highlighter.js +188 -0
- data/test/fixtures/site/themes/default/scripts/code_syntax.js +92 -0
- data/test/fixtures/site/themes/default/styles/code_syntax.css +68 -0
- data/test/fixtures/site/themes/default/styles/main.css +66 -0
- data/test/fixtures/site/themes/default/templates/layouts/main.html +36 -0
- data/test/fixtures/site/themes/default/templates/objects/article.html +7 -0
- data/test/fixtures/site/themes/default/templates/objects/article.index.html +8 -0
- data/test/fixtures/site/themes/default/templates/objects/feed.xml +25 -0
- data/test/fixtures/site/themes/default/templates/objects/page.html +7 -0
- data/test/fixtures/site/themes/default/templates/objects/page.index.html +10 -0
- data/test/fixtures/site/themes/default/templates/objects/post.html +22 -0
- data/test/fixtures/site/themes/default/templates/objects/post.index.html +10 -0
- data/test/fixtures/site/www/index.html +82 -0
- data/test/fixtures/site/www/pages/about/index.html +43 -0
- data/test/fixtures/site/www/pages/home/index.html +82 -0
- data/test/fixtures/site/www/pages/index.html +52 -0
- data/test/fixtures/site/www/pages/projects/index.html +43 -0
- data/test/fixtures/site/www/posts/fun-for-the-whole-family/index.html +66 -0
- data/test/fixtures/site/www/posts/fun-for-the-whole-family/snippet_one.rb +5 -0
- data/test/fixtures/site/www/posts/index.html +63 -0
- data/test/fixtures/site/www/posts/life-is-quite-fun-really/index.html +58 -0
- data/test/fixtures/site/www/posts/new-blog/dom.js +123 -0
- data/test/fixtures/site/www/posts/new-blog/index.html +192 -0
- data/test/fixtures/site/www/posts/new-blog/old.html +18 -0
- data/test/fixtures/site/www/theme/scripts/code_highlighter.js +188 -0
- data/test/fixtures/site/www/theme/scripts/code_syntax.js +92 -0
- data/test/fixtures/site/www/theme/styles/code_syntax.css +68 -0
- data/test/fixtures/site/www/theme/styles/main.css +66 -0
- data/test/fixtures/site/www/themes/default/styles/main.css +62 -0
- data/test/test_helper.rb +0 -0
- metadata +143 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
5
|
+
<title>My Site</title>
|
|
6
|
+
<script src="../../theme/scripts/code_highlighter.js"></script>
|
|
7
|
+
<script src="../../theme/scripts/code_syntax.js"></script>
|
|
8
|
+
<link href="../../theme/styles/main.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
9
|
+
<link href="../../theme/styles/code_syntax.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
10
|
+
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="page-container">
|
|
14
|
+
<div class="header">
|
|
15
|
+
<h1>My Site</h1>
|
|
16
|
+
<div class="subtitle">
|
|
17
|
+
... is a testacular site. Ew, that doesn't sound right at all.
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="navigation">
|
|
21
|
+
<a href="../../index.html">Home</a>
|
|
22
|
+
::
|
|
23
|
+
<a href="../../posts/index.html">Archive</a>
|
|
24
|
+
::
|
|
25
|
+
<a href="../../pages/about/index.html">About</a>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="contents">
|
|
28
|
+
|
|
29
|
+
<div class="post">
|
|
30
|
+
<h2>Fun for the whole family</h2>
|
|
31
|
+
<div class="body">
|
|
32
|
+
|
|
33
|
+
<p>I'll be visible on index page, rss feed and probably the post page. My Site</p>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<p>I'm the main body. There are 3 available.</p>
|
|
37
|
+
<p>It's good to use <code class="javascript">document.onload</code></p>
|
|
38
|
+
<pre><code class="ruby">class Test
|
|
39
|
+
def init
|
|
40
|
+
puts "INIT"
|
|
41
|
+
end
|
|
42
|
+
end</code></pre>
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
<div class="meta">
|
|
46
|
+
Published on 12/18/2008. 23 words.
|
|
47
|
+
</div>
|
|
48
|
+
<div>
|
|
49
|
+
<div>
|
|
50
|
+
|
|
51
|
+
<a href="../../posts/new-blog/index.html">« New Blog!</a>
|
|
52
|
+
|
|
53
|
+
<a href="../../index.html">Home</a>
|
|
54
|
+
|
|
55
|
+
<a href="../../posts/life-is-quite-fun-really/index.html">Life is quite fun, really »</a>
|
|
56
|
+
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="footer">
|
|
62
|
+
© 2008 Me. All rights reserved.
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
5
|
+
<title>My Site</title>
|
|
6
|
+
<script src="../theme/scripts/code_highlighter.js"></script>
|
|
7
|
+
<script src="../theme/scripts/code_syntax.js"></script>
|
|
8
|
+
<link href="../theme/styles/main.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
9
|
+
<link href="../theme/styles/code_syntax.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
10
|
+
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="page-container">
|
|
14
|
+
<div class="header">
|
|
15
|
+
<h1>My Site</h1>
|
|
16
|
+
<div class="subtitle">
|
|
17
|
+
... is a testacular site. Ew, that doesn't sound right at all.
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="navigation">
|
|
21
|
+
<a href="../index.html">Home</a>
|
|
22
|
+
::
|
|
23
|
+
<a href="../posts/index.html">Archive</a>
|
|
24
|
+
::
|
|
25
|
+
<a href="../pages/about/index.html">About</a>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="contents">
|
|
28
|
+
|
|
29
|
+
<div class="posts">
|
|
30
|
+
|
|
31
|
+
<div class="post summary">
|
|
32
|
+
<h2>Life is quite fun, really <span>12/18/2008</span></h2>
|
|
33
|
+
|
|
34
|
+
<p>Summary is as summary does.</p>
|
|
35
|
+
|
|
36
|
+
<a href="../posts/life-is-quite-fun-really/index.html">Read more...</a>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div class="post summary">
|
|
40
|
+
<h2>Fun for the whole family <span>12/18/2008</span></h2>
|
|
41
|
+
|
|
42
|
+
<p>I'll be visible on index page, rss feed and probably the post page. My Site</p>
|
|
43
|
+
|
|
44
|
+
<a href="../posts/fun-for-the-whole-family/index.html">Read more...</a>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div class="post summary">
|
|
48
|
+
<h2>New Blog! <span>12/12/2008</span></h2>
|
|
49
|
+
|
|
50
|
+
<p>I'm the summary</p>
|
|
51
|
+
<p>I'll be visible on index page, rss feed and probably the post page.</p>
|
|
52
|
+
|
|
53
|
+
<a href="../posts/new-blog/index.html">Read more...</a>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="footer">
|
|
59
|
+
© 2008 Me. All rights reserved.
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
5
|
+
<title>My Site</title>
|
|
6
|
+
<script src="../../theme/scripts/code_highlighter.js"></script>
|
|
7
|
+
<script src="../../theme/scripts/code_syntax.js"></script>
|
|
8
|
+
<link href="../../theme/styles/main.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
9
|
+
<link href="../../theme/styles/code_syntax.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
10
|
+
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="page-container">
|
|
14
|
+
<div class="header">
|
|
15
|
+
<h1>My Site</h1>
|
|
16
|
+
<div class="subtitle">
|
|
17
|
+
... is a testacular site. Ew, that doesn't sound right at all.
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="navigation">
|
|
21
|
+
<a href="../../index.html">Home</a>
|
|
22
|
+
::
|
|
23
|
+
<a href="../../posts/index.html">Archive</a>
|
|
24
|
+
::
|
|
25
|
+
<a href="../../pages/about/index.html">About</a>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="contents">
|
|
28
|
+
|
|
29
|
+
<div class="post">
|
|
30
|
+
<h2>Life is quite fun, really</h2>
|
|
31
|
+
<div class="body">
|
|
32
|
+
|
|
33
|
+
<p>Summary is as summary does.</p>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<p>Hello, I’m a post. Nice huh?</p>
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
<div class="meta">
|
|
40
|
+
Published on 12/18/2008. 6 words.
|
|
41
|
+
</div>
|
|
42
|
+
<div>
|
|
43
|
+
<div>
|
|
44
|
+
|
|
45
|
+
<a href="../../posts/fun-for-the-whole-family/index.html">« Fun for the whole family</a>
|
|
46
|
+
|
|
47
|
+
<a href="../../index.html">Home</a>
|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="footer">
|
|
54
|
+
© 2008 Me. All rights reserved.
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Not all functions will work in IE
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function DomElement(e) {
|
|
6
|
+
this.element = e;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
DomElement.prototype = {
|
|
10
|
+
hasClass: function(className) {
|
|
11
|
+
return (this.element.className.indexOf(className) >= 0);
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
addClass: function(className, force) {
|
|
15
|
+
if(force || !this.hasClass(className) ) {
|
|
16
|
+
var klasses = this.element.className.split(' ')
|
|
17
|
+
klasses.push(className);
|
|
18
|
+
this.element.className = klasses.join(' ');
|
|
19
|
+
}
|
|
20
|
+
return this;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
removeClass: function(className, force) {
|
|
24
|
+
if(force || this.hasClass(className)) {
|
|
25
|
+
var klasses = this.element.className.split(' ');
|
|
26
|
+
var newKlasses = [];
|
|
27
|
+
for (var i=0; i < klasses.length; i++) {
|
|
28
|
+
if(klasses[i] != className)
|
|
29
|
+
newKlasses.push(klasses[i]);
|
|
30
|
+
}
|
|
31
|
+
this.element.className = newKlasses.join(' ');
|
|
32
|
+
}
|
|
33
|
+
return this;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
toggleClass: function(className) {
|
|
37
|
+
if( this.hasClass(className) ) {
|
|
38
|
+
this.removeClass( className, true );
|
|
39
|
+
} else {
|
|
40
|
+
this.addClass( className, true );
|
|
41
|
+
}
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function dom(id) {
|
|
47
|
+
var elem = (typeof(id) == 'string') ? document.getElementById(id) : id;
|
|
48
|
+
return new DomElement( elem );
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
|
|
54
|
+
dom('home_button').hasClass('disabled');
|
|
55
|
+
|
|
56
|
+
onclick="dom(this).toggleClass('selected')"
|
|
57
|
+
|
|
58
|
+
onclick="dom(document.body).addClass('selected')"
|
|
59
|
+
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function StatefulElement(e) {
|
|
64
|
+
this.element = e;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
StatefulElement.prototype = {
|
|
68
|
+
is: function(state) {
|
|
69
|
+
return (this.element.className.indexOf(state) >= 0);
|
|
70
|
+
},
|
|
71
|
+
has: function(state) {
|
|
72
|
+
return this.is(state);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
set: function(state) {
|
|
76
|
+
if(! this.has(state) ) {
|
|
77
|
+
var klasses = this.element.className.split(' ')
|
|
78
|
+
klasses.push(state);
|
|
79
|
+
this.element.className = klasses.join(' ');
|
|
80
|
+
}
|
|
81
|
+
return this;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
clear: function(state) {
|
|
85
|
+
if(this.has(state)) {
|
|
86
|
+
klasses = this.element.className.split(' ');
|
|
87
|
+
newKlasses = [];
|
|
88
|
+
for (var i=0; i < klasses.length; i++) {
|
|
89
|
+
if(klasses[i] != state && state != '*')
|
|
90
|
+
newKlasses.push(klasses[i]);
|
|
91
|
+
}
|
|
92
|
+
this.element.className = newKlasses.join(' ');
|
|
93
|
+
}
|
|
94
|
+
return this;
|
|
95
|
+
},
|
|
96
|
+
unset: function(state) {
|
|
97
|
+
return this.clear(state);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
toggle: function(state) {
|
|
101
|
+
if(this.has(state)) this.clear( state );
|
|
102
|
+
else this.set( state );
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function stateFor(id) {
|
|
108
|
+
var elem = (typeof(id) == 'string') ? document.getElementById(id) : id;
|
|
109
|
+
return new StatefulElement(elem);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
/*
|
|
114
|
+
|
|
115
|
+
stateFor(document.body).is('selected')
|
|
116
|
+
|
|
117
|
+
stateFor(this).set('selected')
|
|
118
|
+
|
|
119
|
+
stateFor(this).cleard('selected')
|
|
120
|
+
|
|
121
|
+
stateFor(this).clear('*')
|
|
122
|
+
|
|
123
|
+
*/
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
5
|
+
<title>My Site</title>
|
|
6
|
+
<script src="../../theme/scripts/code_highlighter.js"></script>
|
|
7
|
+
<script src="../../theme/scripts/code_syntax.js"></script>
|
|
8
|
+
<link href="../../theme/styles/main.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
9
|
+
<link href="../../theme/styles/code_syntax.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
|
10
|
+
<script src="../../posts/new-blog/dom.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="page-container">
|
|
14
|
+
<div class="header">
|
|
15
|
+
<h1>My Site</h1>
|
|
16
|
+
<div class="subtitle">
|
|
17
|
+
... is a testacular site. Ew, that doesn't sound right at all.
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="navigation">
|
|
21
|
+
<a href="../../index.html">Home</a>
|
|
22
|
+
::
|
|
23
|
+
<a href="../../posts/index.html">Archive</a>
|
|
24
|
+
::
|
|
25
|
+
<a href="../../pages/about/index.html">About</a>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="contents">
|
|
28
|
+
|
|
29
|
+
<div class="post">
|
|
30
|
+
<h2>New Blog!</h2>
|
|
31
|
+
<div class="body">
|
|
32
|
+
|
|
33
|
+
<p>I'm the summary</p>
|
|
34
|
+
<p>I'll be visible on index page, rss feed and probably the post page.</p>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<p>I'm the main <strong>body</strong>.</p>
|
|
38
|
+
|
|
39
|
+
<p>I'll probably only be shown on the post page.</p>
|
|
40
|
+
|
|
41
|
+
<p>Attachment path: posts/new-blog/old.html</p>
|
|
42
|
+
|
|
43
|
+
<p>How about some code?</p>
|
|
44
|
+
|
|
45
|
+
<pre><code class="javascript">/*
|
|
46
|
+
Not all functions will work in IE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
function DomElement(e) {
|
|
50
|
+
this.element = e;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
DomElement.prototype = {
|
|
54
|
+
hasClass: function(className) {
|
|
55
|
+
return (this.element.className.indexOf(className) >= 0);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
addClass: function(className, force) {
|
|
59
|
+
if(force || !this.hasClass(className) ) {
|
|
60
|
+
var klasses = this.element.className.split(' ')
|
|
61
|
+
klasses.push(className);
|
|
62
|
+
this.element.className = klasses.join(' ');
|
|
63
|
+
}
|
|
64
|
+
return this;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
removeClass: function(className, force) {
|
|
68
|
+
if(force || this.hasClass(className)) {
|
|
69
|
+
var klasses = this.element.className.split(' ');
|
|
70
|
+
var newKlasses = [];
|
|
71
|
+
for (var i=0; i < klasses.length; i++) {
|
|
72
|
+
if(klasses[i] != className)
|
|
73
|
+
newKlasses.push(klasses[i]);
|
|
74
|
+
}
|
|
75
|
+
this.element.className = newKlasses.join(' ');
|
|
76
|
+
}
|
|
77
|
+
return this;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
toggleClass: function(className) {
|
|
81
|
+
if( this.hasClass(className) ) {
|
|
82
|
+
this.removeClass( className, true );
|
|
83
|
+
} else {
|
|
84
|
+
this.addClass( className, true );
|
|
85
|
+
}
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function dom(id) {
|
|
91
|
+
var elem = (typeof(id) == 'string') ? document.getElementById(id) : id;
|
|
92
|
+
return new DomElement( elem );
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
|
|
98
|
+
dom('home_button').hasClass('disabled');
|
|
99
|
+
|
|
100
|
+
onclick="dom(this).toggleClass('selected')"
|
|
101
|
+
|
|
102
|
+
onclick="dom(document.body).addClass('selected')"
|
|
103
|
+
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function StatefulElement(e) {
|
|
108
|
+
this.element = e;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
StatefulElement.prototype = {
|
|
112
|
+
is: function(state) {
|
|
113
|
+
return (this.element.className.indexOf(state) >= 0);
|
|
114
|
+
},
|
|
115
|
+
has: function(state) {
|
|
116
|
+
return this.is(state);
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
set: function(state) {
|
|
120
|
+
if(! this.has(state) ) {
|
|
121
|
+
var klasses = this.element.className.split(' ')
|
|
122
|
+
klasses.push(state);
|
|
123
|
+
this.element.className = klasses.join(' ');
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
clear: function(state) {
|
|
129
|
+
if(this.has(state)) {
|
|
130
|
+
klasses = this.element.className.split(' ');
|
|
131
|
+
newKlasses = [];
|
|
132
|
+
for (var i=0; i < klasses.length; i++) {
|
|
133
|
+
if(klasses[i] != state && state != '*')
|
|
134
|
+
newKlasses.push(klasses[i]);
|
|
135
|
+
}
|
|
136
|
+
this.element.className = newKlasses.join(' ');
|
|
137
|
+
}
|
|
138
|
+
return this;
|
|
139
|
+
},
|
|
140
|
+
unset: function(state) {
|
|
141
|
+
return this.clear(state);
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
toggle: function(state) {
|
|
145
|
+
if(this.has(state)) this.clear( state );
|
|
146
|
+
else this.set( state );
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function stateFor(id) {
|
|
152
|
+
var elem = (typeof(id) == 'string') ? document.getElementById(id) : id;
|
|
153
|
+
return new StatefulElement(elem);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
|
|
159
|
+
stateFor(document.body).is('selected')
|
|
160
|
+
|
|
161
|
+
stateFor(this).set('selected')
|
|
162
|
+
|
|
163
|
+
stateFor(this).cleard('selected')
|
|
164
|
+
|
|
165
|
+
stateFor(this).clear('*')
|
|
166
|
+
|
|
167
|
+
*/</code></pre>
|
|
168
|
+
|
|
169
|
+
<button onclick="alert(stateFor(document.body).is('loaded'))">Is Loaded?</button>
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
</div>
|
|
173
|
+
<div class="meta">
|
|
174
|
+
Published on 12/12/2008. 285 words.
|
|
175
|
+
</div>
|
|
176
|
+
<div>
|
|
177
|
+
<div>
|
|
178
|
+
|
|
179
|
+
<a href="../../index.html">Home</a>
|
|
180
|
+
|
|
181
|
+
<a href="../../posts/fun-for-the-whole-family/index.html">Fun for the whole family »</a>
|
|
182
|
+
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<div class="footer">
|
|
188
|
+
© 2008 Me. All rights reserved.
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</body>
|
|
192
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<head>
|
|
2
|
+
<title>New Blog!</title>
|
|
3
|
+
<meta name="tags" content="news"/>
|
|
4
|
+
</head>
|
|
5
|
+
<summary>
|
|
6
|
+
<c:textile>
|
|
7
|
+
I'm the summary
|
|
8
|
+
|
|
9
|
+
I'll be visible on index page, rss feed and probably the post page.
|
|
10
|
+
</c:textile>
|
|
11
|
+
</summary>
|
|
12
|
+
<body>
|
|
13
|
+
<c:markdown>
|
|
14
|
+
I'm the main body.
|
|
15
|
+
|
|
16
|
+
I'll probably only be shown on the post page.
|
|
17
|
+
</c:markdown>
|
|
18
|
+
</body>
|