Mercurial > repos > saskia-hiltemann > ireport
comparison createHTML.sh @ 4:a4813532bbc6 draft
Added MarkDown support
author | saskia-hiltemann |
---|---|
date | Tue, 07 Oct 2014 08:41:30 -0400 |
parents | 440f4aa3db97 |
children | 42076db43d42 |
comparison
equal
deleted
inserted
replaced
3:4a6ebda2a3ae | 4:a4813532bbc6 |
---|---|
1 ## | |
2 ## Create Cover Page | |
3 ## | |
1 function makeIntroPage ( ){ | 4 function makeIntroPage ( ){ |
2 echo "Creating Intro Page" | 5 echo "Creating Intro Page" |
3 title="$1" | 6 title="$1" |
4 coverimage=$2 | 7 coverimage=$2 |
5 link=$3 | 8 link=$3 |
9 echo -e "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> | 12 echo -e "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> |
10 <html> | 13 <html> |
11 <head> | 14 <head> |
12 </head> | 15 </head> |
13 <body> | 16 <body> |
14 <!-- dummy intro page, since first page will not have any javascript/css features enabled unless specified in universe_wsgi.ini file, but subsequent pages will --> | |
15 <br/> | 17 <br/> |
16 <br/> | 18 <br/> |
17 <center> | 19 <center> |
18 <b><font size=\"15\"> iReport: ${title} </font></b><br/> | 20 <b><font size=\"15\"> iReport: ${title} </font></b><br/> |
19 <br/> | 21 <br/> |
25 </body> | 27 </body> |
26 </html>" > $htmlout | 28 </html>" > $htmlout |
27 | 29 |
28 } | 30 } |
29 | 31 |
30 | 32 ## |
33 ## Create HTML content for the tabs specified by user | |
34 ## | |
31 function makeTabContent ( ){ | 35 function makeTabContent ( ){ |
32 tab=$1 #name of current tab | 36 tab=$1 # name of current tab |
33 itemslist=$2 #list of all items | 37 itemslist=$2 # list of all items |
34 contentline="<br/>" | 38 contentline="" # HTML code for tab |
35 imgcount=0 | 39 imgcount=0 # keep track of the number of images on the current tab |
36 #echo -e "\n Creating items. itemslist: $itemslist" | |
37 | 40 |
38 for item in $itemslist | 41 for item in $itemslist |
39 do | 42 do |
40 #echo -e "\n -> item : $item" | 43 ## Parse items lists |
41 item=${item/::/:emptycol:} | 44 item=${item/::/:emptycol:} |
42 declare -a myarr=(`echo $item |sed 's/:/ /g'`) | 45 declare -a myarr=(`echo $item |sed 's/:/ /g'`) |
43 #echo "break: ${myarr[3]}" | 46 |
47 ## Create the tab contents HTML code | |
44 if [ ${myarr[0]} == $tab ] | 48 if [ ${myarr[0]} == $tab ] |
45 then | 49 then |
46 | 50 |
47 ## add contents of text field to page#### | 51 ## |
52 ## Text Field | |
53 ## | |
48 if [ ${myarr[1]} == "text" ] | 54 if [ ${myarr[1]} == "text" ] |
49 then | 55 then |
50 text=${myarr[2]} | 56 text=${myarr[2]} |
51 ## allow some html formatting tags | 57 md=${myarr[4]} |
52 text=${text//==lt==strong==gt==/<strong>} # search for strong tags | 58 |
53 text=${text//==lt====slash==strong==gt==/<\/strong>} # search for strong tags | 59 # if markdown, convert to html |
54 text=${text//==lt==em==gt==/<em>} # search for strong tags | 60 if [ $md == "Y" ] |
55 text=${text//==lt====slash==em==gt==/<\/em>} # search for strong tags | 61 then |
56 | 62 ## resubstitute sanitized charachters |
57 text=${text//==lt==b==gt==/<strong>} # search for strong tags | 63 text=${text//==space==/ } |
58 text=${text//==lt====slash==b==gt==/<\/strong>} # search for strong tags | 64 text=${text//==colon==/:} |
59 text=${text//==lt==i==gt==/<em>} # search for strong tags | 65 text=${text//==comma==/,} |
60 text=${text//==lt====slash==i==gt==/<\/em>} # search for strong tags | 66 text=${text//==slash==/\/} |
61 | 67 text=${text//==lt==/<} |
62 text=${text//==lt==br==gt==/<br\/>} # search for strong tags | 68 text=${text//==gt==/>} |
63 text=${text//==lt====br==slash==gt==/<br\/>} # search for strong tags | 69 text=${text//==apos==/\'} |
64 text=${text//==lt==h1==gt==/<h1>} # search for h1-h6 tags | 70 text=${text//==quote==/\"} |
65 text=${text//==lt==h2==gt==/<h2>} # search for h1-h6 tags | 71 text=${text//==backtick==/\`} |
66 text=${text//==lt==h3==gt==/<h3>} # search for h1-h6 tags | 72 text=${text//==dollar==/$} |
67 text=${text//==lt==h4==gt==/<h4>} # search for h1-h6 tags | 73 text=${text//==bar==/|} |
68 text=${text//==lt==h5==gt==/<h5>} # search for h1-h6 tags | 74 text=${text//&&/&} |
69 text=${text//==lt==h6==gt==/<h6>} # search for h1-h6 tags | 75 text=${text//\\n/\\n} |
70 text=${text//==lt====slash==h1==gt==/<\/h1>} # search for h1-h6 closing tags | 76 text=${text//\\t/\\t} |
71 text=${text//==lt====slash==h2==gt==/<\/h2>} # search for h1-h6 closing tags | 77 text=${text//\&r\&n/\\n} |
72 text=${text//==lt====slash==h3==gt==/<\/h3>} # search for h1-h6 closing tags | 78 text=${text//\&r/\\n} |
73 text=${text//==lt====slash==h4==gt==/<\/h4>} # search for h1-h6 closing tags | 79 text=${text//\&n/\\n} |
74 text=${text//==lt====slash==h5==gt==/<\/h5>} # search for h1-h6 closing tags | 80 text=${text//\&c/:} |
75 text=${text//==lt====slaxh==h6==gt==/<\/h6>} # search for h1-h6 closing tags | 81 |
76 | 82 |
77 ## display everything else verbatim | 83 ## convert markdown in textfield to html |
78 text=${text//==space==/ } | 84 echo -e "$text" > mytext.md |
79 text=${text//==colon==/:} | 85 |
80 text=${text//==comma==/,} | 86 if [ -z `type -p pandoc` ] |
81 text=${text//==slash==/\/} | 87 then |
82 text=${text//==lt==/<} | 88 # pandoc missing |
83 text=${text//==gt==/>} | 89 ${repositorypath}/Markdown/markdown2.py mytext.md > mytext.html |
84 text=${text//==apos==/'} | 90 |
85 text=${text//==quote==/"} | 91 else |
86 text=${text//&&/&} | 92 # pandoc exists |
87 text=${text//\\n/<br/>} | 93 echo "pandoc exists" |
88 text=${text//\\t/ } | 94 pandoc -o mytext.html mytext.md |
89 text=${text//\&r\&n/<br/>} | 95 pandoc -o standalone.html -s mytext.md |
90 text=${text//\&r/<br/>} | 96 |
91 text=${text//\&n/<br/>} | 97 #get css generated by pandoc and add as scoped attribute (HTML5) |
92 text=${text//\&c/:} | 98 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html` |
93 contentline="${contentline}${text}" | 99 fi |
94 fi | 100 |
95 | 101 markdowntext=$(cat mytext.html) |
96 ## add contents of a text file to page | 102 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n" |
103 | |
104 else # If not markdown, print verbatim (with exception of few html tags) | |
105 | |
106 ## allow some html formatting tags | |
107 text=${text//==lt==strong==gt==/<strong>} # search for strong tags | |
108 text=${text//==lt====slash==strong==gt==/<\/strong>} # search for strong tags | |
109 text=${text//==lt==em==gt==/<em>} # search for strong tags | |
110 text=${text//==lt====slash==em==gt==/<\/em>} # search for strong tags | |
111 | |
112 text=${text//==lt==b==gt==/<strong>} # search for strong tags | |
113 text=${text//==lt====slash==b==gt==/<\/strong>} # search for strong tags | |
114 text=${text//==lt==i==gt==/<em>} # search for strong tags | |
115 text=${text//==lt====slash==i==gt==/<\/em>} # search for strong tags | |
116 | |
117 text=${text//==lt==br==gt==/<br\/>} # search for strong tags | |
118 text=${text//==lt====br==slash==gt==/<br\/>} # search for strong tags | |
119 text=${text//==lt==h1==gt==/<h1>} # search for h1-h6 tags | |
120 text=${text//==lt==h2==gt==/<h2>} # search for h1-h6 tags | |
121 text=${text//==lt==h3==gt==/<h3>} # search for h1-h6 tags | |
122 text=${text//==lt==h4==gt==/<h4>} # search for h1-h6 tags | |
123 text=${text//==lt==h5==gt==/<h5>} # search for h1-h6 tags | |
124 text=${text//==lt==h6==gt==/<h6>} # search for h1-h6 tags | |
125 text=${text//==lt====slash==h1==gt==/<\/h1>} # search for h1-h6 closing tags | |
126 text=${text//==lt====slash==h2==gt==/<\/h2>} # search for h1-h6 closing tags | |
127 text=${text//==lt====slash==h3==gt==/<\/h3>} # search for h1-h6 closing tags | |
128 text=${text//==lt====slash==h4==gt==/<\/h4>} # search for h1-h6 closing tags | |
129 text=${text//==lt====slash==h5==gt==/<\/h5>} # search for h1-h6 closing tags | |
130 text=${text//==lt====slaxh==h6==gt==/<\/h6>} # search for h1-h6 closing tags | |
131 | |
132 ## display everything else verbatim | |
133 text=${text//==space==/ } | |
134 text=${text//==colon==/:} | |
135 text=${text//==comma==/,} | |
136 text=${text//==slash==/\/} | |
137 text=${text//==lt==/<} | |
138 text=${text//==gt==/>} | |
139 text=${text//==apos==/'} | |
140 text=${text//==quote==/"} | |
141 text=${text//&&/&} | |
142 text=${text//\\n/<br/>} | |
143 text=${text//\\t/ } | |
144 text=${text//\&r\&n/<br/>} | |
145 text=${text//\&r/<br/>} | |
146 text=${text//\&n/<br/>} | |
147 text=${text//\&c/:} | |
148 text=${text//==backtick==/`} | |
149 text=${text//==dollar==/$} | |
150 text=${text//==bar==/|} | |
151 contentline="${contentline}\n${text}\n" | |
152 fi | |
153 | |
154 | |
155 fi | |
156 | |
157 ## | |
158 ## Text File | |
159 ## | |
97 if [ ${myarr[1]} == "textfile" ] | 160 if [ ${myarr[1]} == "textfile" ] |
98 then | 161 then |
99 tfile=${myarr[2]} | 162 tfile=${myarr[2]} |
163 md=${myarr[4]} | |
100 fname=`basename ${tfile}` | 164 fname=`basename ${tfile}` |
101 fname=${fname%.*} | 165 fname=${fname%.*} |
102 fname="${fname}.txt" | 166 fname="${fname}.txt" |
103 cp ${tfile} "${galaxypath}/${fname}" | 167 cp ${tfile} "${galaxypath}/${fname}" |
104 | 168 |
105 #estimate height for iframe based on number oflines in the file | 169 #estimate height for iframe based on number oflines in the file |
106 numlines=`wc -l ${tfile} | cut -d" " -f1` | 170 numlines=`wc -l ${tfile} | cut -d" " -f1` |
107 minheight=$[$numlines*17] | 171 minheight=$[$numlines*17] |
108 | 172 |
109 contentline="${contentline}<iframe class=\"invisibleframe\" src=\"${fname}\" width=\"100%\" height=\"$minheight\"> </iframe>" | 173 # if markdown, convert to html |
110 fi | 174 if [ $md == "Y" ] |
111 | 175 then |
112 ## add image file to page | 176 |
177 if [ -z `type -p pandoc` ] | |
178 then | |
179 # pandoc missing | |
180 ${repositorypath}/Markdown/markdown2.py ${tfile} > mytext.html | |
181 | |
182 else | |
183 # pandoc exists | |
184 pandoc -o mytext.html ${tfile} | |
185 pandoc -o standalone.html -s ${tfile} | |
186 | |
187 # get css generated by pandoc and add as scoped attribute (HTML5) | |
188 pandocstyle=`sed -n '/<style/,/style>/p' standalone.html` | |
189 | |
190 fi | |
191 | |
192 markdowntext=$(cat mytext.html) | |
193 contentline="${contentline}\n<div class=\"markdown-body\">${pandocstyle} ${markdowntext}</div>\n" | |
194 else | |
195 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${fname}\" width=\"100%\" height=\"$minheight\"> </iframe>\n" | |
196 fi | |
197 fi | |
198 | |
199 ## | |
200 ## Image | |
201 ## | |
113 if [ ${myarr[1]} == "image" ] | 202 if [ ${myarr[1]} == "image" ] |
203 | |
114 then | 204 then |
115 imgcount=$[$imgcount+1] | 205 imgcount=$[$imgcount+1] |
116 #restore file suffix for html | 206 #restore file suffix for html |
117 ftype=`file ${myarr[2]}` | 207 ftype=`file ${myarr[2]}` |
118 zoomlevel=${myarr[4]} | 208 zoomlevel=${myarr[4]} |
163 else | 253 else |
164 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" | 254 contentline="${contentline}<span class=\"zoomme\" id=\"img${imgcount}\"> <img src=\"${image}\" ${alignstring} ${widthstring} alt=\"loading image..\"/></span>" |
165 fi | 255 fi |
166 | 256 |
167 fi | 257 fi |
258 | |
259 ## | |
260 ## Table | |
261 ## | |
168 if [ ${myarr[1]} == "table" ] | 262 if [ ${myarr[1]} == "table" ] |
169 then | 263 then |
170 maxlines=50000 | 264 maxlines=50000 |
171 tsvfile_orig=${myarr[2]} | 265 tsvfile_orig=${myarr[2]} |
172 tsvfile="tablehead.tsv" | 266 tsvfile="tablehead.tsv" |
221 else{ | 315 else{ |
222 $col=prefix""url""$col""url2""suffix""$col""end | 316 $col=prefix""url""$col""url2""suffix""$col""end |
223 print $0 | 317 print $0 |
224 } | 318 } |
225 }END{}' ${tsvfile} > ${tsvfile}2 | 319 }END{}' ${tsvfile} > ${tsvfile}2 |
226 #echo "converted file: " | 320 |
227 #cat ${tsvfile}2 | |
228 else | 321 else |
229 cp ${tsvfile} ${tsvfile}2 | 322 cp ${tsvfile} ${tsvfile}2 |
230 fi | 323 fi |
231 | 324 |
232 if [ $fancy == "Y" ] | 325 if [ $fancy == "Y" ] |
233 then | 326 then |
234 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html | 327 perl ${repositorypath}/tsv2html.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html |
235 #contentline="${contentline}\n<div class=\"resizable\" id=\"iframe${iframecount}\"><iframe src=\"htmltable_${fname}.html\" style=\"max-width: 100%;vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe></div>" | 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>" |
236 #contentline="${contentline}\n<iframe class=\"resizable\" id=\"iframe${iframecount}\" src=\"htmltable_${fname}.html\" style=\"max-width: 100%;vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe>" | |
237 contentline="${contentline}\n<iframe class=\"invisibleframe fancyiframe\" src=\"htmltable_${fname}.html\" width=\"100%\" style=\"min-height: 300px; overflow-y: hidden; overflow-x: scroll\" ></iframe>" | |
238 | |
239 iframecount=$[$iframecount+1] | 329 iframecount=$[$iframecount+1] |
240 else | 330 else |
241 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html | 331 perl ${repositorypath}/tsv2html_simple.pl < ${tsvfile}2 > ${galaxypath}/htmltable_${fname}.html |
242 #contentline="${contentline}\n<iframe class=\"invisibleframe\" id=\"iframe${iframecount}\" style=\"max-width: 100%; vertical-align: top;\" src=\"htmltable_${fname}.html\" onload=\"resizeIframe(this)\"></iframe>" | |
243 contentline="${contentline}\n<iframe class=\"unfancyiframe invisibleframe\" src=\"htmltable_${fname}.html\" scrolling=\"no\" style=\"max-width: 100%; vertical-align: top;\" onload=\"resizeIframe(this)\"></iframe>" | 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>" |
244 iframecount=$[$iframecount+1] | 333 iframecount=$[$iframecount+1] |
245 fi | 334 fi |
246 | 335 |
247 if [[ $numlines -gt ${maxlines} ]] | 336 if [[ $numlines -gt ${maxlines} ]] |
250 cp ${tsvfile_orig} ${galaxypath}/$tablename | 339 cp ${tsvfile_orig} ${galaxypath}/$tablename |
251 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>." | 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>." |
252 fi | 341 fi |
253 fi | 342 fi |
254 | 343 |
344 ## | |
345 ## PDF | |
346 ## | |
255 if [[ ${myarr[1]} == "pdf" ]] | 347 if [[ ${myarr[1]} == "pdf" ]] |
256 then | 348 then |
257 pdffile=${myarr[2]} | 349 pdffile=${myarr[2]} |
258 fname=`basename ${pdffile}` | 350 fname=`basename ${pdffile}` |
259 fname=${fname%.dat} | 351 fname=${fname%.dat} |
260 pdfname="${fname}.pdf" | 352 pdfname="${fname}.pdf" |
261 cp ${pdffile} "${galaxypath}/${pdfname}" | 353 cp ${pdffile} "${galaxypath}/${pdfname}" |
262 | 354 |
263 width=1000 | 355 width=1000 |
264 height=800 | 356 height=800 |
265 #contentline="${contentline}<object data=\"${fname}\" type=\"application/pdf\" width=\"1000\" height=\"1000\"><p>It appears you have no PDF plugin for your browser. No biggie... you can <a href=\"${fname}\">click here to download the PDF file.</a></p></object>" | |
266 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" | 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" |
267 width=$[$width+10] | 358 width=$[$width+10] |
268 height=$[$height+10] | 359 height=$[$height+10] |
269 contentline="${contentline}<iframe src=\"${fname}.html\" width=\"${width}\" height=\"${height}\"></iframe>\n" | 360 contentline="${contentline}\n<iframe src=\"${fname}.html\" width=\"${width}\" height=\"${height}\"></iframe>\n" |
270 | 361 |
271 fi | 362 fi |
272 ## link to a location on the web, open in new window | 363 |
364 ## | |
365 ## HTML | |
366 ## | |
367 if [[ ${myarr[1]} == "htmlfile" ]] | |
368 then | |
369 htmlfile=${myarr[2]} | |
370 height=${myarr[4]} | |
371 fname=`basename ${htmlfile}` | |
372 fname=${fname%.dat} | |
373 htmlname="${fname}.html" | |
374 cp ${htmlfile} "${galaxypath}/${htmlname}" | |
375 | |
376 contentline="${contentline}\n<iframe class=\"invisibleframe\" src=\"${htmlname}\" width=\"100%\" height=\"${height}px\"></iframe>\n" | |
377 fi | |
378 | |
379 ## | |
380 ## Web Link | |
381 ## | |
273 if [ ${myarr[1]} == "weblink" ] | 382 if [ ${myarr[1]} == "weblink" ] |
274 then | 383 then |
275 url=${myarr[2]} | 384 url=${myarr[2]} |
276 linktext=${myarr[4]} | 385 linktext=${myarr[4]} |
277 url=${url/==colon==/:} | 386 url=${url/==colon==/:} |
278 url=${url/==quote==/&} | 387 url=${url/==quote==/&} |
279 | 388 |
280 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>" | 389 contentline="${contentline}<a href=\"${url}\" target=\"_blank\">${linktext}</a>" |
281 fi | 390 fi |
282 | 391 |
283 ## link to a file in the history | 392 ## |
393 ## Link to Dataset | |
394 ## | |
284 if [ ${myarr[1]} == "link" ] | 395 if [ ${myarr[1]} == "link" ] |
285 then | 396 then |
286 linkfile=${myarr[2]} | 397 linkfile=${myarr[2]} |
287 apiid=${myarr[4]} | 398 apiid=${myarr[4]} |
288 isireport=${myarr[5]} | 399 isireport=${myarr[5]} |
322 fi | 433 fi |
323 | 434 |
324 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>" | 435 contentline="${contentline}<a href=\"${linkfilename}\">${linktext}</a>" |
325 fi | 436 fi |
326 | 437 |
327 ## link to files in an archive in the history item | 438 ## |
439 ## Links to Archive Contents | |
440 ## | |
328 if [[ ${myarr[1]} == "links" ]] | 441 if [[ ${myarr[1]} == "links" ]] |
329 then | 442 then |
330 #echo "making links:" | 443 #echo "making links:" |
331 archive=${myarr[2]} | 444 archive=${myarr[2]} |
332 fname=`basename ${archive}` | 445 fname=`basename ${archive}` |
419 | 532 |
420 fi | 533 fi |
421 | 534 |
422 if [[ ${myarr[3]} == "Y" ]] | 535 if [[ ${myarr[3]} == "Y" ]] |
423 then | 536 then |
424 contentline="${contentline}<br/>" | 537 contentline="${contentline}<br/>\n" |
425 fi | 538 fi |
426 fi | 539 fi |
427 done | 540 done |
428 | 541 |
429 echo "${contentline}" | 542 echo "${contentline}" |
430 } | 543 } |
431 | 544 |
432 | 545 ## |
546 ## Create HTML content for iReport | |
547 ## | |
433 createMainPage (){ | 548 createMainPage (){ |
434 page=$1 | 549 page=$1 |
435 tabtitles=$2 #comma-separated list of tab titles | 550 tabtitles=$2 # comma-separated list of tab titles |
436 tabitems=$3 | 551 tabitems=$3 # colon-sparated list of tabs specifications |
437 iframecount=1 | 552 iframecount=1 # keep track of number of iFrames so that they can be referenced by ID |
438 minwidth=$4 | 553 minwidth=$4 # width of page |
439 | 554 |
440 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles" | 555 echo "createMainPage: tabitems: $tabitems. tabtitles: $tabtitles" |
441 # create correct number of tabs | 556 # create correct number of tabs |
442 count=0 | 557 count=0 |
443 | 558 |
444 tabtitles=${tabtitles//,/ } | 559 tabtitles=${tabtitles//,/ } |
445 tabtitles=${tabtitles//==colon==/:} | 560 tabtitles=${tabtitles//==colon==/:} |
446 tabslist="<ul>\n" | 561 tabslist="<ul>\n" |
447 mytabs="" | 562 mytabs="" |
563 | |
448 for title in $tabtitles | 564 for title in $tabtitles |
449 do | 565 do |
450 #create list of tabs | 566 # Create list of tabs |
451 | |
452 count=$[count+1] | 567 count=$[count+1] |
453 title2=${title//_s_/ } | 568 title2=${title//_s_/ } |
454 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n" | 569 tabslist="${tabslist} <li><a href=\"#tabs-${count}\">${title2}</a></li>\n" |
455 | 570 |
456 #create tabs with content | 571 # Create tabs with content |
457 tabcontent=$(makeTabContent $title "$tabitems") | 572 tabcontent=$(makeTabContent $title "$tabitems") |
458 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n" | 573 mytabs="${mytabs}\n<div id=\"tabs-${count}\">\n" |
459 mytabs="${mytabs}${tabcontent}" | 574 mytabs="${mytabs}${tabcontent}" |
460 mytabs="${mytabs}\n</div>\n" | 575 mytabs="${mytabs}\n</div>\n" |
461 done | 576 done |
462 tabslist="${tabslist}</ul>" | 577 tabslist="${tabslist}</ul>" |
463 | 578 |
464 #output the webpage | 579 ## Output the webpage |
465 echo -e "<!doctype html> | 580 echo -e "<!doctype html> |
466 <head> | 581 <head> |
467 <meta charset=\"utf-8\"> | 582 <meta charset=\"utf-8\"> |
468 <title>jQuery UI Tabs - Default functionality</title> | 583 <title>iReport</title> |
469 | 584 <link rel=\"stylesheet\" href=\"jquery-ui.css\"> |
470 | 585 <link rel=\"stylesheet\" href=\"ireport_css.css\"> |
471 <link rel=\"stylesheet\" href=\"jquery-ui.css\"> | 586 <link rel=\"stylesheet\" href=\"md.css\"> |
472 <script src=\"jquery-1.10.2.js\"></script> | 587 <script type=\"text/javascript\" src=\"jquery-1.10.2.js\"></script> |
473 <script src=\"jquery-ui.js\"></script> | 588 <script type=\"text/javascript\" src=\"jquery-ui.js\"></script> |
474 <script type=\"text/javascript\" src=\"iframe-resizer/src/iframeResizer.js\"></script> | 589 <script type=\"text/javascript\" src=\"iframe-resizer/src/iframeResizer.js\"></script> |
475 <script type=\"text/javascript\" src=\"jquery.zoom.js\"></script> | 590 <script type=\"text/javascript\" src=\"jquery.zoom.js\"></script> |
476 | 591 <script type=\"text/javascript\" src=\"ireport_jquery.js\"></script> |
477 <script> | 592 <script type=\"text/javascript\" src=\"ireport_javascript.js\"></script> |
478 \$(function() { | 593 </head> |
479 \$( \"#tabs\" ).tabs(); | 594 <body> |
480 }); | 595 <div id=\"tabs\" style=\"display:inline-block; min-height:100%; min-width:${minwidth}px\"> |
596 $tabslist | |
481 | 597 |
482 \$(function() { | 598 $mytabs |
483 \$( \".resizable\" ).resizable(); | 599 </div> |
484 }); | 600 </body> |
485 | |
486 \$(document).ready(function(){ | |
487 \$('.zoomme').zoom(); | |
488 \$('#ex2').zoom({ on:'grab' }); | |
489 \$('#ex3').zoom({ on:'click' }); | |
490 \$('#ex4').zoom({ on:'toggle' }); | |
491 \$('.fancyiframe').iFrameResize({ | |
492 heightCalculationMethod: 'max', | |
493 minHeight: 250, | |
494 scrolling: true, | |
495 checkOrigin: false, | |
496 bodyMargin: 15 | |
497 }); | |
498 \$('.unfancyiframe').iFrameResize({ | |
499 heightCalculationMethod: 'max', | |
500 scrolling: false, | |
501 checkOrigin: false | |
502 }); | |
503 }); | |
504 | |
505 </script> | |
506 | |
507 | |
508 <script language=\"javascript\" type=\"text/javascript\"> | |
509 function resizeIframe(obj) { | |
510 oldheight=obj.style.height | |
511 oldwidth=obj.style.width | |
512 obj.style.height = obj.contentWindow.document.body.scrollHeight + 4 + 'px'; | |
513 obj.style.width = obj.contentWindow.document.body.scrollWidth + 4 + 'px'; | |
514 | |
515 if(obj.style.height < 50){ | |
516 obj.style.height=oldheight | |
517 } | |
518 } | |
519 </script> | |
520 <style type=\"text/css\"> | |
521 body { | |
522 min-width: ${minwidth}px; | |
523 width: ${minwidth}px; | |
524 min-height: 100%; | |
525 } | |
526 .invisibleframe{ | |
527 border: 0px; | |
528 overflow: hidden | |
529 } | |
530 .mylinks{ | |
531 color: blue !important; | |
532 } | |
533 .mylinks:visited { | |
534 color: #551A8B !important; | |
535 } | |
536 </style> | |
537 <style > | |
538 .zoomme { | |
539 display: inline-block; | |
540 } | |
541 </style> | |
542 | |
543 | |
544 </head> | |
545 <body> | |
546 | |
547 <div id=\"tabs\" style=\"display:inline-block; min-height:100%; min-width:${minwidth}px\"> | |
548 $tabslist | |
549 | |
550 $mytabs | |
551 </div> | |
552 | |
553 | |
554 </body> | |
555 </html>" > $page | 601 </html>" > $page |
556 | |
557 | |
558 | |
559 } | 602 } |