forked from devopsdays/devopsdays-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_new_event.sh
executable file
·74 lines (60 loc) · 2.55 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
#!/bin/bash
set -e
cd `dirname ${0}`
source common_code
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_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
# Update the redirection for a previous year of this event to the desired year
if grep -q "^/$city_slug" "../static/_redirects";
then
sedcmd "/^\/$city_slug/ s/.\{4\}-$city_slug/$event_slug/" "../static/_redirects"
else
# If a previous-year event does not exist, create the redirection for the desired year
sedcmd -e '$a\' "../static/_redirects"
echo "/$city_slug/* /events/$event_slug/:splat 302" >> "../static/_redirects"
fi
# 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 list
sedcmd "s/city_email/$city_slug/" $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"