Author: ben
Date: 2007-11-17 19:48:16 -0800 (Sat, 17 Nov 2007)
New Revision: 7310

Modified:
   sandbox/ben/ruby/linkchecker.rb
Log:
ruby link checker actually reports useful broken links in ol docs

Modified: sandbox/ben/ruby/linkchecker.rb
===================================================================
--- sandbox/ben/ruby/linkchecker.rb     2007-11-18 03:08:09 UTC (rev 7309)
+++ sandbox/ben/ruby/linkchecker.rb     2007-11-18 03:48:16 UTC (rev 7310)
@@ -8,6 +8,8 @@
 LASZLO_PORT = 8080
 CHECK_EXTERNAL_LINKS = true
 
+report_broken_links = true
+
 class HTMLPage
   @url
   @response
@@ -26,11 +28,11 @@
     @response = Net::HTTP.get_response( URI.parse(url) ) 
     puts "ok." if verbose
   rescue SystemCallError
-    puts "couldn't connect to load url #{url}." if verbose
+    puts "couldn't connect to load url #{url}." if (verbose or 
report_broken_links)
   end 
   
   def is_ok?
-    (@response and (@response.code == "200") ) 
+    (@response and (@response.code =~ %r{[23]\d\d} ) )
   end
   
   def print_result
@@ -74,7 +76,7 @@
       
         
       relative_url = ""
-      if source_uri.path =~  %r{(.*)/[\w.]*.html} then
+      if source_uri.path =~  %r{(.*)/[\w+-_.]*.html} then
         relative_url +=  $1 + "/" 
       else 
         if source_uri.path !~ %r{^/}
@@ -124,7 +126,7 @@
     if p.is_ok? then
       @@urls_that_exist.push( url ) 
     else
-      @@missing_urls.push( url ) 
+      @@missing_urls.push( url + "-error-" + p.response.code ) 
     end
     filenames = p.find_urls 
     @@files_to_check.concat( filenames )
@@ -143,7 +145,7 @@
       unique_new_urls = urls.uniq - @@files_to_check - @@files_weve_checked; 
       @@files_to_check.concat( unique_new_urls )
     else
-      @@missing_urls.push( url ) 
+      @@missing_urls.push( url + "-error-" + page.response.code ) 
     end
     
     @@files_weve_checked.uniq!
@@ -204,7 +206,17 @@
           "http://localhost:8080/trunk/docs/includes/lzx-pretty-print.css"; ],
       [ "http://localhost:8080/trunk/docs/reference/ref.preface.html";, 
           "peepers.html", 
-          "http://localhost:8080/trunk/docs/reference/peepers.html"; ]
+          "http://localhost:8080/trunk/docs/reference/peepers.html"; ], 
+        ["http://localhost:8080/trunk/docs/reference/LZX.ref.html";, 
+          "tag.splash-view.html", 
+          "http://localhost:8080/trunk/docs/reference/tag.splash-view.html";], 
+        ["http://localhost:8080/trunk/docs/reference/LZX.ref.html";, 
+          "tag.splash+as2.html", 
+          "http://localhost:8080/trunk/docs/reference/tag.splash+as2.html";], 
+        ["http://localhost:8080/trunk/docs/reference/tag.splash+as2.html";, 
+          "tag.splash-view.html", 
+          "http://localhost:8080/trunk/docs/reference/tag.splash-view.html";]
+          
     ]
     links.each { | t | 
       l = Link.new( t[0], t[1] )
@@ -238,6 +250,12 @@
 
   end
   
+  def test_complex_url 
+    url = "http://localhost:8080/trunk/docs/reference/tag.splash+as2.html";
+    p = HTMLPage.new( url )
+    assert( p.is_ok?, "spash as2 page" )
+  end 
+  
   def test_implicit_page_name 
     url = "http://localhost:8080/trunk/docs/";
     p = HTMLPage.new( url )


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to