-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
80 lines (76 loc) · 2.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# frozen_string_literal: true
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'html-proofer'
desc 'Validate HTML files'
task :proof do
HTMLProofer.check_directory(
'_site',
typhoeus: {
connecttimeout: 30,
timeout: 60
},
cache: {
timeframe: { external: '4w' }
},
checks: ['Links', 'Images', 'Scripts', 'Favicon', 'OpenGraph'],
enforce_https: false,
ignore_status_codes: [302],
ignore_urls: [
%r{^https?://localhost},
%r{^https?://t\.co/},
%r{^https?://twitter\.com},
%r{^https?://web\.archive\.org/web/},
# _include/fonts.html
%r{^https://fonts\.gstatic\.com$},
# /about/
%r{^https://tweetdeck\.twitter\.com},
# /2013/02/18/ios-6.1-music-album-shuffle/
%r{^http://www\.hackint0sh\.org/free-toolchain-software-126/req-album-shuffle-option-18867\.htm},
%r{^https://www\.i-funbox\.com/en/index\.html},
# /2014/01/20/ghost-in-the-shellcode-2014-inview-write-up/
%r{^https://2014\.ghostintheshellcode\.com/inview-324b8fb59c14da0d5ca1fe2c31192d80cec8e155},
# /2014/02/24/support-facebook-open-graph-and-twitter-cards-on-octopress/
%r{^https://cards-dev\.twitter\.com/validator},
# /2014/12/25/christmasctf-2014-write-up/
%r{^http://web-prob\.dkserver\.wo\.tc/letter_4f1ad94372c166c3cb9632ed5041849a/},
%r{^http://web-prob\.dkserver\.wo\.tc/sqli_962a035aacf08966ffc7610957ac0c29/},
%r{^http://988087853},
%r{^http://58\.229\.6\.45},
# /2016/10/11/hitcon-ctf-2016-rop-write-up/
%r{^https://s3-ap-northeast-1\.amazonaws\.com/hitcon2016qual/rop\.iseq_a9ac4b7a1669257d0914ca556a6aa6d14b4a2092}
],
swap_urls: {
%r{^(//.*)} => 'https:\1',
%r{^(https?://github\.com/[^#]+)#.*} => '\1'
}
).run
end
desc 'Create a new post'
task :post, :title do |_t, args|
if args.title
title = args.title
else
print 'Enter a title for your post: '
title = $stdin.gets.chomp
end
time = Time.now.utc
slug = "#{time.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/[^\w]+/, '-')}"
filename = File.join(File.dirname(__FILE__), '_posts', "#{slug}.markdown")
if File.exist?(filename)
puts "#{filename} already exists."
abort 'rake aborted!'
end
puts "Creating new post: #{filename}"
File.open(filename, 'w') do |f|
f.puts '---'
f.puts 'layout: post'
f.puts "title: \"#{title}\""
f.puts "date: #{time.strftime('%Y-%m-%d %H:%M:%S %z')}"
f.puts 'categories:'
f.puts 'description:'
f.puts 'keywords:'
f.puts "redirect_from: /p/#{time.strftime('%Y%m%d')}/"
f.puts '---'
end
end