-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeck
More file actions
executable file
·226 lines (157 loc) · 4.06 KB
/
deck
File metadata and controls
executable file
·226 lines (157 loc) · 4.06 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/usr/bin/env bash
appDir=~/.polysync-deck
pathExport='export PATH="$PATH:$HOME/.polysync-deck"'
installDeck () {
# Create the deck dir
mkdir -p $appDir
# move in themes
cp -r themes $appDir/themes
cp deck $appDir/deck
cd $appDir
# Install Decktape
echo ''
echo -e "\e[1m > Installing Decktape \e[0m "
echo ''
curl -L https://github.com/astefanutti/decktape/archive/v1.0.0.tar.gz | tar -xz --exclude phantomjs
cd decktape-1.0.0
# Install Phantom JS Fork
echo ''
echo -e "\e[1m > Installing Phantom JS \e[0m "
echo ''
local OS="$(uname -s)"
case "$OS" in
Linux)
curl -L https://github.com/astefanutti/decktape/releases/download/v1.0.0/phantomjs-linux-x86-64 -o phantomjs
;;
Darwin)
curl -L https://github.com/astefanutti/decktape/releases/download/v1.0.0/phantomjs-osx-cocoa-x86-64 -o phantomjs
;;
MINGW* | MSYS* | CYGWIN*)
local _ostype=pc-windows-gnu
;;
*)
err "unrecognized OS type: $_ostype"
;;
esac
chmod +x phantomjs
echo ''
echo -e "\e[1m > Adding Path \e[0m "
echo ''
# Export Path
# (if it doesn't exist already)
grep -q -F "$pathExport" ~/.zshrc || echo $pathExport >> ~/.zshrc
grep -q -F "$pathExport" ~/.bashrc || echo $pathExport >> ~/.bashrc
# Show help
echo -e "\e[1m > Done \e[0m "
echo ''
echo -e "\e[1mFor basic commands, type \e[34mdeck help\e[0m"
echo ''
}
newDeck () {
name=$1
mkdir $name
cd $name
touch slides.md
mkdir images
mkdir output
git init --quiet
echo "output" >> .gitignore
echo "Deck Created"
}
exportDeck () {
DEFAULT_THEME="polysync"
local currentDir=$(pwd)
local name=${currentDir##*/}
local type=$1
local theme=${2:-$DEFAULT_THEME}
local tempHTML="temp.html"
local outputDir="output"
[ -e $tempHTML ] && rm $tempHTML
# Build the temp HTML
cat $appDir/themes/$theme/header.html >> $tempHTML
cat slides.md >> $tempHTML
cat $appDir/themes/$theme/footer.html >> $tempHTML
case "$type" in
pdf)
echo ">>>> Building PDF"
cd $appDir/decktape-1.0.0
./phantomjs decktape.js "$currentDir/$tempHTML" "$currentDir/$outputDir/$name.pdf"
;;
html)
echo ">>>> Exporting HTML"
# Remove if exists
[ -e $outputDir/$name ] && rm -rf $outputDir/$name
mkdir $outputDir/$name
# Move in new files
mv $tempHTML $outputDir/$name/index.html
cp -r images/ $outputDir/$name/images/
;;
*)
err "$command is not a valid type."
;;
esac
[ -e $tempHTML ] && rm $tempHTML
echo "Done"
open "$currentDir/$outputDir"
}
showHelp () {
echo ""
echo "---------------------"
echo ""
echo -e "\e[34m\e[1m▣ PolySync Deck \e[0m "
echo ""
echo "Usage : deck [ command ] "
echo ""
echo "Commands : "
echo ""
echo -e " \e[1m install \e[0m"
echo -e " \e[2m- install deck files to ~/.polysync-deck \e[0m"
echo -e " \e[1m help \e[0m "
echo -e " \e[2m- open help (this) \e[0m"
echo -e " \e[1m new [project-name] \e[0m"
echo -e " \e[2m- create a new deck \e[0m"
echo -e " \e[1m export [filetype] [theme-name] \e[0m"
echo -e " \e[2m- export deck \e[0m"
echo -e " \e[1m themes \e[0m"
echo -e " \e[2m- open themes folder \e[0m"
echo -e " \e[1m uninstall \e[0m"
echo -e " \e[2m- zap deck \e[0m"
echo ""
echo "Export Filetypes : pdf, html"
echo ""
echo "---------------------"
}
uninstall () {
echo ">>>> Uninstalling ..."
# Remove Path
grep -v "polysync-deck" ~/.zshrc > ~/.zshrc-temp; mv ~/.zshrc-temp ~/.zshrc
grep -v "polysync-deck" ~/.bashrc > ~/.bashrc-temp; mv ~/.bashrc-temp ~/.bashrc
[ -e $appDir ] && rm -rf $appDir
echo "Done."
}
command=$1
case "$command" in
install)
installDeck
;;
help)
showHelp
;;
new)
newDeck $2
;;
themes)
open $appDir/themes
;;
export)
type=$2
theme=$3
exportDeck $name $type $theme
;;
uninstall)
uninstall
;;
*)
err "Hmm ... $command is no a command I understand."
;;
esac