staticmatic 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +24 -0
- data/README.rdoc +48 -0
- data/Rakefile +22 -27
- data/bin/staticmatic +0 -0
- data/lib/staticmatic.rb +12 -4
- data/lib/staticmatic/base.rb +30 -242
- data/lib/staticmatic/mixins/build.rb +46 -0
- data/lib/staticmatic/mixins/helpers.rb +15 -0
- data/lib/staticmatic/mixins/render.rb +125 -0
- data/lib/staticmatic/mixins/rescue.rb +12 -0
- data/lib/staticmatic/mixins/server.rb +6 -0
- data/lib/staticmatic/mixins/setup.rb +20 -0
- data/lib/staticmatic/template_error.rb +40 -0
- data/lib/staticmatic/templates/{application.haml → default/application.haml} +0 -0
- data/lib/staticmatic/templates/{application.sass → default/application.sass} +0 -0
- data/lib/staticmatic/templates/{index.haml → default/index.haml} +0 -0
- data/lib/staticmatic/templates/rescues/default.haml +7 -0
- data/lib/staticmatic/templates/rescues/template.haml +18 -0
- data/test/test_helper.rb +20 -48
- metadata +55 -124
- data/CHANGELOG +0 -57
- data/LICENSE +0 -21
- data/README +0 -56
- data/example/site/contact.html +0 -17
- data/example/site/index.html +0 -16
- data/example/site/javascripts/application.css +0 -2
- data/example/src/layouts/application.haml +0 -11
- data/example/src/pages/contact.haml +0 -3
- data/example/src/pages/index.haml +0 -3
- data/example/src/pages/test test/blah.haml +0 -1
- data/example/src/stylesheets/application.sass +0 -4
- data/lib/staticmatic/version.rb +0 -34
- data/test/base_test.rb +0 -60
- data/test/helpers_test.rb +0 -296
- data/test/sandbox/test_site/configuration.rb +0 -0
- data/test/sandbox/test_site/site/index.html +0 -10
- data/test/sandbox/test_site/site/stylesheets/application.css +0 -2
- data/test/sandbox/test_site/src/helpers/application_helper.rb +0 -5
- data/test/sandbox/test_site/src/layouts/alternate_layout.haml +0 -3
- data/test/sandbox/test_site/src/layouts/application.haml +0 -7
- data/test/sandbox/test_site/src/layouts/projects.haml +0 -1
- data/test/sandbox/test_site/src/pages/index.haml +0 -5
- data/test/sandbox/test_site/src/pages/layout_test.haml +0 -2
- data/test/sandbox/test_site/src/partials/menu.haml +0 -1
- data/test/sandbox/test_site/src/stylesheets/application.sass +0 -2
- data/test/server_test.rb +0 -12
- data/test/test_helper_test.rb +0 -49
- data/test/version_test.rb +0 -28
- data/website/site/download.html +0 -84
- data/website/site/faq.html +0 -101
- data/website/site/helper_central/index.html +0 -144
- data/website/site/how_to_use.html +0 -307
- data/website/site/images/bycurve21.gif +0 -0
- data/website/site/images/curve21.jpg +0 -0
- data/website/site/images/homepage-build.jpg +0 -0
- data/website/site/images/homepage-previewing.jpg +0 -0
- data/website/site/images/homepage-templating.jpg +0 -0
- data/website/site/index.html +0 -98
- data/website/site/releases/0_8_10.html +0 -106
- data/website/site/releases/0_8_4.html +0 -101
- data/website/site/releases/0_8_8.html +0 -96
- data/website/site/releases/0_9_0.html +0 -124
- data/website/site/stylesheets/application.css +0 -287
- data/website/src/helpers/application_helper.rb +0 -5
- data/website/src/layouts/application.haml +0 -43
- data/website/src/layouts/test.haml +0 -4
- data/website/src/pages/_qa.haml +0 -2
- data/website/src/pages/download.haml +0 -15
- data/website/src/pages/faq.haml +0 -8
- data/website/src/pages/helper_central/_helper.haml +0 -7
- data/website/src/pages/helper_central/index.haml +0 -21
- data/website/src/pages/how_to_use.haml +0 -270
- data/website/src/pages/index.haml +0 -27
- data/website/src/pages/releases/0_8_10.haml +0 -22
- data/website/src/pages/releases/0_8_4.haml +0 -25
- data/website/src/pages/releases/0_8_8.haml +0 -35
- data/website/src/pages/releases/0_9_0.haml +0 -34
- data/website/src/partials/news.haml +0 -10
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
bin/staticmatic
|
6
|
+
lib/staticmatic.rb
|
7
|
+
lib/staticmatic/base.rb
|
8
|
+
lib/staticmatic/configuration.rb
|
9
|
+
lib/staticmatic/error.rb
|
10
|
+
lib/staticmatic/helpers.rb
|
11
|
+
lib/staticmatic/mixins/build.rb
|
12
|
+
lib/staticmatic/mixins/helpers.rb
|
13
|
+
lib/staticmatic/mixins/render.rb
|
14
|
+
lib/staticmatic/mixins/server.rb
|
15
|
+
lib/staticmatic/mixins/setup.rb
|
16
|
+
lib/staticmatic/server.rb
|
17
|
+
lib/staticmatic/templates/default/application.haml
|
18
|
+
lib/staticmatic/templates/default/application.sass
|
19
|
+
lib/staticmatic/templates/default/index.haml
|
20
|
+
lib/staticmatic/templates/default/index.haml
|
21
|
+
lib/staticmatic/templates/rescues/default.haml
|
22
|
+
lib/staticmatic/templates/rescues/template.haml
|
23
|
+
lib/staticmatic/template_error.rb
|
24
|
+
lib/staticmatic/mixins/rescue.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= staticmatic-core
|
2
|
+
|
3
|
+
* FIX (url)
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2008 FIXME full name
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,33 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
require 'rake/clean'
|
4
|
-
Gem::manage_gems
|
5
|
-
require 'rake/gempackagetask'
|
6
|
-
require File.join(File.dirname(__FILE__), 'lib/staticmatic/version')
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/staticmatic'
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
s.add_dependency("mongrel")
|
26
|
-
s.executables=['staticmatic']
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('staticmatic', StaticMatic::VERSION) do |p|
|
7
|
+
p.developer('Stephen Bartholomew', 'steve@curve21.com')
|
8
|
+
p.rubyforge_name = p.name
|
9
|
+
p.extra_deps = [
|
10
|
+
['haml','>= 2.0'],
|
11
|
+
['mongrel','>= 1.0']
|
12
|
+
]
|
13
|
+
p.extra_dev_deps = [
|
14
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
15
|
+
]
|
16
|
+
|
17
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
18
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
19
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
20
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
|
23
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
24
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
25
|
+
|
31
26
|
|
32
27
|
desc "Run all unit tests"
|
33
28
|
Rake::TestTask.new(:test) do |t|
|
data/bin/staticmatic
CHANGED
File without changes
|
data/lib/staticmatic.rb
CHANGED
@@ -2,11 +2,19 @@ require 'rubygems'
|
|
2
2
|
require 'haml'
|
3
3
|
require 'sass'
|
4
4
|
require 'mongrel'
|
5
|
-
require
|
5
|
+
require 'fileutils'
|
6
6
|
|
7
|
-
|
7
|
+
module StaticMatic
|
8
|
+
VERSION = '0.10.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
["render", "build", "setup", "server", "helpers", "rescue"].each do |mixin|
|
12
|
+
require File.join(File.dirname(__FILE__), "staticmatic", "mixins", mixin)
|
13
|
+
end
|
8
14
|
|
9
|
-
|
10
|
-
require File.join(File.dirname(__FILE__),
|
15
|
+
["base", "configuration", "error", "server", "helpers", "template_error"].each do |lib|
|
16
|
+
require File.join(File.dirname(__FILE__), "staticmatic", lib)
|
11
17
|
end
|
12
18
|
|
19
|
+
Haml::Helpers.class_eval("include StaticMatic::Helpers")
|
20
|
+
|
data/lib/staticmatic/base.rb
CHANGED
@@ -1,33 +1,38 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
1
|
module StaticMatic
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
# Directories generated for a new site setup
|
3
|
+
BASE_DIRS = %w{
|
4
|
+
site/
|
5
|
+
site/stylesheets
|
6
|
+
site/images
|
7
|
+
site/javascripts
|
8
|
+
src/
|
9
|
+
src/pages/
|
10
|
+
src/layouts
|
11
|
+
src/stylesheets
|
12
|
+
src/helpers
|
13
|
+
}
|
14
|
+
|
15
|
+
# Templates for setup and their location
|
16
|
+
TEMPLATES = {
|
17
|
+
'application.haml' => 'layouts',
|
18
|
+
'application.sass' => 'stylesheets',
|
19
|
+
'index.haml' => 'pages'
|
20
|
+
}
|
18
21
|
|
19
|
-
|
20
|
-
@@templates = {
|
21
|
-
'application.haml' => 'layouts',
|
22
|
-
'application.sass' => 'stylesheets',
|
23
|
-
'index.haml' => 'pages'
|
24
|
-
}
|
22
|
+
class Base
|
25
23
|
|
24
|
+
include StaticMatic::RenderMixin
|
25
|
+
include StaticMatic::BuildMixin
|
26
|
+
include StaticMatic::SetupMixin
|
27
|
+
include StaticMatic::HelpersMixin
|
28
|
+
include StaticMatic::ServerMixin
|
29
|
+
include StaticMatic::RescueMixin
|
30
|
+
|
26
31
|
attr_accessor :configuration
|
27
32
|
attr_reader :current_page, :src_dir, :site_dir
|
28
33
|
|
29
34
|
def current_file
|
30
|
-
@current_file_stack[0]
|
35
|
+
@current_file_stack[0] || ""
|
31
36
|
end
|
32
37
|
|
33
38
|
def initialize(base_dir, configuration = Configuration.new)
|
@@ -37,7 +42,7 @@ module StaticMatic
|
|
37
42
|
@base_dir = base_dir
|
38
43
|
@src_dir = "#{@base_dir}/src"
|
39
44
|
@site_dir = "#{@base_dir}/site"
|
40
|
-
@templates_dir = File.dirname(__FILE__) + '/templates'
|
45
|
+
@templates_dir = File.dirname(__FILE__) + '/templates/default/'
|
41
46
|
@layout = "application"
|
42
47
|
@scope = Object.new
|
43
48
|
@scope.instance_variable_set("@staticmatic", self)
|
@@ -55,185 +60,7 @@ module StaticMatic
|
|
55
60
|
puts "#{command} is not a valid StaticMatic command"
|
56
61
|
end
|
57
62
|
end
|
58
|
-
|
59
|
-
def build
|
60
|
-
build_css
|
61
|
-
build_html
|
62
|
-
end
|
63
|
-
|
64
|
-
def setup
|
65
|
-
Dir.mkdir(@base_dir) unless File.exists?(@base_dir)
|
66
|
-
|
67
|
-
@@base_dirs.each do |directory|
|
68
|
-
directory = "#{@base_dir}/#{directory}"
|
69
|
-
if !File.exists?(directory)
|
70
|
-
Dir.mkdir(directory)
|
71
|
-
puts "created #{directory}"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
@@templates.each do |template, destination|
|
76
|
-
copy_file("#{@templates_dir}/#{template}", "#{@src_dir}/#{destination}")
|
77
|
-
end
|
78
|
-
|
79
|
-
puts "Done"
|
80
|
-
end
|
81
|
-
|
82
|
-
def preview
|
83
|
-
puts "StaticMatic Preview Server Starting..."
|
84
|
-
StaticMatic::Server.start(self)
|
85
|
-
end
|
86
|
-
|
87
|
-
def copy_file(from, to)
|
88
|
-
FileUtils.cp(from, to)
|
89
|
-
end
|
90
|
-
|
91
|
-
def save_page(filename, content)
|
92
|
-
generate_site_file(filename, 'html', content)
|
93
|
-
end
|
94
|
-
|
95
|
-
def save_stylesheet(filename, content)
|
96
|
-
generate_site_file(File.join('stylesheets', filename), 'css', content)
|
97
|
-
end
|
98
|
-
|
99
|
-
def generate_site_file(filename, extension, content)
|
100
|
-
path = File.join(@site_dir,"#{filename}.#{extension}")
|
101
|
-
FileUtils.mkdir_p(File.dirname(path))
|
102
|
-
File.open(path, 'w+') do |f|
|
103
|
-
f << content
|
104
|
-
end
|
105
|
-
|
106
|
-
puts "created #{path}"
|
107
|
-
end
|
108
|
-
|
109
|
-
def source_for_layout
|
110
|
-
if layout_exists?(@layout)
|
111
|
-
File.read(full_layout_path(@layout))
|
112
|
-
else
|
113
|
-
raise StaticMatic::Error.new("", full_layout_path(@layout), "Layout not found")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# Generate html from source file:
|
118
|
-
# generate_html("index.haml")
|
119
|
-
def generate_html(source_file, source_dir = '')
|
120
|
-
full_file_path = File.join(@src_dir, 'pages', source_dir, "#{source_file}.haml")
|
121
|
-
|
122
|
-
begin
|
123
|
-
# clear all scope variables except @staticmatic
|
124
|
-
@scope.instance_variables.each do |var|
|
125
|
-
@scope.instance_variable_set(var, nil) unless var == '@staticmatic'
|
126
|
-
end
|
127
|
-
html = generate_html_from_template_source(File.read(full_file_path))
|
128
63
|
|
129
|
-
@layout = detirmine_layout(source_dir)
|
130
|
-
rescue StaticMatic::Error => staticmatic_error
|
131
|
-
# Catch any errors from the actual template - otherwise the error will be assumed to be from the
|
132
|
-
# layout
|
133
|
-
raise staticmatic_error
|
134
|
-
rescue Haml::Error => haml_error
|
135
|
-
raise StaticMatic::Error.new(haml_error.line, "#{source_dir}/#{source_file}", haml_error.message)
|
136
|
-
end
|
137
|
-
|
138
|
-
#
|
139
|
-
# # TODO: DRY this up
|
140
|
-
# if @scope.instance_variable_get("@layout")
|
141
|
-
# @layout = @scope.instance_variable_get("@layout")
|
142
|
-
# end
|
143
|
-
#
|
144
|
-
html
|
145
|
-
end
|
146
|
-
|
147
|
-
def generate_html_with_layout(source, source_dir = '')
|
148
|
-
@current_page = File.join(source_dir, "#{source}.html")
|
149
|
-
@current_file_stack.unshift(File.join(source_dir, "#{source}.haml"))
|
150
|
-
|
151
|
-
template_content = generate_html(source, source_dir)
|
152
|
-
@layout = detirmine_layout(source_dir)
|
153
|
-
|
154
|
-
begin
|
155
|
-
generate_html_from_template_source(source_for_layout) { template_content }
|
156
|
-
rescue StaticMatic::Error => staticmatic_error
|
157
|
-
# Catch any errors from the actual template - otherwise the error will be assumed to be from the
|
158
|
-
# layout
|
159
|
-
raise staticmatic_error
|
160
|
-
rescue Haml::Error => haml_error
|
161
|
-
raise StaticMatic::Error.new("", "Layout: #{source_dir}/#{@layout}", haml_error.message)
|
162
|
-
ensure
|
163
|
-
@current_page = nil
|
164
|
-
@current_file_stack.shift
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def generate_partial(name, options = {})
|
169
|
-
partial_dir, partial_name = File.dirname(self.current_file), name # default relative to current file
|
170
|
-
partial_dir, partial_name = File.split(name) if name.index('/') # contains a path so it's absolute from src/pages dir
|
171
|
-
partial_name = "_#{partial_name}.haml"
|
172
|
-
|
173
|
-
partial_path = File.join(@src_dir, 'pages', partial_dir, partial_name)
|
174
|
-
unless File.exists?(partial_path)
|
175
|
-
# couldn't find it in the pages subdirectory tree so try old way (ignoring the path)
|
176
|
-
partial_dir = 'partials'; partial_name = "#{File.basename(name)}.haml"
|
177
|
-
partial_path = File.join(@src_dir, partial_dir, partial_name)
|
178
|
-
end
|
179
|
-
|
180
|
-
if File.exists?(partial_path)
|
181
|
-
partial_rel_path = "/#{partial_dir}/#{partial_name}".gsub(/\/+/, '/')
|
182
|
-
@current_file_stack.unshift(partial_rel_path)
|
183
|
-
begin
|
184
|
-
generate_html_from_template_source(File.read(partial_path), options)
|
185
|
-
rescue Haml::Error => haml_error
|
186
|
-
raise StaticMatic::Error.new(haml_error.line, "Partial: #{partial_rel_path[0,partial_rel_path.length-5]}", haml_error.message)
|
187
|
-
ensure
|
188
|
-
@current_file_stack.shift
|
189
|
-
end
|
190
|
-
else
|
191
|
-
raise StaticMatic::Error.new("", name, "Partial not found")
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def generate_css(source, source_dir = '')
|
196
|
-
full_file_path = File.join(@src_dir, 'stylesheets', source_dir, "#{source}.sass")
|
197
|
-
begin
|
198
|
-
sass_options = { :load_paths => [ File.join(@src_dir, 'stylesheets') ] }.merge(self.configuration.sass_options)
|
199
|
-
stylesheet = Sass::Engine.new(File.read(full_file_path), sass_options)
|
200
|
-
stylesheet.to_css
|
201
|
-
rescue Sass::SyntaxError => sass_error
|
202
|
-
raise StaticMatic::Error.new(sass_error.sass_line, full_file_path, sass_error.message)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# Generates html from the passed source string
|
207
|
-
#
|
208
|
-
# generate_html_from_template_source("%h1 Welcome to My Site") -> "<h1>Welcome to My Site</h1>"
|
209
|
-
#
|
210
|
-
# Pass a block containing a string to yield within in the passed source:
|
211
|
-
#
|
212
|
-
# generate_html_from_template_source("content:\n= yield") { "blah" } -> "content: blah"
|
213
|
-
#
|
214
|
-
def generate_html_from_template_source(source, options = {})
|
215
|
-
html = Haml::Engine.new(source, options)
|
216
|
-
|
217
|
-
html.render(@scope) { yield }
|
218
|
-
end
|
219
|
-
|
220
|
-
def detirmine_layout(dir = '')
|
221
|
-
layout_name = "application"
|
222
|
-
|
223
|
-
if @scope.instance_variable_get("@layout")
|
224
|
-
layout_name = @scope.instance_variable_get("@layout")
|
225
|
-
elsif dir
|
226
|
-
dirs = dir.split("/")
|
227
|
-
dir_layout_name = dirs[1]
|
228
|
-
|
229
|
-
if layout_exists?(dir_layout_name)
|
230
|
-
layout_name = dir_layout_name
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
layout_name
|
235
|
-
end
|
236
|
-
|
237
64
|
# TODO: DRY this _exists? section up
|
238
65
|
def template_exists?(name, dir = '')
|
239
66
|
File.exists?(File.join(@src_dir, 'pages', dir, "#{name}.haml")) || File.exists?(File.join(@src_dir, 'stylesheets', "#{name}.sass"))
|
@@ -251,48 +78,9 @@ module StaticMatic
|
|
251
78
|
"#{@src_dir}/layouts/#{name}.haml"
|
252
79
|
end
|
253
80
|
|
254
|
-
# Build HTML from the source files
|
255
|
-
def build_html
|
256
|
-
Dir["#{@src_dir}/pages/**/*.haml"].each do |path|
|
257
|
-
next if File.basename(path) =~ /^\_/ # skip partials
|
258
|
-
file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}\/pages/, ''))
|
259
|
-
save_page(File.join(file_dir, template), generate_html_with_layout(template, file_dir))
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
# Build CSS from the source files
|
264
|
-
def build_css
|
265
|
-
Dir["#{@src_dir}/stylesheets/**/*.sass"].each do |path|
|
266
|
-
file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}\/stylesheets/, ''))
|
267
|
-
save_stylesheet(File.join(file_dir, template), generate_css(template, file_dir))
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
# Returns a raw template name from a source file path:
|
272
|
-
# source_template_from_path("/path/to/site/src/stylesheets/application.sass") -> "application"
|
273
|
-
def source_template_from_path(path)
|
274
|
-
file_dir, file_name = File.split(path)
|
275
|
-
file_name.chomp!(File.extname(file_name))
|
276
|
-
[ file_dir, file_name ]
|
277
|
-
end
|
278
|
-
|
279
|
-
# Loads any helpers present in the helpers dir and mixes them into the template helpers
|
280
|
-
def load_helpers
|
281
|
-
|
282
|
-
Dir["#{@src_dir}/helpers/**/*_helper.rb"].each do |helper|
|
283
|
-
load_helper(helper)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
def load_helper(helper)
|
288
|
-
load helper
|
289
|
-
module_name = File.basename(helper, '.rb').gsub(/(^|\_)./) { |c| c.upcase }.gsub(/\_/, '')
|
290
|
-
Haml::Helpers.class_eval("include #{module_name}")
|
291
|
-
end
|
292
|
-
|
293
81
|
class << self
|
294
82
|
def base_dirs
|
295
|
-
|
83
|
+
StaticMatic::BASE_DIRS
|
296
84
|
end
|
297
85
|
end
|
298
86
|
end
|