Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
replacing w3c feed validator with nokogiri xml validate
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Oct 16, 2010
1 parent b2530e8 commit 109fa16
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions kensho.rb
Expand Up @@ -6,6 +6,7 @@
require "sass"
require "haml"
require "w3c_validators"
require "nokogiri"

class Kensho < Sinatra::Base

Expand All @@ -23,22 +24,21 @@ class Kensho < Sinatra::Base
@validator = MarkupValidator.new
@validator.set_debug!(true)
when "FEED"
@validator = FeedValidator.new(:validator_uri => "http://validator.w3.org/feed/check.cgi")
@validator = Nokogiri::XML.parse(params[:markup])
when "CSS"
@validator = CSSValidator.new
@validator.set_warn_level!(2)
else
@validator = nil
end

begin
@errors = @validator.validate_text(params[:markup])
rescue W3CValidators::ValidatorUnavailable
if params[:type] == "HTML" || params[:type] == "CSS"
@errors = @validator.validate_text(params[:markup]).errors
@warnings = @validator.validate_text(params[:markup]).warnings
elsif params[:type] == "FEED"
@errors = @validator.errors
else
@errors = nil
@exception = "Unable to connect to validator, perhaps your request was too large"
rescue Net::HTTPRetriableError
@errors = nil
@exception = "Unable to connect to validator, response 302"
end

haml :validate
Expand Down

0 comments on commit 109fa16

Please sign in to comment.