annotate createHTML.sh @ 5:4e21ce709269 draft

Uploaded
author saskia-hiltemann
date Tue, 07 Oct 2014 08:49:14 -0400
parents a4813532bbc6
children 42076db43d42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
1 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
2 ## Create Cover Page
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
3 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 function makeIntroPage ( ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 echo "Creating Intro Page"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 title="$1"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 coverimage=$2
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 link=$3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 htmlout=$4
1
440f4aa3db97 Added option to dowload iReports
saskia-hiltemann
parents: 0
diff changeset
10 zipireport=$5
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 echo -e "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 <html>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 <head>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 </head>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 <body>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 <br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 <br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 <center>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 <b><font size=\"15\"> iReport: ${title} </font></b><br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 <br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 <br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 <a href=\"$link\"> Click here to view report </a> <br/><br/>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 <a href=\"$link\"> <img src="$coverimage" width=\"50%\" alt=\"loading image..\"/> </a><br/><br/>
1
440f4aa3db97 Added option to dowload iReports
saskia-hiltemann
parents: 0
diff changeset
25 <a href=\"$zipireport\"> Click here to download a copy of this iReport </a> <br/><br/>
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 </center>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 </body>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 </html>" > $htmlout
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
32 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
33 ## Create HTML content for the tabs specified by user
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
34 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 function makeTabContent ( ){
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
36 tab=$1 # name of current tab
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
37 itemslist=$2 # list of all items
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
38 contentline="" # HTML code for tab
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
39 imgcount=0 # keep track of the number of images on the current tab
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 for item in $itemslist
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 do
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
43 ## Parse items lists
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 item=${item/::/:emptycol:}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 declare -a myarr=(`echo $item |sed 's/:/ /g'`)
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
46
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
47 ## Create the tab contents HTML code
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 if [ ${myarr[0]} == $tab ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
51 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
52 ## Text Field
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
53 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 if [ ${myarr[1]} == "text" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 text=${myarr[2]}
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
57 md=${myarr[4]}
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
59 # if markdown, convert to html
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
60 if [ $md == "Y" ]
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
61 then
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
62 ## resubstitute sanitized charachters
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
63 text=${text//==space==/ }
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
64 text=${text//==colon==/:}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
65 text=${text//==comma==/,}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
66 text=${text//==slash==/\/}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
67 text=${text//==lt==/<}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
68 text=${text//==gt==/>}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
69 text=${text//==apos==/\'}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
70 text=${text//==quote==/\"}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
71 text=${text//==backtick==/\`}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
72 text=${text//==dollar==/$}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
73 text=${text//==bar==/|}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
74 text=${text//&&/&}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
75 text=${text//\\n/\\n}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
76 text=${text//\\t/\\t}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
77 text=${text//\&r\&n/\\n}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
78 text=${text//\&r/\\n}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
79 text=${text//\&n/\\n}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
80 text=${text//\&c/:}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
81
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
82
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
83 ## convert markdown in textfield to html
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
84 echo -e "$text" > mytext.md
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
85
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
86 if [ -z `type -p pandoc` ]
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
87 then
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
88 # pandoc missing
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
89 ${repositorypath}/Markdown/markdown2.py mytext.md > mytext.html
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
90
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
91 else
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
92 # pandoc exists
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
93 echo "pandoc exists"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
94 pandoc -o mytext.html mytext.md
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
95 pandoc -o standalone.html -s mytext.md
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
96
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
97 #get css generated by pandoc and add as scoped attribute (HTML5)
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
98 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html`
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
99 fi
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
100
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
101 markdowntext=$(cat mytext.html)
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
102 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
103
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
104 else # If not markdown, print verbatim (with exception of few html tags)
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
106 ## allow some html formatting tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
107 text=${text//==lt==strong==gt==/<strong>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
108 text=${text//==lt====slash==strong==gt==/<\/strong>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
109 text=${text//==lt==em==gt==/<em>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
110 text=${text//==lt====slash==em==gt==/<\/em>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
111
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
112 text=${text//==lt==b==gt==/<strong>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
113 text=${text//==lt====slash==b==gt==/<\/strong>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
114 text=${text//==lt==i==gt==/<em>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
115 text=${text//==lt====slash==i==gt==/<\/em>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
116
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
117 text=${text//==lt==br==gt==/<br\/>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
118 text=${text//==lt====br==slash==gt==/<br\/>} # search for strong tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
119 text=${text//==lt==h1==gt==/<h1>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
120 text=${text//==lt==h2==gt==/<h2>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
121 text=${text//==lt==h3==gt==/<h3>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
122 text=${text//==lt==h4==gt==/<h4>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
123 text=${text//==lt==h5==gt==/<h5>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
124 text=${text//==lt==h6==gt==/<h6>} # search for h1-h6 tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
125 text=${text//==lt====slash==h1==gt==/<\/h1>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
126 text=${text//==lt====slash==h2==gt==/<\/h2>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
127 text=${text//==lt====slash==h3==gt==/<\/h3>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
128 text=${text//==lt====slash==h4==gt==/<\/h4>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
129 text=${text//==lt====slash==h5==gt==/<\/h5>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
130 text=${text//==lt====slaxh==h6==gt==/<\/h6>} # search for h1-h6 closing tags
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
131
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
132 ## display everything else verbatim
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
133 text=${text//==space==/ }
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
134 text=${text//==colon==/:}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
135 text=${text//==comma==/,}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
136 text=${text//==slash==/\/}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
137 text=${text//==lt==/&lt;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
138 text=${text//==gt==/&gt;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
139 text=${text//==apos==/&apos;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
140 text=${text//==quote==/&quot;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
141 text=${text//&&/&amp;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
142 text=${text//\\n/<br/>}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
143 text=${text//\\t/&emsp;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
144 text=${text//\&r\&n/<br/>}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
145 text=${text//\&r/<br/>}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
146 text=${text//\&n/<br/>}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
147 text=${text//\&c/:}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
148 text=${text//==backtick==/&#96;}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
149 text=${text//==dollar==/$}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
150 text=${text//==bar==/|}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
151 contentline="${contentline}\n${text}\n"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
152 fi
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
153
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
154
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
155 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
156
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
157 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
158 ## Text File
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
159 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
160 if [ ${myarr[1]} == "textfile" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
161 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
162 tfile=${myarr[2]}
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
163 md=${myarr[4]}
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
164 fname=`basename ${tfile}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
165 fname=${fname%.*}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
166 fname="${fname}.txt"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
167 cp ${tfile} "${galaxypath}/${fname}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
168
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
169 #estimate height for iframe based on number oflines in the file
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
170 numlines=`wc -l ${tfile} | cut -d" " -f1`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
171 minheight=$[$numlines*17]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
172
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
173 # if markdown, convert to html
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
174 if [ $md == "Y" ]
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
175 then
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
176
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
177 if [ -z `type -p pandoc` ]
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
178 then
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
179 # pandoc missing
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
180 ${repositorypath}/Markdown/markdown2.py ${tfile} > mytext.html
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
181
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
182 else
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
183 # pandoc exists
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
184 pandoc -o mytext.html ${tfile}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
185 pandoc -o standalone.html -s ${tfile}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
186
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
187 # get css generated by pandoc and add as scoped attribute (HTML5)
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
188 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html`
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
189
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
190 fi
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
191
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
192 markdowntext=$(cat mytext.html)
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
193 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
194 else
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
195 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${fname}\" width=\"100%\" height=\"$minheight\"> </iframe>\n"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
196 fi
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
197 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
198
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
199 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
200 ## Image
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
201 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
202 if [ ${myarr[1]} == "image" ]
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
203
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
204 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
205 imgcount=$[$imgcount+1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
206 #restore file suffix for html
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
207 ftype=`file ${myarr[2]}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
208 zoomlevel=${myarr[4]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
209 zoomenable=${myarr[5]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
210 align=${myarr[6]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
211 #####echo "zoomenable:${zoomenable}, align:${align}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
212 if [[ $ftype == *JPEG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
213 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
214 suffix=".jpg"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
215 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
216 if [[ $ftype == *SVG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
217 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
218 suffix=".svg"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
219 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
220 if [[ $ftype == *PNG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
221 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
222 suffix=".png"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
223 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
224
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
225 image=`basename ${myarr[2]}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
226 image=${image%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
227 image="${image}${suffix}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
228 cp ${myarr[2]} ${galaxypath}/${image}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
230 if [[ ${align} == "none" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
231 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
232 alignstring=""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
233 alignstring2=""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
234 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
235 alignstring="<div float=\"${align}\">"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
236 alignstring2="</div>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
237
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
238 alignstring="align=\"${align}\""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
239 alignstring2=""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
240 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
241
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
242
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
243 if [[ ${zoomlevel} -eq 0 ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
244 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
245 widthstring=""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
246 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
247 widthstring="width=\"${zoomlevel}\""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
248 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
249
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
250 if [[ ${zoomlevel} -eq 0 || ${zoomenable} == "N" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
251 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
252 contentline="${contentline}<span id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
253 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
254 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
255 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
256
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
257 fi
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
258
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
259 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
260 ## Table
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
261 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
262 if [ ${myarr[1]} == "table" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
263 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
264 maxlines=50000
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
265 tsvfile_orig=${myarr[2]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
266 tsvfile="tablehead.tsv"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
267 fname=`basename ${tsvfile_orig}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
268 fname=${fname%.*}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
269 fancy=${myarr[4]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
270 makelinks=${myarr[5]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
271 #echo "\nmakelinks: $makelinks fancy: $fancy <br>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
273 #TODO client side database for large files. For now only display first section of file and add download link
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
274 numlines=`wc -l ${tsvfile_orig} |cut -d" " -f1`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
276 head -${maxlines} ${tsvfile_orig} > tsvtmpfile
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
277
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
278 #remove any empty or header lines (lines starting with #, unless vcf file, then keep #CHROM line)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
279 awk 'BEGIN{
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
280 FS="\t"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
281 OFS="\t"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
282 }{
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
283 if((index($0,"#")==1 && index($0,"#CHROM")!=1) || $0==""){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
284 headerlines++
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
285 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
286 else print $0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
287
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
288 }END{}' tsvtmpfile > ${tsvfile}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
289
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
290 if [[ $makelinks == "Y" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
291 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
292 col=${myarr[6]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
293 prefix=${myarr[7]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
294 suffix=${myarr[8]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
295 suffix=${suffix/emptycol/}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
296 suffix=${suffix/==quote==/&}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
297 prefix=${prefix/emptycol/}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
298 prefix=${prefix/==quote==/&}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
299 prefix=${prefix/==colon==/:}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
300 #echo "prefix: $prefix"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
301
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
302 #edit the table to include links
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
303 awk 'BEGIN{
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
304 FS="\t"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
305 OFS="\t"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
306 url="'"$prefix"'"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
307 url2="'"$suffix"'"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
308 prefix="<a href=\42"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
309 suffix="\42>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
310 col="'"$col"'"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
311 end="</a>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
312 }{
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
313 if(FNR==1)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
314 print $0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
315 else{
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
316 $col=prefix""url""$col""url2""suffix""$col""end
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
317 print $0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
318 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
319 }END{}' ${tsvfile} > ${tsvfile}2
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
320
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
321 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
322 cp ${tsvfile} ${tsvfile}2
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
323 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
324
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
325 if [ $fancy == "Y" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
326 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
327 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
328 contentline="${contentline}\n<iframe class=\"invisibleframe fancyiframe\" src=\"htmltable_${fname}.html\" width=\"100%\" style=\"min-height: 525px; overflow-y: hidden; overflow-x: scroll\" ></iframe>"
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
329 iframecount=$[$iframecount+1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
330 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
331 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
332 contentline="${contentline}\n<iframe class=\"unfancyiframe invisibleframe\" src=\"htmltable_${fname}.html\" scrolling=\"no\" style=\"max-width: 100%; vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
333 iframecount=$[$iframecount+1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
334 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
335
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
336 if [[ $numlines -gt ${maxlines} ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
337 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
338 tablename=`basename ${tsvfile_orig}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
339 cp ${tsvfile_orig} ${galaxypath}/$tablename
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
340 contentline="${contentline}<br/>\nLarge tables will be supported soon. The first ${maxlines} lines are shown here, and you can download the full file <a href=\"${tablename}\">here</a>."
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
341 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
342 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
343
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
344 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
345 ## PDF
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
346 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
347 if [[ ${myarr[1]} == "pdf" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
348 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
349 pdffile=${myarr[2]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
350 fname=`basename ${pdffile}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
351 fname=${fname%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
352 pdfname="${fname}.pdf"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
353 cp ${pdffile} "${galaxypath}/${pdfname}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
354
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
355 width=1000
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
356 height=800
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
357 echo -e "<html><body><object data=\"${pdfname}\" type=\"application/pdf\" width=\"$width\" height=\"$height\"><embed src=\"${pdfname}\" type=\"application/pdf\" /><p>It appears you have no PDF plugin for your browser. No biggie... you can <a href=\"${pdfname}\">click here to download the PDF file.</a></p></object></body></html>" > "${galaxypath}/${fname}.html"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
358 width=$[$width+10]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
359 height=$[$height+10]
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
360 contentline="${contentline}\n<iframe src=\"${fname}.html\" width=\"${width}\" height=\"${height}\"></iframe>\n"
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
361
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
362 fi
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
363
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
364 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
365 ## HTML
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
366 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
367 if [[ ${myarr[1]} == "htmlfile" ]]
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
368 then
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
369 htmlfile=${myarr[2]}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
370 height=${myarr[4]}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
371 fname=`basename ${htmlfile}`
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
372 fname=${fname%.dat}
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
373 htmlname="${fname}.html"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
374 cp ${htmlfile} "${galaxypath}/${htmlname}"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
375
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
376 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n"
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
377 fi
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
378
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
379 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
380 ## Web Link
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
381 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
382 if [ ${myarr[1]} == "weblink" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
383 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
384 url=${myarr[2]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
385 linktext=${myarr[4]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
386 url=${url/==colon==/:}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
387 url=${url/==quote==/&}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
388
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
389 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
390 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
391
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
392 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
393 ## Link to Dataset
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
394 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
395 if [ ${myarr[1]} == "link" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
396 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
397 linkfile=${myarr[2]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
398 apiid=${myarr[4]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
399 isireport=${myarr[5]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
400 linkfilename=`basename ${linkfile}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
401 linktext=${myarr[6]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
402
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
404 #check for some basic filetypes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
405 ftype=`file $linkfile`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
406 if [[ $ftype == *HTML* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
407 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
408 linkfilename=${linkfilename%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
409 linkfilename=${linkfilename}.html
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
410 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
411 if [[ $ftype == *PNG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
412 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
413 linkfilename=${linkfilename%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
414 linkfilename=${linkfilename}.png
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
415 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
416 if [[ $ftype == *SVG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
417 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
418 linkfilename=${linkfilename%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
419 linkfilename=${linkfilename}.svg
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
420 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
421 if [[ $ftype == *JPEG* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
422 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
423 linkfilename=${linkfilename%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
424 linkfilename=${linkfilename}.jpg
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
425 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
426
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
427
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
428 if [[ ${isireport} == "Y" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
429 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
430 linkfilename="/datasets/${apiid}/display/"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
431 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
432 cp ${linkfile} "${galaxypath}/${linkfilename}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
433 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
435 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
436 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
437
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
438 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
439 ## Links to Archive Contents
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
440 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
441 if [[ ${myarr[1]} == "links" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
442 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
443 #echo "making links:"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
444 archive=${myarr[2]}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
445 fname=`basename ${archive}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
446 fname=${fname%.dat}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
447 ftype=`file $archive`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
448 mkdir ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
449
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
450 #echo "archive type: `file $archive`"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
451 # decompress archive
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
452 if [[ $ftype == *Zip* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
453 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
454 #echo "detected zip file"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
455 cp $archive ${galaxypath}/archive_${fname}/${fname}.zip
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
456 wd=`pwd`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
457 cd ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
458 unzip -q ${fname}.zip
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
459 rm ${fname}.zip
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
460 cd $wd
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
461 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
462 if [[ $ftype == *tar* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
463 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
464 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
465 wd=`pwd`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
466 cd ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
467 tar xf ${fname}.tar
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
468 rm ${fname}.tar
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
469 cd $wd
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
470 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
471 if [[ $ftype == *gzip* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
472 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
473 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
474 gunzip ${galaxypath}/archive_${fname}/${fname}.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
475 #ls ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
476
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
477 # check for tar.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
478 ftype=`file ${galaxypath}/archive_${fname}/${fname}`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
479 if [[ $ftype == *tar* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
480 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
481 # turns out it was tar.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
482 rm -Rf ${galaxypath}/archive_${fname}/*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
483 ls ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
484 cp $archive ${galaxypath}/archive_${fname}/${fname}.tar.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
485
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
486 wd=`pwd`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
487 cd ${galaxypath}/archive_${fname}/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
488 tar xzf ${fname}.tar.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
489 cd $wd
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
490 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
491 wait
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
492 rm -f ${galaxypath}/archive_${fname}/*.tar
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
493 rm -f ${galaxypath}/archive_${fname}/*.tar.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
494 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
495 if [[ $ftype == *bzip2* ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
496 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
497 cp $archive ${galaxypath}/archive_${fname}/${fname}.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
498 gunzip2 ${galaxypath}/archive_${fname}/${fname}.gz
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
499 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
500
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
501
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
502
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
503 # add links to webpage
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
504 # separate line for each folder, files within folder on same line
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
505 for linkfile in `ls ${galaxypath}/archive_${fname}/ |sort -V`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
506 do
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
507 #echo "<br/> ->making link to file: $linkfile "
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
508 if [ -d ${galaxypath}/archive_${fname}/$linkfile ] # if directory, add break, and list all contained files, max level 1 deep
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
509 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
510 #echo "<br/> ->is directory, entering: $linkfile "
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
511 #ls ${galaxypath}/archive_${fname}/$linkfile
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
512 contentline="${contentline}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
513 for linkfile2 in `ls ${galaxypath}/archive_${fname}/$linkfile | sort -V`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
514 do
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
515 #echo "<br/> ->making link to file: ${galaxypath}/archive_${fname}/$linkfile2"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
516 if [ -f ${galaxypath}/archive_${fname}/$linkfile/$linkfile2 ] # if directory, add break, and list all contained files, max level 1 deep
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
517 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
518 #echo "<br/> ->is file, making link: $linkfile "
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
519 label=`basename $linkfile2`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
520 label=${label%.*}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
521 contentline="${contentline}<a class=\"mylinks\" href=\"archive_${fname}/${linkfile}/${linkfile2}\">${label}</a>&nbsp;\n "
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
522 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
523 done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
524 elif [ -f ${galaxypath}/archive_${fname}/$linkfile ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
525 then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
526 label=`basename ${galaxypath}/archive_${fname}/$linkfile`
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
527 label=${label%.*}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
528 contentline="${contentline}<a class=\"mylinks\" href=\"archive_${fname}/${linkfile}\">$label</a>&nbsp;\n"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
529 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
530 done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
531
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
532
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
533 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
534
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
535 if [[ ${myarr[3]} == "Y" ]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
536 then
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
537 contentline="${contentline}<br/>\n"
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
538 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
539 fi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
540 done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
541
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
542 echo "${contentline}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
543 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
544
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
545 ##
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
546 ## Create HTML content for iReport
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
547 ##
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
548 createMainPage (){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
549 page=$1
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
550 tabtitles=$2 # comma-separated list of tab titles
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
551 tabitems=$3 # colon-sparated list of tabs specifications
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
552 iframecount=1 # keep track of number of iFrames so that they can be referenced by ID
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
553 minwidth=$4 # width of page
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
554
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
555 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
556 # create correct number of tabs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
557 count=0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
558
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
559 tabtitles=${tabtitles//,/ }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
560 tabtitles=${tabtitles//==colon==/:}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
561 tabslist="<ul>\n"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
562 mytabs=""
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
563
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
564 for title in $tabtitles
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
565 do
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
566 # Create list of tabs
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
567 count=$[count+1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
568 title2=${title//_s_/ }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
569 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
570
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
571 # Create tabs with content
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
572 tabcontent=$(makeTabContent $title "$tabitems")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
573 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
574 mytabs="${mytabs}${tabcontent}"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
575 mytabs="${mytabs}\n</div>\n"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
576 done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
577 tabslist="${tabslist}</ul>"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
578
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
579 ## Output the webpage
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
580 echo -e "<!doctype html>
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
581 <head>
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
582 <meta charset=\"utf-8\">
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
583 <title>iReport</title>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
584 <link rel=\"stylesheet\" href=\"jquery-ui.css\">
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
585 <link rel=\"stylesheet\" href=\"ireport_css.css\">
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
586 <link rel=\"stylesheet\" href=\"md.css\">
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
587 <script type=\"text/javascript\" src=\"jquery-1.10.2.js\"></script>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
588 <script type=\"text/javascript\" src=\"jquery-ui.js\"></script>
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
589 <script type=\"text/javascript\" src=\"iframe-resizer/src/iframeResizer.js\"></script>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
590 <script type=\"text/javascript\" src=\"jquery.zoom.js\"></script>
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
591 <script type=\"text/javascript\" src=\"ireport_jquery.js\"></script>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
592 <script type=\"text/javascript\" src=\"ireport_javascript.js\"></script>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
593 </head>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
594 <body>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
595 <div id=\"tabs\" style=\"display:inline-block; min-height:100%; min-width:${minwidth}px\">
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
596 $tabslist
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
597
4
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
598 $mytabs
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
599 </div>
a4813532bbc6 Added MarkDown support
saskia-hiltemann
parents: 1
diff changeset
600 </body>
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
601 </html>" > $page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
602 }