| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | |||
| 2 | /*************************************** | ||
| 3 | Auteur : Pierre Aubert | ||
| 4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 5 | Licence : CeCILL-C | ||
| 6 | ****************************************/ | ||
| 7 | |||
| 8 | #include <fstream> | ||
| 9 | #include <iostream> | ||
| 10 | |||
| 11 | #include "PPath.h" | ||
| 12 | #include "OptionParser.h" | ||
| 13 | |||
| 14 | ///Create the OptionParser of this program | ||
| 15 | /** @return OptionParser of this program | ||
| 16 | */ | ||
| 17 | 1 | OptionParser createOptionParser(){ | |
| 18 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | OptionParser parser(true, __PROGRAM_VERSION__); |
| 19 |
2/2✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
|
1 | parser.setExampleLongOption("phoenix_slider --input=fileInput.png --output=output.html"); |
| 20 |
2/2✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
|
1 | parser.setExampleShortOption("phoenix_slider -i fileInput1.png fileInput2.png fileInput3.mp4 fileInput4.png -o output.html"); |
| 21 | |||
| 22 |
4/4✓ Branch 0 (11→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
✓ Branch 4 (13→14) taken 1 times.
✓ Branch 6 (14→15) taken 1 times.
|
1 | parser.addOption("input", "i", OptionType::FILENAME, true, "list of input files"); |
| 23 | |||
| 24 |
1/1✓ Branch 0 (18→19) taken 1 times.
|
1 | PString defaultOutput("output.html"); |
| 25 |
5/5✓ Branch 0 (19→20) taken 1 times.
✓ Branch 2 (20→21) taken 1 times.
✓ Branch 4 (21→22) taken 1 times.
✓ Branch 6 (22→23) taken 1 times.
✓ Branch 8 (23→24) taken 1 times.
|
1 | parser.addOption("output", "o", defaultOutput, "name of the output HTML file"); |
| 26 | |||
| 27 |
1/1✓ Branch 0 (28→29) taken 1 times.
|
1 | PString defaultColor("black"); |
| 28 |
5/5✓ Branch 0 (29→30) taken 1 times.
✓ Branch 2 (30→31) taken 1 times.
✓ Branch 4 (31→32) taken 1 times.
✓ Branch 6 (32→33) taken 1 times.
✓ Branch 8 (33→34) taken 1 times.
|
1 | parser.addOption("numbercolor", "n", defaultColor, "color of the slides' number (black, white, blue, green, red, yellow, gray(by default))"); |
| 29 | |||
| 30 |
1/1✓ Branch 0 (38→39) taken 1 times.
|
1 | PString defaultTextFootpage(""); |
| 31 |
5/5✓ Branch 0 (39→40) taken 1 times.
✓ Branch 2 (40→41) taken 1 times.
✓ Branch 4 (41→42) taken 1 times.
✓ Branch 6 (42→43) taken 1 times.
✓ Branch 8 (43→44) taken 1 times.
|
1 | parser.addOption("footpage", "f", defaultTextFootpage, "text to be written on the foot page"); |
| 32 | |||
| 33 |
1/1✓ Branch 0 (48→49) taken 1 times.
|
1 | PString defaultFootpageColor("white"); |
| 34 |
5/5✓ Branch 0 (49→50) taken 1 times.
✓ Branch 2 (50→51) taken 1 times.
✓ Branch 4 (51→52) taken 1 times.
✓ Branch 6 (52→53) taken 1 times.
✓ Branch 8 (53→54) taken 1 times.
|
1 | parser.addOption("footpagecolor", "g", defaultFootpageColor, "color of the foot page (black, white, blue, green, red, yellow, white(by default))"); |
| 35 | |||
| 36 | 1 | return parser; | |
| 37 | 1 | } | |
| 38 | |||
| 39 | ///Make the HTML slider header | ||
| 40 | /** @param[out] fs : file to be completed | ||
| 41 | * @param numberColor : color of the slide number (black, white, red, blue, green, yellow, gray(by default)) | ||
| 42 | * @param footPageColor : color of the foot page | ||
| 43 | */ | ||
| 44 | 1 | void slider_saveHtmlHeader(std::ofstream & fs, const PString & numberColor, const PString & footPageColor){ | |
| 45 | 1 | fs << "<!DOCTYPE html>\n"; | |
| 46 | 1 | fs << "<html>\n"; | |
| 47 | 1 | fs << "\t<head>\n"; | |
| 48 | 1 | fs << "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"; | |
| 49 | 1 | fs << "\t\t<style>\n"; | |
| 50 | 1 | fs << "\t\t\t* {box-sizing: border-box;}\n"; | |
| 51 | 1 | fs << "\t\t\tbody {\n"; | |
| 52 | // fs << "\t\t\t\tfont-family: Verdana, sans-serif;\n"; | ||
| 53 | 1 | fs << "\t\t\t\tfont-family: Arial, sans-serif;\n"; | |
| 54 | 1 | fs << "\t\t\t\tbackground-color: black;\n"; | |
| 55 | // fs << "\t\t\t\t/* margin: auto; */\n"; | ||
| 56 | 1 | fs << "\t\t\t}\n"; | |
| 57 | 1 | fs << "\t\t\t.mySlides {\n"; | |
| 58 | 1 | fs << "\t\t\t\tdisplay: none;\n"; | |
| 59 | 1 | fs << "\t\t\t\tvertical-align: middle;\n"; | |
| 60 | 1 | fs << "\t\t\t}\n"; | |
| 61 | 1 | fs << "\t\t\timg {\n"; | |
| 62 | 1 | fs << "\t\t\t\tvertical-align: middle;\n"; | |
| 63 | 1 | fs << "\t\t\t}\n"; | |
| 64 | 1 | fs << "\t\t\t\n"; | |
| 65 | 1 | fs << "\t\t\t/* Slideshow container */\n"; | |
| 66 | 1 | fs << "\t\t\t.slideshow-container {\n"; | |
| 67 | // fs << "\t\t\t\t/* max-width: 1000px; */ /*Limite pour rien la taille des slides*/\n"; | ||
| 68 | 1 | fs << "\t\t\t\tposition: relative;\n"; | |
| 69 | 1 | fs << "\t\t\t\tmargin: auto;\n"; | |
| 70 | 1 | fs << "\t\t\t}\n"; | |
| 71 | 1 | fs << "\t\t\t\n"; | |
| 72 | 1 | fs << "\t\t\t/* Caption text */\n"; | |
| 73 | 1 | fs << "\t\t\t.text {\n"; | |
| 74 | // fs << "\t\t\t\t/* color: #f2f2f2; */\n"; | ||
| 75 | 1 | fs << "\t\t\t\tcolor: "<<footPageColor<<";\n"; | |
| 76 | // fs << "\t\t\t\t/* color: black; */\n"; | ||
| 77 | 1 | fs << "\t\t\t\tfont-size: 30px;\n"; | |
| 78 | 1 | fs << "\t\t\t\tpadding: 8px 12px;\n"; | |
| 79 | 1 | fs << "\t\t\t\tposition: absolute;\n"; | |
| 80 | 1 | fs << "\t\t\t\tbottom: 8px;\n"; | |
| 81 | 1 | fs << "\t\t\t\tmargin-left: 40px;\n"; | |
| 82 | // fs << "\t\t\t\twidth: 100%;\n"; | ||
| 83 | 1 | fs << "\t\t\t\ttext-align: left;\n"; | |
| 84 | 1 | fs << "\t\t\t}\n"; | |
| 85 | 1 | fs << "\t\t\t\n"; | |
| 86 | 1 | fs << "\t\t\t/* Number text (1/3 etc) */\n"; | |
| 87 | 1 | fs << "\t\t\t.numbertext {\n"; | |
| 88 | // fs << "\t\t\t\t/* color: #f2f2f2; */\n"; | ||
| 89 | 1 | fs << "\t\t\t\tcolor: "<<numberColor<<";\n"; | |
| 90 | 1 | fs << "\t\t\t\tfont-size: 40px;\n"; | |
| 91 | 1 | fs << "\t\t\t\tpadding: 8px 12px;\n"; | |
| 92 | 1 | fs << "\t\t\t\tposition: absolute;\n"; | |
| 93 | // fs << "\t\t\t\t/* top: 0; */\n"; | ||
| 94 | 1 | fs << "\t\t\t\tbottom: 8px;\n"; | |
| 95 | 1 | fs << "\t\t\t\twidth: 100%;\n"; | |
| 96 | 1 | fs << "\t\t\t\ttext-align: right;\n"; | |
| 97 | 1 | fs << "\t\t\t}\n"; | |
| 98 | 1 | fs << "\t\t\t\n"; | |
| 99 | 1 | fs << "\t\t\t.slideContent{\n"; | |
| 100 | 1 | fs << "\t\t\t\tcolor: "<<footPageColor<<";\n"; | |
| 101 | 1 | fs << "\t\t\t\tdisplay: block;\n"; | |
| 102 | 1 | fs << "\t\t\t\tposition: absolute;\n"; | |
| 103 | 1 | fs << "\t\t\t\twidth: 100%;\n"; | |
| 104 | 1 | fs << "\t\t\t\ttop: 0px;\n"; | |
| 105 | 1 | fs << "\t\t\t}\n"; | |
| 106 | |||
| 107 | 1 | fs << "\t\t\t.slideContent h1{\n"; | |
| 108 | 1 | fs << "\t\t\t\tcolor: "<<footPageColor<<";\n"; | |
| 109 | 1 | fs << "\t\t\t\ttext-align: center;\n"; | |
| 110 | 1 | fs << "\t\t\t\tfont-size: 60px;\n"; | |
| 111 | 1 | fs << "\t\t\t}\n"; | |
| 112 | |||
| 113 | 1 | fs << "\t\t\t.slideContent .slidebody{\n"; | |
| 114 | 1 | fs << "\t\t\t\tcolor: "<<footPageColor<<";\n"; | |
| 115 | 1 | fs << "\t\t\t\tmargin-left: 40px;\n"; | |
| 116 | 1 | fs << "\t\t\t\ttext-align: left;\n"; | |
| 117 | 1 | fs << "\t\t\t\tfont-size: 40px;\n"; | |
| 118 | 1 | fs << "\t\t\t}\n"; | |
| 119 | |||
| 120 | // fs << "\t\t\t/*.vertical-center {\n"; | ||
| 121 | // fs << "\t\t\t\tmargin: 0;\n"; | ||
| 122 | // fs << "\t\t\t\tposition: absolute;\n"; | ||
| 123 | // fs << "\t\t\t\ttop: 50%;\n"; | ||
| 124 | // fs << "\t\t\t\t-ms-transform: translateY(-50%);\n"; | ||
| 125 | // fs << "\t\t\t\ttransform: translateY(-50%);\n"; | ||
| 126 | // fs << "\t\t\t}*/\n"; | ||
| 127 | // fs << \t"\t\t\n"; | ||
| 128 | 1 | fs << "\t\t\t/* The dots/bullets/indicators */\n"; | |
| 129 | 1 | fs << "\t\t\t.dot {\n"; | |
| 130 | 1 | fs << "\t\t\t\theight: 15px;\n"; | |
| 131 | 1 | fs << "\t\t\t\twidth: 15px;\n"; | |
| 132 | 1 | fs << "\t\t\t\tmargin: 0 2px;\n"; | |
| 133 | 1 | fs << "\t\t\t\tbackground-color: #bbb;\n"; | |
| 134 | 1 | fs << "\t\t\t\tborder-radius: 50%;\n"; | |
| 135 | 1 | fs << "\t\t\t\tdisplay: inline-block;\n"; | |
| 136 | 1 | fs << "\t\t\t\ttransition: background-color 0.6s ease;\n"; | |
| 137 | 1 | fs << "\t\t\t}\n"; | |
| 138 | 1 | fs << "\t\t\t\n"; | |
| 139 | 1 | fs << "\t\t\t.active {\n"; | |
| 140 | 1 | fs << "\t\t\t\tbackground-color: #717171;\n"; | |
| 141 | 1 | fs << "\t\t\t}\n"; | |
| 142 | 1 | fs << "\t\t\t\n"; | |
| 143 | 1 | fs << "\t\t\t/* Fading animation */\n"; | |
| 144 | 1 | fs << "\t\t\t.fade {\n"; | |
| 145 | 1 | fs << "\t\t\t\tanimation-name: fade;\n"; | |
| 146 | 1 | fs << "\t\t\t\tanimation-duration: 1.5s;\n"; | |
| 147 | 1 | fs << "\t\t\t}\n"; | |
| 148 | 1 | fs << "\t\t\t\n"; | |
| 149 | 1 | fs << "\t\t\t@keyframes fade {\n"; | |
| 150 | 1 | fs << "\t\t\t\tfrom {opacity: .4}\n"; | |
| 151 | 1 | fs << "\t\t\t\tto {opacity: 1}\n"; | |
| 152 | 1 | fs << "\t\t\t}\n"; | |
| 153 | 1 | fs << "\t\t\t\n"; | |
| 154 | 1 | fs << "\t\t\t/* On smaller screens, decrease text size */\n"; | |
| 155 | 1 | fs << "\t\t\t@media only screen and (max-width: 300px) {\n"; | |
| 156 | 1 | fs << "\t\t\t\t.text {font-size: 11px}\n"; | |
| 157 | 1 | fs << "\t\t\t}\n"; | |
| 158 | 1 | fs << "\t\t</style>\n"; | |
| 159 | 1 | fs << "\t</head>\n"; | |
| 160 | 1 | } | |
| 161 | |||
| 162 | ///Make the HTML slider javascript | ||
| 163 | /** @param[out] fs : file to be completed | ||
| 164 | */ | ||
| 165 | 1 | void slider_saveJavascript(std::ofstream & fs){ | |
| 166 | 1 | fs << "<script>\n"; | |
| 167 | 1 | fs << "let slideIndex = 1;\n"; | |
| 168 | 1 | fs << "showSlides(slideIndex);\n"; | |
| 169 | 1 | fs << "\n"; | |
| 170 | 1 | fs << "// Next/previous controls\n"; | |
| 171 | 1 | fs << "function plusSlides(n){\n"; | |
| 172 | 1 | fs << "\tshowSlides(slideIndex += n);\n"; | |
| 173 | 1 | fs << "}\n"; | |
| 174 | 1 | fs << "\n"; | |
| 175 | 1 | fs << "// Thumbnail image controls\n"; | |
| 176 | 1 | fs << "function currentSlide(n){\n"; | |
| 177 | 1 | fs << "\tshowSlides(slideIndex = n);\n"; | |
| 178 | 1 | fs << "}\n"; | |
| 179 | 1 | fs << "\n"; | |
| 180 | 1 | fs << "function showSlides(n) {\n"; | |
| 181 | 1 | fs << "\tlet i;\n"; | |
| 182 | 1 | fs << "\tlet slides = document.getElementsByClassName(\"mySlides\");\n"; | |
| 183 | // fs << "\t// let dots = document.getElementsByClassName(\"dot\");\n"; | ||
| 184 | 1 | fs << "\tif(n > slides.length){slideIndex = 1}\n"; | |
| 185 | 1 | fs << "\tif(n < 1){slideIndex = slides.length}\n"; | |
| 186 | 1 | fs << "\tfor(i = 0; i < slides.length; i++){\n"; | |
| 187 | 1 | fs << "\t\tslides[i].style.display = \"none\";\n"; | |
| 188 | 1 | fs << "\t}\n"; | |
| 189 | // fs << "\t// for (i = 0; i < dots.length; i++) {\n"; | ||
| 190 | // fs << "\t// dots[i].className = dots[i].className.replace(\" active\", \"\");\n"; | ||
| 191 | // fs << "\t// }\n"; | ||
| 192 | 1 | fs << "\tslides[slideIndex-1].style.display = \"block\";\n"; | |
| 193 | // fs << "\t// dots[slideIndex-1].className += \" active\";\n"; | ||
| 194 | 1 | fs << "}\n"; | |
| 195 | 1 | fs << "\n"; | |
| 196 | 1 | fs << "document.onkeydown = function(e){\n"; | |
| 197 | 1 | fs << "\tswitch(e.keyCode){\n"; | |
| 198 | 1 | fs << "\t\tcase 37:\n"; | |
| 199 | 1 | fs << "\t\t\t//left\n"; | |
| 200 | 1 | fs << "\t\t\te.preventDefault();\n"; | |
| 201 | 1 | fs << "\t\t\tslideIndex--;\n"; | |
| 202 | 1 | fs << "\t\t\tshowSlides(slideIndex);\n"; | |
| 203 | 1 | fs << "\t\t\tbreak;\n"; | |
| 204 | 1 | fs << "\t\tcase 39:\n"; | |
| 205 | 1 | fs << "\t\t\t//right\n"; | |
| 206 | 1 | fs << "\t\t\te.preventDefault();\n"; | |
| 207 | 1 | fs << "\t\t\tslideIndex++;\n"; | |
| 208 | 1 | fs << "\t\t\tshowSlides(slideIndex);\n"; | |
| 209 | 1 | fs << "\t\t\tbreak;\n"; | |
| 210 | 1 | fs << "\t}\n"; | |
| 211 | 1 | fs << "}\n"; | |
| 212 | 1 | fs << "</script>\n"; | |
| 213 | 1 | } | |
| 214 | |||
| 215 | ///Save the HTML slide number | ||
| 216 | /** @param[out] fs : file to be written | ||
| 217 | * @param slideNumber : slide number | ||
| 218 | * @param footPage : string to be written in the footpage of the slides | ||
| 219 | */ | ||
| 220 | 8 | void slider_saveHtmlSlideNumber(std::ofstream & fs, long unsigned int slideNumber, const PString & footPage){ | |
| 221 |
2/2✓ Branch 0 (2→3) taken 7 times.
✓ Branch 1 (2→11) taken 1 times.
|
8 | if(slideNumber != 0lu){ |
| 222 | 7 | fs << "\t\t\t\t<div class=\"numbertext\">"<<(slideNumber + 1lu)<<"</div>\n"; | |
| 223 | |||
| 224 |
1/2✓ Branch 0 (7→8) taken 7 times.
✗ Branch 1 (7→11) not taken.
|
7 | if(footPage != ""){ |
| 225 | 7 | fs << "\t\t\t\t<div class=\"text\">"<<footPage<<"</div>\n"; | |
| 226 | } | ||
| 227 | } | ||
| 228 | 8 | } | |
| 229 | |||
| 230 | ///Make the html png slide | ||
| 231 | /** @param[out] fs : file to be completed | ||
| 232 | * @param filePng : file png to be in the slide | ||
| 233 | * @param slideNumber : slide number | ||
| 234 | * @param footPage : string to be written in the footpage of the slides | ||
| 235 | */ | ||
| 236 | 5 | void slider_saveHtmlSlidePng(std::ofstream & fs, const PPath & filePng, long unsigned int slideNumber, const PString & footPage) | |
| 237 | { | ||
| 238 | 5 | fs << "\t\t\t<div class=\"mySlides\">\n"; | |
| 239 | 5 | slider_saveHtmlSlideNumber(fs, slideNumber, footPage); | |
| 240 | 5 | fs << "\t\t\t\t<img src=\""<<filePng<<"\" style=\"width:100%\">\n"; | |
| 241 | // fs << "\t\t\t\t<div class=\"text\">Caption One</div>\n"; | ||
| 242 | 5 | fs << "\t\t\t</div>\n"; | |
| 243 | 5 | } | |
| 244 | |||
| 245 | ///Make the html mp4 slide | ||
| 246 | /** @param[out] fs : file to be completed | ||
| 247 | * @param fileMp4 : mp4 file to be in the slide | ||
| 248 | * @param slideNumber : slide number | ||
| 249 | * @param footPage : string to be written in the footpage of the slides | ||
| 250 | */ | ||
| 251 | 2 | void slider_saveHtmlSlideMp4(std::ofstream & fs, const PPath & fileMp4, long unsigned int slideNumber, const PString & footPage){ | |
| 252 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | PString loopAttribute(""); |
| 253 |
1/2✓ Branch 0 (4→5) taken 2 times.
✗ Branch 1 (4→17) not taken.
|
2 | if(fileMp4.size() > 8lu){ |
| 254 |
2/2✓ Branch 0 (5→6) taken 2 times.
✓ Branch 2 (6→7) taken 2 times.
|
2 | PString baseName(fileMp4.eraseExtension()); |
| 255 |
4/4✓ Branch 0 (10→11) taken 2 times.
✓ Branch 2 (11→12) taken 2 times.
✓ Branch 4 (13→14) taken 1 times.
✓ Branch 5 (13→15) taken 1 times.
|
2 | if(baseName.substr(baseName.size() - 4lu, baseName.size()) == "loop"){ |
| 256 |
1/1✓ Branch 0 (14→15) taken 1 times.
|
1 | loopAttribute = " loop"; |
| 257 | } | ||
| 258 | 2 | } | |
| 259 | |||
| 260 |
1/1✓ Branch 0 (17→18) taken 2 times.
|
2 | fs << "\t\t\t<div class=\"mySlides\">\n"; |
| 261 |
1/1✓ Branch 0 (18→19) taken 2 times.
|
2 | slider_saveHtmlSlideNumber(fs, slideNumber, footPage); |
| 262 |
3/3✓ Branch 0 (19→20) taken 2 times.
✓ Branch 2 (20→21) taken 2 times.
✓ Branch 4 (21→22) taken 2 times.
|
2 | fs << "\t\t\t\t<video style=\"width:100%\" autoplay muted"<<loopAttribute<<">\n"; |
| 263 |
1/1✓ Branch 0 (22→23) taken 2 times.
|
2 | fs << "\t\t\t\t <!-- Be careful, if you do not have sound, check if the video has MP3 sound and not AC3 -->\n"; |
| 264 |
3/3✓ Branch 0 (23→24) taken 2 times.
✓ Branch 2 (24→25) taken 2 times.
✓ Branch 4 (25→26) taken 2 times.
|
2 | fs << "\t\t\t\t <source src=\""<<fileMp4<<"\" type=\"video/mp4\">\n"; |
| 265 |
1/1✓ Branch 0 (26→27) taken 2 times.
|
2 | fs << "\t\t\t\t</video>\n"; |
| 266 | |||
| 267 | // fs << "\t\t\t\t<div class=\"text\">Caption One</div>\n"; | ||
| 268 |
1/1✓ Branch 0 (27→28) taken 2 times.
|
2 | fs << "\t\t\t</div>\n"; |
| 269 | 2 | } | |
| 270 | |||
| 271 | ///Save the html slide with a html file | ||
| 272 | /** @param[out] fs : file to be written | ||
| 273 | * @param fileTex : name of the tex file to be red | ||
| 274 | * @param slideNumber : slide number | ||
| 275 | * @param footPage : string to be written in the footpage of the slides | ||
| 276 | */ | ||
| 277 | 1 | void slider_saveHtmlSlideHtml(std::ofstream & fs, const PPath & fileTex, long unsigned int slideNumber, const PString & footPage) | |
| 278 | { | ||
| 279 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PString backGroundFile(CMAKE_INSTALL_PREFIX "/share/PhoenixSlider/theme2.png"); |
| 280 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | if(slideNumber == 0){ |
| 281 | ✗ | backGroundFile = CMAKE_INSTALL_PREFIX "/share/PhoenixSlider/firstTheme.png"; | |
| 282 | } | ||
| 283 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | fs << "\t\t\t<div class=\"mySlides\">\n"; |
| 284 |
1/1✓ Branch 0 (6→7) taken 1 times.
|
1 | slider_saveHtmlSlideNumber(fs, slideNumber, footPage); |
| 285 |
3/3✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
|
1 | fs << "\t\t\t\t<img src=\""<<backGroundFile<<"\" style=\"width:100%\">\n"; |
| 286 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
1 | fs << "\t\t\t\t<div class=\"slideContent\">\n"; |
| 287 |
3/3✓ Branch 0 (11→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
✓ Branch 4 (13→14) taken 1 times.
|
1 | fs << fileTex.loadFileContent() << std::endl; |
| 288 |
1/1✓ Branch 0 (15→16) taken 1 times.
|
1 | fs << "\t\t\t\t</div>\n"; |
| 289 |
1/1✓ Branch 0 (16→17) taken 1 times.
|
1 | fs << "\t\t\t</div>\n"; |
| 290 | 1 | } | |
| 291 | |||
| 292 | ///Make the beamer tex slide | ||
| 293 | /** @param[out] fs : file to be completed | ||
| 294 | * @param filePng : file png to be in the slide | ||
| 295 | * @param slideNumber : slide number | ||
| 296 | * @param footPage : string to be written in the footpage of the slides | ||
| 297 | */ | ||
| 298 | 8 | void slider_saveHtmlSlide(std::ofstream & fs, const PPath & filePng, long unsigned int slideNumber, const PString & footPage){ | |
| 299 | //Check if the extention is png or mp4 | ||
| 300 | // If the extention is html I need to put the content into a slide | ||
| 301 | // I need also to add the theme and the page number | ||
| 302 | |||
| 303 |
1/1✓ Branch 0 (2→3) taken 8 times.
|
8 | PString fileExtention(filePng.getExtension()); |
| 304 |
3/3✓ Branch 0 (3→4) taken 8 times.
✓ Branch 2 (4→5) taken 5 times.
✓ Branch 3 (4→6) taken 3 times.
|
8 | if(fileExtention == "png"){ |
| 305 |
1/1✓ Branch 0 (5→18) taken 5 times.
|
5 | slider_saveHtmlSlidePng(fs, filePng, slideNumber, footPage); |
| 306 |
3/3✓ Branch 0 (6→7) taken 3 times.
✓ Branch 2 (7→8) taken 2 times.
✓ Branch 3 (7→9) taken 1 times.
|
3 | }else if(fileExtention == "mp4"){ |
| 307 |
1/1✓ Branch 0 (8→18) taken 2 times.
|
2 | slider_saveHtmlSlideMp4(fs, filePng, slideNumber, footPage); |
| 308 |
2/3✓ Branch 0 (9→10) taken 1 times.
✓ Branch 2 (10→11) taken 1 times.
✗ Branch 3 (10→12) not taken.
|
1 | }else if(fileExtention == "html"){ |
| 309 |
1/1✓ Branch 0 (11→18) taken 1 times.
|
1 | slider_saveHtmlSlideHtml(fs, filePng, slideNumber, footPage); |
| 310 | }else{ | ||
| 311 | ✗ | std::cerr << "slider_saveHtmlSlide : unknown extention '"<<fileExtention<<"' of file '"<<filePng<<"'" << std::endl; | |
| 312 | } | ||
| 313 | 8 | } | |
| 314 | |||
| 315 | ///Make the tex slides | ||
| 316 | /** @param outputFileName : output file name | ||
| 317 | * @param listInputFile : list of the png slides input | ||
| 318 | * @param numberColor : color of the slide number (black, white, red, blue, green, yellow, gray(by default)) | ||
| 319 | * @param footPage : string to be written in the footpage of the slides | ||
| 320 | * @param footPageColor : color of the foot page | ||
| 321 | */ | ||
| 322 | 1 | void slider_makeHtmlSlides(const PPath & outputFileName, const PVecPath & listInputFile, const PString & numberColor, | |
| 323 | const PString & footPage, const PString & footPageColor) | ||
| 324 | { | ||
| 325 |
4/7✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→6) not taken.
✗ Branch 4 (5→6) not taken.
✓ Branch 5 (5→7) taken 1 times.
✗ Branch 6 (8→9) not taken.
✓ Branch 7 (8→10) taken 1 times.
|
1 | if(outputFileName == "" || listInputFile.size() == 0lu){return;} |
| 326 | |||
| 327 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
1 | std::ofstream fs; |
| 328 |
1/1✓ Branch 0 (12→13) taken 1 times.
|
1 | fs.open(outputFileName.c_str()); |
| 329 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→20) taken 1 times.
|
1 | if(!fs.is_open()){ |
| 330 | ✗ | std::cerr << "slider_makeHtmlSlides : can't open file '" << outputFileName << "'" << std::endl; | |
| 331 | ✗ | return; | |
| 332 | } | ||
| 333 |
1/1✓ Branch 0 (20→21) taken 1 times.
|
1 | slider_saveHtmlHeader(fs, numberColor, footPageColor); |
| 334 | |||
| 335 |
2/2✓ Branch 0 (21→22) taken 1 times.
✓ Branch 2 (22→23) taken 1 times.
|
1 | fs << "\t<body>" << std::endl; |
| 336 |
2/2✓ Branch 0 (23→24) taken 1 times.
✓ Branch 2 (24→25) taken 1 times.
|
1 | fs << "\t\t<div class=\"slideshow-container\">" << std::endl; |
| 337 |
1/1✓ Branch 0 (25→26) taken 1 times.
|
1 | PString previousFile(""); |
| 338 | 1 | long unsigned int i(-1lu); | |
| 339 |
2/2✓ Branch 0 (65→27) taken 8 times.
✓ Branch 1 (65→66) taken 1 times.
|
18 | for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){ |
| 340 |
1/1✓ Branch 0 (29→30) taken 8 times.
|
8 | PVecString listFileName = it->split('/'); |
| 341 |
1/1✓ Branch 0 (31→32) taken 8 times.
|
8 | PString currentFileName(listFileName.back()); |
| 342 | |||
| 343 |
5/6✓ Branch 0 (33→34) taken 7 times.
✓ Branch 1 (33→36) taken 1 times.
✗ Branch 2 (35→36) not taken.
✓ Branch 3 (35→37) taken 7 times.
✓ Branch 4 (38→39) taken 1 times.
✓ Branch 5 (38→40) taken 7 times.
|
8 | if(previousFile.size() < 6lu || currentFileName.size() < 6lu){ |
| 344 | 1 | ++i; | |
| 345 | }else{ | ||
| 346 |
4/4✓ Branch 0 (41→42) taken 7 times.
✓ Branch 2 (43→44) taken 7 times.
✓ Branch 4 (47→48) taken 6 times.
✓ Branch 5 (47→49) taken 1 times.
|
7 | if(previousFile.substr(0, previousFile.size() - 6lu) != currentFileName.substr(0, currentFileName.size() - 6lu)){ |
| 347 | 6 | ++i; | |
| 348 | } | ||
| 349 | } | ||
| 350 |
1/1✓ Branch 0 (49→50) taken 8 times.
|
8 | previousFile = currentFileName; |
| 351 |
1/1✓ Branch 0 (52→53) taken 8 times.
|
8 | slider_saveHtmlSlide(fs, *it, i, footPage); |
| 352 | 8 | } | |
| 353 |
2/2✓ Branch 0 (66→67) taken 1 times.
✓ Branch 2 (67→68) taken 1 times.
|
1 | fs << "\t\t</div>" << std::endl; |
| 354 |
2/2✓ Branch 0 (68→69) taken 1 times.
✓ Branch 2 (69→70) taken 1 times.
|
1 | fs << "\t\t<br>" << std::endl; |
| 355 |
1/1✓ Branch 0 (70→71) taken 1 times.
|
1 | slider_saveJavascript(fs); |
| 356 |
2/2✓ Branch 0 (71→72) taken 1 times.
✓ Branch 2 (72→73) taken 1 times.
|
1 | fs << "\t</body>" << std::endl; |
| 357 |
2/2✓ Branch 0 (73→74) taken 1 times.
✓ Branch 2 (74→75) taken 1 times.
|
1 | fs << "</html>\n" << std::endl; |
| 358 | |||
| 359 |
1/1✓ Branch 0 (75→76) taken 1 times.
|
1 | fs.close(); |
| 360 | 1 | } | |
| 361 | |||
| 362 | 1 | int main(int argc, char** argv){ | |
| 363 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | OptionParser parser = createOptionParser(); |
| 364 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | parser.parseArgument(argc, argv); |
| 365 | |||
| 366 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | const OptionMode & defaultMode = parser.getDefaultMode(); |
| 367 | 1 | PVecPath listInputFile; | |
| 368 |
2/2✓ Branch 0 (6→7) taken 1 times.
✓ Branch 2 (7→8) taken 1 times.
|
1 | defaultMode.getValue(listInputFile, "input"); |
| 369 | |||
| 370 |
2/2✓ Branch 0 (9→10) taken 1 times.
✓ Branch 2 (10→11) taken 1 times.
|
1 | PPath outputFile("output.html"); |
| 371 |
2/2✓ Branch 0 (12→13) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
|
1 | defaultMode.getValue(outputFile, "output"); |
| 372 | |||
| 373 |
1/1✓ Branch 0 (15→16) taken 1 times.
|
1 | PString numberColor("black"); |
| 374 |
2/2✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (17→18) taken 1 times.
|
1 | defaultMode.getValue(numberColor, "numbercolor"); |
| 375 | |||
| 376 |
1/1✓ Branch 0 (19→20) taken 1 times.
|
1 | PString footPage(""); |
| 377 |
2/2✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
|
1 | defaultMode.getValue(footPage, "footpage"); |
| 378 | |||
| 379 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | PString footPageColor("white"); |
| 380 |
2/2✓ Branch 0 (24→25) taken 1 times.
✓ Branch 2 (25→26) taken 1 times.
|
1 | defaultMode.getValue(footPageColor, "footpagecolor"); |
| 381 | |||
| 382 |
1/1✓ Branch 0 (27→28) taken 1 times.
|
1 | slider_makeHtmlSlides(outputFile, listInputFile, numberColor, footPage, footPageColor); |
| 383 | 1 | return 0; | |
| 384 | 1 | } | |
| 385 | |||
| 386 |