# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")desc"Begin a new post in #{source_dir}/#{posts_dir}"task:new_post,:title,:oneline_dialydo|t,args|# Added a 2nd argument"oneline_dialy"# for debugputsargs.oneline_dialyifargs.titletitle=args.titleelsetitle=get_stdin("Enter a title for your post: ")endraise"### You haven't set anything up yet. First run `rake install` to set up an Octopress theme."unlessFile.directory?(source_dir)mkdir_p"#{source_dir}/#{posts_dir}"filename="#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"ifFile.exist?(filename)abort("rake aborted!")ifask("#{filename} already exists. Do you want to overwrite?",['y','n'])=='n'endputs"Creating new post: #{filename}"open(filename,'w')do|post|post.puts"---"post.puts"layout: post"post.puts"title: \"#{title.gsub(/&/,'&')}\""post.puts"date: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}"post.puts"comments: true"ifargs.oneline_dialypost.puts"categories: 30daysChallenge20140207"post.puts"---"post.putsargs.oneline_dialyelsepost.puts"categories: "post.puts"---"endendend
But idk this is a BEAUTIFUL CODE. I dont suppose so :(