forked from devopsdays/devopsdays-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_speakers.sh
executable file
·105 lines (83 loc) · 3.21 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
#!/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
sedcmd "s/CITY/$city/" $speakerspage
sedcmd "s/YYYY/$year/" $speakerspage
# uncomment link to speakers page
sedcmd "s/# - name: speakers/ - name: speakers/" ../data/events/$event_slug.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
sedcmd "s/SPEAKERNAME/$speakername/" $speakerfile
sedcmd "s/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/@//')
sedcmd "s/SPEAKERTWITTER/$twitter/" $speakerfile
# bio
read -p "Enter speaker bio (return for none): " bio
[ -z "${bio}" ] && bio=''
sedcmd "s/SPEAKERBIO/$bio/" $speakerfile
####################
# Populate talk file
####################
talkfile="../content/events/$event_slug/program/$speaker_slug.md"
cp examples/templates/program-speaker-full-name.md $talkfile
sedcmd "s/SPEAKERSLUG/$speaker_slug/" $talkfile
# talk title
read -p "Enter speaker talk title (return for none): " title
[ -z "${title}" ] && title=''
sedcmd "s/TALKTITLE/$title/" $talkfile
# talk description
read -p "Enter speaker talk description (return for none): " abstract
[ -z "${abstract}" ] && abstract=''
sedcmd "s/ABSTRACT/$abstract/" $talkfile
#######################
# Set speaker image
#######################
read -p "Enter path to speaker image PNG: " speakerimage
[ -z "${speakerimage}" ] && speakerimage=''
if [ $speakerimage ]; then
cp "$speakerimage" ../static/events/$event_slug/speakers/$speaker_slug.png
sedcmd "s/image = \"\"/image = \"$speaker_slug.png\"/" $speakerfile
else
echo "Put speaker image at ../static/events/$event_slug/speakers/$speaker_slug.png before creating the pull request, if desired."
fi
done