benschwarz / bonsai

A tiny static web site generator
http://tinytree.info/
MIT License
297 stars 39 forks source link

Files with names that are only digits are copied to /output/ stripped of \d+\. #7

Closed heliostatic closed 14 years ago

heliostatic commented 14 years ago

Something in page.rb is ignoring filetype when looking at filename to assess hierarchy, so that images, for example, named "1.jpg" will be copied to the output directory as "jpg" and can't be served properly.

jridgewell commented 14 years ago

Specifically, it's web_path inside page.rb that's causing the problem. Worse yet, it'll take a complicated regex to fix it. =[

benschwarz commented 14 years ago

I think a more simple fix can be made here.

I have something in mind - I'll see what I can do over the weekend.

jridgewell commented 14 years ago

I have a fix, though not the most elegant (it feels like PHP...)

    def web_path(path)
      return path.gsub(self.class.path, '').gsub(/\/\d+\./, '/') if File.directory?(path)
      path.slice(0, path.rindex('/') + 1).gsub(self.class.path, '').gsub(/\/\d+\./, '/') + File.basename(path)
    end
benschwarz commented 14 years ago

So do I. Just about to finish the specs.

benschwarz commented 14 years ago

Change asset files to cleanup the path to a file but not the filename itself. This is a more expectant result and also allows for asset filenames like 001.jpg. Closed by 7ca62989c07570bbad8dcd5563d08798a2a15f07

benschwarz commented 14 years ago

Resolved in HEAD. This will be released as 1.3.0 shortly, just waiting to see if any other changes are required.

http://github.com/benschwarz/bonsai/commit/7ca62989c07570bbad8dcd5563d08798a2a15f07