-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
67 lines (60 loc) · 1.56 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
#html_index = 'docs/index.html'
#FileList['src/content/*.md'].each {|md| file html_index => md}
require 'yaml'
WORK_DIR = Dir.getwd
CONFIG = WORK_DIR + '/src/pelican/pelicanconf.py'
CONTENT_DIR = WORK_DIR + '/src/content'
OUT_DIR = WORK_DIR + '/docs/'
THEMES_DIR = WORK_DIR + '/src/pelican/themes'
THEME = THEMES_DIR + '/aboutwilson'
TMP_PATH = WORK_DIR + '/src/tmp'
DRAFTS_PATH = WORK_DIR + '/src/drafts'
ALIASES_PATH = WORK_DIR + '/src/aliases'
def run_pelican(config: CONFIG, content: CONTENT_DIR, out: OUT_DIR, theme: THEME, args: [])
cmd = "pelican -s #{config} #{content} -o #{out} -t #{theme} #{args.join(' ')}"
exec cmd
end
def build_docs
run_pelican
end
def read_contents
end
desc 'Default task for project building'
task :default => [:build] do
end
task :build do
build_docs
end
task :clean do
rm_rf OUT_DIR
mkdir OUT_DIR
end
task :commit do
settings = YAML.load_file("#{WORK_DIR}/src/default.yaml")
puts(settings)
end
task :test do
ENV['PELICAN_ENV'] = 'testing'
run_pelican(content: DRAFTS_PATH, out: TMP_PATH, args: ['--listen', '-r'])
end
task :post do
cmd = "bash #{WORK_DIR}/bin/new_post"
exec cmd
end
task :aliases do
mkdir_p ALIASES_PATH
Dir.glob("#{CONTENT_DIR}/**/*.md").each do |file|
File.open(file) {|f|
title = f.read.match(/[tT]itle\:(.*)/)[1]
.strip.downcase.tr(" ", "_")
link = "#{ALIASES_PATH}/#{title}.txt"
puts("Try create #{link}")
File.symlink(file,link) if not File.exist?(link)
}
end
end
task :drafts do
end
#file 'docs/index.html' => 'src/content/*.md' do
#end
task :build => :clean