Guest User

Untitled

a guest
Feb 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'xmlrpc/client'
  3.  
  4. # USERNAME
  5. username = ""
  6. # PASSWORD
  7. password = ""
  8. # DOMAIN - of the style tommorris.org
  9. domain = ""
  10. # XMLRPC PATH
  11. xmlrpcpath = "/"
  12. # EDITOR - vim, gvim, emacs or gedit for the fail
  13. editor = "vim"
  14.  
  15. # create file and open up vim
  16. filename = "/home/tom/tmp/blog" + Time.now.hash.abs.to_s + ".html"
  17. system(editor + " " + filename)
  18.  
  19. # read file in
  20. exit unless File.exists?(filename)
  21. file = File.open(filename)
  22.  
  23. # pull out title
  24. poss_title = file.readline
  25. if poss_title =~ /^Title: .*$/
  26. title = poss_title.gsub(/^Title: (.*)\n$/, "\\1")
  27. end
  28. file.close
  29. file.reopen(filename)
  30. if title.nil?
  31. description = file.readlines.join("")
  32. else
  33. description = file.readlines.slice(2..-1).join("")
  34. end
  35. description.gsub!(/(.*)\n$/m, "\\1") if description =~ /\n$/m
  36.  
  37.  
  38. # push to server
  39. server = XMLRPC::Client.new(domain, xmlrpcpath)
  40. post = {:description => description}
  41. post[:title] = title unless title.nil?
  42. response = server.call("metaWeblog.newPost", 1, username, password, post, true) unless description.nil? || description.length == 0
  43. if response == "0"
  44. print "Failed -- " + filename + "\n"
  45. else
  46. print "Success!\n"
  47. File.delete(filename)
  48. end
Add Comment
Please, Sign In to add comment