middleman-core 3.0.0.alpha.9 → 3.0.0.beta.1
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/.gemtest +0 -0
- data/Rakefile +45 -1
- data/bin/fsevent_watch_guard +0 -0
- data/bin/middleman +1 -1
- data/ext/extconf.rb +61 -0
- data/{lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext → ext}/fsevent/fsevent_watch.c +0 -0
- data/features/cli.feature +2 -3
- data/lib/middleman-core/base.rb +2 -2
- data/lib/middleman-core/cli/build.rb +1 -1
- data/lib/middleman-core/cli/server.rb +15 -10
- data/lib/middleman-core/core_extensions/data.rb +32 -50
- data/lib/middleman-core/core_extensions/file_watcher.rb +81 -34
- data/lib/middleman-core/core_extensions/front_matter.rb +4 -4
- data/lib/middleman-core/core_extensions/rendering.rb +3 -3
- data/lib/middleman-core/core_extensions/sitemap.rb +4 -4
- data/lib/middleman-core/sitemap/template.rb +1 -1
- data/lib/middleman-core/step_definitions/middleman_steps.rb +2 -2
- data/lib/middleman-core/templates/default/source/layouts/layout.erb +1 -1
- data/lib/middleman-core/templates/default/source/stylesheets/all.css +55 -0
- data/lib/middleman-core/templates/default/source/stylesheets/{_normalize.scss → normalize.css} +0 -0
- data/lib/middleman-core/templates/default.rb +2 -3
- data/lib/middleman-core/vendor/darwin/.gitignore +18 -0
- data/lib/middleman-core/vendor/darwin/Gemfile +6 -0
- data/lib/middleman-core/vendor/darwin/Guardfile +8 -0
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/LICENSE +0 -0
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/README.rdoc +0 -0
- data/lib/middleman-core/vendor/darwin/Rakefile +21 -0
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/ext/extconf.rb +0 -0
- data/lib/middleman-core/vendor/darwin/ext/fsevent/fsevent_watch.c +226 -0
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/lib/rb-fsevent/fsevent.rb +2 -2
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/lib/rb-fsevent/version.rb +0 -0
- data/lib/middleman-core/vendor/{rb-fsevent-0.4.3.1 → darwin}/lib/rb-fsevent.rb +0 -0
- data/lib/middleman-core/vendor/darwin/rb-fsevent.gemspec +24 -0
- data/lib/middleman-core/vendor/darwin/spec/fixtures/custom 'path/.gitignore +0 -0
- data/lib/middleman-core/vendor/darwin/spec/fixtures/folder1/file1.txt +0 -0
- data/lib/middleman-core/vendor/darwin/spec/fixtures/folder1/folder2/file2.txt +0 -0
- data/lib/middleman-core/vendor/darwin/spec/rb-fsevent/fsevent_spec.rb +75 -0
- data/lib/middleman-core/vendor/darwin/spec/spec_helper.rb +24 -0
- data/lib/middleman-core/vendor/linux/.gitignore +3 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/.yardopts +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/MIT-LICENSE +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/README.md +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/Rakefile +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/VERSION +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify/event.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify/native/flags.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify/native.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify/notifier.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify/watcher.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/lib/rb-inotify.rb +0 -0
- data/lib/middleman-core/vendor/{rb-inotify-0.8.8 → linux}/rb-inotify.gemspec +0 -0
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core/watcher.rb +19 -14
- data/middleman-core.gemspec +4 -4
- metadata +40 -26
- data/lib/middleman-core/templates/default/source/stylesheets/_animate.scss +0 -23
- data/lib/middleman-core/templates/default/source/stylesheets/all.css.scss +0 -40
data/.gemtest
ADDED
File without changes
|
data/Rakefile
CHANGED
@@ -2,4 +2,48 @@
|
|
2
2
|
RAKE_ROOT = __FILE__
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
|
6
|
+
|
7
|
+
desc "Build vendored gems"
|
8
|
+
task :build_vendor do
|
9
|
+
raise unless File.exist?('Rakefile')
|
10
|
+
|
11
|
+
# Destroy vendor
|
12
|
+
sh "rm -rf lib/middleman-core/vendor/darwin"
|
13
|
+
sh "rm -rf lib/middleman-core/vendor/linux"
|
14
|
+
|
15
|
+
# Clone the correct gems
|
16
|
+
sh "git clone https://github.com/thibaudgg/rb-fsevent.git lib/middleman-core/vendor/darwin"
|
17
|
+
sh "cd lib/middleman-core/vendor/darwin && git checkout 1ca42b987596f350ee7b19d8f8210b7b6ae8766b"
|
18
|
+
sh "git clone https://github.com/nex3/rb-inotify.git lib/middleman-core/vendor/linux"
|
19
|
+
sh "cd lib/middleman-core/vendor/linux && git checkout 01e7487e7a8d8f26b13c6835a321390c6618ccb7"
|
20
|
+
|
21
|
+
# Strip out the .git directories
|
22
|
+
%w[darwin linux].each {|platform| sh "rm -rf lib/middleman-core/vendor/#{platform}/.git"}
|
23
|
+
|
24
|
+
# Move ext directory of darwin to root
|
25
|
+
sh "mkdir -p ext"
|
26
|
+
sh "cp -r lib/middleman-core/vendor/darwin/ext/* ext/"
|
27
|
+
|
28
|
+
# Alter darwin extconf.rb
|
29
|
+
extconf_path = File.expand_path("../ext/extconf.rb", __FILE__)
|
30
|
+
extconf_contents = File.read(extconf_path)
|
31
|
+
extconf_contents.sub!(/puts "Warning/, '#\0')
|
32
|
+
extconf_contents.gsub!(/bin\/fsevent_watch/, 'bin/fsevent_watch_guard')
|
33
|
+
File.open(extconf_path, 'w') { |f| f << extconf_contents }
|
34
|
+
|
35
|
+
# Alter lib/middleman-core/vendor/darwin/lib/rb-fsevent/fsevent.rb
|
36
|
+
fsevent_path = File.expand_path("../lib/middleman-core/vendor/darwin/lib/rb-fsevent/fsevent.rb", __FILE__)
|
37
|
+
fsevent_contents = File.read(fsevent_path)
|
38
|
+
fsevent_contents.sub!(/fsevent_watch/, 'fsevent_watch_guard')
|
39
|
+
fsevent_contents.sub!(/'\.\.'/, "'..', '..', '..', '..', '..'")
|
40
|
+
|
41
|
+
File.open(fsevent_path, 'w') { |f| f << fsevent_contents }
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Compile mac executable"
|
45
|
+
task :build_mac_exec do
|
46
|
+
Dir.chdir(File.expand_path("../ext", __FILE__)) do
|
47
|
+
system("ruby extconf.rb") or raise
|
48
|
+
end
|
49
|
+
end
|
Binary file
|
data/bin/middleman
CHANGED
data/ext/extconf.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Workaround to make Rubygems believe it builds a native gem
|
2
|
+
require 'mkmf'
|
3
|
+
create_makefile('none')
|
4
|
+
|
5
|
+
# TODO: determine whether we really need to be working around instead of with mkmf
|
6
|
+
|
7
|
+
if `uname -s`.chomp != 'Darwin'
|
8
|
+
#puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
|
9
|
+
else
|
10
|
+
begin
|
11
|
+
xcode_path = %x[xcode-select -print-path].to_s.strip!
|
12
|
+
rescue Errno::ENOENT
|
13
|
+
end
|
14
|
+
|
15
|
+
raise "Could not find a suitable Xcode installation" unless xcode_path
|
16
|
+
|
17
|
+
gem_root = File.expand_path(File.join('..'))
|
18
|
+
darwin_version = `uname -r`.to_i
|
19
|
+
sdk_version = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[darwin_version]
|
20
|
+
|
21
|
+
raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version
|
22
|
+
|
23
|
+
core_flags = %W{
|
24
|
+
-isysroot #{xcode_path}/SDKs/MacOSX#{sdk_version}.sdk
|
25
|
+
-mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
|
26
|
+
}
|
27
|
+
|
28
|
+
cflags = core_flags + %w{-Os -pipe}
|
29
|
+
|
30
|
+
wflags = %w{
|
31
|
+
-Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
|
32
|
+
-Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
|
33
|
+
-Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow
|
34
|
+
-Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion
|
35
|
+
-Wshorten-64-to-32 -Wglobal-constructors -pedantic
|
36
|
+
}
|
37
|
+
|
38
|
+
ldflags = %w{
|
39
|
+
-dead_strip -framework CoreServices
|
40
|
+
}
|
41
|
+
|
42
|
+
cc_opts = core_flags + ldflags
|
43
|
+
|
44
|
+
cc_opts += %w{
|
45
|
+
-D DEBUG=true
|
46
|
+
} if ENV['FWDEBUG'] == "true"
|
47
|
+
|
48
|
+
cc_bin = `which clang || which gcc`.to_s.strip!
|
49
|
+
|
50
|
+
compile_command = "CFLAGS='#{cflags.join(' ')} #{wflags.join(' ')}' #{cc_bin} #{cc_opts.join(' ')} -o '#{gem_root}/bin/fsevent_watch_guard' fsevent/fsevent_watch.c"
|
51
|
+
|
52
|
+
STDERR.puts(compile_command)
|
53
|
+
|
54
|
+
# Compile the actual fsevent_watch binary
|
55
|
+
system "mkdir -p #{File.join(gem_root, 'bin')}"
|
56
|
+
system compile_command
|
57
|
+
|
58
|
+
unless File.executable?("#{gem_root}/bin/fsevent_watch_guard")
|
59
|
+
raise "Compilation of fsevent_watch failed (see README)"
|
60
|
+
end
|
61
|
+
end
|
File without changes
|
data/features/cli.feature
CHANGED
@@ -11,9 +11,8 @@ Feature: Middleman CLI
|
|
11
11
|
| source/images/middleman.png |
|
12
12
|
| source/layouts/layout.erb |
|
13
13
|
| source/javascripts/all.js |
|
14
|
-
| source/stylesheets/all.css
|
15
|
-
| source/stylesheets/
|
16
|
-
| source/stylesheets/_normalize.scss |
|
14
|
+
| source/stylesheets/all.css |
|
15
|
+
| source/stylesheets/normalize.css |
|
17
16
|
|
18
17
|
Scenario: Create a new project (alias i)
|
19
18
|
When I run `middleman i MY_PROJECT`
|
data/lib/middleman-core/base.rb
CHANGED
@@ -322,9 +322,9 @@ class Middleman::Base
|
|
322
322
|
|
323
323
|
if env["PATH_INFO"] == "/__middleman__" && env["REQUEST_METHOD"] == "POST"
|
324
324
|
if req.params.has_key?("change")
|
325
|
-
|
325
|
+
self.files.did_change(req.params["change"])
|
326
326
|
elsif req.params.has_key?("delete")
|
327
|
-
|
327
|
+
self.files.did_delete(req.params["delete"])
|
328
328
|
end
|
329
329
|
|
330
330
|
res.status = 200
|
@@ -93,7 +93,7 @@ module Middleman::Cli
|
|
93
93
|
# @param [String] destination
|
94
94
|
# @param [Hash] config
|
95
95
|
# @return [String] the actual destination file path that was created
|
96
|
-
desc "
|
96
|
+
desc "", "", :hide => true
|
97
97
|
def tilt_template(source, destination, config={})
|
98
98
|
build_dir = self.class.shared_instance.build_dir
|
99
99
|
request_path = destination.sub(/^#{build_dir}/, "")
|
@@ -8,38 +8,43 @@ module Middleman::Cli
|
|
8
8
|
namespace :server
|
9
9
|
|
10
10
|
desc "server [options]", "Start the preview server"
|
11
|
-
method_option
|
11
|
+
method_option :environment,
|
12
12
|
:aliases => "-e",
|
13
13
|
:default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
14
14
|
:desc => "The environment Middleman will run under"
|
15
15
|
method_option :host,
|
16
|
-
:type
|
16
|
+
:type => :string,
|
17
17
|
:aliases => "-h",
|
18
18
|
:default => "0.0.0.0",
|
19
|
-
:desc
|
20
|
-
method_option
|
19
|
+
:desc => "Bind to HOST address"
|
20
|
+
method_option :port,
|
21
21
|
:aliases => "-p",
|
22
22
|
:default => "4567",
|
23
23
|
:desc => "The port Middleman will listen on"
|
24
|
-
method_option
|
24
|
+
method_option :verbose,
|
25
25
|
:type => :boolean,
|
26
26
|
:default => false,
|
27
27
|
:desc => 'Print debug messages'
|
28
|
+
method_option "disable-watcher",
|
29
|
+
:type => :boolean,
|
30
|
+
:default => false,
|
31
|
+
:desc => 'Disable the file change and delete watcher process'
|
28
32
|
|
29
33
|
# Start the server
|
30
34
|
def server
|
31
35
|
if !ENV["MM_ROOT"]
|
32
|
-
puts "==
|
36
|
+
puts "== Could not find a Middleman project config.rb"
|
33
37
|
puts "== Treating directory as a static site to be served"
|
34
38
|
ENV["MM_ROOT"] = Dir.pwd
|
35
39
|
ENV["MM_SOURCE"] = ""
|
36
40
|
end
|
37
41
|
|
38
42
|
params = {
|
39
|
-
:port
|
40
|
-
:host
|
41
|
-
:environment
|
42
|
-
:debug
|
43
|
+
:port => options["port"],
|
44
|
+
:host => options["host"],
|
45
|
+
:environment => options["environment"],
|
46
|
+
:debug => options["verbose"],
|
47
|
+
:"disable-watcher" => options["disable-watcher"]
|
43
48
|
}
|
44
49
|
|
45
50
|
puts "== The Middleman is loading"
|
@@ -21,12 +21,12 @@ module Middleman::CoreExtensions::Data
|
|
21
21
|
# Setup data files before anything else so they are available when
|
22
22
|
# parsing config.rb
|
23
23
|
def initialize
|
24
|
-
|
25
|
-
data.touch_file(file) if file.match(%r{^#{data_dir}\/})
|
24
|
+
self.files.changed DataStore.matcher do |file|
|
25
|
+
self.data.touch_file(file) if file.match(%r{^#{self.data_dir}\/})
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
data.remove_file(file) if file.match(%r{^#{data_dir}\/})
|
28
|
+
self.files.deleted DataStore.matcher do |file|
|
29
|
+
self.data.remove_file(file) if file.match(%r{^#{self.data_dir}\/})
|
30
30
|
end
|
31
31
|
|
32
32
|
super
|
@@ -36,24 +36,7 @@ module Middleman::CoreExtensions::Data
|
|
36
36
|
#
|
37
37
|
# @return [DataStore]
|
38
38
|
def data
|
39
|
-
@
|
40
|
-
end
|
41
|
-
|
42
|
-
# Makes a hash available on the data var with a given name
|
43
|
-
#
|
44
|
-
# @param [Symbol] name Name of the data, used for namespacing
|
45
|
-
# @param [Hash] content The content for this data
|
46
|
-
# @return [void]
|
47
|
-
def data_content(name, content)
|
48
|
-
DataStore.data_content(name, content)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Makes a hash available on the data var with a given name
|
52
|
-
#
|
53
|
-
# @param [Symbol] name Name of the data, used for namespacing
|
54
|
-
# @return [void]
|
55
|
-
def data_callback(name, &block)
|
56
|
-
DataStore.data_callback(name, block)
|
39
|
+
@_data ||= DataStore.new(self)
|
57
40
|
end
|
58
41
|
end
|
59
42
|
|
@@ -69,26 +52,28 @@ module Middleman::CoreExtensions::Data
|
|
69
52
|
def matcher
|
70
53
|
%r{[\w-]+\.(yml|yaml|json)$}
|
71
54
|
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Store static data hash
|
58
|
+
#
|
59
|
+
# @param [Symbol] name Name of the data, used for namespacing
|
60
|
+
# @param [Hash] content The content for this data
|
61
|
+
# @return [void]
|
62
|
+
def store(name=nil, content=nil)
|
63
|
+
@_local_sources ||= {}
|
64
|
+
@_local_sources[name.to_s] = content unless name.nil? || content.nil?
|
65
|
+
@_local_sources
|
66
|
+
end
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# Store callback-based data
|
84
|
-
#
|
85
|
-
# @param [Symbol] name Name of the data, used for namespacing
|
86
|
-
# @param [Proc] proc The callback which will return data
|
87
|
-
# @return [void]
|
88
|
-
def data_callback(name, proc)
|
89
|
-
@@callback_sources ||= {}
|
90
|
-
@@callback_sources[name.to_s] = proc
|
91
|
-
end
|
68
|
+
# Store callback-based data
|
69
|
+
#
|
70
|
+
# @param [Symbol] name Name of the data, used for namespacing
|
71
|
+
# @param [Proc] proc The callback which will return data
|
72
|
+
# @return [void]
|
73
|
+
def callbacks(name=nil, proc=nil)
|
74
|
+
@_callback_sources ||= {}
|
75
|
+
@_callback_sources[name.to_s] = proc unless name.nil? || proc.nil?
|
76
|
+
@_callback_sources
|
92
77
|
end
|
93
78
|
|
94
79
|
# Setup data store
|
@@ -139,10 +124,10 @@ module Middleman::CoreExtensions::Data
|
|
139
124
|
@@local_sources ||= {}
|
140
125
|
@@callback_sources ||= {}
|
141
126
|
|
142
|
-
if
|
143
|
-
response =
|
144
|
-
elsif
|
145
|
-
response =
|
127
|
+
if self.store.has_key?(path.to_s)
|
128
|
+
response = self.store[path.to_s]
|
129
|
+
elsif self.callbacks.has_key?(path.to_s)
|
130
|
+
response = self.callbacks[path.to_s].call()
|
146
131
|
end
|
147
132
|
|
148
133
|
response
|
@@ -172,14 +157,11 @@ module Middleman::CoreExtensions::Data
|
|
172
157
|
def to_h
|
173
158
|
data = {}
|
174
159
|
|
175
|
-
|
176
|
-
@@callback_sources ||= {}
|
177
|
-
|
178
|
-
(@@local_sources || {}).each do |k, v|
|
160
|
+
self.store.each do |k, v|
|
179
161
|
data[k] = data_for_path(k)
|
180
162
|
end
|
181
163
|
|
182
|
-
|
164
|
+
self.callbacks.each do |k, v|
|
183
165
|
data[k] = data_for_path(k)
|
184
166
|
end
|
185
167
|
|
@@ -2,30 +2,24 @@ require "find"
|
|
2
2
|
|
3
3
|
# API for watching file change events
|
4
4
|
module Middleman::CoreExtensions::FileWatcher
|
5
|
+
|
5
6
|
# Setup extension
|
6
7
|
class << self
|
7
|
-
|
8
|
+
|
9
|
+
# Once registered
|
8
10
|
def registered(app)
|
9
11
|
app.extend ClassMethods
|
10
12
|
app.send :include, InstanceMethods
|
11
13
|
|
12
|
-
app.delegate :file_changed, :file_deleted, :to => :"self.class"
|
13
|
-
|
14
14
|
# Before parsing config, load the data/ directory
|
15
15
|
app.before_configuration do
|
16
|
-
data_path = File.join(root, data_dir)
|
17
|
-
|
18
|
-
next if File.directory?(path)
|
19
|
-
file_did_change(path.sub("#{root}/", ""))
|
20
|
-
end if File.exists?(data_path)
|
16
|
+
data_path = File.join(self.root, self.data_dir)
|
17
|
+
self.files.reload_path(data_path) if File.exists?(data_path)
|
21
18
|
end
|
22
19
|
|
23
20
|
# After config, load everything else
|
24
21
|
app.ready do
|
25
|
-
|
26
|
-
next if File.directory?(path)
|
27
|
-
file_did_change(path.sub("#{root}/", ""))
|
28
|
-
end
|
22
|
+
self.files.reload_path(self.root)
|
29
23
|
end
|
30
24
|
end
|
31
25
|
alias :included :registered
|
@@ -33,52 +27,105 @@ module Middleman::CoreExtensions::FileWatcher
|
|
33
27
|
|
34
28
|
# Class methods
|
35
29
|
module ClassMethods
|
30
|
+
|
31
|
+
# Access the file api
|
32
|
+
# @return [Middleman::CoreExtensions::FileWatcher::API]
|
33
|
+
def files
|
34
|
+
@_files_api ||= API.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Instance methods
|
39
|
+
module InstanceMethods
|
40
|
+
|
41
|
+
# Access the file api
|
42
|
+
# @return [Middleman::CoreExtensions::FileWatcher::API]
|
43
|
+
def files
|
44
|
+
api = self.class.files
|
45
|
+
api.instance ||= self
|
46
|
+
api
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Core File Change API class
|
51
|
+
class API
|
52
|
+
attr_accessor :instance, :known_paths
|
53
|
+
|
54
|
+
# Initialize api and internal path cache
|
55
|
+
def initialize
|
56
|
+
self.known_paths = []
|
57
|
+
end
|
58
|
+
|
36
59
|
# Add callback to be run on file change
|
37
60
|
#
|
38
61
|
# @param [nil,Regexp] matcher A Regexp to match the change path against
|
39
62
|
# @return [Array<Proc>]
|
40
|
-
def
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
63
|
+
def changed(matcher=nil, &block)
|
64
|
+
@_changed ||= []
|
65
|
+
@_changed << [block, matcher] if block_given?
|
66
|
+
@_changed
|
44
67
|
end
|
45
68
|
|
46
69
|
# Add callback to be run on file deletion
|
47
70
|
#
|
48
71
|
# @param [nil,Regexp] matcher A Regexp to match the deleted path against
|
49
72
|
# @return [Array<Proc>]
|
50
|
-
def
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
73
|
+
def deleted(matcher=nil, &block)
|
74
|
+
@_deleted ||= []
|
75
|
+
@_deleted << [block, matcher] if block_given?
|
76
|
+
@_deleted
|
54
77
|
end
|
55
|
-
end
|
56
78
|
|
57
|
-
# Instance methods
|
58
|
-
module InstanceMethods
|
59
79
|
# Notify callbacks that a file changed
|
60
80
|
#
|
61
81
|
# @param [String] path The file that changed
|
62
82
|
# @return [void]
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
next if path.match(%r{^#{build_dir}/})
|
67
|
-
next if !matcher.nil? && !path.match(matcher)
|
68
|
-
instance_exec(path, &callback)
|
69
|
-
end
|
83
|
+
def did_change(path)
|
84
|
+
self.known_paths << path unless self.known_paths.include?(path)
|
85
|
+
self.run_callbacks(path, :changed)
|
70
86
|
end
|
71
87
|
|
72
88
|
# Notify callbacks that a file was deleted
|
73
89
|
#
|
74
90
|
# @param [String] path The file that was deleted
|
75
91
|
# @return [void]
|
76
|
-
def
|
92
|
+
def did_delete(path)
|
93
|
+
self.known_paths.delete(path) if self.known_paths.include?(path)
|
94
|
+
self.run_callbacks(path, :deleted)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Manually trigger update events
|
98
|
+
#
|
99
|
+
# @param [String] path The path to reload
|
100
|
+
# @return [void]
|
101
|
+
def reload_path(path)
|
102
|
+
subset = self.known_paths.select { |p| p.match(%r{^#{path}}) }
|
103
|
+
|
104
|
+
Find.find(path) do |path|
|
105
|
+
next if File.directory?(path)
|
106
|
+
relative_path = path.sub("#{self.instance.root}/", "")
|
107
|
+
subset.delete(relative_path) if subset.include?(relative_path)
|
108
|
+
self.did_change(relative_path)
|
109
|
+
end
|
110
|
+
|
111
|
+
subset.each do |removed_path|
|
112
|
+
self.did_delete(removed_path)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
# Notify callbacks for a file given an array of callbacks
|
118
|
+
#
|
119
|
+
# @param [String] path The file that was changed
|
120
|
+
# @param [Symbol] callbacks_name The name of the callbacks method
|
121
|
+
# @return [void]
|
122
|
+
def run_callbacks(path, callbacks_name)
|
77
123
|
return if ::Middleman::Watcher.ignore_list.any? { |r| path.match(r) }
|
78
|
-
|
79
|
-
|
124
|
+
|
125
|
+
self.send(callbacks_name).each do |callback, matcher|
|
126
|
+
next if path.match(%r{^#{self.instance.build_dir}/})
|
80
127
|
next unless matcher.nil? || path.match(matcher)
|
81
|
-
instance_exec(path, &callback)
|
128
|
+
self.instance.instance_exec(path, &callback)
|
82
129
|
end
|
83
130
|
end
|
84
131
|
end
|
@@ -30,12 +30,12 @@ module Middleman::CoreExtensions::FrontMatter
|
|
30
30
|
|
31
31
|
matcher = %r{#{static_path}.*(#{exts})}
|
32
32
|
|
33
|
-
|
34
|
-
frontmatter_extension.touch_file(file)
|
33
|
+
self.files.changed matcher do |file|
|
34
|
+
self.frontmatter_extension.touch_file(file)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
frontmatter_extension.remove_file(file)
|
37
|
+
self.files.deleted matcher do |file|
|
38
|
+
self.frontmatter_extension.remove_file(file)
|
39
39
|
end
|
40
40
|
|
41
41
|
provides_metadata matcher do |path|
|
@@ -26,9 +26,9 @@ module Middleman::CoreExtensions::Rendering
|
|
26
26
|
static_path = source_dir.sub(self.root, "").sub(/^\//, "")
|
27
27
|
render_regex = static_path.empty? ? // : (%r{^#{static_path + "/"}})
|
28
28
|
|
29
|
-
|
30
|
-
path = File.expand_path(file, root)
|
31
|
-
cache.remove(:raw_template, path)
|
29
|
+
self.files.changed render_regex do |file|
|
30
|
+
path = File.expand_path(file, self.root)
|
31
|
+
self.cache.remove(:raw_template, path)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -31,12 +31,12 @@ module Middleman::CoreExtensions::Sitemap
|
|
31
31
|
static_path = source_dir.sub(self.root, "").sub(/^\//, "")
|
32
32
|
sitemap_regex = static_path.empty? ? // : (%r{^#{static_path + "/"}})
|
33
33
|
|
34
|
-
|
35
|
-
sitemap.touch_file(file)
|
34
|
+
self.files.changed sitemap_regex do |file|
|
35
|
+
self.sitemap.touch_file(file)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
sitemap.remove_file(file)
|
38
|
+
self.files.deleted sitemap_regex do |file|
|
39
|
+
self.sitemap.remove_file(file)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -9,9 +9,9 @@ Then /^the file "([^\"]*)" is removed$/ do |path|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Then /^the file "([^\"]*)" did change$/ do |path|
|
12
|
-
@server_inst.
|
12
|
+
@server_inst.files.did_change(path)
|
13
13
|
end
|
14
14
|
|
15
15
|
Then /^the file "([^\"]*)" did delete$/ do |path|
|
16
|
-
@server_inst.
|
16
|
+
@server_inst.files.did_delete(path)
|
17
17
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
@charset "utf-8";
|
2
|
+
|
3
|
+
body {
|
4
|
+
background: #d4d4d4 url("../images/background.png");
|
5
|
+
text-align: center;
|
6
|
+
font-family: sans-serif; }
|
7
|
+
|
8
|
+
h1 {
|
9
|
+
color: rgba(0, 0, 0, .3);
|
10
|
+
font-weight: bold;
|
11
|
+
font-size: 32px;
|
12
|
+
letter-spacing: -1px;
|
13
|
+
text-transform: uppercase;
|
14
|
+
text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
|
15
|
+
background: url("../images/middleman.png") no-repeat center 100px;
|
16
|
+
padding: 350px 0 10px;
|
17
|
+
margin: 0; }
|
18
|
+
|
19
|
+
.doc {
|
20
|
+
font-size: 14px;
|
21
|
+
margin: 0; }
|
22
|
+
.doc:before,
|
23
|
+
.doc:after {
|
24
|
+
opacity: .2;
|
25
|
+
padding: 6px;
|
26
|
+
font-style: normal;
|
27
|
+
position: relative;
|
28
|
+
content: "•"; }
|
29
|
+
.doc a {
|
30
|
+
color: rgba(0, 0, 0, 0.3); }
|
31
|
+
.doc a:hover {
|
32
|
+
color: #666; }
|
33
|
+
|
34
|
+
.welcome {
|
35
|
+
-webkit-animation-name: welcome;
|
36
|
+
-webkit-animation-duration: .9s; }
|
37
|
+
|
38
|
+
@-webkit-keyframes welcome {
|
39
|
+
from {
|
40
|
+
-webkit-transform: scale(0);
|
41
|
+
opacity: 0;
|
42
|
+
}
|
43
|
+
50% {
|
44
|
+
-webkit-transform: scale(0);
|
45
|
+
opacity: 0;
|
46
|
+
}
|
47
|
+
82.5% {
|
48
|
+
-webkit-transform: scale(1.03);
|
49
|
+
-webkit-animation-timing-function: ease-out;
|
50
|
+
opacity: 1;
|
51
|
+
}
|
52
|
+
to {
|
53
|
+
-webkit-transform: scale(1);
|
54
|
+
}
|
55
|
+
}
|
data/lib/middleman-core/templates/default/source/stylesheets/{_normalize.scss → normalize.css}
RENAMED
File without changes
|
@@ -14,9 +14,8 @@ class Middleman::Templates::Default < Middleman::Templates::Base
|
|
14
14
|
copy_file "default/source/index.html.erb", File.join(location, "source/index.html.erb")
|
15
15
|
copy_file "default/source/layouts/layout.erb", File.join(location, "source/layouts/layout.erb")
|
16
16
|
empty_directory File.join(location, "source", options[:css_dir])
|
17
|
-
copy_file "default/source/stylesheets/all.css
|
18
|
-
copy_file "default/source/stylesheets/
|
19
|
-
copy_file "default/source/stylesheets/_normalize.scss", File.join(location, "source", options[:css_dir], "_normalize.scss")
|
17
|
+
copy_file "default/source/stylesheets/all.css", File.join(location, "source", options[:css_dir], "all.css")
|
18
|
+
copy_file "default/source/stylesheets/normalize.css", File.join(location, "source", options[:css_dir], "normalize.css")
|
20
19
|
empty_directory File.join(location, "source", options[:js_dir])
|
21
20
|
copy_file "default/source/javascripts/all.js", File.join(location, "source", options[:js_dir], "all.js")
|
22
21
|
empty_directory File.join(location, "source", options[:images_dir])
|