Damien Robert
2010-Jan-23 19:28 UTC
[webgen-users] symbolic link to a directory with ruby 1.9 and UTF-8 encoding
Hello everyone. For my website, I use a lot of symbolic links. There is no problem with symbolic links to a file, however a symbolic link to a directory is not treated by webgen as a real directory. I have tried to use in the config file: patterns: Directory: add: - /docs/common but it does not seem to work (the files in docs/common/ are not generated). Currently what i do is i use something like sources: - ["/docs/", "Webgen::Source::FileSystem", "../common/docs"] and it works great! By the way, i tried to add a pattern to copy all files in the doc directory: patterns: Copy: add: - /docs/**/* But /docs/**/* does not match the files in /docs/* (that is only the files under a subdirectory of docs are copied). Is that the intended behavior? (I also get a warning for subdirectories: WARN -- Node already exists: source = /docs/foo/ | path = /docs/foo/ | alcn = /docs/foo/ I think this is because the node /docs/foo/ is created twice, once by the directory handler, and once by the copy handler, apparently docs/**/* catches /docs/foo/) Cheers!
Thomas Leitner
2010-Jan-24 07:13 UTC
[webgen-users] symbolic link to a directory with ruby 1.9 and UTF-8 encoding
Hi,> I have tried to use in the config file: > patterns: > Directory: > add: - /docs/common > but it does not seem to work (the files in docs/common/ are not > generated).It seems that `Dir.glob` which is used to get the files for a filesystem source doesn''t handle directory links correctly, i.e. it only returns the link. However, when checking `File.directory?(link)` it returns +true+. So somewhere Ruby knows that it is a link pointing to a directory but it does not handle it right all the time.> Currently what i do is i use something like > sources: - ["/docs/", "Webgen::Source::FileSystem", "../common/docs"] > and it works great!If you hadn''t included that I would have recommended it! ;-)> By the way, i tried to add a pattern to copy all files in the doc > directory: > > patterns: > Copy: > add: > - /docs/**/* > But /docs/**/* does not match the files in /docs/* > (that is only the files under a subdirectory of docs are copied). > > Is that the intended behavior?No, not really. I have fixed this in my local repo. You can circumvent the problem by additionally adding the pattern `/docs/*`.> (I also get a warning for subdirectories: > WARN -- Node already exists: source = /docs/foo/ | path = /docs/foo/ > | alcn = /docs/foo/ > > I think this is because the node /docs/foo/ is created twice, once > by the directory handler, and once by the copy handler, apparently > docs/**/* catches /docs/foo/)You are right. Since you tell the copy handler to use all the paths underneath /docs/, it also tries to add directory path. If you only have files with extensions, you could use the pattern `/docs/**/*.*` instead. -- Thomas