nanoc strips the extension when generating item IDs. Denis has talked
about implementing an option to include the extension in the item ID,
but this isn't possible yet (that I'm aware of).
I resolved this by naming them blah_pdf.pdf and blah_tex.tex and then
including a routing rule to set the correct destination.
--
arno s hautala /-| ar...@alum.wpi.edu
pgp b2c9d448
If it's not too much hassle, a way that works is to change the files names to be unique.
The main (non extension) part that is. ie to blah_pdf.pdf and blah_tex.tex or similar
(just not both "blah")
I've had the same problem when importing existing sites before. Doing the rename thing
works... though there might be a better way. (I've not asked. :>)
Regards and best wishes,
Justin Clift
Thanks Arno and Justin, this does work.
So nanoc has text items and binary items, and both are managed/processed
by nanoc. Would it be a good idea to introduce a new type of item that
is simply not processed by nanoc? The compiler would just take those
files from content/ and drop them into output/ without any changes. So
I could have blah.tex, blah.bib, blah.pdf, blah.ps, etc. all tagged as
"items not to be processed" and wouldn't need to mess with the
filenames.
I realize that I could just do this myself, i.e. simply put these files
into output/ directly, but conceptually it makes more sense to have all
the content in content/, and have output/ be completely
computer-generated.
--
Best,
Alex
Alex Ghitza -- http://aghitza.org/
Lecturer in Mathematics -- The University of Melbourne -- Australia
> Would it be a good idea to introduce a new type of item that is simply not processed by nanoc? The compiler would just take those
> files from content/ and drop them into output/ without any changes. So I could have blah.tex, blah.bib, blah.pdf, blah.ps, etc. all tagged as
> "items not to be processed" and wouldn't need to mess with the filenames.
I certainly understand the need for this, but adding a new type of item would add complexity, which I’d like to avoid if possible.
For me, the ideal solution to this problem is to let identifiers include extensions, but still allow matching identifiers without paths. Unfortunately, as far as I can tell, it is impossible to make this work without breaking backwards compatibility. Here’s an example of how it would work:
item.identifier.to_s
# => '/about.txt'
item.identifier =~ '/about'
# => true
item.identifier =~ '/about.html'
# => false
item.identifier =~ '/about.txt'
# => true
I think I _might_ be able to get it to work without breaking compatibility by letting this identifier class behave a lot like String (overriding and abusing #==), but I have a feeling that I will regret this later on. So this will likely not change before nanoc 4.0.
> I realize that I could just do this myself, i.e. simply put these files into output/ directly, but conceptually it makes more sense to have all
> the content in content/, and have output/ be completely computer-generated.
Yes… the output directory should be entirely managed by nanoc. This is an assumption nanoc makes for e.g. the “prune” command.
Cheers
Denis
I'll add a +1 here, too. For me, one of the most significant
limitations with nanoc is the lack of a simple "copy these contents"
directive; I do not think it is an uncommon use case. I currently
maintain a "static output" directory that I simply rsync to the server
on top of the nanoc content directory, but this is definitely
suboptimal and not in the spirit of having nanoc in control.
The identifier description below may allow such a "copy" directive,
but I haven't thought through clearly how that would look in the Rules
file.
Sean
> --
> You received this message because you are subscribed to the nanoc
> discusssion group.
>
> To post to this group, send email to na...@googlegroups.com
> To unsubscribe from this group, send email to
> nanoc+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nanoc?hl=en
Yeah, it would be really useful to have *some* way for this to work.
Maybe some code changes, so files not covered by the "text_extensions"
list, can be copied as is...?
Wonder if it would be possible, for files not covered by the
"text_extensions" list, to have their whole filename become the
identifier?
Pseudo logic something like this:
If file_extension is in list, then identifier is the first part of
the filename. i.e. foo.haml -> /foo/
If file_extension is NOT in list, then identifier is the whole
filename. i.e. foo.png -> /foo.png/
Sounds a bit half arsed, but might not be too hard to implement (for
someone who can code), plus also gets the desired result.
?
I was thinking about adding an `add_extensions_below:` attribute,
containing a list of path prefixes. Items with an path starting with
any of those prefixes will have an identifier containing the
extension. For example:
Configuration:
add_extensions_below: [ '/assets' ]
Files and directories:
content/
assets/
stylesheet.css
blog.html
Identifiers:
/assets/stylesheet.css/
/blog/
What do you think?
Denis
I would aim for the same model as Kimo, generally, with each folder
representing a page, in some sense. I routinely write a tutorial or a
blog post and want to have supporting files in the same folder for
easy referencing on the web and on the file system. I'm not sure how
common this setup is, though.
Sean
> Kimo
>
>
> On Monday, April 16, 2012 7:28:32 AM UTC-4, Denis Defreyne wrote:
>>
>> Letting files with extensions not in `text_extensions` include their
>> extension in the identifier is a step in the right direction, but will
>> break backwards compatibility.
>>
>> I was thinking about adding an `add_extensions_below:` attribute,
>> containing a list of path prefixes. Items with an path starting with
>> any of those prefixes will have an identifier containing the
>> extension. For example:
>>
>> Configuration:
>>
>> add_extensions_below: [ '/assets' ]
>>
>> Files and directories:
>>
>> content/
>> assets/
>> stylesheet.css
>> blog.html
>>
>> Identifiers:
>>
>> /assets/stylesheet.css/
>> /blog/
>>
>> What do you think?
>>
>> Denis
>>
>>
> I'm not sure how this would work for my setup. I have my files organized by "publication" where each publication has its own folder and there can be various types of files associated with a publication (images, pdfs, movies, etc).
Ahh, in that case an add_extensions_below would not be useful. Two alternative suggestions:
1. keep_extensions: [ 'jpg', 'png', 'js', 'pdf', 'mov' ] -- this will cause the data source not to remove any of the extensions in the list from the identifier. Other extensions are removed. The disadvantage is that this list could become rather long, so perhaps instead of specifying a list of extensions to keep, it is better to do the opposite:
2. remove_extensions: [ 'html', 'md', 'txt', 'css' ] -- this will cause the data source to remove any of the extensions. Other extensions are kept. This list can grow fairly large as well, but not as large as a keep_extensions list I believe. If set to “nil”, all extensions will be removed (the default, for backwards compatibility).
I would also like a keep_extensions_below attribute, because it can be quite useful to people with an assets/ directory which contains all assets.
Wouldn't work for one of the major uses of it... importing and
existing code base. :(
For example, we pull in javascript libraries, templating engines,
and so forth. So far, and for every one, I have to manually go
through them and change their filenames and internally references
just to make them work with nanoc. (sometimes painful)
An effect of that, is that we don't really upgrade our javascript
libraries and similar when a new release comes out, unless there's
a _really good reason_ for it. (hasn't been so far :>)
To my thinking (so far), this is an important scenario that the
"right" solution should somehow support. :)
+ Justin
> Denis