-
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
|
||
|
||
# def cache_buster | ||
# if File.readable?(real_path) | ||
# File.mtime(real_path).strftime("%s") | ||
# else | ||
# $stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}" | ||
# end | ||
# end | ||
class Middleman::Base | ||
helpers do | ||
alias_method :pre_cache_buster_asset_url, :asset_url | ||
def asset_url(path, prefix="") | ||
path = pre_cache_buster_asset_url(path, prefix) | ||
if path.include?("://") | ||
path | ||
else | ||
real_path = File.join(options.public, path) | ||
if File.readable?(real_path) | ||
path << "?" + File.mtime(real_path).strftime("%s") | ||
else | ||
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'haml' | ||
|
||
module Middleman | ||
module Haml | ||
def self.included(base) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
require 'slickmap' | ||
|
||
get '/sitemap.html' do | ||
haml :sitemap, :layout => false | ||
end | ||
class Middleman::Base | ||
def build_sitemap(&block) | ||
# views - stylesheets | ||
# public | ||
# .select | ||
# block.call(this) | ||
end | ||
|
||
get '/sitemap.html' do | ||
@tree = build_sitemap do |file_name| | ||
true | ||
end | ||
haml :sitemap, :layout => false | ||
end | ||
|
||
use_in_file_templates! | ||
end | ||
|
||
__END__ | ||
|
||
@@ sitemap | ||
%div.title Hello world!!!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require File.join(File.dirname(__FILE__), "spec_helper") | ||
|
||
base = ::Middleman::Base | ||
base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample") | ||
|
||
describe "Cache Buster Feature" do | ||
before do | ||
base.disable :cache_buster | ||
base.init! | ||
@app = base.new | ||
end | ||
|
||
it "should not append query string if off" do | ||
@app.asset_url("stylesheets/static.css").should_not include("?") | ||
end | ||
end | ||
|
||
describe "Cache Buster Feature" do | ||
before do | ||
base.enable :cache_buster | ||
base.init! | ||
@app = base.new | ||
end | ||
|
||
it "should append query string if on" do | ||
@app.asset_url("stylesheets/static.css").should include("?") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# require File.join(File.dirname(__FILE__), "spec_helper") | ||
# | ||
# base = ::Middleman::Base | ||
# base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample") | ||
# | ||
# describe "Relative Assets Feature" do | ||
# before do | ||
# base.disable :relative_assets | ||
# base.init! | ||
# @app = base.new | ||
# end | ||
# | ||
# it "should not contain ../ if off" do | ||
# @app.asset_url("stylesheets/static.css").should_not include("?") | ||
# end | ||
# end | ||
# | ||
# describe "Relative Assets Feature" do | ||
# before do | ||
# base.enable :relative_assets | ||
# base.init! | ||
# @app = base.new | ||
# end | ||
# | ||
# it "should contain ../ if on" do | ||
# @app.asset_url("stylesheets/static.css").should include("?") | ||
# end | ||
# end |