magnars / stasis

Some Clojure functions for creating static websites.
348 stars 27 forks source link

slurp-directory not working for me #9

Closed kzar closed 10 years ago

kzar commented 10 years ago

slurp-directory seems to be attempting to slurp the root directory and therefore returning a FileNotFoundException. I guess the solution would be to filter away directories before slurping?

(Perhaps the exception is caused by something else, I'm not best person to say.)

Cheers, Dave.

magnars commented 10 years ago

Yes, you're right - it does try to load in the root directory. Add some more meat to your regexp to avoid this for now. I use #"\.md$" for instance.

kzar commented 10 years ago

Oh I see. Well the thing is I was trying to mimic how my site used to work with Jekyll; all files (static or not) in a directory, ones that start with YAML front matter get processed and ones without just get copied across. That's why I used the #".*" regexp, I was planning on manually processing the YAML stuff.

I guess maybe I'm better making my own slurp-directory type function?

magnars commented 10 years ago

You can solve your issue by just using a generic regex that doesn't match folders, like #"[^.]+\.[^.]+"

I'd say the better solution is to:

kzar commented 10 years ago

Say if I were to do it that way, I could have a slurp-directory regexp to match files possibly needing processing, filter the list down myself to get only the right files, process them and have stasis output them correctly I think. But could I then tell optimus to copy all files but the processed ones?

magnars commented 10 years ago

They are just maps, so you could merge the processed ones over the non-processed afterwards.

kzar commented 10 years ago

OK thanks I'll have a go at doing it the way you suggested. Thanks for the help

karneaud commented 8 years ago

What if I want to map the directories to the root? e.g.

slurp-directory "resourcses/md" .....

{"/", "....."}

How can I accomplish this with REGEX?

magnars commented 8 years ago

@karneaud I'm not sure I understand what you're trying to accomplish. Please expand you explanation in a new issue.

karneaud commented 8 years ago

@magnars

Sorry this should have been on @cjohansen repo. My bad.

its ok I was trying to build md files into the "/" of the build directory rather than "/dir/". I accomplished this task by changing the regex.

Works the way I want to now