Guest User

Untitled

a guest
May 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. # Creates a blank textile file with basic YAML front matter for
  4. # your Jekyll blog. Then it launches gvim so that you can start
  5. # writing immediately.
  6. #
  7. # Assumes your posts are in ./blog/_posts and that you're using a layout
  8. # called 'post'.
  9.  
  10. if ARGV.empty?
  11. puts "As an argument, write your new post's title. Eg 'newpost Something I want to share'."
  12. exit
  13. end
  14.  
  15. title = ARGV.join(" ")
  16. slug = title.gsub(/\s+/, '-').downcase
  17. path = "blog/_posts/#{Time.now.strftime("%Y-%m-%d")}-#{slug}.textile"
  18.  
  19. File.open(path, "w") do |f|
  20. f.write "---\n"
  21. f.write "title: #{title}\n"
  22. f.write "layout: post\n"
  23. f.write "---\n\n"
  24. end
  25.  
  26. puts "=> #{path}"
  27. `gvim #{path}`
Add Comment
Please, Sign In to add comment