Guest User

Untitled

a guest
Dec 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. unless ARGV[0]
  4. puts 'Usage: newdraft "the draft title"'
  5. exit(-1)
  6. end
  7.  
  8. date_prefix = Time.now.strftime("%Y-%m-%d")
  9. post_name = ARGV.join ' '
  10. post_file_name = post_name.strip.downcase.gsub(/ /, '-')
  11. post = "./_posts/#{date_prefix}-#{post_file_name}.draft.md"
  12.  
  13. header = <<-END
  14. ---
  15. layout: post
  16. tags:
  17. title: "#{post_name}"
  18. ---
  19.  
  20. Write the "#{post_name}" content here...
  21. END
  22.  
  23. File.open(post, 'w') do |f|
  24. f << header
  25. end
  26.  
  27. system("vim #{post}")
  28. exit(0)
Add Comment
Please, Sign In to add comment