On 10 Dec 2009, at 01:37, Peter Valdemar Mørch (Google Groups) wrote:
> As I understand it, because nanoc 3.0.X doesn't have binary assets, it
> is recommended to put things like images directly in the output/
> directory. So output/ is actually a mixture of real source files and
> output generated from sources in content/.
>
> Is that correct? Is that the best-practice until 3.1?
Hi,
I don’t consider this to be the best practice, but it is probaby the easiest way to keep binary assets around.
The best practice is to keep assets in a separate directory, and copy the files over when the site is compiled. This technique is described on the <
http://projects.stoneship.org/trac/nanoc/wiki/Tips/CopyingAssetsIntelligently> page on the wiki. This is the technique I use on the Stoneship and nanoc web sites.
For the nanoc web site, whose source you can find at <
http://projects.stoneship.org/hg/sites-nanoc>, I implemented a custom "clean" task that deletes static files copied from assets/ as well as normal files generated by nanoc. You can find this rake task at <
http://projects.stoneship.org/hg/sites-nanoc/file/716425754f63/tasks/clean.rake>. This task is useful for making binary asset handling easier in nanoc 3.0, but will not be necessary for nanoc 3.1.
> * The name of the folder is "output", but really it contains output and source mixed together.
This is something that has annoyed me as well, and it’s on the todo list for 3.1. There’s a high-priority ticket for it on the nanoc issue tracker: <
http://projects.stoneship.org/trac/nanoc/ticket/32>.
When using the copy-assets technique, though, you *can* treat the output directory as a build directory that can be emptied without the risk of losing data.
> * Because of that, a .gitignore file (or svn:ignore or .cvsignore) is
> going to be a mess: It will have to contain separate lines for all the
> generated output. Or rely on wildcards or something like that. Would be
> nice to have all of output/ in .gitignore and be done with it.
The entire output directory can be put into the .gitignore file when using the asset copying technique.
> * I'd like to keep e.g. images in directories with the pages that use
> them. I now need to maintain similar trees in content/ and in output/
> manually.
One of the goals of nanoc 3.1 is to keep the binary files in content/ as well, eliminating the need for a separate tree. Images that belong to a certain page can therefore be put close to the page itself, for example.
> * "rake clean" removes generated files, but not the directories around
> them making it harder to find actual source files in output/. (Yeah, I
> guess "find output -type f" would do it) But it would be nice to be able
> to "rm -rf output; nanoc3 compile" and be done with it.
"rake clean" is fairly naïve: it fetches the names of all files generated by nanoc and removes them. Empty directories will not be removed, but this is probably a useful feature that is fairly easy to add.
In 3.1, a "rake clean" task will probably be able to simply remove all files in output/ (with the appropriate safety checks to make sure no files are accidentally deleted).
Hope this helps,
--
Denis Defreyne
denis.d...@stoneship.org