From 6827382ebe9d05fb34fbcd564f2e12813adafd97 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Mon, 14 May 2012 01:20:28 +0200 Subject: [PATCH 1/3] Force content files to UTF-8 encoding to make them working under nginx+passenger. --- lib/showoff.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/showoff.rb b/lib/showoff.rb index b3841f29b..f5fb53b3d 100644 --- a/lib/showoff.rb +++ b/lib/showoff.rb @@ -146,6 +146,7 @@ def empty? def process_markdown(name, content, static=false, pdf=false) # if there are no !SLIDE markers, then make every H1 define a new slide + content.force_encoding('UTF-8') if content.respond_to?(:force_encoding) unless content =~ /^\\n# ") end From c2113f9549dbc95901719e7d424d74289bcf7731 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Thu, 17 May 2012 21:50:20 +0100 Subject: [PATCH 2/3] Make encoding-forcing user-configurable. --- lib/showoff.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/showoff.rb b/lib/showoff.rb index f5fb53b3d..6f5a2f776 100644 --- a/lib/showoff.rb +++ b/lib/showoff.rb @@ -36,6 +36,7 @@ class ShowOff < Sinatra::Application set :page_size, "Letter" set :pres_template, nil set :showoff_config, nil + set :encoding, nil def initialize(app=nil) super(app) @@ -145,8 +146,11 @@ def empty? def process_markdown(name, content, static=false, pdf=false) + if settings.encoding and content.respond_to?(:force_encoding) + content.force_encoding(settings.encoding) + end + # if there are no !SLIDE markers, then make every H1 define a new slide - content.force_encoding('UTF-8') if content.respond_to?(:force_encoding) unless content =~ /^\\n# ") end From ae11f6a3c82e96319ed6e37ea9ae092e9d871230 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Thu, 17 May 2012 23:12:06 +0100 Subject: [PATCH 3/3] Allow encoding to be set through showoff.json. --- lib/showoff.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/showoff.rb b/lib/showoff.rb index 6f5a2f776..dfbaa3a6d 100644 --- a/lib/showoff.rb +++ b/lib/showoff.rb @@ -62,7 +62,8 @@ def initialize(app=nil) showoff_json = JSON.parse(File.read(ShowOffUtils.presentation_config_file)) settings.showoff_config = showoff_json - # Set options for template and page size + # Set options for encoding, template and page size + settings.encoding = showoff_json["encoding"] settings.page_size = showoff_json["page-size"] || "Letter" settings.pres_template = showoff_json["templates"] end