middleman 0.9.8 → 0.9.9
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/VERSION +1 -1
- data/bin/mm-build +2 -79
- data/bin/mm-init +1 -1
- data/lib/middleman/base.rb +8 -4
- data/lib/middleman/builder.rb +73 -9
- data/lib/middleman/features/slickmap.rb +5 -3
- data/middleman.gemspec +2 -2
- data/spec/cache_buster_spec.rb +2 -2
- data/spec/fixtures/sample/init.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.9
|
data/bin/mm-build
CHANGED
@@ -1,87 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'templater'
|
4
|
-
|
5
3
|
ENV['MM_ENV'] = "build"
|
6
4
|
|
7
5
|
# Require app
|
8
6
|
require File.join(File.dirname(__FILE__), "..", "lib", "middleman")
|
9
|
-
require 'middleman/builder'
|
10
|
-
|
11
7
|
Middleman::Base.init!
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
desc "Build a staticmatic site"
|
16
|
-
|
17
|
-
class Builder < Templater::Generator
|
18
|
-
# Define source and desintation
|
19
|
-
def self.source_root; Dir.pwd; end
|
20
|
-
def destination_root; File.join(Dir.pwd, Middleman::Base.build_dir); end
|
21
|
-
|
22
|
-
# Override template to ask middleman for the correct extension to output
|
23
|
-
def self.template(name, *args, &block)
|
24
|
-
return if args[0].include?('layout')
|
25
|
-
|
26
|
-
args.first.split('/').each do |part|
|
27
|
-
return if part[0,1] == '_'
|
28
|
-
end
|
29
|
-
|
30
|
-
if (args[0] === args[1])
|
31
|
-
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "")
|
32
|
-
.gsub("#{File.basename(Middleman::Base.public)}/", "")
|
33
|
-
if File.extname(args[1]) != ".js"
|
34
|
-
args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
super(name, *args, &block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.file(name, *args, &block)
|
42
|
-
if (args[0] === args[1])
|
43
|
-
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "")
|
44
|
-
.gsub("#{File.basename(Middleman::Base.public)}/", "")
|
45
|
-
end
|
46
|
-
super(name, *args, &block)
|
47
|
-
end
|
48
|
-
|
49
|
-
glob! File.basename(Middleman::Base.public), Middleman::Base.supported_formats
|
50
|
-
glob! File.basename(Middleman::Base.views), Middleman::Base.supported_formats
|
51
|
-
|
52
|
-
if Middleman::Base.slickmap?
|
53
|
-
template :slickmap, "sitemap.html", "sitemap.html"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
add :build, Builder
|
58
|
-
end
|
59
|
-
|
60
|
-
# Monkey-patch to use a dynamic renderer
|
61
|
-
class Templater::Actions::File
|
62
|
-
def identical?
|
63
|
-
if exists?
|
64
|
-
return true if File.mtime(source) < File.mtime(destination)
|
65
|
-
::FileUtils.identical?(source, destination)
|
66
|
-
else
|
67
|
-
false
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class Templater::Actions::Template
|
73
|
-
def render
|
74
|
-
::Middleman::Builder.render_file(source, destination)
|
75
|
-
end
|
76
|
-
|
77
|
-
def identical?
|
78
|
-
if ::File.exists?(destination)
|
79
|
-
return true if File.exists?(source) && File.mtime(source) < File.mtime(destination)
|
80
|
-
::File.read(destination) == render
|
81
|
-
else
|
82
|
-
false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))
|
9
|
+
require 'middleman/builder'
|
10
|
+
Middleman::Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))
|
data/bin/mm-init
CHANGED
@@ -6,7 +6,7 @@ module Generators
|
|
6
6
|
desc "Generator for streamlining staticmatic"
|
7
7
|
|
8
8
|
class NewSite < Templater::Generator
|
9
|
-
desc "Creates a new
|
9
|
+
desc "Creates a new middleman scaffold."
|
10
10
|
first_argument :location, :required => true, :desc => "Project location"
|
11
11
|
|
12
12
|
option :css_dir, :desc => 'The path to the css files'
|
data/lib/middleman/base.rb
CHANGED
@@ -40,7 +40,7 @@ module Middleman
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Rack helper for adding mime-types during local preview
|
43
|
-
def mime(ext, type)
|
43
|
+
def self.mime(ext, type)
|
44
44
|
ext = ".#{ext}" unless ext.to_s[0] == ?.
|
45
45
|
Rack::Mime::MIME_TYPES[ext.to_s] = type
|
46
46
|
end
|
@@ -55,7 +55,11 @@ module Middleman
|
|
55
55
|
# Base case renderer (do nothing), Should be over-ridden
|
56
56
|
module StaticRender
|
57
57
|
def render_path(path)
|
58
|
-
|
58
|
+
if template_exists?(path, :erb)
|
59
|
+
erb(path.to_sym)
|
60
|
+
else
|
61
|
+
false
|
62
|
+
end
|
59
63
|
end
|
60
64
|
end
|
61
65
|
include StaticRender
|
@@ -113,7 +117,7 @@ module Middleman
|
|
113
117
|
end
|
114
118
|
|
115
119
|
# Require the features for this project
|
116
|
-
def self.init!
|
120
|
+
def self.init!(quiet=false)
|
117
121
|
# Built-in helpers
|
118
122
|
require 'middleman/helpers'
|
119
123
|
helpers Middleman::Helpers
|
@@ -124,7 +128,7 @@ module Middleman
|
|
124
128
|
# Check for and evaluate local configuration
|
125
129
|
local_config = File.join(self.root, "init.rb")
|
126
130
|
if File.exists? local_config
|
127
|
-
puts "== Local config at: #{local_config}"
|
131
|
+
puts "== Local config at: #{local_config}" unless quiet
|
128
132
|
class_eval File.read(local_config)
|
129
133
|
end
|
130
134
|
|
data/lib/middleman/builder.rb
CHANGED
@@ -1,15 +1,79 @@
|
|
1
|
-
|
2
|
-
require 'rack/test'
|
1
|
+
require 'templater'
|
2
|
+
require 'rack/test' # Use Rack::Test to access Sinatra without starting up a full server
|
3
3
|
|
4
4
|
# Placeholder for any methods the builder needs to abstract to allow feature integration
|
5
5
|
module Middleman
|
6
|
-
class Builder
|
7
|
-
#
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
class Builder < ::Templater::Generator
|
7
|
+
# Define source and desintation
|
8
|
+
def self.source_root; Dir.pwd; end
|
9
|
+
def destination_root; File.join(Dir.pwd, Middleman::Base.build_dir); end
|
10
|
+
|
11
|
+
# Override template to ask middleman for the correct extension to output
|
12
|
+
def self.template(name, *args, &block)
|
13
|
+
return if args[0].include?('layout')
|
14
|
+
|
15
|
+
args.first.split('/').each do |part|
|
16
|
+
return if part[0,1] == '_'
|
17
|
+
end
|
18
|
+
|
19
|
+
if (args[0] === args[1])
|
20
|
+
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "")
|
21
|
+
.gsub("#{File.basename(Middleman::Base.public)}/", "")
|
22
|
+
if File.extname(args[1]) != ".js"
|
23
|
+
args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
super(name, *args, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.file(name, *args, &block)
|
31
|
+
if (args[0] === args[1])
|
32
|
+
args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "")
|
33
|
+
.gsub("#{File.basename(Middleman::Base.public)}/", "")
|
34
|
+
end
|
35
|
+
super(name, *args, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
glob! File.basename(Middleman::Base.public), Middleman::Base.supported_formats
|
39
|
+
glob! File.basename(Middleman::Base.views), Middleman::Base.supported_formats
|
40
|
+
end
|
41
|
+
|
42
|
+
module Generators
|
43
|
+
extend ::Templater::Manifold
|
44
|
+
desc "Build a static site"
|
45
|
+
|
46
|
+
add :build, ::Middleman::Builder
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Monkey-patch to use a dynamic renderer
|
51
|
+
class Templater::Actions::File
|
52
|
+
def identical?
|
53
|
+
if exists?
|
54
|
+
return true if File.mtime(source) < File.mtime(destination)
|
55
|
+
FileUtils.identical?(source, destination)
|
56
|
+
else
|
57
|
+
false
|
13
58
|
end
|
14
59
|
end
|
15
60
|
end
|
61
|
+
|
62
|
+
class Templater::Actions::Template
|
63
|
+
def render
|
64
|
+
# The default render just requests the page over Rack and writes the response
|
65
|
+
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
|
66
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
|
67
|
+
browser.get(request_path)
|
68
|
+
browser.last_response.body
|
69
|
+
end
|
70
|
+
|
71
|
+
def identical?
|
72
|
+
if File.exists?(destination)
|
73
|
+
return true if File.exists?(source) && File.mtime(source) < File.mtime(destination)
|
74
|
+
File.read(destination) == render
|
75
|
+
else
|
76
|
+
false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -5,12 +5,14 @@ rescue LoadError
|
|
5
5
|
puts "Slickmap not available. Install it with: gem install compass-slickmap"
|
6
6
|
end
|
7
7
|
|
8
|
+
if Middleman::Base.environment == "build"
|
9
|
+
Middleman::Builder.template :slickmap, "sitemap.html", "sitemap.html"
|
10
|
+
end
|
11
|
+
|
8
12
|
Entry = Struct.new(:dir, :children)
|
9
13
|
|
10
14
|
class Middleman::Base
|
11
|
-
def build_sitemap(&block)
|
12
|
-
html_files = Dir[File.join(File.dirname(Middleman::Base.views), "**", "*.html*")]
|
13
|
-
|
15
|
+
def build_sitemap(&block)
|
14
16
|
@@utility = []
|
15
17
|
[recurse_sitemap(Middleman::Base.views, &block), @@utility]
|
16
18
|
end
|
data/middleman.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{middleman}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thomas Reynolds"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-08}
|
13
13
|
s.email = %q{tdreyno@gmail.com}
|
14
14
|
s.executables = ["mm-init", "mm-build", "mm-server"]
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/cache_buster_spec.rb
CHANGED
@@ -6,7 +6,7 @@ base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
|
6
6
|
describe "Cache Buster Feature" do
|
7
7
|
before do
|
8
8
|
base.disable :cache_buster
|
9
|
-
base.init!
|
9
|
+
base.init!(true)
|
10
10
|
@app = base.new
|
11
11
|
end
|
12
12
|
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
describe "Cache Buster Feature" do
|
19
19
|
before do
|
20
20
|
base.enable :cache_buster
|
21
|
-
base.init!
|
21
|
+
base.init!(true)
|
22
22
|
@app = base.new
|
23
23
|
end
|
24
24
|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
# enable :maruku
|
2
|
-
#enable :markaby
|
2
|
+
# enable :markaby
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-08 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|