Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing resource mapping to add new binary types #5

Closed
marshallpierce opened this issue Jan 4, 2015 · 2 comments
Closed

Customizing resource mapping to add new binary types #5

marshallpierce opened this issue Jan 4, 2015 · 2 comments

Comments

@marshallpierce
Copy link
Contributor

I I have non-image assets that are treated as binary files (pdfs, for instance). I'm not seeing how to customize resource mapping to make that happen.

I see that DefaultConfig.groovy (in grain itself) has a 'binary_files" var that appears to control what the default binary files are. It'd be nice to simply add another regex to that, but it's not clear how to do so.

I've tried customizing the ResourceMapper in the theme (I'm using the template theme) but my code doesn't appear to be being hit. I've tried logging and even throwing exceptions from inside ResourceMapper but nothing seems to produce any visible effect.

Here's the error I'm seeing:

Caused by: com.sysgears.grain.render.RenderException: Failed to parse /home/mbp/dev/piercelab/grain-theme-template/theme/......./filename.pdf script: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
GrainScript7.groovy: 415: unexpected char: 0x11 @ line 415, column 99.

   �7����K�����A����
                    ���:${<6���
@larixer
Copy link
Member

larixer commented Jan 4, 2015

Please check Configuration -> Filesystem Layout section of Grain documentation:
http://sysgears.com/grain/docs/latest/#filesystem-layout

You can override binary_files in SiteConfig.groovy, i.e. you can have the line like that in SiteConfig.groovy:

binary_files += [/(?i).*.(pdf)$/]

@marshallpierce
Copy link
Contributor Author

That worked, thanks!

When I applied the change at first, the grain preview server continued to throw exceptions when serving pdfs; it seems that I had to clean first. For my own curiosity, why was a clean necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants