Hardware authentication for Linux using ordinary USB Flash Drives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

18 years ago
18 years ago
  1. #!/usr/bin/env ruby
  2. #
  3. # fetch_doc.rb
  4. #
  5. # Fetch the documentation from the wiki and translate it
  6. # to be human readable.
  7. #
  8. require 'open-uri'
  9. BASE_URI = 'http://www.pamusb.org/doku/doc/'
  10. DOC_PATH = './pam_usb/doc/'
  11. DOCS = [ 'install', 'upgrading' ]
  12. REPLACE_LIST = [
  13. # Extract text area from xhtml document.
  14. { :pattern => /.*<textarea .+>(.*)<\/textarea>.*/m, :with => '\1' },
  15. # Remove wiki links [[link|name]]
  16. { :pattern => /\[\[.+\|(.+)\]\]/, :with => '\1' },
  17. # Remove misc xhtml/wiki characters
  18. { :pattern => /\/\//, :with => '' },
  19. { :pattern => /\\\\ /, :with => '' },
  20. { :pattern => /\*\*/, :with => '' },
  21. { :pattern => /&lt;/, :with => '<' },
  22. { :pattern => /&gt;/, :with => '>' },
  23. { :pattern => /&quot;/, :with => '"' },
  24. # Remove trailing whitespaces
  25. { :pattern => /^ /, :with => '' },
  26. # Fit 80 colums
  27. { :pattern => /(.{1,80})( +|$\n?)|(.{1,80})/, :with => "\\1\\3\n" },
  28. ]
  29. def fetch_doc(name)
  30. uri = BASE_URI + name + '?do=edit'
  31. body = open(uri) { |f| f.read }
  32. REPLACE_LIST.each { |r| body.gsub!(r[:pattern], r[:with]) }
  33. body
  34. end
  35. DOCS.each do |doc|
  36. print "Fetching doc:#{doc}... "
  37. STDOUT.flush
  38. text = fetch_doc(doc)
  39. File.open(File.join(DOC_PATH, doc), 'w') { |f| f.write(text) }
  40. puts "Done."
  41. end