Skip to content

Instantly share code, notes, and snippets.

@bunchc
Created April 17, 2017 18:11
Show Gist options
  • Save bunchc/c91c0267999ddf8256fe60b954336aa0 to your computer and use it in GitHub Desktop.
Save bunchc/c91c0267999ddf8256fe60b954336aa0 to your computer and use it in GitHub Desktop.
Rakefile for notes and blogs
require 'fileutils'
task :post do
title = ENV['title'] || "new-post"
tags = ENV['tags'] || ''
layout = ENV['layout'] || 'post'
make_img_dir = ENV['imgdir'] || false
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
filename = File.join('/paht/to/drafts/', "#{Time.now.strftime('%Y-%m-%d')}-#{title.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.md")
open(filename, 'w') do |post|
post.puts "---"
post.puts "title: \"#{title}\""
post.puts "date: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "layout: \"#{layout}\""
post.puts "categories: "
post.puts "---"
post.puts "\nYour content here."
if make_img_dir
img_dir = File.basename(filename.chomp(File.extname(filename)))
FileUtils.mkdir_p("../images/posts/#{img_dir}")
post.puts "\n" * 5
post.puts "[imgdir]: /images/posts/#{img_dir}/"
end
end
end
task :note do
customer = ENV['customer'] || 'internal'
project = ENV['project'] || 'stuff'
author = ENV['author'] || 'Your Name'
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
filename = File.join('/path/to/case-notes/', "#{Time.now.strftime('%Y-%m-%d')}-#{customer.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}-#{project.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.md")
open(filename, 'w') do |post|
post.puts "Customer: #{customer}"
post.puts "Project: #{project}"
post.puts "Author: #{author}"
post.puts "Date: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "categories: "
post.puts "---"
post.puts " "
post.puts "\# #{customer}"
post.puts "\nSome background here\n"
post.puts "\# #{project}"
post.puts "\nSome background here\n"
post.puts "\# Notes:"
end
end
task :call do
subject = ENV['subject'] || "new-call"
customer = ENV['customer'] || 'internal'
project = ENV['project'] || ''
author = ENV['author'] || 'Your Name'
bridge = ENV["bridge"] || ''
owner = ENV["owner"] || ''
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
filename = File.join('/path/to/call-notes/', "#{Time.now.strftime('%Y-%m-%d')}-#{customer.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}-#{subject.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.md")
open(filename, 'w') do |post|
post.puts "---"
post.puts "Subject: #{subject}"
post.puts "Customer: #{customer}"
post.puts "Project: #{project}"
post.puts "Author: #{author}"
post.puts "Date: #{Time.now.strftime('%Y-%m-%d')}"
post.puts "categories: "
post.puts "---\n"
post.puts "\# Background"
post.puts "\nThe context of the call goes here.\n\n"
post.puts "\# Call details:"
post.puts "Organiser: #{owner}"
post.puts "Bridge: #{bridge}"
post.puts "\nOn the call:"
post.puts "* \n\n"
post.puts "\# Unformatted notes:"
post.puts "\nStart taking notes here"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment