Running under nginx+passenger throws an encoding error #183

Merged
merged 3 commits into from May 17, 2012

Projects

None yet

3 participants

Contributor
jcoglan commented May 13, 2012

If you try to serve a Showoff deck under nginx+passenger, you get this when trying to load the slides:

ArgumentError - invalid byte sequence in US-ASCII:
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:149:in `process_markdown'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:356:in `block (2 levels) in get_slides_html'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:354:in `each'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:354:in `block in get_slides_html'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:345:in `each'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:345:in `get_slides_html'
    /home/jcoglan/www/slides.jcoglan.com/app/vendor/showoff/lib/showoff.rb:459:in `slides'
        ...

This patch forces the Markdown content to UTF-8 encoding to stop the error.

Collaborator

I don't think this is the best approach. Enforcing UTF-8 is not the way to go, imho. However, having an encoding option in the showoff.json file seems like a good idea to me.

Contributor
jcoglan commented May 17, 2012

Done. App now has an encoding setting in my branch. I went with this over a field in showoff.json this because this makes it easier to configure many decks at once if hosting several on the same host, e.g. see https://github.com/jcoglan/presentations/blob/master/config.ru#L4-11

Collaborator

Why can't they co-exist?

I'm thinking about the folks that know nothing about Sinatra/Rack and just want to run a simple presentation in UTF-16?

Contributor
jcoglan commented May 17, 2012

See latest commit -- encoding is read from showoff.json but can be overridden through the class API.

@goncalossilva goncalossilva merged commit fa6af29 into schacon:master May 17, 2012
Collaborator

Nice, thanks!

it's great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment