forked from devopsdays/devopsdays-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_new_event.sh
executable file
·77 lines (62 loc) · 2.35 KB
/
add_new_event.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
#!/bin/bash
set -e
cd `dirname ${0}`
# Detect OS for correct 'sed' syntax
OSNAME=`uname`
GNUSED=$(which sed)
SEDCMD(){
if [[ $OSNAME == 'Linux' ]]; then
sed -i "$@"
elif [[ $OSNAME == 'Darwin' && $GNUSED == '/usr/local/bin/sed' ]]; then
sed -i "$@"
else
sed -i '' "$@"
fi
}
if [[ $(date +"%m") -ge 10 ]]; then
default_year=$(echo $(echo `date +"%Y"` + 1) | bc)
else
default_year=$(date +"%Y")
fi
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"
if [[ ! -z $DOD_CITY ]] ; then
city=$DOD_LUG_CITY
else
read -p "Enter your city name: " city
fi
# We urlize the city slug
city_slug=$(echo $city | tr '-' ' ' | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
# Get event twitter handle
read -p "Enter your devopsdays event twitter handle (defaults to devopsdays): " twitter
[ -z "${twitter}" ] && twitter='devopsdays'
# remove @ if they added it
twitter=$(echo $twitter | sed 's/@//')
# We use the term event_slug in the hugo files too
event_slug=$year-$city_slug
# Create default event datafile
eventdatafile="../data/events/$event_slug.yml"
cp examples/data/events/yyyy-city.yml $eventdatafile
SEDCMD "s/YYYY/$year/" $eventdatafile
SEDCMD "s/City/$city/" $eventdatafile
SEDCMD "s/yourlocation/$city/" $eventdatafile
SEDCMD "s/yyyy-city/$event_slug/" $eventdatafile
SEDCMD "s/devopsdayscityabbr/$twitter/" $eventdatafile
# Name the email lists
SEDCMD "s/city-year/$city_slug-$year/" $eventdatafile
# Seed initial files for event
cp -r examples/content/events/yyyy-city ../content/events/$event_slug
# Setting the creation date at the time the event is instantiated
datestamp=$(date +%Y-%m-%dT%H:%M:%S%z | sed 's/^\(.\{22\}\)/\1:/')
SEDCMD "s/2000-01-01T01:01:01-06:00/$datestamp/" ../content/events/$event_slug/*.md
SEDCMD "s/yyyy-city/$event_slug/" ../content/events/$event_slug/welcome.md
SEDCMD "s/CITY/$city/" ../content/events/$event_slug/*.md
SEDCMD "s/YYYY/$year/" ../content/events/$event_slug/*.md
echo " "
echo "Check your event at http://localhost:1313/events/$event_slug/"
echo "Add your team members to $eventdatafile before sending pull request"