middleman 1.2.8 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +7 -0
- data/README.rdoc +1 -1
- data/bin/mm-server +15 -39
- data/features/coffee-script.feature +6 -1
- data/features/minify_javascript.feature +14 -6
- data/features/slim.feature +7 -0
- data/features/step_definitions/builder_steps.rb +1 -23
- data/features/step_definitions/env.rb +7 -1
- data/features/step_definitions/generator_steps.rb +1 -1
- data/features/step_definitions/middleman_steps.rb +5 -0
- data/fixtures/test-app/config.rb +2 -0
- data/fixtures/test-app/{views → source}/_partial.haml +0 -0
- data/fixtures/test-app/{views → source}/asset_host.html.haml +0 -0
- data/fixtures/test-app/{views → source}/auto-css.html.haml +0 -0
- data/fixtures/test-app/{views → source}/auto-image-sizes.html.haml +0 -0
- data/fixtures/test-app/{views → source}/cache-buster.html.haml +0 -0
- data/fixtures/test-app/{views → source}/custom-layout-dir/index.html.haml +0 -0
- data/fixtures/test-app/{views → source}/custom-layout.html.haml +0 -0
- data/fixtures/test-app/source/front-matter.html.erb +7 -0
- data/fixtures/test-app/{public → source}/images/blank.gif +0 -0
- data/fixtures/test-app/{views → source}/index.html.haml +0 -0
- data/fixtures/test-app/source/inline-coffeescript.html.haml +3 -0
- data/fixtures/test-app/{views → source}/inline-css.html.haml +0 -0
- data/fixtures/test-app/{views → source}/inline-js.html.haml +1 -1
- data/fixtures/test-app/{views → source}/javascripts/coffee_test.js.coffee +0 -0
- data/fixtures/test-app/source/javascripts/jquery.plugin.with.dots.js +1 -0
- data/fixtures/test-app/{views → source}/layout.haml +0 -0
- data/fixtures/test-app/{views → source}/layouts/custom.haml +0 -0
- data/fixtures/test-app/{views → source}/padrino_test.html.haml +0 -0
- data/fixtures/test-app/{views → source}/page-classes.html.haml +0 -0
- data/fixtures/test-app/{views → source}/services/index.html.haml +0 -0
- data/fixtures/test-app/source/slim.html.slim +7 -0
- data/fixtures/test-app/{public → source}/static.html +0 -0
- data/fixtures/test-app/{views → source}/stylesheets/asset_host.css.sass +0 -0
- data/fixtures/test-app/{public → source}/stylesheets/auto-css.css +0 -0
- data/fixtures/test-app/{views → source}/stylesheets/relative_assets.css.sass +0 -0
- data/fixtures/test-app/{views → source}/stylesheets/site.css.sass +0 -0
- data/fixtures/test-app/{views → source}/stylesheets/site_scss.css.scss +0 -0
- data/fixtures/test-app/{public → source}/stylesheets/static.css +0 -0
- data/fixtures/test-app/{public → source}/stylesheets/sub1/auto-css.css +0 -0
- data/fixtures/test-app/{public → source}/stylesheets/sub1/sub2/auto-css.css +0 -0
- data/fixtures/test-app/{views → source}/tiny_src.html.haml +0 -0
- data/lib/middleman.rb +1 -0
- data/lib/middleman/builder.rb +15 -22
- data/lib/middleman/features.rb +7 -1
- data/lib/middleman/features/automatic_image_sizes.rb +1 -1
- data/lib/middleman/features/blog.rb +118 -0
- data/lib/middleman/features/cache_buster.rb +2 -2
- data/lib/middleman/features/data.rb +19 -6
- data/lib/middleman/features/default_helpers.rb +1 -1
- data/lib/middleman/features/front_matter.rb +69 -0
- data/lib/middleman/features/live_reload.rb +8 -3
- data/lib/middleman/features/minify_javascript/rack.rb +27 -6
- data/lib/middleman/renderers/haml.rb +1 -0
- data/lib/middleman/renderers/sass.rb +5 -4
- data/lib/middleman/renderers/slim.rb +12 -0
- data/lib/middleman/server.rb +30 -11
- data/lib/middleman/templates/default.rb +4 -4
- data/lib/middleman/templates/default/{views → source}/index.html.haml +0 -0
- data/lib/middleman/templates/default/{views → source}/layout.haml +0 -0
- data/lib/middleman/templates/default/source/stylesheets/site.css.sass +34 -0
- data/lib/middleman/templates/html5.rb +2 -2
- data/lib/middleman/templates/html5/{public → source}/404.html +0 -0
- data/lib/middleman/templates/html5/{public → source}/apple-touch-icon.png +0 -0
- data/lib/middleman/templates/html5/{public → source}/crossdomain.xml +0 -0
- data/lib/middleman/templates/html5/{public → source}/css/handheld.css +0 -0
- data/lib/middleman/templates/html5/{public → source}/css/style.css +0 -0
- data/lib/middleman/templates/html5/{public → source}/favicon.ico +0 -0
- data/lib/middleman/templates/html5/{public → source}/humans.txt +0 -0
- data/lib/middleman/templates/html5/{public → source}/images/.gitignore +0 -0
- data/lib/middleman/templates/html5/{public → source}/index.html +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/libs/dd_belatedpng.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/libs/jquery-1.5.0.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/libs/jquery-1.5.0.min.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/libs/modernizr-1.6.min.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/mylibs/.gitignore +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/plugins.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/js/script.js +0 -0
- data/lib/middleman/templates/html5/{public → source}/robots.txt +0 -0
- data/lib/middleman/templates/xhtml.rb +4 -4
- data/lib/middleman/templates/xhtml/{views → source}/index.html.haml +0 -0
- data/lib/middleman/templates/xhtml/{views → source}/layout.haml +0 -0
- data/lib/middleman/templates/xhtml/source/stylesheets/site.css.sass +34 -0
- data/lib/middleman/version.rb +1 -1
- data/middleman.gemspec +7 -7
- metadata +149 -113
- data/lib/middleman/templates/default/views/stylesheets/site.css.sass +0 -27
- data/lib/middleman/templates/xhtml/views/stylesheets/site.css.sass +0 -27
@@ -15,7 +15,7 @@ module Middleman::Features::AutomaticImageSizes
|
|
15
15
|
http_prefix = settings.http_images_path rescue settings.images_dir
|
16
16
|
|
17
17
|
begin
|
18
|
-
real_path = File.join(settings.
|
18
|
+
real_path = File.join(settings.views, settings.images_dir, path)
|
19
19
|
if File.exists? real_path
|
20
20
|
dimensions = ::FastImage.size(real_path, :raise_on_failure => true)
|
21
21
|
params[:width] ||= dimensions[0]
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require "rdiscount"
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Features
|
5
|
+
module Blog
|
6
|
+
class << self
|
7
|
+
def registered(app)
|
8
|
+
# Include helpers
|
9
|
+
app.helpers Middleman::Features::Blog::Helpers
|
10
|
+
|
11
|
+
app.after_feature_init do
|
12
|
+
if !app.settings.respond_to? :blog_permalink
|
13
|
+
app.set :blog_permalink, "/:year/:month/:day/:title.html"
|
14
|
+
end
|
15
|
+
|
16
|
+
if !app.settings.respond_to? :blog_layout
|
17
|
+
app.set :blog_layout, "layout"
|
18
|
+
end
|
19
|
+
|
20
|
+
if !app.settings.respond_to? :blog_summary_separator
|
21
|
+
app.set :blog_summary_separator, /READMORE/
|
22
|
+
end
|
23
|
+
|
24
|
+
if !app.settings.respond_to? :blog_summary_length
|
25
|
+
app.set :blog_summary_length, 250
|
26
|
+
end
|
27
|
+
|
28
|
+
if !app.settings.respond_to? :blog_layout_engine
|
29
|
+
app.set :blog_layout_engine, "erb"
|
30
|
+
end
|
31
|
+
|
32
|
+
if !app.settings.respond_to? :blog_index_template
|
33
|
+
app.set :blog_index_template, "index_template"
|
34
|
+
end
|
35
|
+
|
36
|
+
if !app.settings.respond_to? :blog_article_template
|
37
|
+
app.set :blog_article_template, "article_template"
|
38
|
+
end
|
39
|
+
|
40
|
+
$stderr.puts "== Blog: #{app.settings.blog_permalink}"
|
41
|
+
|
42
|
+
articles_glob = File.join(app.views, app.settings.blog_permalink.gsub(/(:\w+)/, "*") + ".*")
|
43
|
+
|
44
|
+
articles = Dir[articles_glob].map do |article|
|
45
|
+
template_content = File.read(article)
|
46
|
+
data, content = parse_front_matter(template_content)
|
47
|
+
data["date"] = Date.parse(data["date"])
|
48
|
+
|
49
|
+
yaml_regex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
50
|
+
data["raw"] = template_content.split(yaml_regex).last
|
51
|
+
data["url"] = article.gsub(app.views, "").split(".html").first + ".html"
|
52
|
+
|
53
|
+
all_content = Tilt.new(article).render
|
54
|
+
data["body"] = all_content.gsub!(app.settings.blog_summary_separator, "")
|
55
|
+
|
56
|
+
sum = if data["raw"] =~ app.settings.blog_summary_separator
|
57
|
+
data["raw"].split(app.settings.blog_summary_separator).first
|
58
|
+
else data["raw"].match(/(.{1,#{app.settings.blog_summary_length}}.*?)(\n|\Z)/m).to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
engine = RDiscount.new(sum)
|
62
|
+
data["summary"] = engine.to_html
|
63
|
+
data
|
64
|
+
end.sort { |a, b| b["date"] <=> a["date"] }
|
65
|
+
|
66
|
+
app.data_content("blog", { :articles => articles })
|
67
|
+
|
68
|
+
app.get(app.settings.blog_permalink) do
|
69
|
+
options = {}
|
70
|
+
options[:layout] = settings.blog_layout
|
71
|
+
options[:layout_engine] = settings.blog_layout_engine
|
72
|
+
|
73
|
+
extensionless_path, template_engine = resolve_template(request.path)
|
74
|
+
|
75
|
+
full_file_path = "#{extensionless_path}.#{template_engine}"
|
76
|
+
system_path = File.join(settings.views, full_file_path)
|
77
|
+
data, content = self.class.parse_front_matter(File.read(system_path))
|
78
|
+
|
79
|
+
# Forward remaining data to helpers
|
80
|
+
self.class.data_content("page", data)
|
81
|
+
|
82
|
+
output = render(request.path, options)
|
83
|
+
|
84
|
+
# No need for separator on permalink page
|
85
|
+
output.gsub!(settings.blog_summary_separator, "")
|
86
|
+
|
87
|
+
status 200
|
88
|
+
output
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
alias :included :registered
|
94
|
+
end
|
95
|
+
|
96
|
+
module Helpers
|
97
|
+
def is_blog_article?
|
98
|
+
!current_article_title.blank?
|
99
|
+
end
|
100
|
+
|
101
|
+
def blog_title
|
102
|
+
end
|
103
|
+
|
104
|
+
def current_article_date
|
105
|
+
DateTime.parse(current_article_metadata.date)
|
106
|
+
end
|
107
|
+
|
108
|
+
def current_article_title
|
109
|
+
current_article_metadata.title
|
110
|
+
end
|
111
|
+
|
112
|
+
def current_article_metadata
|
113
|
+
data.page
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -12,7 +12,7 @@ module Middleman::Features::CacheBuster
|
|
12
12
|
rescue
|
13
13
|
end
|
14
14
|
|
15
|
-
real_path_static = File.join(Middleman::Server.
|
15
|
+
real_path_static = File.join(Middleman::Server.views, prefix, path)
|
16
16
|
|
17
17
|
if File.readable?(real_path_static)
|
18
18
|
http_path << "?" + File.mtime(real_path_static).strftime("%s")
|
@@ -29,7 +29,7 @@ module Middleman::Features::CacheBuster
|
|
29
29
|
::Compass.configuration do |config|
|
30
30
|
config.asset_cache_buster do |path, real_path|
|
31
31
|
real_path = real_path.path if real_path.is_a? File
|
32
|
-
real_path = real_path.gsub(File.join(Middleman::Server.root, Middleman::Server.build_dir), Middleman::Server.
|
32
|
+
real_path = real_path.gsub(File.join(Middleman::Server.root, Middleman::Server.build_dir), Middleman::Server.views)
|
33
33
|
if File.readable?(real_path)
|
34
34
|
File.mtime(real_path).strftime("%s")
|
35
35
|
else
|
@@ -25,14 +25,18 @@ module Middleman::Features::Data
|
|
25
25
|
def method_missing(path)
|
26
26
|
response = nil
|
27
27
|
|
28
|
+
@@local_sources ||= {}
|
28
29
|
@@remote_sources ||= {}
|
29
|
-
if @@remote_sources.has_key?(path.to_s)
|
30
|
-
response = HTTParty.get(@@remote_sources[path.to_s]).parsed_response
|
31
|
-
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
if @@local_sources.has_key?(path.to_s)
|
32
|
+
response = @@local_sources[path.to_s]
|
33
|
+
elsif @@remote_sources.has_key?(path.to_s)
|
34
|
+
response = HTTParty.get(@@remote_sources[path.to_s]).parsed_response
|
35
|
+
else
|
36
|
+
file_path = File.join(@app.class.root, "data", "#{path}.yml")
|
37
|
+
if File.exists? file_path
|
38
|
+
response = YAML.load_file(file_path)
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
if response
|
@@ -44,6 +48,11 @@ module Middleman::Features::Data
|
|
44
48
|
@@remote_sources ||= {}
|
45
49
|
@@remote_sources[name.to_s] = json_url
|
46
50
|
end
|
51
|
+
|
52
|
+
def self.data_content(name, content)
|
53
|
+
@@local_sources ||= {}
|
54
|
+
@@local_sources[name.to_s] = content
|
55
|
+
end
|
47
56
|
|
48
57
|
private
|
49
58
|
def recursively_enhance(data)
|
@@ -75,5 +84,9 @@ module Middleman::Features::Data
|
|
75
84
|
def data_source(name, url)
|
76
85
|
Middleman::Features::Data::DataObject.add_source(name, url)
|
77
86
|
end
|
87
|
+
|
88
|
+
def data_content(name, content)
|
89
|
+
Middleman::Features::Data::DataObject.data_content(name, content)
|
90
|
+
end
|
78
91
|
end
|
79
92
|
end
|
@@ -14,7 +14,7 @@ module Middleman::Features::DefaultHelpers
|
|
14
14
|
path = path.gsub(File.extname(path), '')
|
15
15
|
path = path.gsub("/", separator)
|
16
16
|
|
17
|
-
css_file = File.join(self.class.
|
17
|
+
css_file = File.join(self.class.views, self.class.css_dir, "#{path}.css")
|
18
18
|
sass_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.sass")
|
19
19
|
scss_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.scss")
|
20
20
|
less_file = File.join(self.class.views, self.class.css_dir, "#{path}.css.less")
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "tilt"
|
3
|
+
|
4
|
+
module Middleman::Features::FrontMatter
|
5
|
+
class << self
|
6
|
+
def registered(app)
|
7
|
+
app.extend ClassMethods
|
8
|
+
|
9
|
+
::Tilt::register MarukuTemplate, 'markdown', 'mkd', 'md'
|
10
|
+
::Tilt::register KramdownTemplate, 'markdown', 'mkd', 'md'
|
11
|
+
::Tilt::register BlueClothTemplate, 'markdown', 'mkd', 'md'
|
12
|
+
::Tilt::register RedcarpetTemplate, 'markdown', 'mkd', 'md'
|
13
|
+
::Tilt::register RDiscountTemplate, 'markdown', 'mkd', 'md'
|
14
|
+
::Tilt::register RedClothTemplate, 'textile'
|
15
|
+
end
|
16
|
+
alias :included :registered
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def parse_front_matter(content)
|
21
|
+
yaml_regex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
22
|
+
if content =~ yaml_regex
|
23
|
+
begin
|
24
|
+
data = YAML.load($1)
|
25
|
+
rescue => e
|
26
|
+
puts "YAML Exception: #{e.message}"
|
27
|
+
end
|
28
|
+
|
29
|
+
content = content.split(yaml_regex).last
|
30
|
+
end
|
31
|
+
|
32
|
+
data ||= {}
|
33
|
+
[data, content]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module YamlAware
|
38
|
+
def prepare
|
39
|
+
options, @data = Middleman::Server.parse_front_matter(@data)
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# MARKDOWN
|
45
|
+
class MarukuTemplate < ::Tilt::MarukuTemplate
|
46
|
+
include Middleman::Features::FrontMatter::YamlAware
|
47
|
+
end
|
48
|
+
|
49
|
+
class KramdownTemplate < ::Tilt::KramdownTemplate
|
50
|
+
include Middleman::Features::FrontMatter::YamlAware
|
51
|
+
end
|
52
|
+
|
53
|
+
class BlueClothTemplate < ::Tilt::BlueClothTemplate
|
54
|
+
include Middleman::Features::FrontMatter::YamlAware
|
55
|
+
end
|
56
|
+
|
57
|
+
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate
|
58
|
+
include Middleman::Features::FrontMatter::YamlAware
|
59
|
+
end
|
60
|
+
|
61
|
+
class RDiscountTemplate < ::Tilt::RDiscountTemplate
|
62
|
+
include Middleman::Features::FrontMatter::YamlAware
|
63
|
+
end
|
64
|
+
|
65
|
+
# TEXTILE
|
66
|
+
class RedClothTemplate < ::Tilt::RedClothTemplate
|
67
|
+
include Middleman::Features::FrontMatter::YamlAware
|
68
|
+
end
|
69
|
+
end
|
@@ -10,11 +10,16 @@ module Middleman::Features::LiveReload
|
|
10
10
|
end
|
11
11
|
|
12
12
|
new_config = ::LiveReload::Config.new do |config|
|
13
|
-
|
13
|
+
::Tilt.mappings.each do |key, v|
|
14
|
+
config.exts << key
|
15
|
+
end
|
14
16
|
end
|
17
|
+
|
18
|
+
pid = fork {
|
19
|
+
require 'livereload'
|
20
|
+
::LiveReload.run [Middleman::Server.views], new_config
|
21
|
+
}
|
15
22
|
|
16
|
-
# Middleman::Server.public
|
17
|
-
::LiveReload.run [Middleman::Server.views], new_config
|
18
23
|
end
|
19
24
|
alias :included :registered
|
20
25
|
end
|
@@ -3,10 +3,10 @@ begin
|
|
3
3
|
rescue LoadError
|
4
4
|
puts "UglifyJS not available. Install it with: gem install uglifier"
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
module Middleman
|
8
8
|
module Rack
|
9
|
-
|
9
|
+
|
10
10
|
class MinifyJavascript
|
11
11
|
def initialize(app, options={})
|
12
12
|
@app = app
|
@@ -14,10 +14,10 @@ module Middleman
|
|
14
14
|
|
15
15
|
def call(env)
|
16
16
|
status, headers, response = @app.call(env)
|
17
|
-
|
17
|
+
|
18
18
|
if env["PATH_INFO"].match(/\.js$/)
|
19
19
|
compressor = ::Uglifier.new
|
20
|
-
|
20
|
+
|
21
21
|
if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile)
|
22
22
|
uncompressed_source = File.read(response.path)
|
23
23
|
else
|
@@ -27,10 +27,31 @@ module Middleman
|
|
27
27
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
28
28
|
response = [minified]
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
if env["PATH_INFO"].match(/\.html$/)
|
32
|
+
compressor = ::Uglifier.new
|
33
|
+
|
34
|
+
if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile)
|
35
|
+
uncompressed_source = File.read(response.path)
|
36
|
+
else
|
37
|
+
uncompressed_source = response.join
|
38
|
+
end
|
39
|
+
|
40
|
+
minified = uncompressed_source.gsub(/(<scri.*?\/\/<!\[CDATA\[\n)(.*?)(\/\/\]\].*?<\/script>)/m) do |m|
|
41
|
+
first = $1
|
42
|
+
uncompressed_source = $2
|
43
|
+
last = $3
|
44
|
+
minified_js = compressor.compile(uncompressed_source)
|
45
|
+
|
46
|
+
first << minified_js << "\n" << last
|
47
|
+
end
|
48
|
+
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
49
|
+
response = [minified]
|
50
|
+
end
|
51
|
+
|
31
52
|
[status, headers, response]
|
32
53
|
end
|
33
54
|
end
|
34
|
-
|
55
|
+
|
35
56
|
end
|
36
57
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "sass"
|
2
2
|
require "sass/plugin"
|
3
3
|
require "compass"
|
4
|
+
require "susy"
|
4
5
|
|
5
6
|
module Middleman
|
6
7
|
module Renderers
|
@@ -13,9 +14,9 @@ module Middleman
|
|
13
14
|
config.project_path = self.root
|
14
15
|
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
15
16
|
config.output_style = :nested
|
16
|
-
config.fonts_dir = File.join(File.basename(self.
|
17
|
-
config.css_dir = File.join(File.basename(self.
|
18
|
-
config.images_dir = File.join(File.basename(self.
|
17
|
+
config.fonts_dir = File.join(File.basename(self.views), self.fonts_dir)
|
18
|
+
config.css_dir = File.join(File.basename(self.views), self.css_dir)
|
19
|
+
config.images_dir = File.join(File.basename(self.views), self.images_dir)
|
19
20
|
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix || "/", self.images_dir)
|
20
21
|
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix || "/", self.css_dir)
|
21
22
|
config.asset_cache_buster { false }
|
@@ -43,7 +44,7 @@ class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate
|
|
43
44
|
|
44
45
|
location_of_sass_file = Middleman::Server.environment == :build ?
|
45
46
|
File.join(Middleman::Server.root, Middleman::Server.build_dir) :
|
46
|
-
Middleman::Server.
|
47
|
+
Middleman::Server.views
|
47
48
|
|
48
49
|
parts = basename.split('.')
|
49
50
|
parts.pop
|
data/lib/middleman/server.rb
CHANGED
@@ -15,8 +15,6 @@ module Middleman
|
|
15
15
|
set :logging, false
|
16
16
|
set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
|
17
17
|
|
18
|
-
# Import padrino helper methods
|
19
|
-
|
20
18
|
# Middleman-specific options
|
21
19
|
set :index_file, "index.html" # What file responds to folder requests
|
22
20
|
# Such as the homepage (/) or subfolders (/about/)
|
@@ -30,9 +28,14 @@ module Middleman
|
|
30
28
|
set :build_dir, "build" # Which folder are builds output to
|
31
29
|
set :http_prefix, nil # During build, add a prefix for absolute paths
|
32
30
|
|
31
|
+
set :static, false
|
32
|
+
set :views, "source"
|
33
|
+
|
34
|
+
# Disable Padrino cache buster until explicitly enabled
|
35
|
+
set :asset_stamp, false
|
36
|
+
|
33
37
|
# Use Padrino Helpers
|
34
38
|
register Padrino::Helpers
|
35
|
-
set :asset_stamp, false # Disable Padrino cache buster until explicitly enabled
|
36
39
|
|
37
40
|
# Activate custom features
|
38
41
|
register Middleman::Features
|
@@ -46,6 +49,8 @@ module Middleman
|
|
46
49
|
# Activate Webservices Proxy package
|
47
50
|
# register Middleman::Features::Proxy
|
48
51
|
|
52
|
+
register Middleman::Features::FrontMatter
|
53
|
+
|
49
54
|
# Activate Lorem helpers
|
50
55
|
register Middleman::Features::Lorem
|
51
56
|
|
@@ -70,6 +75,7 @@ module Middleman
|
|
70
75
|
end
|
71
76
|
|
72
77
|
# Activate custom renderers
|
78
|
+
register Middleman::Renderers::Slim
|
73
79
|
register Middleman::Renderers::Haml
|
74
80
|
register Middleman::Renderers::Sass
|
75
81
|
|
@@ -140,11 +146,27 @@ module Middleman
|
|
140
146
|
# Normalize the path and add index if we're looking at a directory
|
141
147
|
path = self.class.path_to_index(request.path)
|
142
148
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
149
|
+
extensionless_path, template_engine = resolve_template(path)
|
150
|
+
|
151
|
+
if !::Tilt.mappings.has_key?(template_engine.to_s)
|
152
|
+
content_type mime_type(File.extname(path)), :charset => 'utf-8'
|
153
|
+
status 200
|
154
|
+
send_file File.join(Middleman::Server.views, path)
|
155
|
+
return
|
156
|
+
end
|
157
|
+
|
158
|
+
full_file_path = "#{extensionless_path}.#{template_engine}"
|
159
|
+
system_path = File.join(settings.views, full_file_path)
|
160
|
+
data, content = self.class.parse_front_matter(File.read(system_path))
|
161
|
+
|
162
|
+
%w(layout layout_engine).each do |opt|
|
163
|
+
if data.has_key?(opt)
|
164
|
+
options[opt.to_sym] = data.delete(opt)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Forward remaining data to helpers
|
169
|
+
self.class.data_content("page", data)
|
148
170
|
|
149
171
|
old_layout = settings.current_layout
|
150
172
|
settings.layout(options[:layout]) if !options[:layout].nil?
|
@@ -182,9 +204,6 @@ class Middleman::Server
|
|
182
204
|
Middleman::Server.class_eval File.read(local_config)
|
183
205
|
set :app_file, File.expand_path(local_config)
|
184
206
|
end
|
185
|
-
|
186
|
-
use ::Rack::ConditionalGet
|
187
|
-
use ::Rack::Static, :urls => ["/#{self.images_dir}"], :root => "public"
|
188
207
|
|
189
208
|
@@run_after_features.each { |block| class_eval(&block) }
|
190
209
|
|