forked from dentarg/auth0-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
63 lines (58 loc) · 2.16 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require "stringex"
new_post_ext = "markdown"
posts_dir = "_posts"
#usage rake
desc 'push to github, deploy to heroku and finally notify search engines about the sitemap.xml'
task :default do
puts '* Pushing to github'
`git push origin`
puts '* Deploying to heroku'
`git push heroku`
#notify search engines
Rake::Task["sitemap"].invoke
end
#usage rake sitemap, but this task will be executed automatically after deploying
desc 'notify search engines'
task :sitemap do
begin
require 'net/http'
require 'uri'
puts '* Pinging Google about our sitemap'
Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('http://blog.auth0.com/sitemap.xml'))
rescue LoadError
puts '! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found.'
end
end
# borrowed this from octopress
# 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 _posts"
task :new_post, :title do |t, args|
mkdir_p "#{posts_dir}"
args.with_defaults(:title => 'new-post')
title = args.title
filename = "#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "description: <A SHORT DESCRIPTION OF THE POST>"
post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
post.puts "category: <FROM HERE: https://docs.google.com/spreadsheets/d/1e_RKzi8kVwzqPG8si8kyDOWPiBk9tI-XNGh0KgRIF7Q>"
post.puts "author: "
post.puts " name: <YOUR NAME>"
post.puts " url: <YOUR URL>"
post.puts " mail: <YOUR MAIL>"
post.puts "design: "
post.puts " bg_color: <A HEX BACKGROUND COLOR>"
post.puts " image: <A PATH TO A 200x200 IMAGE>"
post.puts "tags: "
post.puts "- foo"
post.puts "related:"
post.puts "- <ADD SOME RELATED POSTS FROM AUTH0'S BLOG>"
post.puts "---"
end
end