lib/kdwatch-app.rb in kdwatch-0.2.0 vs lib/kdwatch-app.rb in kdwatch-0.3.0

- old
+ new

@@ -7,10 +7,12 @@ # require "guard-livereload" require "rack-livereload" require "guard" require "sinatra" require "kramdown-rfc2629" +ENV["KDRFC_PREPEND"] = "time" +require "kramdown-rfc/kdrfc-processor" require "net/http/persistent" host = ENV["KDWATCH_HOST"] port = ENV["KDWATCH_PORT"] @@ -19,16 +21,25 @@ dfn = File.join(File.dirname(sfn), "#{File.basename(sfn, ".*")}.html") puts dfn +kdrfc = KramdownRFC::KDRFC.new +kdrfc.options.v3 = true +kdrfc.options.html = true + get "/" do sfc = File.stat(sfn).ctime dfc = File.stat(dfn).ctime rescue Time.at(0) if sfc > dfc warn "Rebuilding..." - system("time kdrfc -3h --no-txt #{sfn}") - warn "...done" + begin + kdrfc.process sfn + rescue StandardError => e + warn e.to_s + else + warn "...done" + end end File.read(dfn) end get "/metadata.min.js" do