Sha256: 8e72d262e2440e8605f92c403bfe2c92f113db0b3eb5d28e9f39cee9f9918792
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'rubygems' require 'optparse' require 'yaml' desc "create new post with textmate" task :np do OptionParser.new.parse! ARGV.shift title = ARGV.join(' ') path = "config/jekyll/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.markdown" home_dir = Dir.respond_to?(:home) ? Dir.home : ENV['HOME'] if File.exist?(path) puts "[WARN] File exists - skipping create" else File.open(path, "w") do |file| file.puts YAML.dump({'layout' => 'post', 'published' => false, 'title' => title}) file.puts "---" end begin config = {'editor' => 'mate'} if File.exist?("#{home_dir}/.bloggyrc") config.merge!(YAML.load_file("#{home_dir}/.bloggyrc")) end rescue TypeError puts "[WARN] Failed to parse editor from .bloggyrc" end file = `which #{config['editor']} 2> /dev/null`.chomp if $?.to_i == 0 and File.exists?(file) begin `#{config['editor']} #{path}` rescue Exception puts "[WARN] Could not find editor #{config['editor']} - please edit #{path} manually" end else puts "[WARN] Could not find editor #{config['editor']} - please edit #{path} manually" end end exit 1 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bloggy-0.3 | lib/generators/jekyll/blog/templates/tasks/new_post.rake.tt |