Filename globbing

40 views
Skip to first unread message

Sam Burnett

unread,
Mar 23, 2011, 3:43:31 PM3/23/11
to hakyll
Hi,

Is there any easy way to get filename globbing to work with Hakyll 3?
For
example, I'd like to be able to say something like:

route "posts/*.markdown" $ setExtension ".html"
route "posts/*.jpg" idRoute

I realize that Hakyll can't do globbing the way I've written it above,
but is
there some way to approximate this behavior? Otherwise it looks like
I'm forced
to route all files in a directory using the same rule, which semes
like a pretty big
limitation.

If this is non-trivial, then it might be good to add an example to the
documentation.

Thanks!

Sam

Gwern Branwen

unread,
Mar 23, 2011, 4:19:10 PM3/23/11
to hak...@googlegroups.com
On Wed, Mar 23, 2011 at 3:43 PM, Sam Burnett <srbu...@gmail.com> wrote:
>
> I realize that Hakyll can't do globbing the way I've written it above,
> but is
> there some way to approximate this behavior? Otherwise it looks like
> I'm forced
> to route all files in a directory using the same rule, which semes
> like a pretty big
> limitation.

Maybe you could just use the usual list processing functions on the
full file list? eg. a glob like "*.html" has an obvious implementation
with filter, and isSuffixOf.

--
gwern
http://www.gwern.net

Jasper Van der Jeugt

unread,
Mar 23, 2011, 4:45:14 PM3/23/11
to hak...@googlegroups.com, Gwern Branwen
Hello,

I think it's a pretty good request. I can think of a few use cases
where this might come in handy...

I will probably implement regexes instead of globs, though -- because
Hakyll already depends on regex-pcre anyway.

Cheers,
Jasper

Sam Burnett

unread,
Mar 24, 2011, 11:31:20 AM3/24/11
to hak...@googlegroups.com
Ok, thanks. I just wanted to make sure there wasn't an existing solution
I wasn't aware of. For now, I'll just glob the filenames before passing
them to route.

Thanks,
Sam

Jasper Van der Jeugt

unread,
Mar 29, 2011, 9:32:38 AM3/29/11
to hak...@googlegroups.com, Sam Burnett
Hello,

I've just implemented [1] filename globbing. It should be fully
backward-compatible with the previous implementation. It's not on
Hackage yet because I want to do some more testing, but you can get it
from github [2] if you want.

[1]: http://github.com/jaspervdj/hakyll/commit/8bd45b
[2]: http://github.com/jaspervdj/hakyll/

Cheers,
Jasper

Sam Burnett

unread,
Mar 29, 2011, 12:49:05 PM3/29/11
to hak...@googlegroups.com
Hi,

Cool! It seems to work fine with the basic globs I've thrown at it.
I'll let you know if I run into any problems.

I think it'd be nice if patterns acted more like sets so you could
union/intersect/subtract them. This would allow more expressive policies
like "compile all non-markdown files using copyFile". But it looks like
this wouldn't make sense with current model of Patterns/Identifiers, so
I understand if you wouldn't want to implement it.

Keep up the great work!

Sam

Reply all
Reply to author
Forward
0 new messages