Permalink
Browse files

support debug mode.

  • Loading branch information...
kou committed Dec 22, 2010
1 parent 6ebf3f9 commit 02ec92b52cad4f0997866ebc95cfa0d1cd570f63
Showing with 24 additions and 6 deletions.
  1. +24 −6 app.rb
View
30 app.rb
@@ -16,6 +16,16 @@
include ERB::Util
@@configurations = {
:debug => false,
:rendering_mode => :big,
}
@@configurations[:debug] = true if ENV["RACK_ENV"] == "development"
def debug?
@@configurations[:debug]
end
get '/' do
erb :index
end
@@ -43,7 +53,8 @@ def make_surface(paper, scale, format, output, &block)
surface.write_to_png(output)
end
else
raise Sinatra::NotFound
raise "invalid format: #{format.inspect}" if debug?
not_found
end
end
@@ -52,7 +63,8 @@ def make_layout(context, text, width, height, font)
layout.text = text
layout.width = width * Pango::SCALE
unless @@font_families.any? {|family| family == font}
raise Sinatra::NotFound
raise "failed to find font family: #{font.inspect}" if debug?
not_found
end
font_description = Pango::FontDescription.new
font_description.family = font
@@ -227,7 +239,10 @@ def cache_public_file(data, *path)
def prepare_font_name(name)
if name.respond_to?(:force_encoding)
name.force_encoding("UTF-8")
raise Sintara::NotFound unless name.valid_encoding?
unless name.valid_encoding?
raise "invalid encoding name: #{name.inspect}" if debug?
not_found
end
end
name
end
@@ -243,7 +258,8 @@ def prepare_font_name(name)
"fonts", font, "thumbnails", "#{user}.#{format}")
nameplate
rescue
raise Sinatra::NotFound
raise if debug?
not_found
end
end
@@ -261,7 +277,8 @@ def prepare_font_name(name)
cache_public_file(nameplate, "fonts", font, "#{user}.#{format}")
nameplate
rescue
raise Sinatra::NotFound
raise if debug?
not_found
end
end
@@ -287,6 +304,7 @@ def prepare_font_name(name)
cache_putblic_file(nameplate, "#{user}.#{format}")
nameplate
rescue
raise Sinatra::NotFound
raise if debug?
not_found
end
end

0 comments on commit 02ec92b

Please sign in to comment.