-
Notifications
You must be signed in to change notification settings - Fork 664
/
add_organizers.sh
executable file
·115 lines (91 loc) · 2.83 KB
/
add_organizers.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
#!/bin/bash
set -e
cd `dirname ${0}`
source common_code
OUT=$(mktemp /tmp/output.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
# 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 ../static/events/$event_slug/organizers
# Set the creation date to current timestamp
datestamp=$(date +%Y-%m-%dT%H:%M:%S%z | sed 's/^\(.\{22\}\)/\1:/')
# Prompt for inputting organizers
while true; do
echo "What would you like to do?"
echo "1. Add info for an organizer"
echo "2. View organizers thus far"
echo "3. Exit"
echo
echo -n "Enter your choice: "
read choice
echo
case $choice in
1)
#################
# Organizer entry
#################
read -p "Enter organizer name: " organizername
organizer_slug=$(echo $organizername | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
# employer
read -p "Enter organizer's employer (return to skip): " employer
[ -z "${employer}" ] && employer=""
# twitter handle
read -p "Enter organizer twitter handle (return to skip): " twitter
[ -z "${twitter}" ] && twitter=''
# remove @ if they added it
twitter=$(echo $twitter | sed 's/@//')
# bio
read -p "Enter organizer bio (return to skip): " bio
[ -z "${bio}" ] && bio=""
#######################
# Set organizer image
#######################
read -p "Enter path to organizer image as jpg (return to skip): " organizerimage
[ -z "${organizerimage}" ] && organizerimage=''
if [ $organizerimage ]; then
cp "$organizerimage" ../assets/events/$event_slug/organizers/$organizer_slug.jpg
else
echo "Put organizer image at ../assets/events/$event_slug/organizers/$organizer_slug.jpg before creating the pull request, if desired."
fi
####################
# Populate data file
####################
echo "
- name: \"$organizername\"
employer: \"$employer\"
twitter: \"$twitter\"
bio: \"$bio\"" >> $OUT
if [ $organizerimage ]; then
echo " image: \"$organizer_slug.jpg\"" >> $OUT
fi
;;
2)
cat "$OUT"
;;
3)
echo "Add to ../data/events/$year/$city_slug/main.yml under team_members: "
cat "$OUT"
break
;;
*)
echo "Invalid choice. Choose a number from 1 to 3."
;;
esac
done
rm $OUT