middleman-core 3.0.14 → 3.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/features/clean_build.feature +4 -5
- data/features/content_type.feature +43 -0
- data/features/data.feature +9 -4
- data/features/front-matter-neighbor.feature +151 -0
- data/features/queryable.feature +31 -0
- data/features/step_definitions/queryable_steps.rb +123 -0
- data/fixtures/content-type-app/config.rb +1 -0
- data/fixtures/content-type-app/source/.htaccess +1 -0
- data/fixtures/content-type-app/source/README +1 -0
- data/fixtures/content-type-app/source/images/blank.gif +0 -0
- data/fixtures/content-type-app/source/index.html +1 -0
- data/fixtures/content-type-app/source/javascripts/app.js +1 -0
- data/fixtures/content-type-app/source/override.html +5 -0
- data/fixtures/content-type-app/source/stylesheets/site.css +1 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +0 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-2.php.erb +2 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-2.php.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-change.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-change.html.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-encoding.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-encoding.html.erb.frontmatter +5 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb +2 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.html +1 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.html.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.php +1 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.php.frontmatter +4 -0
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +4 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/alternate_layout.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/alternate_layout.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/ignored.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/ignored.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/layouts/alternate.erb +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb +2 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/override_layout.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/override_layout.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/page_mentioned.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/page_mentioned.html.erb.frontmatter +3 -0
- data/fixtures/nested-data-app/config.rb +1 -0
- data/fixtures/nested-data-app/data/examples/test.yml +1 -0
- data/fixtures/nested-data-app/source/test.html.erb +1 -0
- data/fixtures/queryable-app/config.rb +0 -0
- data/fixtures/queryable-app/source/2010-08-08-test-document-file.html.markdown +8 -0
- data/fixtures/queryable-app/source/2010-08-09-another-test-document.html.markdown +10 -0
- data/fixtures/queryable-app/source/2011-12-26-some-test-document.html.markdown +6 -0
- data/fixtures/queryable-app/source/document_with_date_in_yaml.html.markdown +7 -0
- data/fixtures/queryable-app/source/document_without_date.html.markdown +7 -0
- data/lib/middleman-core/application.rb +52 -84
- data/lib/middleman-core/cli.rb +3 -2
- data/lib/middleman-core/cli/build.rb +5 -7
- data/lib/middleman-core/cli/bundler.rb +1 -1
- data/lib/middleman-core/cli/console.rb +46 -0
- data/lib/middleman-core/configuration.rb +235 -0
- data/lib/middleman-core/core_extensions.rb +0 -6
- data/lib/middleman-core/core_extensions/data.rb +34 -11
- data/lib/middleman-core/core_extensions/extensions.rb +31 -35
- data/lib/middleman-core/core_extensions/external_helpers.rb +7 -7
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +44 -38
- data/lib/middleman-core/core_extensions/rendering.rb +27 -21
- data/lib/middleman-core/core_extensions/request.rb +41 -73
- data/lib/middleman-core/core_extensions/routing.rb +7 -24
- data/lib/middleman-core/core_extensions/show_exceptions.rb +6 -8
- data/lib/middleman-core/extensions.rb +35 -0
- data/lib/middleman-core/logger.rb +9 -0
- data/lib/middleman-core/meta_pages.rb +93 -0
- data/lib/middleman-core/meta_pages/assets/config.css +36 -0
- data/lib/middleman-core/meta_pages/assets/glyphicons-halflings.png +0 -0
- data/lib/middleman-core/meta_pages/assets/jquery-1.8.2.min.js +2 -0
- data/lib/middleman-core/meta_pages/assets/jquery.details-1.6.min.js +6 -0
- data/lib/middleman-core/meta_pages/assets/meta.css +368 -0
- data/lib/middleman-core/meta_pages/assets/sitemap.css +635 -0
- data/lib/middleman-core/meta_pages/assets/sitemap.js +0 -0
- data/lib/middleman-core/meta_pages/config_setting.rb +39 -0
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +52 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +73 -0
- data/lib/middleman-core/meta_pages/templates/config.html.erb +59 -0
- data/lib/middleman-core/meta_pages/templates/index.html.erb +21 -0
- data/lib/middleman-core/meta_pages/templates/sitemap.html.erb +31 -0
- data/lib/middleman-core/preview_server.rb +18 -7
- data/lib/middleman-core/profiling.rb +1 -1
- data/lib/middleman-core/renderers/erb.rb +5 -5
- data/lib/middleman-core/renderers/less.rb +3 -3
- data/lib/middleman-core/renderers/markdown.rb +10 -9
- data/lib/middleman-core/renderers/redcarpet.rb +16 -21
- data/lib/middleman-core/renderers/sass.rb +4 -5
- data/lib/middleman-core/renderers/slim.rb +4 -1
- data/lib/middleman-core/sitemap.rb +3 -3
- data/lib/middleman-core/sitemap/extensions/content_type.rb +16 -0
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/proxies.rb +26 -16
- data/lib/middleman-core/sitemap/queryable.rb +148 -0
- data/lib/middleman-core/sitemap/resource.rb +14 -2
- data/lib/middleman-core/sitemap/store.rb +8 -7
- data/lib/middleman-core/step_definitions/builder_steps.rb +3 -0
- data/lib/middleman-core/step_definitions/server_steps.rb +6 -1
- data/lib/middleman-core/templates/default/source/layouts/layout.erb +1 -1
- data/lib/middleman-core/templates/extension/lib/lib.rb +17 -26
- data/lib/middleman-core/templates/html5/source/layouts/layout.erb +1 -1
- data/lib/middleman-core/templates/shared/Gemfile.tt +6 -1
- data/lib/middleman-core/util.rb +7 -5
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -1
- metadata +126 -28
- data/lib/middleman-core/core_extensions/builder.rb +0 -17
- data/lib/middleman-core/core_extensions/ruby_encoding.rb +0 -25
- data/middleman-core-x86-mingw32.gemspec +0 -38
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Middleman
|
2
|
+
module MetaPages
|
3
|
+
# View class for a config entry
|
4
|
+
class ConfigSetting
|
5
|
+
include Padrino::Helpers::OutputHelpers
|
6
|
+
include Padrino::Helpers::TagHelpers
|
7
|
+
|
8
|
+
def initialize(setting)
|
9
|
+
@setting = setting
|
10
|
+
end
|
11
|
+
|
12
|
+
def render
|
13
|
+
content = ""
|
14
|
+
key_classes = ['key']
|
15
|
+
key_classes << 'modified' if @setting.value_set?
|
16
|
+
content << content_tag(:span, @setting.key.inspect, :class => key_classes.join(' '))
|
17
|
+
content << " = "
|
18
|
+
content << content_tag(:span, CGI::escapeHTML(@setting.value.inspect), :class => 'value')
|
19
|
+
if @setting.default
|
20
|
+
content << content_tag(:span, :class => 'default') do
|
21
|
+
if @setting.value_set?
|
22
|
+
"Default: #{CGI::escapeHTML(@setting.default.inspect)}"
|
23
|
+
else
|
24
|
+
"(Default)"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if @setting.description
|
30
|
+
content << content_tag(:p, :class => 'description') do
|
31
|
+
CGI::escapeHTML(@setting.description)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
content
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Middleman
|
2
|
+
module MetaPages
|
3
|
+
# View class for a sitemap resource
|
4
|
+
class SitemapResource
|
5
|
+
include Padrino::Helpers::OutputHelpers
|
6
|
+
include Padrino::Helpers::TagHelpers
|
7
|
+
|
8
|
+
def initialize(resource)
|
9
|
+
@resource = resource
|
10
|
+
end
|
11
|
+
|
12
|
+
def render
|
13
|
+
content_tag :div, :class => 'resource-details' do
|
14
|
+
content_tag :table do
|
15
|
+
content = ""
|
16
|
+
resource_properties.each do |label, value|
|
17
|
+
content << content_tag(:tr) do
|
18
|
+
row_content = ""
|
19
|
+
row_content << content_tag(:th, label)
|
20
|
+
row_content << content_tag(:td, value)
|
21
|
+
row_content
|
22
|
+
end
|
23
|
+
end
|
24
|
+
content
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# A hash of label to value for all the properties we want to display
|
30
|
+
def resource_properties
|
31
|
+
props = {
|
32
|
+
'Path' => @resource.path,
|
33
|
+
'Build Path' => @resource.destination_path,
|
34
|
+
'URL' => content_tag(:a, @resource.url, :href => @resource.url),
|
35
|
+
'Template' => @resource.source_file,
|
36
|
+
}
|
37
|
+
|
38
|
+
data = @resource.data
|
39
|
+
props['Data'] = data unless data.empty?
|
40
|
+
|
41
|
+
options = @resource.metadata[:options]
|
42
|
+
props['Options'] = options unless options.empty?
|
43
|
+
|
44
|
+
props
|
45
|
+
end
|
46
|
+
|
47
|
+
def css_classes
|
48
|
+
['resource']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'middleman-core/meta_pages/sitemap_resource'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module MetaPages
|
5
|
+
# View class for a sitemap tree
|
6
|
+
class SitemapTree
|
7
|
+
def initialize
|
8
|
+
@children = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_resource(resource)
|
12
|
+
add_path(resource.path.split('/'), resource)
|
13
|
+
end
|
14
|
+
|
15
|
+
def render
|
16
|
+
content = ""
|
17
|
+
@children.keys.sort do |a,b|
|
18
|
+
a_subtree = @children[a]
|
19
|
+
b_subtree = @children[b]
|
20
|
+
if a_subtree.is_a? SitemapResource
|
21
|
+
if b_subtree.is_a? SitemapResource
|
22
|
+
a.downcase <=> b.downcase
|
23
|
+
else
|
24
|
+
1
|
25
|
+
end
|
26
|
+
elsif b_subtree.is_a? SitemapResource
|
27
|
+
if a_subtree.is_a? SitemapResource
|
28
|
+
b.downcase <=> a.downcase
|
29
|
+
else
|
30
|
+
-1
|
31
|
+
end
|
32
|
+
else
|
33
|
+
a.downcase <=> b.downcase
|
34
|
+
end
|
35
|
+
end.each do |path_part|
|
36
|
+
subtree = @children[path_part]
|
37
|
+
content << "<details class='#{subtree.css_classes.join(' ')}'>"
|
38
|
+
content << "<summary>"
|
39
|
+
content << "<i class='icon-folder-open'></i>" unless subtree.is_a? SitemapResource
|
40
|
+
content << "#{path_part}</summary>"
|
41
|
+
content << subtree.render
|
42
|
+
content << "</details>"
|
43
|
+
end
|
44
|
+
content
|
45
|
+
end
|
46
|
+
|
47
|
+
def css_classes
|
48
|
+
['tree']
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def add_path(path_parts, resource)
|
54
|
+
first_part = path_parts.first
|
55
|
+
|
56
|
+
if path_parts.size == 1
|
57
|
+
sitemap_class = SitemapResource
|
58
|
+
# Allow special sitemap resources to use custom metadata view calsses
|
59
|
+
sitemap_class = resource.meta_pages_class if resource.respond_to? :meta_pages_class
|
60
|
+
|
61
|
+
@children[first_part] = sitemap_class.new(resource)
|
62
|
+
else
|
63
|
+
@children[first_part] ||= SitemapTree.new
|
64
|
+
@children[first_part].add_path(path_parts[1..-1], resource)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
"Sitemap Tree"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Middleman Configuration</title>
|
6
|
+
<link type="text/css" rel="stylesheet" href="../assets/meta.css">
|
7
|
+
<link type="text/css" rel="stylesheet" href="../assets/config.css">
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body>
|
11
|
+
<div class="container">
|
12
|
+
<article id="main">
|
13
|
+
<a href="../">« back</a>
|
14
|
+
<h1>Middleman Configuration</h1>
|
15
|
+
|
16
|
+
<p>This page shows the current configuration of your Middleman application.</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<a href="#core">Core configuration</a>
|
20
|
+
| <a href="#extensions">Extensions</a>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<h2 id="core">Core Configuration</h2>
|
24
|
+
<ul class="settings">
|
25
|
+
<% global_config.each do |setting| %>
|
26
|
+
<li class="setting"><%= setting.render %></li>
|
27
|
+
<% end %>
|
28
|
+
</ul>
|
29
|
+
|
30
|
+
<h2 id="extensions">Extensions</h2>
|
31
|
+
<ul class="extensions">
|
32
|
+
<% extension_config.each do |ext_name, configs| %>
|
33
|
+
<li>
|
34
|
+
<% registered_extensions.delete(ext_name) %>
|
35
|
+
|
36
|
+
<span class="extension active"><%= ext_name.inspect %></span>
|
37
|
+
|
38
|
+
|
39
|
+
<% if configs && !configs.empty? %>
|
40
|
+
<ul class="settings">
|
41
|
+
<% configs.each do |setting| %>
|
42
|
+
<li class="setting"><%= setting.render %></li>
|
43
|
+
<% end %>
|
44
|
+
</ul>
|
45
|
+
<% end %>
|
46
|
+
</li>
|
47
|
+
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<% registered_extensions.keys.each do |ext_name| %>
|
51
|
+
<li><span class="extension"><%= ext_name.inspect %></span> (Inactive)</li>
|
52
|
+
<% end %>
|
53
|
+
</ul>
|
54
|
+
</article>
|
55
|
+
</div>
|
56
|
+
</body>
|
57
|
+
</html>
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Middleman Info</title>
|
6
|
+
<link type="text/css" rel="stylesheet" href="assets/meta.css">
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
<div class="container">
|
11
|
+
<h1>Middleman Information</h1>
|
12
|
+
|
13
|
+
<ul>
|
14
|
+
<li><a href="sitemap/">Sitemap</a></li>
|
15
|
+
<li><a href="config/">Configuration</a></li>
|
16
|
+
<li><a href="http://middlemanapp.com">Middleman Guides</a></li>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
</body>
|
20
|
+
</html>
|
21
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
|
6
|
+
<title>Middleman Sitemap</title>
|
7
|
+
|
8
|
+
|
9
|
+
<link type="text/css" rel="stylesheet" href="../assets/meta.css">
|
10
|
+
<link type="text/css" rel="stylesheet" href="../assets/sitemap.css">
|
11
|
+
<script src="../assets/jquery-1.8.2.min.js"></script>
|
12
|
+
<script src="../assets/jquery.details-1.6.min.js"></script>
|
13
|
+
<script src="../assets/sitemap.js"></script>
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
<div class="container">
|
18
|
+
<article id="main">
|
19
|
+
<a href="../">« back</a>
|
20
|
+
<h1>Middleman Sitemap</h1>
|
21
|
+
|
22
|
+
<p>This page shows all of the pages in
|
23
|
+
the <a href="http://middlemanapp.com/advanced/sitemap/">sitemap</a>,
|
24
|
+
Middleman's view of your site.</p>
|
25
|
+
|
26
|
+
<%= sitemap_tree.render %>
|
27
|
+
</article>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "webrick"
|
2
|
+
require 'middleman-core/meta_pages'
|
2
3
|
|
3
4
|
module Middleman
|
4
5
|
module PreviewServer
|
@@ -18,6 +19,7 @@ module Middleman
|
|
18
19
|
|
19
20
|
mount_instance
|
20
21
|
logger.info "== The Middleman is standing watch at http://#{host}:#{port}"
|
22
|
+
logger.info "== Inspect your site configuration at http://#{host}:#{port}/__middleman/"
|
21
23
|
|
22
24
|
@initialized ||= false
|
23
25
|
unless @initialized
|
@@ -76,9 +78,17 @@ module Middleman
|
|
76
78
|
private
|
77
79
|
def new_app
|
78
80
|
opts = @options
|
79
|
-
|
81
|
+
server = ::Middleman::Application.server
|
82
|
+
|
83
|
+
# Add in the meta pages application
|
84
|
+
meta_app = Middleman::MetaPages::Application.new(server)
|
85
|
+
server.map '/__middleman' do
|
86
|
+
run meta_app
|
87
|
+
end
|
88
|
+
|
89
|
+
@app = server.inst do
|
80
90
|
if opts[:environment]
|
81
|
-
|
91
|
+
config[:environment] = opts[:environment].to_sym
|
82
92
|
end
|
83
93
|
|
84
94
|
logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
|
@@ -100,7 +110,7 @@ module Middleman
|
|
100
110
|
added_and_modified = (modified + added)
|
101
111
|
|
102
112
|
# See if the changed file is config.rb or lib/*.rb
|
103
|
-
if needs_to_reload?(added_and_modified
|
113
|
+
if needs_to_reload?(added_and_modified + removed)
|
104
114
|
reload
|
105
115
|
else
|
106
116
|
added_and_modified.each do |path|
|
@@ -148,7 +158,7 @@ module Middleman
|
|
148
158
|
|
149
159
|
begin
|
150
160
|
::WEBrick::HTTPServer.new(http_opts)
|
151
|
-
rescue Errno::EADDRINUSE
|
161
|
+
rescue Errno::EADDRINUSE
|
152
162
|
logger.error "== Port #{port} is unavailable. Either close the instance of Middleman already running on #{port} or start this Middleman on a new port with: --port=#{port.to_i+1}"
|
153
163
|
exit(1)
|
154
164
|
end
|
@@ -164,7 +174,8 @@ module Middleman
|
|
164
174
|
|
165
175
|
start_file_watcher
|
166
176
|
|
167
|
-
|
177
|
+
rack_app = app.class.to_rack_app
|
178
|
+
@webrick.mount "/", ::Rack::Handler::WEBrick, rack_app
|
168
179
|
end
|
169
180
|
|
170
181
|
# Detach the current Middleman::Application instance
|
@@ -180,8 +191,8 @@ module Middleman
|
|
180
191
|
def needs_to_reload?(paths)
|
181
192
|
match_against = [
|
182
193
|
%r{^config\.rb},
|
183
|
-
%r{^lib
|
184
|
-
%r{^helpers
|
194
|
+
%r{^lib/[^\.](.*)\.rb$},
|
195
|
+
%r{^helpers/[^\.](.*)\.rb$}
|
185
196
|
]
|
186
197
|
|
187
198
|
if @options[:reload_paths]
|
@@ -34,7 +34,7 @@ module Middleman
|
|
34
34
|
begin
|
35
35
|
require 'ruby-prof'
|
36
36
|
rescue LoadError
|
37
|
-
raise "To use the --profile option, you must
|
37
|
+
raise "To use the --profile option, you must add the 'ruby-prof' gem to your Gemfile"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -8,8 +8,8 @@ module Middleman
|
|
8
8
|
# once registered
|
9
9
|
def registered(app)
|
10
10
|
# Setup a default ERb engine
|
11
|
-
app.
|
12
|
-
app.
|
11
|
+
app.config.define_setting :erb_engine, :erb, 'The engine to use for rendering ERb templates'
|
12
|
+
app.config.define_setting :erb_engine_prefix, ::Tilt, 'The parent module for ERb template engines'
|
13
13
|
|
14
14
|
app.before_configuration do
|
15
15
|
template_extensions :erb => :html
|
@@ -19,14 +19,14 @@ module Middleman
|
|
19
19
|
app.after_configuration do
|
20
20
|
# Find the user's prefered engine
|
21
21
|
# Convert symbols to classes
|
22
|
-
if erb_engine.is_a? Symbol
|
22
|
+
if config[:erb_engine].is_a? Symbol
|
23
23
|
engine = engine.to_s
|
24
24
|
engine = engine == "erb" ? "ERB" : engine.camelize
|
25
|
-
erb_engine = erb_engine_prefix.const_get("#{engine}Template")
|
25
|
+
config[:erb_engine] = config[:erb_engine_prefix].const_get("#{engine}Template")
|
26
26
|
end
|
27
27
|
|
28
28
|
# Tell Tilt to use the preferred engine
|
29
|
-
::Tilt.prefer(erb_engine)
|
29
|
+
::Tilt.prefer(config[:erb_engine])
|
30
30
|
end
|
31
31
|
end
|
32
32
|
alias :included :registered
|
@@ -11,15 +11,15 @@ module Middleman
|
|
11
11
|
|
12
12
|
# Once registered
|
13
13
|
def registered(app)
|
14
|
-
# Default
|
15
|
-
app.
|
14
|
+
# Default less options
|
15
|
+
app.config.define_setting :less, {}, 'LESS compiler options'
|
16
16
|
|
17
17
|
app.before_configuration do
|
18
18
|
template_extensions :less => :css
|
19
19
|
end
|
20
20
|
|
21
21
|
app.after_configuration do
|
22
|
-
::Less.paths << File.
|
22
|
+
::Less.paths << File.join(source_dir, config[:css_dir])
|
23
23
|
end
|
24
24
|
|
25
25
|
# Tell Tilt to use it as well (for inline sass blocks)
|
@@ -10,8 +10,8 @@ module Middleman
|
|
10
10
|
# Once registered
|
11
11
|
def registered(app)
|
12
12
|
# Set our preference for a markdown engine
|
13
|
-
app.
|
14
|
-
app.
|
13
|
+
app.config.define_setting :markdown_engine, :kramdown, 'Preferred markdown engine'
|
14
|
+
app.config.define_setting :markdown_engine_prefix, ::Tilt, 'The parent module for markdown template engines'
|
15
15
|
|
16
16
|
app.before_configuration do
|
17
17
|
template_extensions :markdown => :html,
|
@@ -26,24 +26,25 @@ module Middleman
|
|
26
26
|
|
27
27
|
begin
|
28
28
|
# Look for the user's preferred engine
|
29
|
-
if markdown_engine == :redcarpet
|
29
|
+
if config[:markdown_engine] == :redcarpet
|
30
30
|
require "middleman-core/renderers/redcarpet"
|
31
31
|
::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate)
|
32
|
-
|
32
|
+
MiddlemanRedcarpetHTML.middleman_app = self
|
33
|
+
elsif !config[:markdown_engine].nil?
|
33
34
|
# Map symbols to classes
|
34
|
-
markdown_engine_klass = if markdown_engine.is_a? Symbol
|
35
|
-
engine = markdown_engine.to_s
|
35
|
+
markdown_engine_klass = if config[:markdown_engine].is_a? Symbol
|
36
|
+
engine = config[:markdown_engine].to_s
|
36
37
|
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
37
|
-
markdown_engine_prefix.const_get("#{engine}Template")
|
38
|
+
config[:markdown_engine_prefix].const_get("#{engine}Template")
|
38
39
|
else
|
39
|
-
markdown_engine_prefix
|
40
|
+
config[:markdown_engine_prefix]
|
40
41
|
end
|
41
42
|
|
42
43
|
# Tell tilt to use that engine
|
43
44
|
::Tilt.prefer(markdown_engine_klass)
|
44
45
|
end
|
45
46
|
rescue LoadError
|
46
|
-
logger.warn "Requested Markdown engine (#{markdown_engine}) not found. Maybe the gem needs to be installed and required?"
|
47
|
+
logger.warn "Requested Markdown engine (#{config[:markdown_engine]}) not found. Maybe the gem needs to be installed and required?"
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|