Skip to content

Commit bbaf31e

Browse files
committed
scripts for some themes may be precalculated .. speed boost!
1 parent 55da70f commit bbaf31e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app.rb

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
require 'wpitjq_generator'
55
require 'haml'
66

7+
default_themes_dir = File.dirname(__FILE__) + "/public/defaults"
8+
79
get '/' do
810
haml :index
911
end
@@ -13,6 +15,15 @@
1315
halt "no feed" unless params[:feed]
1416
halt "no site" unless params[:site]
1517

18+
# check for precalculated themes .. easy way out!
19+
theme = params[:theme] || ""
20+
theme = theme.downcase.gsub(" ", "_") + ".js"
21+
22+
if theme && File.exists?("#{default_themes_dir}/#{theme}") then
23+
return File.new "#{default_themes_dir}/#{theme}"
24+
end
25+
26+
# else, calculate the js for this theme
1627
return Generator.new.for( params[:feed], params[:site] )
1728

1829
end

0 commit comments

Comments
 (0)