-
Notifications
You must be signed in to change notification settings - Fork 664
/
add_sponsors.sh
executable file
·84 lines (63 loc) · 2.22 KB
/
add_sponsors.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
#!/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
# Prompt for inputting sponsors
while [ 1 ]
do
echo "Adding new sponsors; use CTRL+C to stop..."
# Gather info
read -p "Enter sponsor name: " sponsorname
sponsor_slug=$(echo $sponsorname | tr '-' ' ' | tr -dc '[:alnum:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
sponsor_initial=$(echo "${sponsor_slug}" | cut -c 1)
# set default sponsor yaml file
sponsorfile="../data/sponsors/$sponsor_slug.yml"
if [ -f $sponsorfile ];
then
echo "Sponsor already exists"
exit 0
fi
read -p "Enter sponsor url: " url
[ -z "${url}" ] && url=''
read -p "Enter sponsor twitter handle: " twitter
[ -z "${twitter}" ] && twitter=''
read -p "Enter path to PNG logo (must be at least 200px wide & have white or transparent background): " logo
[ -z "${logo}" ] && logo=''
# Populate data file
cp examples/data/sponsors/sponsorname.yml $sponsorfile
sedcmd "s/SPONSORNAME/$sponsorname/" $sponsorfile
sedcmd "s%URL%$url%" $sponsorfile
if ! [ -z "${twitter}" ]; then
echo "twitter: \"${twitter}\"" >> $sponsorfile
fi
# Set logo
if [ $logo ]; then
if [ ! -d ../assets/sponsors/$sponsor_initial/]; then
mkdir -p ../assets/sponsors/$sponsor_initial/
fi
cp "$logo" ../assets/sponsors/$sponsor_initial/$sponsor_slug.png
else
echo "Set the sponsor logo at ../assets/sponsors/$sponsor_initial/$sponsor_slug.png before submitting PR."
fi
echo "Add this to ../data/events/"$year"/"$city_slug"/main.yml under sponsors:"
echo " - id:" $sponsor_slug
echo " level: theirlevel"
done