-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
140 lines (130 loc) · 3.79 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
require 'date'
require 'time'
require 'rake'
require 'json'
require 'front_matter_parser'
require 'open3'
require 'jekyll'
require 'fileutils'
require 'kramdown'
class String
def titlecase
split(/([[:alpha:]]+)/).map(&:capitalize).join
end
def striphtml
split(/\<.*?\>/)
.map(&:strip)
.reject(&:empty?)
.join(' ')
.gsub(/\s,/,',')
end
end
desc "Install dependencies"
task :install_dependencies do
sh 'bundle install'
end
desc "Build the site."
task :build_site do
sh 'bundle exec jekyll build'
end
desc "Make a research project"
task :new_project, [:title] do |t, args|
title_slug = args.title.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
fn = 'collections/_work/' + title_slug + '.md'
if File.exist? fn; raise RuntimeError.new("The file #{fn} already exists."); end
titlecase_title = args.title.titlecase
File.open(fn, 'w'){|f|
f.puts("---
layout: work
slug: the-slug
title: ""
collaborators:
- name: First Last
slug: first-last
role:
research-category:
start-year:
end-year:
---
More details to come.")
}
puts "New research project created at #{fn}"
end
desc "Make a new event"
task :new_event, [:title, :date] do |t, args|
title_slug = args.title.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
event_date = args.date
fn = 'collections/_events/' + title_slug + '-' + event_date + '.md'
if File.exist? fn; raise RuntimeError.new("The file #{fn} already exists."); end
titlecase_title = args.title.titlecase
current_time = Time.new.strftime("%Y-%m-%d %H:%M:%S")
File.open(fn, 'w'){|f|
f.puts("---
author: first-last
start_date: #{event_date}
end_date: '#{event_date}'
start_time: '00:00:00'
end_time: '00:00:00'
layout: events
location: 'Shannon Library 308 (SLab Common Room)'
title: '#{titlecase_title}'
rsvp: \"https://cal.lib.virginia.edu/calendar/events/GradCamp2024\"
---
More details to come.
")
}
puts "New event page created at #{fn}"
end
desc "Make a new person"
task :new_person, [:first_name, :last_name] do |t, args|
slug = args.first_name.downcase.split.join('-') + '-' + args.last_name.downcase.split.join('-')
fn = 'collections/_people/' + slug + '.md'
if File.exist? fn; raise RuntimeError.new("The file #{fn} already exists."); end
File.open(fn, 'w'){|f|
f.puts("---
layout: people
title: FirstName LastName
slug: firstname-lastname
first_name: FirstName
last_name: LastName
website:
email:
status: current or not_current
department: UVA Academic Department If Any
position: Name of Role
people-category:
- Pick one of student, director, or staff
roles:
- LAMI Fellow, 2018 (for example)
- Multiple role get added on a new line like this
---
More details to come.")
}
puts "New person created at #{fn}"
end
desc "Make a new post, given a title and author"
task :new_post, [:title, :author] do |t, args|
author_slug = args.author.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
title_slug = args.title.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
date = Date.today.to_s
fn = 'collections/_posts/' + date + '-' + title_slug + '.md'
if File.exist? fn; raise RuntimeError.new("The file #{fn} already exists."); end
current_time = Time.new.strftime("%Y-%m-%d")
File.open(fn, 'w'){|f|
f.puts("---
author: #{author_slug}
date: #{current_time}
layout: post
slug: #{title_slug}
title: #{args.title.titlecase}
category: essay or announcement (Pick one, delete the \"or\", and this parenthetical)
crosspost:
- title: if your post is crossposted, the text here will be the text of the link, while the URL key will be the link itself. If not crossposting you can delete the crossposting key.
url: https://yourcoollink.com
---
content of your post here. The above information is meant to be a template.")
}
puts "New post created at #{fn}"
end
task :default => [:install_dependencies]
task :publish => [:install_dependencies, :build_site]