rackmap hates me
This commit is contained in:
parent
f4fa1acd3e
commit
c82a40dde5
|
@ -1 +0,0 @@
|
|||
I am real
|
|
@ -1 +0,0 @@
|
|||
I am real: one
|
|
@ -1 +0,0 @@
|
|||
I am real: two
|
|
@ -1,12 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>My Sample Site</title>
|
||||
<!-- Comment in layout -->
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome</h1>
|
||||
<h2 id='h2'>H2</h2>
|
||||
|
||||
<p>Paragraph</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1 +0,0 @@
|
|||
I am real
|
|
@ -1 +0,0 @@
|
|||
I am real:
|
|
@ -1 +0,0 @@
|
|||
Static, no code!
|
|
@ -1 +0,0 @@
|
|||
<h1>Ignore me! 3</h1>
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
@font-face {
|
||||
font-family: "St Marie";
|
||||
src: url('/fonts/StMarie-Thin.otf') format('opentype'); }
|
|
@ -1 +0,0 @@
|
|||
Indexable
|
|
@ -1 +0,0 @@
|
|||
Stay away
|
|
@ -1 +0,0 @@
|
|||
Indexable
|
|
@ -1 +0,0 @@
|
|||
Regular
|
|
@ -50,8 +50,4 @@ with_layout false do
|
|||
}.each do |path|
|
||||
page path
|
||||
end
|
||||
end
|
||||
|
||||
get "/sinatra_test" do
|
||||
"Ratpack"
|
||||
end
|
|
@ -22,6 +22,15 @@ class Middleman::Base
|
|||
@app ||= Rack::Builder.new
|
||||
end
|
||||
|
||||
def inst(&block)
|
||||
@inst ||= new(&block)
|
||||
end
|
||||
|
||||
def to_rack_app(&block)
|
||||
app.run inst(&block)
|
||||
app
|
||||
end
|
||||
|
||||
def prototype
|
||||
@prototype ||= app.to_app
|
||||
end
|
||||
|
@ -154,6 +163,8 @@ class Middleman::Base
|
|||
|
||||
super
|
||||
|
||||
instance_exec(&block) if block_given?
|
||||
|
||||
run_hook :initialized
|
||||
end
|
||||
|
||||
|
@ -181,39 +192,45 @@ class Middleman::Base
|
|||
original_path = @env["PATH_INFO"].dup
|
||||
request_path = full_path(@env["PATH_INFO"].gsub("%20", " "))
|
||||
|
||||
# return not_found if sitemap.ignored_path?(request_path)
|
||||
return not_found if sitemap.ignored_path?(request_path)
|
||||
|
||||
# if sitemap.path_is_proxy?(request_path)
|
||||
# request["is_proxy"] = true
|
||||
# request_path = "/" + sitemap.path_target(request_path)
|
||||
# end
|
||||
if sitemap.path_is_proxy?(request_path)
|
||||
# request["is_proxy"] = true
|
||||
request_path = "/" + sitemap.path_target(request_path)
|
||||
end
|
||||
|
||||
found_template = resolve_template(request_path)
|
||||
return not_found unless found_template
|
||||
|
||||
@current_path = request_path
|
||||
path, engine = found_template
|
||||
|
||||
# Static File
|
||||
return send_file(path) if engine.nil?
|
||||
|
||||
# return unless settings.execute_before_processing!(self, found_template)
|
||||
return unless self.class.execute_before_processing!(self, found_template)
|
||||
|
||||
# context = settings.sitemap.get_context(original_path) || {}
|
||||
#
|
||||
options = {}
|
||||
# options = context.has_key?(:options) ? context[:options] : {}
|
||||
# options.merge!(request['custom_options'] || {})
|
||||
#
|
||||
context = sitemap.get_context(original_path) || {}
|
||||
|
||||
options = context.has_key?(:options) ? context[:options] : {}
|
||||
# options.merge!(request['custom_options'] || {})
|
||||
|
||||
provides_metadata.each do |callback, matcher|
|
||||
next if !matcher.nil? && !path.match(matcher)
|
||||
options.merge!(instance_exec(path, &callback) || {})
|
||||
end
|
||||
|
||||
local_layout = if options.has_key?(:layout)
|
||||
options[:layout]
|
||||
elsif %w(.js .css).include?(File.extname(request_path))
|
||||
false
|
||||
else
|
||||
layout
|
||||
end
|
||||
|
||||
# if context.has_key?(:block) && context[:block]
|
||||
# instance_eval(&context[:block])
|
||||
# end
|
||||
if context.has_key?(:block) && context[:block]
|
||||
instance_eval(&context[:block])
|
||||
end
|
||||
|
||||
# locals = request['custom_locals'] || {}
|
||||
locals = {}
|
||||
|
@ -221,14 +238,16 @@ class Middleman::Base
|
|||
# content_type mime_type(File.extname(request_path))
|
||||
@res.status = 200
|
||||
|
||||
output = if layout
|
||||
output = if local_layout
|
||||
layout_engine = if options.has_key?(:layout_engine)
|
||||
options[:layout_engine]
|
||||
else
|
||||
engine
|
||||
end
|
||||
|
||||
layout_path, *etc = resolve_template(layout, :preferred_engine => layout_engine)
|
||||
layout_path, *etc = resolve_template(local_layout, :preferred_engine => layout_engine)
|
||||
|
||||
throw "Could not locate layout: #{local_layout}" unless layout_path
|
||||
|
||||
render(layout_path, locals) do
|
||||
render(path, locals)
|
||||
|
@ -242,9 +261,64 @@ class Middleman::Base
|
|||
end
|
||||
|
||||
public
|
||||
def extensionless_path(file)
|
||||
@_extensionless_path_cache ||= {}
|
||||
|
||||
if @_extensionless_path_cache.has_key?(file)
|
||||
@_extensionless_path_cache[file]
|
||||
else
|
||||
path = file.dup
|
||||
end_of_the_line = false
|
||||
while !end_of_the_line
|
||||
file_extension = File.extname(path)
|
||||
|
||||
if ::Tilt.mappings.has_key?(file_extension.gsub(/^\./, ""))
|
||||
path = path.sub(file_extension, "")
|
||||
else
|
||||
end_of_the_line = true
|
||||
end
|
||||
end
|
||||
|
||||
@_extensionless_path_cache[file] = path
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
def logging?
|
||||
logging
|
||||
end
|
||||
|
||||
def current_path
|
||||
@current_path || nil
|
||||
end
|
||||
|
||||
def raw_templates_cache
|
||||
@_raw_templates_cache ||= {}
|
||||
end
|
||||
|
||||
def read_raw_template(path)
|
||||
if !raw_templates_cache.has_key?(path)
|
||||
raw_templates_cache[path] = File.read(path)
|
||||
end
|
||||
|
||||
raw_templates_cache[path]
|
||||
end
|
||||
|
||||
# def compiled_templates_cache
|
||||
# @_compiled_templates_cache ||= {}
|
||||
# end
|
||||
#
|
||||
# def read_compiled_template(path, locals, options, &block)
|
||||
# key = [path, locals, options]
|
||||
#
|
||||
# if !raw_templates_cache.has_key?(key)
|
||||
# raw_templates_cache[key] = yield
|
||||
# end
|
||||
#
|
||||
# raw_templates_cache[key]
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
def full_path(path)
|
||||
parts = path ? path.split('/') : []
|
||||
if parts.last.nil? || parts.last.split('.').length == 1
|
||||
|
@ -302,29 +376,6 @@ protected
|
|||
@_resolved_templates[request_path]
|
||||
end
|
||||
|
||||
def extensionless_path(file)
|
||||
@_extensionless_path_cache ||= {}
|
||||
|
||||
if @_extensionless_path_cache.has_key?(file)
|
||||
@_extensionless_path_cache[file]
|
||||
else
|
||||
path = file.dup
|
||||
end_of_the_line = false
|
||||
while !end_of_the_line
|
||||
file_extension = File.extname(path)
|
||||
|
||||
if ::Tilt.mappings.has_key?(file_extension.gsub(/^\./, ""))
|
||||
path = path.sub(file_extension, "")
|
||||
else
|
||||
end_of_the_line = true
|
||||
end
|
||||
end
|
||||
|
||||
@_extensionless_path_cache[file] = path
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
def send_file(path)
|
||||
|
||||
# matched_mime = mime_type(File.extname(request_path))
|
||||
|
@ -333,16 +384,14 @@ protected
|
|||
|
||||
file = ::Rack::File.new nil
|
||||
file.path = path
|
||||
file.serving# env
|
||||
file.serving(@env)
|
||||
end
|
||||
|
||||
def render(path, locals = {}, options = {}, &block)
|
||||
path = path.to_s
|
||||
template = ::Tilt.new(path, 1, options)
|
||||
|
||||
body = read_raw_template(path)
|
||||
template = ::Tilt.new(path, 1, options) { body }
|
||||
template.render(self, locals, &block)
|
||||
end
|
||||
|
||||
def logging?
|
||||
logging
|
||||
end
|
||||
end
|
|
@ -4,8 +4,10 @@ require 'rack/test'
|
|||
require 'find'
|
||||
require 'hooks'
|
||||
|
||||
SHARED_SERVER = Middleman.server
|
||||
SHARED_SERVER.set :environment, :build
|
||||
SHARED_SERVER_INST = Middleman.server.inst do
|
||||
set :environment, :build
|
||||
end
|
||||
SHARED_SERVER = SHARED_SERVER_INST.class
|
||||
|
||||
module Middleman
|
||||
module ThorActions
|
||||
|
@ -13,10 +15,10 @@ module Middleman
|
|||
config = args.last.is_a?(Hash) ? args.pop : {}
|
||||
destination = args.first || source
|
||||
|
||||
request_path = destination.sub(/^#{SHARED_SERVER.build_dir}/, "")
|
||||
request_path = destination.sub(/^#{SHARED_SERVER_INST.build_dir}/, "")
|
||||
|
||||
begin
|
||||
destination, request_path = SHARED_SERVER.reroute_builder(destination, request_path)
|
||||
# begin
|
||||
# destination, request_path = SHARED_SERVER.reroute_builder(destination, request_path)
|
||||
|
||||
request_path.gsub!(/\s/, "%20")
|
||||
response = Middleman::Builder.shared_rack.get(request_path)
|
||||
|
@ -24,8 +26,8 @@ module Middleman
|
|||
create_file destination, nil, config do
|
||||
response.body
|
||||
end if response.status == 200
|
||||
rescue
|
||||
end
|
||||
# rescue
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,9 +40,7 @@ module Middleman
|
|||
|
||||
def self.shared_rack
|
||||
@shared_rack ||= begin
|
||||
app = SHARED_SERVER.new!
|
||||
app_rack = SHARED_SERVER.build_new(app)
|
||||
mock = ::Rack::MockSession.new(app_rack)
|
||||
mock = ::Rack::MockSession.new(SHARED_SERVER.to_rack_app)
|
||||
sess = ::Rack::Test::Session.new(mock)
|
||||
response = sess.get("__middleman__")
|
||||
sess
|
||||
|
@ -54,13 +54,13 @@ module Middleman
|
|||
super
|
||||
|
||||
if options.has_key?("relative") && options["relative"]
|
||||
SHARED_SERVER.activate :relative_assets
|
||||
SHARED_SERVER_INST.activate :relative_assets
|
||||
end
|
||||
end
|
||||
|
||||
def source_paths
|
||||
@source_paths ||= [
|
||||
SHARED_SERVER.root
|
||||
SHARED_SERVER_INST.root
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -71,7 +71,7 @@ module Middleman
|
|||
opts[:glob] = options["glob"] if options.has_key?("glob")
|
||||
opts[:clean] = options["clean"] if options.has_key?("clean")
|
||||
|
||||
action GlobAction.new(self, SHARED_SERVER, opts)
|
||||
action GlobAction.new(self, SHARED_SERVER_INST, opts)
|
||||
|
||||
run_hook :after_build
|
||||
end
|
||||
|
|
|
@ -6,23 +6,36 @@ module Middleman::CoreExtensions::Data
|
|||
class << self
|
||||
def registered(app)
|
||||
app.set :data_dir, "data"
|
||||
app.extend ClassMethods
|
||||
app.helpers Helpers
|
||||
|
||||
app.file_changed DataStore.matcher do |file|
|
||||
data.touch_file(file) if file.match(%r{^#{settings.data_dir}\/})
|
||||
end
|
||||
|
||||
app.file_deleted DataStore.matcher do |file|
|
||||
data.remove_file(file) if file.match(%r{^#{settings.data_dir}\/})
|
||||
end
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
module Helpers
|
||||
module InstanceMethods
|
||||
def initialize
|
||||
file_changed DataStore.matcher do |file|
|
||||
data.touch_file(file) if file.match(%r{^#{data_dir}\/})
|
||||
end
|
||||
|
||||
file_deleted DataStore.matcher do |file|
|
||||
data.remove_file(file) if file.match(%r{^#{data_dir}\/})
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def data
|
||||
settings.data
|
||||
@data ||= DataStore.new(self)
|
||||
end
|
||||
|
||||
# Makes a hash available on the data var with a given name
|
||||
def data_content(name, content)
|
||||
DataStore.data_content(name, content)
|
||||
end
|
||||
|
||||
# Makes a hash available on the data var with a given name
|
||||
def data_callback(name, &block)
|
||||
DataStore.data_callback(name, block)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,7 +62,7 @@ module Middleman::CoreExtensions::Data
|
|||
return
|
||||
end
|
||||
|
||||
@app.logger.debug :data_update, Time.now, basename if @app.settings.logging?
|
||||
# @app.logger.debug :data_update, Time.now, basename if @app.logging?
|
||||
@local_data[basename] = recursively_enhance(data)
|
||||
end
|
||||
|
||||
|
@ -137,20 +150,4 @@ module Middleman::CoreExtensions::Data
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def data
|
||||
@data ||= DataStore.new(self)
|
||||
end
|
||||
|
||||
# Makes a hash available on the data var with a given name
|
||||
def data_content(name, content)
|
||||
DataStore.data_content(name, content)
|
||||
end
|
||||
|
||||
# Makes a hash available on the data var with a given name
|
||||
def data_callback(name, &block)
|
||||
DataStore.data_callback(name, block)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +1,6 @@
|
|||
require "padrino-helpers"
|
||||
|
||||
module Middleman::CoreExtensions::DefaultHelpers
|
||||
class << self
|
||||
def registered(app)
|
||||
# Use Padrino Helpers
|
||||
app.register Padrino::Helpers
|
||||
|
||||
# Middleman Helpers
|
||||
app.helpers Helpers
|
||||
end
|
||||
|
@ -13,6 +8,11 @@ module Middleman::CoreExtensions::DefaultHelpers
|
|||
end
|
||||
|
||||
module Helpers
|
||||
|
||||
# TODO: Implement
|
||||
def javascript_include_tag(path)
|
||||
end
|
||||
|
||||
def auto_stylesheet_link_tag(separator="/")
|
||||
auto_tag(:css, separator) do |path|
|
||||
stylesheet_link_tag path
|
||||
|
@ -28,25 +28,25 @@ module Middleman::CoreExtensions::DefaultHelpers
|
|||
def auto_tag(asset_ext, separator="/", asset_dir=nil)
|
||||
if asset_dir.nil?
|
||||
asset_dir = case asset_ext
|
||||
when :js then self.class.js_dir
|
||||
when :css then self.class.css_dir
|
||||
when :js then self.js_dir
|
||||
when :css then self.css_dir
|
||||
end
|
||||
end
|
||||
path = request.path_info.dup
|
||||
path = current_path.dup
|
||||
# If the basename of the request as no extension, assume we are serving a
|
||||
# directory and join index_file to the path.
|
||||
path = File.join(path, self.class.index_file) if File.extname(path).empty?
|
||||
path = File.join(path, self.index_file) if File.extname(path).empty?
|
||||
path = path.gsub(%r{^/}, '')
|
||||
path = path.gsub(File.extname(path), ".#{asset_ext}")
|
||||
path = path.gsub("/", separator)
|
||||
|
||||
view = File.join(self.class.views, asset_dir, path)
|
||||
view = File.join(self.views, asset_dir, path)
|
||||
yield path if File.exists?(view) or Dir["#{view}.*"].any?
|
||||
end
|
||||
|
||||
def page_classes
|
||||
path = request.path_info.dup
|
||||
path << settings.index_file if path.match(%r{/$})
|
||||
path = current_path.dup
|
||||
path << self.index_file if path.match(%r{/$})
|
||||
path = path.gsub(%r{^/}, '')
|
||||
|
||||
classes = []
|
||||
|
@ -60,9 +60,9 @@ module Middleman::CoreExtensions::DefaultHelpers
|
|||
def asset_path(kind, source)
|
||||
return source if source =~ /^http/
|
||||
asset_folder = case kind
|
||||
when :css then settings.css_dir
|
||||
when :js then settings.js_dir
|
||||
when :images then settings.images_dir
|
||||
when :css then self.css_dir
|
||||
when :js then self.js_dir
|
||||
when :images then self.images_dir
|
||||
else kind.to_s
|
||||
end
|
||||
source = source.to_s.gsub(/\s/, '')
|
||||
|
|
|
@ -89,8 +89,7 @@ module Middleman::CoreExtensions::Features
|
|||
local_config = File.join(self.root, "config.rb")
|
||||
if File.exists? local_config
|
||||
puts "== Reading: Local config" if logging?
|
||||
# instance_eval File.read(local_config)
|
||||
# set :app_file, File.expand_path(local_config)
|
||||
instance_eval File.read(local_config)
|
||||
end
|
||||
|
||||
run_hook :after_configuration
|
||||
|
|
|
@ -11,7 +11,6 @@ module Middleman::CoreExtensions::FileWatcher
|
|||
file_did_change(path.sub("#{root}/", ""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
@ -31,8 +30,8 @@ module Middleman::CoreExtensions::FileWatcher
|
|||
end
|
||||
|
||||
module InstanceMethods
|
||||
def file_changed(*args)
|
||||
self.class.file_changed(*args)
|
||||
def file_changed(*args, &block)
|
||||
self.class.file_changed(*args, &block)
|
||||
end
|
||||
|
||||
def file_did_change(path)
|
||||
|
|
|
@ -4,59 +4,50 @@ require "tilt"
|
|||
module Middleman::CoreExtensions::FrontMatter
|
||||
class << self
|
||||
def registered(app)
|
||||
app.extend ClassMethods
|
||||
app.send :include, InstanceMethods
|
||||
|
||||
app.file_changed FrontMatter.matcher do |file|
|
||||
frontmatter.touch_file(file)
|
||||
end
|
||||
|
||||
app.file_deleted do |file|
|
||||
frontmatter.remove_file(file)
|
||||
end
|
||||
|
||||
app.after_configuration do
|
||||
app.before_processing(:front_matter) do |result|
|
||||
if result && Tilt.mappings.has_key?(result[1].to_s)
|
||||
extensionless_path, template_engine = result
|
||||
full_file_path = "#{extensionless_path}.#{template_engine}"
|
||||
|
||||
if app.frontmatter.has_data?(full_file_path)
|
||||
data = app.frontmatter.data(full_file_path).first
|
||||
|
||||
request['custom_options'] = {}
|
||||
%w(layout layout_engine).each do |opt|
|
||||
if data.has_key?(opt)
|
||||
request['custom_options'][opt.to_sym] = data[opt]
|
||||
end
|
||||
end
|
||||
else
|
||||
data = {}
|
||||
end
|
||||
|
||||
# Forward remaining data to helpers
|
||||
app.data_content("page", data)
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
module InstanceMethods
|
||||
def initialize
|
||||
file_changed FrontMatter.matcher do |file|
|
||||
frontmatter.touch_file(file)
|
||||
end
|
||||
|
||||
file_deleted do |file|
|
||||
frontmatter.remove_file(file)
|
||||
end
|
||||
|
||||
provides_metadata FrontMatter.matcher do |path|
|
||||
relative_path = path.sub(source_dir, "")
|
||||
|
||||
data = if frontmatter.has_data?(relative_path)
|
||||
frontmatter.data(relative_path).first
|
||||
else
|
||||
{}
|
||||
end
|
||||
|
||||
# Forward remaining data to helpers
|
||||
data_content("page", data)
|
||||
|
||||
%w(layout layout_engine).each do |opt|
|
||||
if data.has_key?(opt)
|
||||
data[opt.to_sym] = data.delete(opt)
|
||||
end
|
||||
end
|
||||
|
||||
data
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def frontmatter
|
||||
@frontmatter ||= FrontMatter.new(self)
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def frontmatter
|
||||
settings.frontmatter
|
||||
end
|
||||
end
|
||||
|
||||
class FrontMatter
|
||||
def self.matcher
|
||||
%r{source/.*\.html}
|
||||
|
@ -64,7 +55,7 @@ module Middleman::CoreExtensions::FrontMatter
|
|||
|
||||
def initialize(app)
|
||||
@app = app
|
||||
@source ||= File.expand_path(@app.views, @app.root)
|
||||
@source = File.expand_path(@app.views, @app.root)
|
||||
@local_data = {}
|
||||
end
|
||||
|
||||
|
@ -78,22 +69,22 @@ module Middleman::CoreExtensions::FrontMatter
|
|||
|
||||
file = File.expand_path(file, @app.root)
|
||||
content = File.read(file)
|
||||
file = file.sub(@source, "")
|
||||
file = file.sub(@app.source_dir, "")
|
||||
|
||||
@app.logger.debug :frontmatter_update, Time.now, file if @app.settings.logging?
|
||||
# @app.logger.debug :frontmatter_update, Time.now, file if @app.logging?
|
||||
result = parse_front_matter(content)
|
||||
|
||||
if result
|
||||
@local_data[file] = result
|
||||
path = @app.extensionless_path(file)
|
||||
@app.settings.templates[path.to_sym] = [result[1], path.to_s, 1]
|
||||
@app.raw_templates_cache[path] = result[1]
|
||||
end
|
||||
end
|
||||
|
||||
def remove_file(file)
|
||||
file = File.expand_path(file, @app.root)
|
||||
file = file.sub(@source, "")
|
||||
@app.logger.debug :frontmatter_remove, Time.now, file if @app.settings.logging?
|
||||
file = file.sub(@app.source_dir, "")
|
||||
# @app.logger.debug :frontmatter_remove, Time.now, file if @app.logging?
|
||||
|
||||
if @local_data.has_key?(file)
|
||||
@local_data.delete(file)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module Middleman::CoreExtensions::Routing
|
||||
class << self
|
||||
def registered(app)
|
||||
app.extend ClassMethods
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
module InstanceMethods
|
||||
# Takes a block which allows many pages to have the same layout
|
||||
# with_layout :admin do
|
||||
# page "/admin/"
|
||||
|
@ -16,7 +16,7 @@ module Middleman::CoreExtensions::Routing
|
|||
old_layout = layout
|
||||
|
||||
set :layout, layout_name
|
||||
class_eval(&block) if block_given?
|
||||
instance_exec(&block) if block_given?
|
||||
ensure
|
||||
set :layout, old_layout
|
||||
end
|
||||
|
|
|
@ -3,27 +3,24 @@ require 'find'
|
|||
module Middleman::CoreExtensions::Sitemap
|
||||
class << self
|
||||
def registered(app)
|
||||
app.extend ClassMethods
|
||||
app.helpers Helpers
|
||||
|
||||
app.file_changed do |file|
|
||||
sitemap.touch_file(file)
|
||||
end
|
||||
|
||||
app.file_deleted do |file|
|
||||
sitemap.remove_file(file)
|
||||
end
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
module Helpers
|
||||
def sitemap
|
||||
self.class.sitemap
|
||||
module InstanceMethods
|
||||
def initialize
|
||||
file_changed do |file|
|
||||
sitemap.touch_file(file)
|
||||
end
|
||||
|
||||
file_deleted do |file|
|
||||
sitemap.remove_file(file)
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
def sitemap
|
||||
@sitemap ||= SitemapStore.new(self)
|
||||
end
|
||||
|
@ -36,6 +33,12 @@ module Middleman::CoreExtensions::Sitemap
|
|||
def reroute(url, target)
|
||||
sitemap.set_path(url, target)
|
||||
end
|
||||
|
||||
def provides_metadata(matcher=nil, &block)
|
||||
@_provides_metadata ||= []
|
||||
@_provides_metadata << [block, matcher] if block_given?
|
||||
@_provides_metadata
|
||||
end
|
||||
end
|
||||
|
||||
class SitemapStore
|
||||
|
@ -216,7 +219,7 @@ module Middleman::CoreExtensions::Sitemap
|
|||
return false if path == "layout" ||
|
||||
path.match(/^layouts/)
|
||||
|
||||
@app.logger.debug :sitemap_update, Time.now, path if @app.settings.logging?
|
||||
# @app.logger.debug :sitemap_update, Time.now, path if @app.logging?
|
||||
set_path(path)
|
||||
|
||||
true
|
||||
|
|
|
@ -2,6 +2,13 @@ require 'pathname'
|
|||
require 'rbconfig'
|
||||
require "sprockets"
|
||||
|
||||
class RackThingy
|
||||
def call(env)
|
||||
$stderr.puts "thingy"
|
||||
[200, {}, "Sup"]
|
||||
end
|
||||
end
|
||||
|
||||
module Middleman::CoreExtensions::Sprockets
|
||||
class << self
|
||||
def registered(app)
|
||||
|
@ -20,48 +27,49 @@ module Middleman::CoreExtensions::Sprockets
|
|||
end
|
||||
end
|
||||
|
||||
app.after_configuration do
|
||||
js_env = Middleman::CoreExtensions::Sprockets::JavascriptEnvironment.new(self)
|
||||
|
||||
vendor_dir = File.join("vendor", "assets", "javascripts")
|
||||
gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
::Middleman.spec_has_file?(spec, vendor_dir)
|
||||
end.each do |spec|
|
||||
js_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
||||
end
|
||||
|
||||
app_dir = File.join("app", "assets", "javascripts")
|
||||
gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
::Middleman.spec_has_file?(spec, app_dir)
|
||||
end.each do |spec|
|
||||
js_env.append_path File.join(spec.full_gem_path, app_dir)
|
||||
end
|
||||
|
||||
# add paths to js_env (vendor/assets/javascripts)
|
||||
app.map "/#{self.js_dir}" do
|
||||
run js_env
|
||||
end
|
||||
end
|
||||
# app.after_configuration do
|
||||
# js_env = Middleman::CoreExtensions::Sprockets::JavascriptEnvironment.new(self)
|
||||
#
|
||||
# vendor_dir = File.join("vendor", "assets", "javascripts")
|
||||
# gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
# ::Middleman.spec_has_file?(spec, vendor_dir)
|
||||
# end.each do |spec|
|
||||
# js_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
||||
# end
|
||||
#
|
||||
# app_dir = File.join("app", "assets", "javascripts")
|
||||
# gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
# ::Middleman.spec_has_file?(spec, app_dir)
|
||||
# end.each do |spec|
|
||||
# js_env.append_path File.join(spec.full_gem_path, app_dir)
|
||||
# end
|
||||
#
|
||||
# # add paths to js_env (vendor/assets/javascripts)
|
||||
# app.map "/#{self.js_dir}" do
|
||||
# run js_env
|
||||
# end
|
||||
# end
|
||||
|
||||
app.after_compass_config do
|
||||
css_env = Middleman::CoreExtensions::Sprockets::StylesheetEnvironment.new(self)
|
||||
|
||||
vendor_dir = File.join("vendor", "assets", "stylesheets")
|
||||
gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
::Middleman.spec_has_file?(spec, vendor_dir)
|
||||
end.each do |spec|
|
||||
css_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
||||
end
|
||||
|
||||
app_dir = File.join("app", "assets", "stylesheets")
|
||||
gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
::Middleman.spec_has_file?(spec, app_dir)
|
||||
end.each do |spec|
|
||||
css_env.append_path File.join(spec.full_gem_path, app_dir)
|
||||
end
|
||||
# css_env = Middleman::CoreExtensions::Sprockets::StylesheetEnvironment.new(self)
|
||||
#
|
||||
# vendor_dir = File.join("vendor", "assets", "stylesheets")
|
||||
# gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
# ::Middleman.spec_has_file?(spec, vendor_dir)
|
||||
# end.each do |spec|
|
||||
# css_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
||||
# end
|
||||
#
|
||||
# app_dir = File.join("app", "assets", "stylesheets")
|
||||
# gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
||||
# ::Middleman.spec_has_file?(spec, app_dir)
|
||||
# end.each do |spec|
|
||||
# css_env.append_path File.join(spec.full_gem_path, app_dir)
|
||||
# end
|
||||
|
||||
app.map "/#{self.css_dir}" do
|
||||
run css_env
|
||||
# run css_env
|
||||
run ::RackThingy.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,18 +56,4 @@ module Middleman::Renderers::Sass
|
|||
::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
|
||||
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
|
||||
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
|
||||
end
|
||||
|
||||
# Use sass settings in Haml filters
|
||||
# Other, tilt-based filters (like those used in Slim) will
|
||||
# work automatically.
|
||||
# module Middleman::Renderers::Haml
|
||||
# module Sass
|
||||
# include ::Haml::Filters::Base
|
||||
#
|
||||
# def render(text)
|
||||
# sass_options = scope.settings.sass
|
||||
# ::Sass::Engine.new(text, sass_options).render
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
|
@ -39,9 +39,10 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.add_dependency("guard", ["~> 0.8.8"])
|
||||
# s.add_dependency("eventmachine", ["1.0.0.beta.4"])
|
||||
# s.add_dependency("middleman-livereload", ["~> 0.2.0"])
|
||||
|
||||
# Development and test
|
||||
s.add_development_dependency("slim")
|
||||
s.add_development_dependency("maruku")
|
||||
s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
|
||||
s.add_development_dependency("liquid", ["~> 2.2.0"])
|
||||
s.add_development_dependency("cucumber", ["~> 1.1.0"])
|
||||
|
|
Loading…
Reference in a new issue