staticmatic 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -99,6 +99,7 @@ module StaticMatic
99
99
  end
100
100
 
101
101
  def source_for_layout
102
+
102
103
  if layout_exists?(@layout)
103
104
  File.read(full_layout_path(@layout))
104
105
  else
@@ -110,20 +111,41 @@ module StaticMatic
110
111
  # generate_html("index.haml")
111
112
  def generate_html(source_file, source_dir = '')
112
113
  full_file_path = File.join(@src_dir, 'pages', source_dir, "#{source_file}.haml")
114
+
115
+ begin
116
+ html = generate_html_from_template_source(File.read(full_file_path))
113
117
 
114
- html = generate_html_from_template_source(File.read(full_file_path)) {}
115
-
116
- # TODO: DRY this up
117
- if @scope.instance_variable_get("@layout")
118
- @layout = @scope.instance_variable_get("@layout")
118
+ @layout = detirmine_layout(source_dir)
119
+ rescue StaticMatic::Error => staticmatic_error
120
+ # Catch any errors from the actual template - otherwise the error will be assumed to be from the
121
+ # layout
122
+ raise staticmatic_error
123
+ rescue Haml::Error => haml_error
124
+ raise StaticMatic::Error.new(haml_error.haml_line, "#{source_dir}/#{source_file}", haml_error.message)
119
125
  end
120
126
 
127
+ #
128
+ # # TODO: DRY this up
129
+ # if @scope.instance_variable_get("@layout")
130
+ # @layout = @scope.instance_variable_get("@layout")
131
+ # end
132
+ #
121
133
  html
122
134
  end
123
135
 
124
136
  def generate_html_with_layout(source, source_dir = '')
125
- @layout = layout_from_source_dir(source_dir)
126
- generate_html_from_template_source(source_for_layout) { generate_html(source, source_dir) }
137
+ template_content = generate_html(source, source_dir)
138
+ @layout = detirmine_layout(source_dir)
139
+
140
+ begin
141
+ generate_html_from_template_source(source_for_layout) { template_content }
142
+ rescue StaticMatic::Error => staticmatic_error
143
+ # Catch any errors from the actual template - otherwise the error will be assumed to be from the
144
+ # layout
145
+ raise staticmatic_error
146
+ rescue Haml::Error => haml_error
147
+ raise StaticMatic::Error.new(haml_error.haml_line, "Layout: #{source_dir}/#{@layout}", haml_error.message)
148
+ end
127
149
  end
128
150
 
129
151
  def generate_partial(name)
@@ -134,8 +156,8 @@ module StaticMatic
134
156
  end
135
157
  end
136
158
 
137
- def generate_css(source)
138
- full_file_path = "#{@src_dir}/stylesheets/#{source}.sass"
159
+ def generate_css(source, source_dir = '')
160
+ full_file_path = File.join(@src_dir, 'stylesheets', source_dir, "#{source}.sass")
139
161
  begin
140
162
  stylesheet = Sass::Engine.new(File.read(full_file_path))
141
163
  stylesheet.to_css
@@ -155,22 +177,16 @@ module StaticMatic
155
177
  def generate_html_from_template_source(source)
156
178
 
157
179
  html = Haml::Engine.new(source)
158
-
159
- begin
160
- html.render(@scope) { yield }
161
- rescue StaticMatic::Error => staticmatic_error
162
- # Catch any errors from the actual template - otherwise the error will be assumed to be from the
163
- # layout
164
- raise staticmatic_error
165
- rescue Haml::Error => haml_error
166
- raise StaticMatic::Error.new(haml_error.haml_line, "Layout: #{@layout}", haml_error.message)
167
- end
180
+
181
+ html.render(@scope) { yield }
168
182
  end
169
183
 
170
- def layout_from_source_dir(dir)
184
+ def detirmine_layout(dir = '')
171
185
  layout_name = "application"
172
-
173
- if dir
186
+
187
+ if @scope.instance_variable_get("@layout")
188
+ layout_name = @scope.instance_variable_get("@layout")
189
+ elsif dir
174
190
  dirs = dir.split("/")
175
191
  dir_layout_name = dirs[1]
176
192
 
@@ -178,7 +194,7 @@ module StaticMatic
178
194
  layout_name = dir_layout_name
179
195
  end
180
196
  end
181
-
197
+
182
198
  layout_name
183
199
  end
184
200
 
@@ -73,7 +73,7 @@ module StaticMatic
73
73
 
74
74
  # Generates an image tag
75
75
  def img(name, options = {})
76
- options[:src] = "images/#{name}"
76
+ options[:src] = "/images/#{name}"
77
77
  options[:alt] ||= name.split('.').first.capitalize.gsub(/_|-/, ' ')
78
78
  tag :img, options
79
79
  end
@@ -18,7 +18,7 @@ module StaticMatic
18
18
 
19
19
  if file_ext && file_ext.match(/html|css/)
20
20
  response.start(200) do |head, out|
21
- head["Content-Type"] = "text/html"
21
+ head["Content-Type"] = "text/#{file_ext}"
22
22
  output = ""
23
23
 
24
24
  if @staticmatic.template_exists?(file_name, file_dir)
Binary file
data/test/base_test.rb CHANGED
@@ -47,6 +47,6 @@ class StaticMaticBaseTest < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  def test_should_find_layout_from_passed_path
50
- assert_equal "projects", @staticmatic.layout_from_source_dir("test/projects")
50
+ assert_equal "projects", @staticmatic.detirmine_layout("test/projects")
51
51
  end
52
52
  end
@@ -9,7 +9,7 @@
9
9
  <div id='container'>
10
10
  <div id='header'>
11
11
  <div class='bycurve21'>
12
- <a href="http://www.curve21.com"><img alt="Bycurve21" src="images/bycurve21.gif"/>
12
+ <a href="http://www.curve21.com"><img alt="Bycurve21" src="/images/bycurve21.gif"/>
13
13
  </a>
14
14
  </div>
15
15
  <div class='title'>StaticMatic</div>
@@ -17,18 +17,32 @@
17
17
  <div id='menu'>
18
18
  <ul>
19
19
  <li><a href="/">Home</a></li>
20
- <li><a href="download.html">Download</a></li>
21
- <li><a href="how_to_use.html">How to use</a></li>
20
+ <li><a href="/download.html">Download</a></li>
21
+ <li><a href="/how_to_use.html">How to use</a></li>
22
22
  <li>
23
23
  <a href="http://rubyforge.org/projects/staticmatic">Development</a>
24
24
  </li>
25
25
  <li>
26
26
  <a href="http://groups.google.co.uk/group/staticmatic">Community</a>
27
27
  </li>
28
- <li><a href="faq.html">FAQ</a></li>
28
+ <li><a href="/faq.html">FAQ</a></li>
29
29
  </ul>
30
30
  </div>
31
31
  <div id='content_wrapper'>
32
+ <div id='side'>
33
+ <div id='news'>
34
+ <div class='heading'>News</div>
35
+ <div class='title'>0.8.4 Released!</div>
36
+ <p>
37
+ You can now enjoy:
38
+ </p>
39
+ <ul>
40
+ <li>Multiple directories</li>
41
+ <li>Partials</li>
42
+ </ul>
43
+ <a href="/releases/0_8_4.html">And More!</a>
44
+ </div>
45
+ </div>
32
46
  <div id='content'>
33
47
  <h1>Download</h1>
34
48
  <p>
@@ -9,7 +9,7 @@
9
9
  <div id='container'>
10
10
  <div id='header'>
11
11
  <div class='bycurve21'>
12
- <a href="http://www.curve21.com"><img alt="Bycurve21" src="images/bycurve21.gif"/>
12
+ <a href="http://www.curve21.com"><img alt="Bycurve21" src="/images/bycurve21.gif"/>
13
13
  </a>
14
14
  </div>
15
15
  <div class='title'>StaticMatic</div>
@@ -17,18 +17,32 @@
17
17
  <div id='menu'>
18
18
  <ul>
19
19
  <li><a href="/">Home</a></li>
20
- <li><a href="download.html">Download</a></li>
21
- <li><a href="how_to_use.html">How to use</a></li>
20
+ <li><a href="/download.html">Download</a></li>
21
+ <li><a href="/how_to_use.html">How to use</a></li>
22
22
  <li>
23
23
  <a href="http://rubyforge.org/projects/staticmatic">Development</a>
24
24
  </li>
25
25
  <li>
26
26
  <a href="http://groups.google.co.uk/group/staticmatic">Community</a>
27
27
  </li>
28
- <li><a href="faq.html">FAQ</a></li>
28
+ <li><a href="/faq.html">FAQ</a></li>
29
29
  </ul>
30
30
  </div>
31
31
  <div id='content_wrapper'>
32
+ <div id='side'>
33
+ <div id='news'>
34
+ <div class='heading'>News</div>
35
+ <div class='title'>0.8.4 Released!</div>
36
+ <p>
37
+ You can now enjoy:
38
+ </p>
39
+ <ul>
40
+ <li>Multiple directories</li>
41
+ <li>Partials</li>
42
+ </ul>
43
+ <a href="/releases/0_8_4.html">And More!</a>
44
+ </div>
45
+ </div>
32
46
  <div id='content'>
33
47
  <h1>FAQ</h1>
34
48
  <h3>
@@ -9,7 +9,7 @@
9
9
  <div id='container'>
10
10
  <div id='header'>
11
11
  <div class='bycurve21'>
12
- <a href="http://www.curve21.com"><img alt="Bycurve21" src="images/bycurve21.gif"/>
12
+ <a href="http://www.curve21.com"><img alt="Bycurve21" src="/images/bycurve21.gif"/>
13
13
  </a>
14
14
  </div>
15
15
  <div class='title'>StaticMatic</div>
@@ -17,18 +17,32 @@
17
17
  <div id='menu'>
18
18
  <ul>
19
19
  <li><a href="/">Home</a></li>
20
- <li><a href="download.html">Download</a></li>
21
- <li><a href="how_to_use.html">How to use</a></li>
20
+ <li><a href="/download.html">Download</a></li>
21
+ <li><a href="/how_to_use.html">How to use</a></li>
22
22
  <li>
23
23
  <a href="http://rubyforge.org/projects/staticmatic">Development</a>
24
24
  </li>
25
25
  <li>
26
26
  <a href="http://groups.google.co.uk/group/staticmatic">Community</a>
27
27
  </li>
28
- <li><a href="faq.html">FAQ</a></li>
28
+ <li><a href="/faq.html">FAQ</a></li>
29
29
  </ul>
30
30
  </div>
31
31
  <div id='content_wrapper'>
32
+ <div id='side'>
33
+ <div id='news'>
34
+ <div class='heading'>News</div>
35
+ <div class='title'>0.8.4 Released!</div>
36
+ <p>
37
+ You can now enjoy:
38
+ </p>
39
+ <ul>
40
+ <li>Multiple directories</li>
41
+ <li>Partials</li>
42
+ </ul>
43
+ <a href="/releases/0_8_4.html">And More!</a>
44
+ </div>
45
+ </div>
32
46
  <div id='content'>
33
47
  <h1>How to Use</h1>
34
48
  <p>
@@ -9,7 +9,7 @@
9
9
  <div id='container'>
10
10
  <div id='header'>
11
11
  <div class='bycurve21'>
12
- <a href="http://www.curve21.com"><img alt="Bycurve21" src="images/bycurve21.gif"/>
12
+ <a href="http://www.curve21.com"><img alt="Bycurve21" src="/images/bycurve21.gif"/>
13
13
  </a>
14
14
  </div>
15
15
  <div class='title'>StaticMatic</div>
@@ -17,18 +17,32 @@
17
17
  <div id='menu'>
18
18
  <ul>
19
19
  <li><a href="/">Home</a></li>
20
- <li><a href="download.html">Download</a></li>
21
- <li><a href="how_to_use.html">How to use</a></li>
20
+ <li><a href="/download.html">Download</a></li>
21
+ <li><a href="/how_to_use.html">How to use</a></li>
22
22
  <li>
23
23
  <a href="http://rubyforge.org/projects/staticmatic">Development</a>
24
24
  </li>
25
25
  <li>
26
26
  <a href="http://groups.google.co.uk/group/staticmatic">Community</a>
27
27
  </li>
28
- <li><a href="faq.html">FAQ</a></li>
28
+ <li><a href="/faq.html">FAQ</a></li>
29
29
  </ul>
30
30
  </div>
31
31
  <div id='content_wrapper'>
32
+ <div id='side'>
33
+ <div id='news'>
34
+ <div class='heading'>News</div>
35
+ <div class='title'>0.8.4 Released!</div>
36
+ <p>
37
+ You can now enjoy:
38
+ </p>
39
+ <ul>
40
+ <li>Multiple directories</li>
41
+ <li>Partials</li>
42
+ </ul>
43
+ <a href="/releases/0_8_4.html">And More!</a>
44
+ </div>
45
+ </div>
32
46
  <div id='content'>
33
47
  <h1>Static websites, the modern way</h1>
34
48
  <p>
@@ -47,16 +61,16 @@
47
61
  <div class='columns'>
48
62
  <div class='left_column'>
49
63
  <em>Concise and terse Haml Templating</em>
50
- <img alt="Homepage templating" src="images/homepage-templating.jpg"/>
64
+ <img alt="Homepage templating" src="/images/homepage-templating.jpg"/>
51
65
  </div>
52
66
  <div class='right_column'>
53
67
  <em>Live preview server for development</em>
54
- <img alt="Homepage previewing" src="images/homepage-previewing.jpg"/>
68
+ <img alt="Homepage previewing" src="/images/homepage-previewing.jpg"/>
55
69
  </div>
56
70
  </div>
57
71
  <p>
58
72
  <em>Output full HTML pages</em>
59
- <img alt="Homepage build" src="images/homepage-build.jpg"/>
73
+ <img alt="Homepage build" src="/images/homepage-build.jpg"/>
60
74
  </p>
61
75
  </div>
62
76
  </div>
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml: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>StaticMatic</title>
6
+ <link href="/stylesheets/application.css" media="all" rel="stylesheet"/>
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id='header'>
11
+ <div class='bycurve21'>
12
+ <a href="http://www.curve21.com"><img alt="Bycurve21" src="/images/bycurve21.gif"/>
13
+ </a>
14
+ </div>
15
+ <div class='title'>StaticMatic</div>
16
+ </div>
17
+ <div id='menu'>
18
+ <ul>
19
+ <li><a href="/">Home</a></li>
20
+ <li><a href="/download.html">Download</a></li>
21
+ <li><a href="/how_to_use.html">How to use</a></li>
22
+ <li>
23
+ <a href="http://rubyforge.org/projects/staticmatic">Development</a>
24
+ </li>
25
+ <li>
26
+ <a href="http://groups.google.co.uk/group/staticmatic">Community</a>
27
+ </li>
28
+ <li><a href="/faq.html">FAQ</a></li>
29
+ </ul>
30
+ </div>
31
+ <div id='content_wrapper'>
32
+ <div id='side'>
33
+ <div id='news'>
34
+ <div class='heading'>News</div>
35
+ <div class='title'>0.8.4 Released!</div>
36
+ <p>
37
+ You can now enjoy:
38
+ </p>
39
+ <ul>
40
+ <li>Multiple directories</li>
41
+ <li>Partials</li>
42
+ </ul>
43
+ <a href="/releases/0_8_4.html">And More!</a>
44
+ </div>
45
+ </div>
46
+ <div id='content'>
47
+ <h1>StaticMatic 0.8.4</h1>
48
+ <p>
49
+ Don't be fooled by the small minor increments - there's loads of great stuff in the latest release:
50
+ </p>
51
+ <h2>Sub-Directory Support</h2>
52
+ <p>
53
+ Thanks to Brent Beardsley, you can now have as many directories as you like. This should be considered 'beta' at the moment as there is likely to be issues with paths in the helpers, but try it out and we'll figure out the best solution.
54
+ </p>
55
+ <h2>Partials!</h2>
56
+ <p>
57
+ Simply create a 'partials' directory in your src/ and you'll be able to do:
58
+ <div class='code'>partial("partial_name")</div>
59
+ </p>
60
+ <h2>Layouts based on directory</h2>
61
+ <p>
62
+ Along with sub-directory support, you can also create layouts based on the sub-directory a template is in. For example, if you have a 'projects' directory and would like it to render a different template, simply create 'projects.haml' in your layouts directory.
63
+ </p>
64
+ <h2>Relative Stylesheet Linking</h2>
65
+ <p>
66
+ You can now tell the stylesheet helper to use relative linking:
67
+ <div class='code'>= stylesheets :relative => true</div>
68
+ </p>
69
+ <p>
70
+ <em>
71
+ Note that you may get issues with nested directories and relative stylesheets
72
+ </em>
73
+ </p>
74
+ <h2>What's Next?</h2>
75
+ <p>
76
+ The main things on the list are configuration and clearing up any bugs not yet sorted. It'd also be great to start extending the test set more.
77
+ </p>
78
+ </div>
79
+ </div>
80
+ <div id='footer'>
81
+ <p>
82
+ Made with StaticMatic, Hosted by
83
+ <a href="http://rubyforge.org">RubyForge</a>
84
+ </p>
85
+ </div>
86
+ <script src='http://www.google-analytics.com/urchin.js' type='text/javascript'>
87
+ _hamlspace = "";
88
+ </script>
89
+ <script type='text/javascript'>
90
+ _uacct = "UA-775359-8";
91
+ urchinTracker();
92
+ </script>
93
+ </div>
94
+ </body>
95
+ </html>
@@ -154,18 +154,6 @@ hr {
154
154
  position: relative;
155
155
  }
156
156
 
157
- #side {
158
- float: right;
159
- width: 200px;
160
- border: 1px solid #aaa;
161
- background-color: #efefef;
162
- padding: 5px;
163
- margin: 0 0 10px 0;
164
- }
165
-
166
- #side a {
167
- display: block;
168
- }
169
157
 
170
158
  #content_wrapper {
171
159
  width: 920px;
@@ -264,6 +252,18 @@ hr {
264
252
  margin: 10px 0 10px 0;
265
253
  }
266
254
 
255
+ #side {
256
+ float: right;
257
+ width: 200px;
258
+ border: 1px solid #aaa;
259
+ background-color: #efefef;
260
+ padding: 5px;
261
+ margin: 0 0 10px 0;
262
+ }
263
+
264
+ #side a {
265
+ display: block;
266
+ }
267
267
 
268
268
 
269
269
  #side #news {
@@ -14,13 +14,24 @@
14
14
 
15
15
  %ul
16
16
  %li= link "Home", "/"
17
- %li= link "Download"
18
- %li= link "How to use"
17
+ %li= link "Download", "/download.html"
18
+ %li= link "How to use", "/how_to_use.html"
19
19
  %li= link "Development", "http://rubyforge.org/projects/staticmatic"
20
20
  %li= link "Community", "http://groups.google.co.uk/group/staticmatic"
21
- %li= link "FAQ"
21
+ %li= link "FAQ", "/faq.html"
22
22
 
23
23
  #content_wrapper
24
+ #side
25
+ #news
26
+ .heading News
27
+ .title 0.8.4 Released!
28
+ %p
29
+ You can now enjoy:
30
+ %ul
31
+ %li Multiple directories
32
+ %li Partials
33
+ = link "And More!", "/releases/0_8_4.html"
34
+
24
35
 
25
36
  #content
26
37
  = yield
@@ -0,0 +1,25 @@
1
+ %h1 StaticMatic 0.8.4
2
+
3
+ %p Don't be fooled by the small minor increments - there's loads of great stuff in the latest release:
4
+
5
+ %h2 Sub-Directory Support
6
+ %p Thanks to Brent Beardsley, you can now have as many directories as you like. This should be considered 'beta' at the moment as there is likely to be issues with paths in the helpers, but try it out and we'll figure out the best solution.
7
+
8
+ %h2 Partials!
9
+ %p
10
+ Simply create a 'partials' directory in your src/ and you'll be able to do:
11
+ .code partial("partial_name")
12
+
13
+ %h2 Layouts based on directory
14
+ %p Along with sub-directory support, you can also create layouts based on the sub-directory a template is in. For example, if you have a 'projects' directory and would like it to render a different template, simply create 'projects.haml' in your layouts directory.
15
+
16
+ %h2 Relative Stylesheet Linking
17
+ %p
18
+ You can now tell the stylesheet helper to use relative linking:
19
+ .code = stylesheets :relative => true
20
+
21
+ %p
22
+ %em Note that you may get issues with nested directories and relative stylesheets
23
+
24
+ %h2 What's Next?
25
+ %p The main things on the list are configuration and clearing up any bugs not yet sorted. It'd also be great to start extending the test set more.
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: staticmatic
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.4
7
- date: 2007-09-18 00:00:00 +01:00
6
+ version: 0.8.5
7
+ date: 2007-09-19 00:00:00 +01:00
8
8
  summary: Manage static sites using Haml & Sass
9
9
  require_paths:
10
10
  - lib
@@ -63,6 +63,7 @@ files:
63
63
  - StaticMatic - website.zip
64
64
  - staticmatic-0.8.0.gem
65
65
  - staticmatic-0.8.1.gem
66
+ - staticmatic-0.8.4.gem
66
67
  - test
67
68
  - test/base_test.rb
68
69
  - test/helpers_test.rb
@@ -102,6 +103,8 @@ files:
102
103
  - website/site/images/homepage-templating.jpg
103
104
  - website/site/index.html
104
105
  - website/site/javascripts
106
+ - website/site/releases
107
+ - website/site/releases/0_8_4.html
105
108
  - website/site/stylesheets
106
109
  - website/site/stylesheets/application.css
107
110
  - website/src
@@ -113,6 +116,8 @@ files:
113
116
  - website/src/pages/faq.haml
114
117
  - website/src/pages/how_to_use.haml
115
118
  - website/src/pages/index.haml
119
+ - website/src/pages/releases
120
+ - website/src/pages/releases/0_8_4.haml
116
121
  - website/src/partials
117
122
  - website/src/stylesheets
118
123
  test_files: