forked from arthurevans/doctools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_confluence.sh
132 lines (123 loc) · 4.81 KB
/
get_confluence.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
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
#####################################################################
## Purpose: Get the latest version of the guide2 Confluence space ##
## so one can have one piece of the documentation puzzle. ##
## ##
## For more information visit ##
## https://wiki.appcelerator.org/x/MJzBAg ##
#####################################################################
SECONDS=0
DATE=$(date +%Y-%m-%d)
CONFLUENCE_FILE=confluence_guide2-$DATE.zip
date
DOCTOOLSDIR=$TI_ROOT/doctools
HTMLGUIDESDIR=$DOCTOOLSDIR/htmlguides
WORKINGDIR=$TI_ROOT/Confluence_working
## function to download guide2 confluence space
function downloadJarFile() {
REST_URL='https://wiki.appcelerator.org/rest/scroll-eclipsehelp/1.0/sync-export?exportSchemeId=guides2-7F000001015A6C6CD20B1E0B58AE1D82&rootPageId=29004729'
wget --content-disposition "$REST_URL&os_username=$CONFLUENCE_USERNAME&os_password=$CONFLUENCE_PASSWORD"
## rename the downloaded .jar file to include the a human readable name
mv com.*.jar $CONFLUENCE_FILE
## If the working Confluence directory doesn't exist, create it
if [ -d $WORKINGDIR ]; then
cd $TI_ROOT
mkdir Confluence_working
cd -
fi
## move .jar file to working directory
mv $CONFLUENCE_FILE $WORKINGDIR
}
unzipFile() {
## detect if the htmlguides directory is populated or not
cd $HTMLGUIDESDIR
current=${PWD}
if [ "$(ls -A $HTMLGUIDESDIR)" ]; then
echo "Emptying $current"
rm -r *
echo "Unzipping $WORKINGDIR/$CONFLUENCE_FILE in $current"
unzip -o $WORKINGDIR/$CONFLUENCE_FILE
else
## current directory is empty; unzip files in it.
echo "Current directory is empty; proceeding with unzipping of $CONFLUENCE_FILE."
echo "Unzipping $WORKINGDIR/$CONFLUENCE_FILE in $current"
unzip -o $WORKINGDIR/$CONFLUENCE_FILE
fi
}
parse_xml() {
#cd $DOCTOOLSDIR
## parse the $TI_ROOT/doctools/htmlguides/toc.xml file for items related to TIDOC-2718
#node $DOCTOOLSDIR/parse_xml $HTMLGUIDESDIR toc.xml
echo "Parsing $HTMLGUIDESDIR/toc.xml"
}
## Create a series of potentially missing directories
## if the htmlguides directory is missing, add it back in
if [ ! -d $HTMLGUIDESDIR ]; then
echo "htmlguide directory is missing. Creating that directory."
mkdir $HTMLGUIDESDIR
fi
## empty the output directory of the guides
if [ -d $HTMLGUIDESDIR ]; then
echo "Emptying ../htmlguides directory."
cd $HTMLGUIDESDIR
rm -r *
fi
## this addition of the dist/platform and dist/arrowdb directories are not necessary for the creation of the htmlguides content but this directory is wiped out from the update_modules.sh script and needs to be added back in before the doc pub can finish.
if [ ! -d $DOCTOOLSDIR/dist/platform ]; then
echo "../dist/platform directory is missing. Creating that directory."
mkdir -p $DOCTOOLSDIR/dist/platform
fi
if [ ! -d $DOCTOOLSDIR/dist/arrowdb ]; then
echo "../dist/arrowdb directory is missing. Creating that directory."
mkdir -p $DOCTOOLSDIR/dist/arrowdb
fi
## if the Confluence_working is missing, create it
if [ ! -d $WORKINGDIR ]; then
echo "../Confluence_working directory is missing. Create that directory."
mkdir $WORKINGDIR
fi
if [ -s $WORKINGDIR/$CONFLUENCE_FILE ]; then
printf "$CONFLUENCE_FILE exists. Do you wish to download it again, unzip the current file, or download and unzip latest version (total package)? [d]ownload/[u]nzip/[t]otal?"
read -r input
if [ $input == "download" ] || [ $input == "d" ]; then
echo "Downloading today's guide2 .jar file."
downloadJarFile
elif [ $input == "unzip" ] || [ $input == "u" ]; then
echo "Unzipping the existing guide2 file in $HTMLGUIDESDIR."
cd $HTMLGUIDESDIR
unzipFile
parse_xml
elif [ $input == "total" ] || [ $input == "t" ]; then
echo "Downloading latest version of guide2 space and unzipping in $HTMLGUIDESDIR."
downloadJarFile
cd $HTMLGUIDESDIR
unzipFile
parse_xml
else
Echo "Quitting"
fi
else
echo "The guide2 .jar file is out of date or does not exist. Downloading today's version."
## download .jar file into a working directory outside of htmlguides directory
downloadJarFile
unzipFile
parse_xml
fi
printf "Do you need to edit ../doctools/toc.xml?"
read -r edit
if [ $edit == "yes" ] || [ $edit == "y" ]; then
open $DOCTOOLSDIR/toc.xml
else
echo "Skip opening/editing $DOCTOOLSDIR/toc.xml"
fi
## temp fix to copy the ../doctools/toc.xml to ../doctools/htmlguides/
printf "Copy ../doctools/toc.xml to ../doctools/htmlguides/?"
read -r copy
if [ $copy == "yes" ] || [ $copy == "y" ]; then
echo "copying ../doctools/toc.xml to ../doctools/htmlguides/"
cp $DOCTOOLSDIR/toc.xml $HTMLGUIDESDIR/
else
echo "If you need to update the $HTMLGUIDESDIR/toc.xml file, do it before"
echo "executing the documentation build script."
fi
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."