schacon / showoff

moved to puppetlabs/showoff!
2.41k stars 13 forks source link

Running under nginx+passenger throws an encoding error #183

Closed jcoglan closed 12 years ago

jcoglan commented 12 years ago

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.

goncalossilva commented 12 years ago

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.

jcoglan commented 12 years ago

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

goncalossilva commented 12 years ago

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?

jcoglan commented 12 years ago

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

goncalossilva commented 12 years ago

Nice, thanks!