Create an asset datasource so that we don't need all those silly yaml files.

This commit is contained in:
Chris Eppstein 2010-01-26 23:05:57 -08:00
parent b15f641bd7
commit a9440b12c9
42 changed files with 26 additions and 54 deletions

View File

@ -6,7 +6,7 @@ http_path = "/"
project_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
css_dir = "../docs/stylesheets"
sass_dir = "content/stylesheets"
images_dir = "content/images"
images_dir = "assets/images"
http_images_dir = "images"
javascripts_dir = "content/javascripts"
http_javascripts_dir = "javascripts"

View File

@ -4,11 +4,7 @@ require 'compass'
Compass.configuration.parse "#{File.dirname(__FILE__)}/.compass/config.rb"
compile '/css/*/' do
nil
end
compile '/images/*/' do
compile '/assets/*/' do
nil
end
@ -20,10 +16,6 @@ compile '/examples/*/stylesheet/' do
nil
end
compile '/javascripts/*/' do
nil
end
compile '/examples/*/' do
filter :haml, :ugly => true
layout 'example'
@ -43,16 +35,16 @@ route '/stylesheets/_*/' do
nil
end
route '/css/*/' do
item.identifier.chop.gsub(%r{/css}, '/stylesheets')+"."+item[:extension]
route '/assets/css/*/' do
"/stylesheets"+item.identifier.chop[11..-1]+"."+item[:extension]
end
route '/images/*/' do
item.identifier.chop+"."+item[:extension]
route '/assets/images/*/' do
item.identifier.chop[7..-1]+"."+item[:extension]
end
route '/javascripts/*/' do
item.identifier.chop+"."+item[:extension]
route '/assets/javascripts/*/' do
item.identifier.chop[7..-1]+"."+item[:extension]
end
route '/stylesheets/*/' do

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 867 B

After

Width:  |  Height:  |  Size: 867 B

View File

@ -3,4 +3,7 @@ data_sources:
- items_root: /
layouts_root: /
type: filesystem_compact
- items_root: /assets
layouts_root: /assets
type: filesystem_assets
output_dir: ../docs

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: png

View File

@ -1,2 +0,0 @@
---
extension: css

View File

@ -1,2 +0,0 @@
---
extension: gif

View File

@ -1,2 +0,0 @@
---
extension: js

View File

@ -1,2 +0,0 @@
---
extension: js

View File

@ -1,2 +0,0 @@
---
extension: js

View File

@ -0,0 +1,15 @@
class AssetDataSource < Nanoc3::DataSource
identifier :filesystem_assets
def items
files = []
Dir.glob("assets/**/*").each do |f|
files << f if File.file?(f)
end
files.map do |f|
identifier = f[7..-1].gsub(/\.[^.]+$/,'')+"/"
attrs = {:extension => File.extname(f)[1..-1]}
Nanoc3::Item.new(File.read(f), attrs, identifier, File.mtime(f))
end
end
end