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.

56 lines
1.3 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/wiki/doc/'
  10. DOC_PATH = './pam_usb/doc/'
  11. DOCS = [ 'install', 'upgrading', 'configuring' ]
  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. { :pattern => /<code .+>.*\n/, :with => '' },
  25. { :pattern => /<\/code>.*\n/, :with => '' },
  26. # Remove trailing whitespaces
  27. { :pattern => /^ /, :with => '' },
  28. # Fit 80 colums
  29. { :pattern => /(.{1,80})( +|$\n?)|(.{1,80})/, :with => "\\1\\3\n" },
  30. ]
  31. def fetch_doc(name)
  32. uri = BASE_URI + name + '?do=edit'
  33. body = open(uri) { |f| f.read }
  34. REPLACE_LIST.each { |r| body.gsub!(r[:pattern], r[:with]) }
  35. body
  36. end
  37. DOCS.each do |doc|
  38. print "Fetching doc:#{doc}... "
  39. STDOUT.flush
  40. text = fetch_doc(doc)
  41. File.open(File.join(DOC_PATH, doc), 'w') { |f| f.write(text) }
  42. puts "Done."
  43. end