staticmatic2 2.0.2 → 2.1.0
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/Gemfile +6 -3
- data/Gemfile.lock +10 -6
- data/{README.markdown → README.md} +24 -5
- data/Rakefile +4 -4
- data/VERSION.yml +2 -2
- data/bin/staticmatic +6 -4
- data/lib/staticmatic/ambiguous_template_error.rb +19 -0
- data/lib/staticmatic/base.rb +77 -52
- data/lib/staticmatic/configuration.rb +32 -9
- data/lib/staticmatic/helpers/assets_helper.rb +6 -5
- data/lib/staticmatic/helpers/current_path_helper.rb +4 -4
- data/lib/staticmatic/helpers/render_helper.rb +1 -12
- data/lib/staticmatic/helpers/tag_helper.rb +1 -1
- data/lib/staticmatic/mixins/build.rb +25 -61
- data/lib/staticmatic/mixins/render.rb +61 -103
- data/lib/staticmatic/mixins/rescue.rb +1 -1
- data/lib/staticmatic/server.rb +10 -29
- data/lib/staticmatic/templates/rescues/default.haml +1 -1
- data/lib/staticmatic.rb +2 -5
- data/spec/base_spec.rb +2 -2
- data/spec/compass_integration_spec.rb +3 -2
- data/spec/helpers/asset_helper_spec.rb +1 -3
- data/spec/helpers/custom_helper_spec.rb +1 -2
- data/spec/render_spec.rb +4 -4
- data/spec/rescue_spec.rb +3 -3
- data/spec/sandbox/test_site/site/sub_folder/another_sub_folder/index.html +1 -0
- data/spec/sandbox/test_site/site/sub_folder/another_sub_folder/index.html.html +1 -0
- data/spec/sandbox/test_site/site/sub_folder/index.html +1 -0
- data/spec/sandbox/test_site/src/{helpers → _helpers}/application_helper.rb +0 -0
- data/spec/sandbox/test_site/src/{layouts → _layouts}/alternate_layout.haml +0 -0
- data/spec/sandbox/test_site/src/{layouts → _layouts}/default.haml +0 -0
- data/spec/sandbox/test_site/src/{layouts → _layouts}/projects.haml +0 -0
- data/spec/sandbox/test_site/src/{partials → _partials}/menu.haml +0 -0
- data/spec/sandbox/test_site/src/{partials → _partials}/partial_with_error.haml +0 -0
- data/spec/sandbox/test_site/src/{pages/hello_world.erb → hello_world.erb} +0 -0
- data/spec/sandbox/test_site/src/{pages/index.haml → index.haml} +0 -0
- data/spec/sandbox/test_site/src/{pages/layout_test.haml → layout_test.haml} +0 -0
- data/spec/sandbox/test_site/src/{pages/page_one.haml → page_one.haml} +0 -0
- data/spec/sandbox/test_site/src/{pages/page_two.haml → page_two.haml} +0 -0
- data/spec/sandbox/test_site/src/{pages/page_with_error.haml → page_with_error.haml} +0 -0
- data/spec/sandbox/test_site/src/{pages/page_with_partial_error.haml → page_with_partial_error.haml} +0 -0
- data/spec/server_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/template_error_spec.rb +3 -3
- data/staticmatic2.gemspec +43 -54
- metadata +72 -62
- data/spec/setup_spec.rb +0 -22
data/Gemfile
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "haml", "
|
3
|
+
gem "haml", "~> 3"
|
4
|
+
gem "sass", "~> 3"
|
5
|
+
gem "tilt", ">= 1.3"
|
4
6
|
gem "compass"
|
7
|
+
|
5
8
|
gem "rack", ">= 1.0"
|
6
9
|
gem "thor", ">=0.14.6"
|
7
10
|
gem "aws-s3"
|
8
11
|
|
9
12
|
group :development do
|
10
|
-
gem "bundler", "
|
11
|
-
gem "jeweler", "
|
13
|
+
gem "bundler", "~> 1.0"
|
14
|
+
gem "jeweler", "~> 1.6"
|
12
15
|
gem "rspec", "~> 1.3.1"
|
13
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -10,15 +10,17 @@ GEM
|
|
10
10
|
haml (>= 3.0.4)
|
11
11
|
git (1.2.5)
|
12
12
|
haml (3.0.25)
|
13
|
-
jeweler (1.
|
14
|
-
bundler (~> 1.0
|
13
|
+
jeweler (1.6.4)
|
14
|
+
bundler (~> 1.0)
|
15
15
|
git (>= 1.2.5)
|
16
16
|
rake
|
17
17
|
mime-types (1.16)
|
18
18
|
rack (1.2.1)
|
19
|
-
rake (0.
|
19
|
+
rake (0.9.2)
|
20
20
|
rspec (1.3.1)
|
21
|
+
sass (3.1.7)
|
21
22
|
thor (0.14.6)
|
23
|
+
tilt (1.3.3)
|
22
24
|
xml-simple (1.0.14)
|
23
25
|
|
24
26
|
PLATFORMS
|
@@ -26,10 +28,12 @@ PLATFORMS
|
|
26
28
|
|
27
29
|
DEPENDENCIES
|
28
30
|
aws-s3
|
29
|
-
bundler (
|
31
|
+
bundler (~> 1.0)
|
30
32
|
compass
|
31
|
-
haml (
|
32
|
-
jeweler (
|
33
|
+
haml (~> 3)
|
34
|
+
jeweler (~> 1.6)
|
33
35
|
rack (>= 1.0)
|
34
36
|
rspec (~> 1.3.1)
|
37
|
+
sass (~> 3)
|
35
38
|
thor (>= 0.14.6)
|
39
|
+
tilt (>= 1.3)
|
@@ -7,7 +7,7 @@
|
|
7
7
|
- [Coffeescript](http://jashkenas.github.com/coffee-script/)
|
8
8
|
- [Compass](compass-style.org)
|
9
9
|
- [Amazon S3 Websites](http://aws.typepad.com/aws/2011/02/host-your-static-website-on-amazon-s3.html)
|
10
|
-
- And
|
10
|
+
- [And many, many more!](https://github.com/rtomayko/tilt#readme)
|
11
11
|
|
12
12
|
2: Deploy to Amazon S3:
|
13
13
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
## Quick Start
|
34
34
|
|
35
|
-
|
35
|
+
Setup a new project:
|
36
36
|
|
37
37
|
$ staticmatic init my-project
|
38
38
|
|
@@ -63,13 +63,24 @@ To build & convert your haml/sass/whatever files into plain html, css, and javas
|
|
63
63
|
|
64
64
|
This will convert everything into a freshly generated `build/` folder, 100% static.
|
65
65
|
|
66
|
-
If you have an Amazon S3 account and want to deploy to your bucket, run the following command:
|
66
|
+
If you have an [Amazon S3 account](http://aws.amazon.com/s3/) and want to deploy to your bucket, run the following command:
|
67
67
|
|
68
68
|
# NOTE: You must be in the root folder of your project
|
69
69
|
$ staticmatic s3_deploy
|
70
70
|
|
71
71
|
If you haven't deployed your current project to Amazon yet, it will prompt you to create a config file. Edit this file to include your credentials, run the command again, and you're set.
|
72
72
|
|
73
|
+
## Super Special Awesome Quick Start Booster
|
74
|
+
|
75
|
+
Want to use a [Javascript App Starter](https://github.com/mindeavor/staticmatic-js-app-starter) or a skeleton of your own? Check this out!
|
76
|
+
|
77
|
+
$ staticmatic add js-app git://github.com/mindeavor/staticmatic-js-app-starter.git
|
78
|
+
$ staticmatic init my-new-project --skeleton=js-app
|
79
|
+
|
80
|
+
The first line stores a named reference to a repository of your choosing. You only need to do this once.
|
81
|
+
|
82
|
+
The second line clones the referenced repository into a freshly created `my-new-project` folder, as well as removes the `.git/` folder so you can do your own `git init`. Convenient!
|
83
|
+
|
73
84
|
## Special Folders
|
74
85
|
|
75
86
|
<my-project>/
|
@@ -95,7 +106,7 @@ Partials are searched for in the following order:
|
|
95
106
|
|
96
107
|
Examples:
|
97
108
|
|
98
|
-
# Searches for the default rendering engine file type
|
109
|
+
# Searches for the default rendering engine file type (by default, it is haml)
|
99
110
|
= partial 'sidebar'
|
100
111
|
|
101
112
|
# Equivalent to the above statement
|
@@ -105,7 +116,7 @@ Examples:
|
|
105
116
|
= partial 'help-content.html'
|
106
117
|
|
107
118
|
# Use your own directory structure
|
108
|
-
= partial 'blog-content/2011/vacation.
|
119
|
+
= partial 'blog-content/2011/vacation.markdown'
|
109
120
|
|
110
121
|
## Anti-Cache
|
111
122
|
|
@@ -122,3 +133,11 @@ Force the browser to ignore its cache whenever you damn well feel like it:
|
|
122
133
|
javascripts :app, :qstring => '2.0.6'
|
123
134
|
|
124
135
|
<script language="javascript" src="js/app.js?_=2.0.6" type="text/javascript"></script>
|
136
|
+
|
137
|
+
# Roadmap / TODO list
|
138
|
+
|
139
|
+
- Fix slowness of executable (built on [Thor](https://github.com/wycats/thor); maybe reconsider?)
|
140
|
+
- Create a cache that monitors what files have changed in between Amazon S3 uploads to reduce unnecessary uploads
|
141
|
+
- Integrate sprockets both for building and for previewing (probably as an option flag)
|
142
|
+
- Change rendering and yielding syntax to rails syntax
|
143
|
+
- Create a command that converts a staticmatic project to a rails project
|
data/Rakefile
CHANGED
@@ -18,13 +18,13 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.name = "staticmatic2"
|
19
19
|
gem.email = "gilbertbgarza@gmail.com"
|
20
20
|
gem.license = "MIT"
|
21
|
-
gem.summary = "Build static websites using modern dynamic tools"
|
22
|
-
gem.homepage = "http://github.com/mindeavor/
|
21
|
+
gem.summary = "Build Amazon S3 static websites using modern dynamic tools"
|
22
|
+
gem.homepage = "http://github.com/mindeavor/staticmatic2"
|
23
23
|
gem.executables = "staticmatic"
|
24
24
|
gem.authors = ["Stephen Bartholomew", "Gilbert B Garza"]
|
25
25
|
|
26
26
|
gem.description = <<-EOF
|
27
|
-
StaticMatic helps you quickly create maintainable static websites using
|
27
|
+
StaticMatic helps you quickly create maintainable Amazon S3 static websites using
|
28
28
|
tools such as Haml and Sass.
|
29
29
|
|
30
30
|
Quickly deploy to services such as Amazon S3 in a single command.
|
@@ -36,7 +36,7 @@ Jeweler::Tasks.new do |gem|
|
|
36
36
|
gem.files.exclude "spec/sandbox/tmp", "spec/sandbox/test_site/site/*"
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
Jeweler::RubygemsDotOrgTasks.new
|
40
40
|
|
41
41
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
42
42
|
spec.libs << 'lib' << 'spec'
|
data/VERSION.yml
CHANGED
data/bin/staticmatic
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
+
require 'pathname'
|
3
4
|
require 'thor'
|
4
5
|
|
5
|
-
lib_dir =
|
6
|
+
$lib_dir = Pathname.new(__FILE__).realpath.dirname.join('../lib/staticmatic').to_s
|
6
7
|
|
7
|
-
|
8
|
-
Dir[File.join lib_dir,'deployers','*.rb'].each do |deployer|
|
8
|
+
Dir[File.join $lib_dir,'deployers','*.rb'].each do |deployer|
|
9
9
|
require deployer
|
10
10
|
end
|
11
11
|
|
@@ -56,6 +56,7 @@ class StaticExe < Thor
|
|
56
56
|
desc "preview DIRECTORY", "Start a web server to preview your project"
|
57
57
|
def preview(directory = '.')
|
58
58
|
say 'Launching preview server...', :cyan
|
59
|
+
require $lib_dir
|
59
60
|
staticmatic = StaticMatic::Base.new(directory)
|
60
61
|
$:.push File.join(directory, "lib")
|
61
62
|
staticmatic.run('preview')
|
@@ -64,7 +65,8 @@ class StaticExe < Thor
|
|
64
65
|
desc "build DIRECTORY", "Build your project into a freshly generated build/ folder"
|
65
66
|
def build(directory = '.')
|
66
67
|
say 'Building website...', :cyan
|
67
|
-
|
68
|
+
require $lib_dir
|
69
|
+
staticmatic = StaticMatic::Base.new(directory, :build)
|
68
70
|
$:.push File.join(directory, "lib")
|
69
71
|
staticmatic.run('build')
|
70
72
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class StaticMatic::AmbiguousTemplateError < StandardError
|
2
|
+
attr_reader :template_name
|
3
|
+
|
4
|
+
def initialize(template_name, ambiguous_templates)
|
5
|
+
@template_name = template_name
|
6
|
+
@ambiguous_templates = ambiguous_templates
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
<<-MESSAGE
|
11
|
+
Ambiguous request when searching for a template for filename `#{@template_name}`:
|
12
|
+
There is more than one type of template available for rendering.
|
13
|
+
|
14
|
+
Templates causing the ambiguity:
|
15
|
+
#{@ambiguous_templates.join "\n"}
|
16
|
+
MESSAGE
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/staticmatic/base.rb
CHANGED
@@ -8,62 +8,65 @@ module StaticMatic
|
|
8
8
|
include StaticMatic::ServerMixin
|
9
9
|
include StaticMatic::RescueMixin
|
10
10
|
|
11
|
-
attr_accessor :configuration
|
12
|
-
attr_reader :
|
11
|
+
attr_accessor :configuration, :mode
|
12
|
+
attr_reader :src_dir, :site_dir
|
13
13
|
|
14
14
|
def current_file
|
15
15
|
@current_file_stack[0] || ""
|
16
16
|
end
|
17
|
-
|
18
|
-
def
|
19
|
-
@
|
20
|
-
|
17
|
+
|
18
|
+
def self.extensions
|
19
|
+
@extensions ||= (Tilt.mappings.map { |k,v| k } << "slim")
|
20
|
+
end
|
21
|
+
|
22
|
+
def extensions
|
23
|
+
self.class.extensions
|
24
|
+
end
|
25
|
+
|
26
|
+
def ensure_extension(filename)
|
27
|
+
ext = File.extname(filename)
|
28
|
+
ext.length > 0 ? filename : "#{filename}.#{configuration.default_template_engine}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(base_dir, mode = :preview)
|
32
|
+
@configuration = Configuration.new
|
21
33
|
@current_file_stack = []
|
34
|
+
@mode = mode
|
35
|
+
|
22
36
|
@base_dir = base_dir
|
23
37
|
@src_dir = File.join(@base_dir, "src")
|
24
38
|
@site_dir = File.join(@base_dir, "build")
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@default_layout = "application"
|
29
|
-
else
|
30
|
-
@default_layout = "default"
|
31
|
-
end
|
32
|
-
|
39
|
+
|
40
|
+
@default_layout_name = "default"
|
41
|
+
|
33
42
|
@scope = Object.new
|
34
43
|
@scope.instance_variable_set("@staticmatic", self)
|
44
|
+
@scope.instance_eval do
|
45
|
+
extend StaticMatic::Helpers
|
46
|
+
end
|
35
47
|
|
36
48
|
load_configuration
|
37
49
|
configure_compass
|
38
50
|
|
39
51
|
load_helpers
|
40
52
|
end
|
41
|
-
|
53
|
+
|
42
54
|
def load_configuration
|
43
55
|
configuration = StaticMatic::Configuration.new
|
44
56
|
config_file = File.join(@base_dir, "config", "site.rb")
|
45
|
-
|
46
|
-
if !File.exists?(config_file)
|
47
|
-
config_file = File.join(@base_dir, "src", "configuration.rb")
|
48
|
-
|
49
|
-
if File.exists?(config_file)
|
50
|
-
puts "DEPRECATION: #{@base_dir}/src/configuration.rb will be moved to #{@base_dir}/config/site.rb in 0.12.0"
|
51
|
-
end
|
52
|
-
end
|
53
57
|
|
54
58
|
if File.exists?(config_file)
|
55
59
|
config = File.read(config_file)
|
56
60
|
eval(config)
|
57
61
|
end
|
58
62
|
|
59
|
-
# Compass.sass_engine_options.merge!(configuration.sass_options)
|
60
63
|
@configuration = configuration
|
61
64
|
end
|
62
|
-
|
65
|
+
|
63
66
|
def base_dir
|
64
67
|
@base_dir
|
65
68
|
end
|
66
|
-
|
69
|
+
|
67
70
|
def run(command)
|
68
71
|
puts "Site root is: #{@base_dir}"
|
69
72
|
|
@@ -73,39 +76,65 @@ module StaticMatic
|
|
73
76
|
puts "#{command} is not a valid StaticMatic command"
|
74
77
|
end
|
75
78
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
|
80
|
+
def determine_template_path(name, ext, dir = '')
|
81
|
+
# remove src path if present
|
82
|
+
dir.gsub! /^#{@src_dir}\//, ''
|
83
|
+
|
84
|
+
default_template_name = "#{name}.#{configuration.default_template_engine}"
|
85
|
+
default_template = File.join(@src_dir, dir, default_template_name)
|
86
|
+
|
87
|
+
if File.exists? default_template
|
88
|
+
default_template
|
89
|
+
else
|
90
|
+
context = File.join(@src_dir, dir, name)
|
91
|
+
possible_templates = Dir[context + '.*'].select do |fname|
|
92
|
+
extensions.include? File.extname(fname).sub(/^\./, '')
|
93
|
+
end
|
94
|
+
|
95
|
+
if possible_templates.count > 1
|
96
|
+
raise StaticMatic::AmbiguousTemplateError.new("#{name}#{ext}", possible_templates)
|
97
|
+
end
|
98
|
+
|
99
|
+
possible_templates.first
|
86
100
|
end
|
87
101
|
end
|
88
|
-
|
89
|
-
def
|
90
|
-
File.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
102
|
+
|
103
|
+
def expand_path(path_info)
|
104
|
+
dirname, basename = File.split(path_info)
|
105
|
+
|
106
|
+
extname = File.extname(path_info).sub(/^\./, '')
|
107
|
+
filename = basename.chomp(".#{extname}")
|
108
|
+
|
109
|
+
if extname.empty?
|
110
|
+
dir = File.join(dirname, filename)
|
111
|
+
is_dir = path_info[-1, 1] == '/'
|
112
|
+
if is_dir
|
113
|
+
dirname = dir
|
114
|
+
filename = 'index'
|
115
|
+
end
|
116
|
+
extname = 'html'
|
117
|
+
end
|
118
|
+
|
119
|
+
[ dirname, filename, extname ]
|
95
120
|
end
|
96
|
-
|
121
|
+
|
97
122
|
def configure_compass
|
98
123
|
Compass.configuration.project_path = @base_dir
|
99
124
|
|
100
125
|
compass_config_path = File.join(@base_dir, "config", "compass.rb")
|
101
126
|
|
102
127
|
if File.exists?(compass_config_path)
|
103
|
-
Compass.add_configuration(compass_config_path)
|
128
|
+
Compass.add_configuration(compass_config_path)
|
104
129
|
end
|
105
130
|
|
106
|
-
configuration.
|
131
|
+
options = configuration.engine_options
|
132
|
+
compass_options = Compass.configuration.to_sass_engine_options
|
133
|
+
|
134
|
+
options['sass'] = compass_options.merge(options['sass'] || {})
|
135
|
+
options['scss'] = compass_options.merge(options['scss'] || {})
|
107
136
|
end
|
108
|
-
|
137
|
+
|
109
138
|
# TODO OPTIMIZE: caching, maybe?
|
110
139
|
def src_file_paths(*exts)
|
111
140
|
Dir["#{@src_dir}/**/*.{#{ exts.join(',') }}"].reject do |path|
|
@@ -114,10 +143,6 @@ module StaticMatic
|
|
114
143
|
path.split('/').map {|x| x.match('^\_')}.any?
|
115
144
|
end
|
116
145
|
end
|
117
|
-
|
118
|
-
def src_file_names(*exts)
|
119
|
-
src_file_paths(*exts).map {|p| File.split(p)[1]}
|
120
|
-
end
|
121
|
-
|
146
|
+
|
122
147
|
end
|
123
148
|
end
|
@@ -1,20 +1,43 @@
|
|
1
1
|
module StaticMatic
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :preview_server_port
|
4
|
-
|
5
3
|
attr_accessor :preview_server_host
|
4
|
+
attr_accessor :preview_server_port
|
6
5
|
|
7
6
|
attr_accessor :use_extensions_for_page_links
|
8
|
-
attr_accessor :
|
9
|
-
|
10
|
-
attr_accessor :
|
7
|
+
attr_accessor :default_template_engine
|
8
|
+
|
9
|
+
attr_accessor :engine_options, :preview_engine_options
|
10
|
+
attr_accessor :reverse_ext_mappings
|
11
11
|
|
12
12
|
def initialize
|
13
|
+
self.preview_server_host = "localhost"
|
13
14
|
self.preview_server_port = 3000
|
15
|
+
|
14
16
|
self.use_extensions_for_page_links = true
|
15
|
-
self.
|
16
|
-
|
17
|
-
self.
|
17
|
+
self.default_template_engine = 'haml'
|
18
|
+
|
19
|
+
self.preview_engine_options = self.engine_options = {
|
20
|
+
'haml' => {}, 'sass' => {}, 'scss' => {},
|
21
|
+
}
|
22
|
+
# TODO: discover a way of auto-detecting these. one can hope.
|
23
|
+
self.reverse_ext_mappings = {
|
24
|
+
'sass' => 'css',
|
25
|
+
'scss' => 'css',
|
26
|
+
'less' => 'css',
|
27
|
+
|
28
|
+
'coffee' => 'js',
|
29
|
+
|
30
|
+
'builder' => 'xml',
|
31
|
+
'yajl' => 'json'
|
32
|
+
}
|
33
|
+
|
34
|
+
%w{
|
35
|
+
creole erb haml liquid radius mab markdown md
|
36
|
+
mediawiki mkd mw nokogiri rdoc rhtml slim textile wiki
|
37
|
+
}.each do |ext|
|
38
|
+
@reverse_ext_mappings[ext] = 'html'
|
39
|
+
end
|
18
40
|
end
|
41
|
+
|
19
42
|
end
|
20
|
-
end
|
43
|
+
end
|
@@ -39,7 +39,7 @@ module StaticMatic
|
|
39
39
|
|
40
40
|
# Generate javascript source tags for the specified files
|
41
41
|
#
|
42
|
-
# javascripts('test') -> <script language="javascript" src="
|
42
|
+
# javascripts('test') -> <script language="javascript" src="path/to/test.js"></script>
|
43
43
|
#
|
44
44
|
def javascripts(*files)
|
45
45
|
options = (files.last.is_a? Hash) ? files.pop : {}
|
@@ -83,10 +83,11 @@ module StaticMatic
|
|
83
83
|
filename_without_extension = File.basename(path).chomp(File.extname(path))
|
84
84
|
|
85
85
|
path = path.gsub(/^#{@staticmatic.src_dir}/, "").
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
gsub(/^#{@staticmatic.site_dir}/, "").
|
87
|
+
gsub(/#{filename_without_extension}\.(sass|scss|css|js|coffee)/, "").
|
88
|
+
gsub(/^\//, "")
|
89
|
+
paths = [current_page_relative_path, path, "#{filename_without_extension}"].compact
|
90
|
+
src = File.join(*paths)
|
90
91
|
end
|
91
92
|
|
92
93
|
if tag_type == :link
|
@@ -4,17 +4,17 @@ module StaticMatic
|
|
4
4
|
self.extend self
|
5
5
|
|
6
6
|
def current_page
|
7
|
-
@staticmatic.
|
7
|
+
@staticmatic.current_file
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def current_page_relative_path(current_path = nil)
|
13
13
|
if current_path.nil? || current_path.match(/^((\.\.?)?\/|\#|.+?\:)/) == nil
|
14
|
-
current_page_depth = current_page.split('/').length -
|
15
|
-
(current_page_depth > 0) ? ([ '..' ] * current_page_depth).join('/') + '/' :
|
14
|
+
current_page_depth = current_page.split('/').length - 3;
|
15
|
+
(current_page_depth > 0) ? ([ '..' ] * current_page_depth).join('/') + '/' : nil
|
16
16
|
else
|
17
|
-
|
17
|
+
nil
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,20 +4,9 @@ module StaticMatic
|
|
4
4
|
module RenderHelper
|
5
5
|
self.extend self
|
6
6
|
|
7
|
-
def content_hash
|
8
|
-
@content_hash ||= {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def yield_for(index)
|
12
|
-
self.content_hash[index.to_sym] || ""
|
13
|
-
end
|
14
|
-
|
15
|
-
def content_for(index,&block)
|
16
|
-
content_hash[:sidebar] = capture_haml &block
|
17
|
-
end
|
18
|
-
|
19
7
|
# Include a partial template
|
20
8
|
def partial(name, options = {})
|
9
|
+
name = @staticmatic.ensure_extension(name)
|
21
10
|
@staticmatic.generate_partial(name, options)
|
22
11
|
end
|
23
12
|
end
|
@@ -20,7 +20,7 @@ module StaticMatic
|
|
20
20
|
output << yield
|
21
21
|
output << "</#{name}>"
|
22
22
|
else
|
23
|
-
format = @staticmatic.configuration.
|
23
|
+
format = @staticmatic.configuration.engine_options['haml'][:format]
|
24
24
|
|
25
25
|
if format.nil? || format == :xhtml
|
26
26
|
output << "/>"
|
@@ -1,77 +1,41 @@
|
|
1
1
|
module StaticMatic::BuildMixin
|
2
2
|
|
3
3
|
def build
|
4
|
-
|
5
|
-
|
6
|
-
build_html
|
7
|
-
copy_images
|
8
|
-
end
|
9
|
-
|
10
|
-
# Build HTML from the source files
|
11
|
-
def build_html
|
12
|
-
src_file_paths('haml').each do |path|
|
13
|
-
file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}/, ''))
|
14
|
-
save_page(File.join(file_dir, template), generate_html_with_layout(template, file_dir))
|
15
|
-
end
|
16
|
-
end
|
4
|
+
src_file_paths('*').each do |src_path|
|
5
|
+
ext = File.extname(src_path).sub(/^\./, '')
|
17
6
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if !template.match(/(^|\/)\_/)
|
24
|
-
save_stylesheet(File.join(file_dir, template), generate_css(template, file_dir))
|
7
|
+
if Tilt.mappings[ext].length > 0
|
8
|
+
generate_site_file(src_path)
|
9
|
+
else
|
10
|
+
copy_file_from_src_to_site(src_path)
|
25
11
|
end
|
26
12
|
end
|
27
13
|
end
|
28
|
-
|
29
|
-
def build_js
|
30
|
-
coffee_found = ENV['PATH'].split(':').inject(false) { |found, folder| found |= File.exists?("#{folder}/coffee") }
|
31
|
-
if coffee_found
|
32
|
-
src_file_paths('coffee').each do |path|
|
33
|
-
file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}/, ''))
|
34
|
-
save_javascript(File.join(file_dir, template), generate_js(template, file_dir))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
# copy normal javascript files over
|
38
|
-
src_file_paths('js').each do |path|
|
39
|
-
file_dir, template = source_template_from_path(path.sub(/^#{@src_dir}/, ''))
|
40
|
-
copy_file(path, File.join(@site_dir, file_dir, "#{template}.js"))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def copy_images
|
45
|
-
src_file_paths(*%w{gif jpg jpef png tiff}).each do |path|
|
46
|
-
file_dir, file_name = File.split(path.sub(/^#{@src_dir}/, ''))
|
47
|
-
copy_file(path, File.join(@site_dir, file_dir, file_name))
|
48
|
-
end
|
49
|
-
end
|
50
14
|
|
51
|
-
|
52
|
-
FileUtils.mkdir_p(File.dirname(to))
|
53
|
-
FileUtils.cp(from, to)
|
54
|
-
end
|
15
|
+
private
|
55
16
|
|
56
|
-
def
|
57
|
-
|
58
|
-
end
|
17
|
+
def copy_file_from_src_to_site(src_path)
|
18
|
+
site_path = src_path.gsub /^#{@src_dir}/, @site_dir
|
59
19
|
|
60
|
-
|
61
|
-
|
20
|
+
FileUtils.mkdir_p(File.dirname site_path)
|
21
|
+
FileUtils.cp src_path, site_path
|
62
22
|
end
|
63
23
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
24
|
+
def generate_site_file(src_path)
|
25
|
+
dir, name, ext = expand_path(src_path.gsub /^#{@src_dir}/, @site_dir)
|
26
|
+
target_ext = configuration.reverse_ext_mappings[ext]
|
27
|
+
site_path = File.join(dir, "#{name}.#{target_ext}")
|
67
28
|
|
68
|
-
|
69
|
-
|
70
|
-
FileUtils.mkdir_p(File.dirname
|
71
|
-
File.open(
|
72
|
-
|
29
|
+
puts " Rendered #{src_path} => #{site_path}"
|
30
|
+
|
31
|
+
FileUtils.mkdir_p(File.dirname site_path)
|
32
|
+
File.open(site_path, 'w+') do |f|
|
33
|
+
if target_ext == 'html'
|
34
|
+
f << render_template_with_layout(src_path)
|
35
|
+
else
|
36
|
+
f << render_template(src_path)
|
37
|
+
end
|
73
38
|
end
|
74
|
-
|
75
|
-
puts "created #{path}"
|
76
39
|
end
|
40
|
+
|
77
41
|
end
|