-
Notifications
You must be signed in to change notification settings - Fork 667
/
add_speakers.sh
executable file
·118 lines (97 loc) · 3.92 KB
/
add_speakers.sh
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
#!/bin/bash
set -e
cd `dirname ${0}`
source common_code
# Get year
default_year=$(date +"%Y")
if [[ ! -z $DOD_YEAR ]] ; then
year="$DOD_YEAR"
else
# We assume the current year (and also assume bash 3, because macs)
read -p "Enter your event year (default: $default_year): " year
fi
[ -z "${year}" ] && year="$default_year"
# Get city
if [[ ! -z $DOD_CITY ]] ; then
city="$DOD_CITY"
else
read -p "Enter your city name: " city
fi
city_slug=$(echo $city | tr '-' ' ' | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
# Generate event slug
event_slug=$year-$city_slug
# Create necessary directories
mkdir -p ../content/events/$event_slug/program
mkdir -p ../content/events/$event_slug/speakers
mkdir -p ../static/events/$event_slug/speakers
# Create empty speakers page file (will be auto-filled for display)
speakerspage="../content/events/$event_slug/speakers.md"
cp examples/templates/speakers.md $speakerspage
string_replace "CITY" "${city}" "${speakerspage}"
string_replace "YYYY" "${year}" "${speakerspage}"
# uncomment link to speakers page
string_replace "# - name: speakers" " - name: speakers" "../data/events/$year/$city_slug/main.yml"
# Prompt for inputting speakers
while [ 1 ]
do
echo "Entering speakers; use CTRL+C to stop..."
##############
# Speaker file
##############
read -p "Enter speaker name: " speakername
speaker_slug=$(echo $speakername | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
# create speaker file
speakerfile="../content/events/$event_slug/speakers/$speaker_slug.md"
cp examples/templates/speakers-speaker-full-name.md $speakerfile
string_replace "SPEAKERNAME" "${speakername}" "${speakerfile}"
string_replace "SPEAKERSLUG" "${speaker_slug}" "${speakerfile}"
# twitter handle
read -p "Enter speaker twitter handle (return for none): " twitter
[ -z "${twitter}" ] && twitter=''
# remove @ if they added it
twitter=$(echo $twitter | sed 's/@//')
string_replace "SPEAKERTWITTER" "${twitter}" "${speakerfile}"
#linkedin profile
read -p "Enter speaker linkedin profile (return for none): " linkedin
[ -z "${linkedin}" ] && linkedin=''
string_replace "SPEAKERLINKEDIN" "${linkedin}" "${speakerfile}"
# bio
read -p "Enter speaker bio (return for none): " bio
[ -z "${bio}" ] && bio=''
string_replace "SPEAKERBIO" "${bio}" "${speakerfile}"
####################
# Populate talk file
####################
talkfile="../content/events/$event_slug/program/$speaker_slug.md"
cp examples/templates/program-speaker-full-name.md $talkfile
string_replace "SPEAKERSLUG" "${speaker_slug}" "${talkfile}"
# talk title
read -p "Enter speaker talk title (return for none): " title
[ -z "${title}" ] && title=''
string_replace "TALKTITLE" "${title}" "${talkfile}"
# talk description
read -p "Enter speaker talk description (return for none): " abstract
[ -z "${abstract}" ] && abstract=''
string_replace "ABSTRACT" "${abstract}" "${talkfile}"
#######################
# Set speaker image
#######################
#
# if speaker image is already in expected location
if [[ -f "../assets/events/$event_slug/speakers/$speaker_slug.png" ]] ; then
string_replace "image = \"\"" "image = \"${speaker_slug}.png\"" "${speakerfile}"
echo "found ${speaker_slug}.png, using"
else
read -p "Enter path to speaker image PNG: " speakerimage
if [[ -n "${speakerimage}" ]] && [[ -f "${speakerimage}" ]] ; then
cp -v "${speakerimage}" "../assets/events/${event_slug}/speakers/${speaker_slug}.png"
string_replace "image = \"\"" "image = \"${speaker_slug}.png\"" "${speakerfile}"
else
echo "no image used. If desired:
1. Copy PNG into ../assets/events/${event_slug}/speakers/${speaker_slug}.png
2. update ${speakerfile}, changing image = \"${speaker_slug}.png\"
before creating your Pull Request.
"
fi
fi
done