-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrls.sh
More file actions
executable file
·98 lines (84 loc) · 3.66 KB
/
rls.sh
File metadata and controls
executable file
·98 lines (84 loc) · 3.66 KB
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
#!/usr/bin/env bash
RLS_EXEC=$0
RLS_DIR=`dirname $0`
source $RLS_DIR/config.sh
source $RLS_DIR/functions.sh
source $RLS_DIR/colours.sh
source package.info
# If there is no version specified in package.info - use latest
if [[ $DOCKER_VERSION == "" ]]; then
get_latest_version
DOCKER_VERSION=${LATEST_DOCKER_VERSION}
fi
if [[ $2 = "-p" ]]; then
PORT_NUMBER=${3}
else
PORT_NUMBER="4100"
fi
printf "Using docker image version ${SUCCESS} ${DOCKER_VERSION} ${NC}\n\n"
docker_login
case "$1" in
"init")
if rls_init ; then
printf "${HIGHLIGHT1}You presentation ${HIGHLIGHT2}presentation.md${HIGHLIGHT1} was initialised successfully. Serve it by running ./rls.sh serve and Have fun!${NC}\n\n"
# Save the docker version this presentation uses in package.info
echo "#!/usr/bin/env bash" > package.info
echo "DOCKER_VERSION=\"${DOCKER_VERSION}\"" >> package.info
else
printf "${ERROR}Something went wrong. Did you run the setup script?${NC}\n\n"
fi
;;
"serve")
sleep 4 && open http://localhost:${PORT_NUMBER}/presentation.html & rls_serve
;;
"export")
if rls_export ; then
printf "${HIGHLIGHT1}You presentation was exported in the ${HIGHLIGHT2}dist${HIGHLIGHT1} folder${NC}\n\n"
else
printf "${ERROR}Something went wrong.${NC}\n\n"
fi
;;
"pdf")
[[ ! -d dist ]] && mkdir dist # If directory "dist" doesn't exist - create it
rls_export_sync_tmp # Export the html with all assets inlined, used as input for the pdf export
if [[ $2 = "--use-title-as-filename" ]]; then
title=$(sed -n 's/^title:[[:space:]]*\(.*\)/\1/p' "presentation.md" | tr ' ' '-')
FILE_NAME=${title}.pdf
else
FILE_NAME=presentation.pdf
fi
rls_pdf $FILE_NAME
rm "${PWD}/.tmp/presentation.html"
printf "${HIGHLIGHT1}You presentation was exported in the ${HIGHLIGHT2}dist${HIGHLIGHT1} folder${NC}\n\n"
;;
"update")
CURRENT_VERSION=$DOCKER_VERSION
get_latest_version
DOCKER_VERSION=${LATEST_DOCKER_VERSION}
# Update package.info with the docker version this presentation is being updated to
echo "#!/usr/bin/env bash" > package.info
echo "DOCKER_VERSION=\"${LATEST_DOCKER_VERSION}\"" >> package.info
printf "Updated to docker image version ${SUCCESS} ${LATEST_DOCKER_VERSION} ${NC}\n\n"
rls_init
# Update logos to the new template. Only needs to be done for pre 1.1.18 version when they were introduced.
if [[ $CURRENT_VERSION < "1.1.32" ]]; then
cp presentation.md presentation.md-bak
sed -i '' 's/background-size: 100%/background-size: cover/g' presentation.md
if [[ $CURRENT_VERSION < "1.1.18" ]]; then
sed -i '' 's/img\/logo\.jpg/img\/logo_dark_text\.png/g' presentation.md
sed -i '' 's/img\/logo_dark_text.jpg/img\/logo_dark_text.png/g' presentation.md
fi
printf "Styling updated to match the new slide template. A backup of the old presentation was created: presentation.md-bak.\n\n"
fi
;;
*)
printf "${HIGHLIGHT2}"
printf "\nUse one of the following arguments:\n"
printf "\t${HIGHLIGHT2}init${HIGHLIGHT1} - Creates a default ${HIGHLIGHT2}presentation.md${HIGHLIGHT1} file you can use as a starting point\n"
printf "\t${HIGHLIGHT2}serve${HIGHLIGHT1} - Serves the slide deck in a browser\n"
printf "\t${HIGHLIGHT2}export${HIGHLIGHT1} - Exports the slide deck as a standalone html file (no dependencies)\n"
printf "\t${HIGHLIGHT2}pdf${HIGHLIGHT1} - Exports the slide deck as a pdf\n"
printf "\t${HIGHLIGHT2}update${HIGHLIGHT1} - Updates an existing presentation to the latest version"
printf "${NC}"
;;
esac