PhoenixSlider  1.0.0
Create HTML presentation automatically
Loading...
Searching...
No Matches
main.cpp File Reference
#include <fstream>
#include <iostream>
#include "PPath.h"
#include "OptionParser.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program.
 
int main (int argc, char **argv)
 
void slider_makeHtmlSlides (const PPath &outputFileName, const PVecPath &listInputFile, const PString &numberColor, const PString &footPage, const PString &footPageColor)
 Make the tex slides.
 
void slider_saveHtmlHeader (std::ofstream &fs, const PString &numberColor, const PString &footPageColor)
 Make the HTML slider header.
 
void slider_saveHtmlSlide (std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, const PString &footPage)
 Make the beamer tex slide.
 
void slider_saveHtmlSlideHtml (std::ofstream &fs, const PPath &fileTex, long unsigned int slideNumber, const PString &footPage)
 Save the html slide with a html file.
 
void slider_saveHtmlSlideMp4 (std::ofstream &fs, const PPath &fileMp4, long unsigned int slideNumber, const PString &footPage)
 Make the html mp4 slide.
 
void slider_saveHtmlSlideNumber (std::ofstream &fs, long unsigned int slideNumber, const PString &footPage)
 Save the HTML slide number.
 
void slider_saveHtmlSlidePng (std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, const PString &footPage)
 Make the html png slide.
 
void slider_saveJavascript (std::ofstream &fs)
 Make the HTML slider javascript.
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 17 of file main.cpp.

17 {
18 OptionParser parser(true, __PROGRAM_VERSION__);
19 parser.setExampleLongOption("phoenix_slider --input=fileInput.png --output=output.html");
20 parser.setExampleShortOption("phoenix_slider -i fileInput1.png fileInput2.png fileInput3.mp4 fileInput4.png -o output.html");
21
22 parser.addOption("input", "i", OptionType::FILENAME, true, "list of input files");
23
24 PString defaultOutput("output.html");
25 parser.addOption("output", "o", defaultOutput, "name of the output HTML file");
26
27 PString defaultColor("black");
28 parser.addOption("numbercolor", "n", defaultColor, "color of the slides' number (black, white, blue, green, red, yellow, gray(by default))");
29
30 PString defaultTextFootpage("");
31 parser.addOption("footpage", "f", defaultTextFootpage, "text to be written on the foot page");
32
33 PString defaultFootpageColor("white");
34 parser.addOption("footpagecolor", "g", defaultFootpageColor, "color of the foot page (black, white, blue, green, red, yellow, white(by default))");
35
36 return parser;
37}

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 362 of file main.cpp.

362 {
363 OptionParser parser = createOptionParser();
364 parser.parseArgument(argc, argv);
365
366 const OptionMode & defaultMode = parser.getDefaultMode();
367 PVecPath listInputFile;
368 defaultMode.getValue(listInputFile, "input");
369
370 PPath outputFile("output.html");
371 defaultMode.getValue(outputFile, "output");
372
373 PString numberColor("black");
374 defaultMode.getValue(numberColor, "numbercolor");
375
376 PString footPage("");
377 defaultMode.getValue(footPage, "footpage");
378
379 PString footPageColor("white");
380 defaultMode.getValue(footPageColor, "footpagecolor");
381
382 slider_makeHtmlSlides(outputFile, listInputFile, numberColor, footPage, footPageColor);
383 return 0;
384}
void slider_makeHtmlSlides(const PPath &outputFileName, const PVecPath &listInputFile, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Make the tex slides.
Definition main.cpp:322
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition main.cpp:17

References createOptionParser(), and slider_makeHtmlSlides().

+ Here is the call graph for this function:

◆ slider_makeHtmlSlides()

void slider_makeHtmlSlides ( const PPath & outputFileName,
const PVecPath & listInputFile,
const PString & numberColor,
const PString & footPage,
const PString & footPageColor )

Make the tex slides.

Parameters
outputFileName: output file name
listInputFile: list of the png slides input
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 322 of file main.cpp.

324{
325 if(outputFileName == "" || listInputFile.size() == 0lu){return;}
326
327 std::ofstream fs;
328 fs.open(outputFileName.c_str());
329 if(!fs.is_open()){
330 std::cerr << "slider_makeHtmlSlides : can't open file '" << outputFileName << "'" << std::endl;
331 return;
332 }
333 slider_saveHtmlHeader(fs, numberColor, footPageColor);
334
335 fs << "\t<body>" << std::endl;
336 fs << "\t\t<div class=\"slideshow-container\">" << std::endl;
337 PString previousFile("");
338 long unsigned int i(-1lu);
339 for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
340 PVecString listFileName = it->split('/');
341 PString currentFileName(listFileName.back());
342
343 if(previousFile.size() < 6lu || currentFileName.size() < 6lu){
344 ++i;
345 }else{
346 if(previousFile.substr(0, previousFile.size() - 6lu) != currentFileName.substr(0, currentFileName.size() - 6lu)){
347 ++i;
348 }
349 }
350 previousFile = currentFileName;
351 slider_saveHtmlSlide(fs, *it, i, footPage);
352 }
353 fs << "\t\t</div>" << std::endl;
354 fs << "\t\t<br>" << std::endl;
356 fs << "\t</body>" << std::endl;
357 fs << "</html>\n" << std::endl;
358
359 fs.close();
360}
void slider_saveJavascript(std::ofstream &fs)
Make the HTML slider javascript.
Definition main.cpp:165
void slider_saveHtmlSlide(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, const PString &footPage)
Make the beamer tex slide.
Definition main.cpp:298
void slider_saveHtmlHeader(std::ofstream &fs, const PString &numberColor, const PString &footPageColor)
Make the HTML slider header.
Definition main.cpp:44

References slider_saveHtmlHeader(), slider_saveHtmlSlide(), and slider_saveJavascript().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slider_saveHtmlHeader()

void slider_saveHtmlHeader ( std::ofstream & fs,
const PString & numberColor,
const PString & footPageColor )

Make the HTML slider header.

Parameters
[out]fs: file to be completed
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPageColor: color of the foot page

Definition at line 44 of file main.cpp.

44 {
45 fs << "<!DOCTYPE html>\n";
46 fs << "<html>\n";
47 fs << "\t<head>\n";
48 fs << "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
49 fs << "\t\t<style>\n";
50 fs << "\t\t\t* {box-sizing: border-box;}\n";
51 fs << "\t\t\tbody {\n";
52// fs << "\t\t\t\tfont-family: Verdana, sans-serif;\n";
53 fs << "\t\t\t\tfont-family: Arial, sans-serif;\n";
54 fs << "\t\t\t\tbackground-color: black;\n";
55// fs << "\t\t\t\t/* margin: auto; */\n";
56 fs << "\t\t\t}\n";
57 fs << "\t\t\t.mySlides {\n";
58 fs << "\t\t\t\tdisplay: none;\n";
59 fs << "\t\t\t\tvertical-align: middle;\n";
60 fs << "\t\t\t}\n";
61 fs << "\t\t\timg {\n";
62 fs << "\t\t\t\tvertical-align: middle;\n";
63 fs << "\t\t\t}\n";
64 fs << "\t\t\t\n";
65 fs << "\t\t\t/* Slideshow container */\n";
66 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 fs << "\t\t\t\tposition: relative;\n";
69 fs << "\t\t\t\tmargin: auto;\n";
70 fs << "\t\t\t}\n";
71 fs << "\t\t\t\n";
72 fs << "\t\t\t/* Caption text */\n";
73 fs << "\t\t\t.text {\n";
74// fs << "\t\t\t\t/* color: #f2f2f2; */\n";
75 fs << "\t\t\t\tcolor: "<<footPageColor<<";\n";
76// fs << "\t\t\t\t/* color: black; */\n";
77 fs << "\t\t\t\tfont-size: 30px;\n";
78 fs << "\t\t\t\tpadding: 8px 12px;\n";
79 fs << "\t\t\t\tposition: absolute;\n";
80 fs << "\t\t\t\tbottom: 8px;\n";
81 fs << "\t\t\t\tmargin-left: 40px;\n";
82// fs << "\t\t\t\twidth: 100%;\n";
83 fs << "\t\t\t\ttext-align: left;\n";
84 fs << "\t\t\t}\n";
85 fs << "\t\t\t\n";
86 fs << "\t\t\t/* Number text (1/3 etc) */\n";
87 fs << "\t\t\t.numbertext {\n";
88// fs << "\t\t\t\t/* color: #f2f2f2; */\n";
89 fs << "\t\t\t\tcolor: "<<numberColor<<";\n";
90 fs << "\t\t\t\tfont-size: 40px;\n";
91 fs << "\t\t\t\tpadding: 8px 12px;\n";
92 fs << "\t\t\t\tposition: absolute;\n";
93// fs << "\t\t\t\t/* top: 0; */\n";
94 fs << "\t\t\t\tbottom: 8px;\n";
95 fs << "\t\t\t\twidth: 100%;\n";
96 fs << "\t\t\t\ttext-align: right;\n";
97 fs << "\t\t\t}\n";
98 fs << "\t\t\t\n";
99 fs << "\t\t\t.slideContent{\n";
100 fs << "\t\t\t\tcolor: "<<footPageColor<<";\n";
101 fs << "\t\t\t\tdisplay: block;\n";
102 fs << "\t\t\t\tposition: absolute;\n";
103 fs << "\t\t\t\twidth: 100%;\n";
104 fs << "\t\t\t\ttop: 0px;\n";
105 fs << "\t\t\t}\n";
106
107 fs << "\t\t\t.slideContent h1{\n";
108 fs << "\t\t\t\tcolor: "<<footPageColor<<";\n";
109 fs << "\t\t\t\ttext-align: center;\n";
110 fs << "\t\t\t\tfont-size: 60px;\n";
111 fs << "\t\t\t}\n";
112
113 fs << "\t\t\t.slideContent .slidebody{\n";
114 fs << "\t\t\t\tcolor: "<<footPageColor<<";\n";
115 fs << "\t\t\t\tmargin-left: 40px;\n";
116 fs << "\t\t\t\ttext-align: left;\n";
117 fs << "\t\t\t\tfont-size: 40px;\n";
118 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 fs << "\t\t\t/* The dots/bullets/indicators */\n";
129 fs << "\t\t\t.dot {\n";
130 fs << "\t\t\t\theight: 15px;\n";
131 fs << "\t\t\t\twidth: 15px;\n";
132 fs << "\t\t\t\tmargin: 0 2px;\n";
133 fs << "\t\t\t\tbackground-color: #bbb;\n";
134 fs << "\t\t\t\tborder-radius: 50%;\n";
135 fs << "\t\t\t\tdisplay: inline-block;\n";
136 fs << "\t\t\t\ttransition: background-color 0.6s ease;\n";
137 fs << "\t\t\t}\n";
138 fs << "\t\t\t\n";
139 fs << "\t\t\t.active {\n";
140 fs << "\t\t\t\tbackground-color: #717171;\n";
141 fs << "\t\t\t}\n";
142 fs << "\t\t\t\n";
143 fs << "\t\t\t/* Fading animation */\n";
144 fs << "\t\t\t.fade {\n";
145 fs << "\t\t\t\tanimation-name: fade;\n";
146 fs << "\t\t\t\tanimation-duration: 1.5s;\n";
147 fs << "\t\t\t}\n";
148 fs << "\t\t\t\n";
149 fs << "\t\t\t@keyframes fade {\n";
150 fs << "\t\t\t\tfrom {opacity: .4}\n";
151 fs << "\t\t\t\tto {opacity: 1}\n";
152 fs << "\t\t\t}\n";
153 fs << "\t\t\t\n";
154 fs << "\t\t\t/* On smaller screens, decrease text size */\n";
155 fs << "\t\t\t@media only screen and (max-width: 300px) {\n";
156 fs << "\t\t\t\t.text {font-size: 11px}\n";
157 fs << "\t\t\t}\n";
158 fs << "\t\t</style>\n";
159 fs << "\t</head>\n";
160}

Referenced by slider_makeHtmlSlides().

+ Here is the caller graph for this function:

◆ slider_saveHtmlSlide()

void slider_saveHtmlSlide ( std::ofstream & fs,
const PPath & filePng,
long unsigned int slideNumber,
const PString & footPage )

Make the beamer tex slide.

Parameters
[out]fs: file to be completed
filePng: file png to be in the slide
slideNumber: slide number
footPage: string to be written in the footpage of the slides

Definition at line 298 of file main.cpp.

298 {
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 PString fileExtention(filePng.getExtension());
304 if(fileExtention == "png"){
305 slider_saveHtmlSlidePng(fs, filePng, slideNumber, footPage);
306 }else if(fileExtention == "mp4"){
307 slider_saveHtmlSlideMp4(fs, filePng, slideNumber, footPage);
308 }else if(fileExtention == "html"){
309 slider_saveHtmlSlideHtml(fs, filePng, slideNumber, footPage);
310 }else{
311 std::cerr << "slider_saveHtmlSlide : unknown extention '"<<fileExtention<<"' of file '"<<filePng<<"'" << std::endl;
312 }
313}
void slider_saveHtmlSlidePng(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, const PString &footPage)
Make the html png slide.
Definition main.cpp:236
void slider_saveHtmlSlideMp4(std::ofstream &fs, const PPath &fileMp4, long unsigned int slideNumber, const PString &footPage)
Make the html mp4 slide.
Definition main.cpp:251
void slider_saveHtmlSlideHtml(std::ofstream &fs, const PPath &fileTex, long unsigned int slideNumber, const PString &footPage)
Save the html slide with a html file.
Definition main.cpp:277

References slider_saveHtmlSlideHtml(), slider_saveHtmlSlideMp4(), and slider_saveHtmlSlidePng().

Referenced by slider_makeHtmlSlides().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slider_saveHtmlSlideHtml()

void slider_saveHtmlSlideHtml ( std::ofstream & fs,
const PPath & fileTex,
long unsigned int slideNumber,
const PString & footPage )

Save the html slide with a html file.

Parameters
[out]fs: file to be written
fileTex: name of the tex file to be red
slideNumber: slide number
footPage: string to be written in the footpage of the slides

Definition at line 277 of file main.cpp.

278{
279 PString backGroundFile(CMAKE_INSTALL_PREFIX "/share/PhoenixSlider/theme2.png");
280 if(slideNumber == 0){
281 backGroundFile = CMAKE_INSTALL_PREFIX "/share/PhoenixSlider/firstTheme.png";
282 }
283 fs << "\t\t\t<div class=\"mySlides\">\n";
284 slider_saveHtmlSlideNumber(fs, slideNumber, footPage);
285 fs << "\t\t\t\t<img src=\""<<backGroundFile<<"\" style=\"width:100%\">\n";
286 fs << "\t\t\t\t<div class=\"slideContent\">\n";
287 fs << fileTex.loadFileContent() << std::endl;
288 fs << "\t\t\t\t</div>\n";
289 fs << "\t\t\t</div>\n";
290}
void slider_saveHtmlSlideNumber(std::ofstream &fs, long unsigned int slideNumber, const PString &footPage)
Save the HTML slide number.
Definition main.cpp:220

References slider_saveHtmlSlideNumber().

Referenced by slider_saveHtmlSlide().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slider_saveHtmlSlideMp4()

void slider_saveHtmlSlideMp4 ( std::ofstream & fs,
const PPath & fileMp4,
long unsigned int slideNumber,
const PString & footPage )

Make the html mp4 slide.

Parameters
[out]fs: file to be completed
fileMp4: mp4 file to be in the slide
slideNumber: slide number
footPage: string to be written in the footpage of the slides

Definition at line 251 of file main.cpp.

251 {
252 PString loopAttribute("");
253 if(fileMp4.size() > 8lu){
254 PString baseName(fileMp4.eraseExtension());
255 if(baseName.substr(baseName.size() - 4lu, baseName.size()) == "loop"){
256 loopAttribute = " loop";
257 }
258 }
259
260 fs << "\t\t\t<div class=\"mySlides\">\n";
261 slider_saveHtmlSlideNumber(fs, slideNumber, footPage);
262 fs << "\t\t\t\t<video style=\"width:100%\" autoplay muted"<<loopAttribute<<">\n";
263 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 fs << "\t\t\t\t <source src=\""<<fileMp4<<"\" type=\"video/mp4\">\n";
265 fs << "\t\t\t\t</video>\n";
266
267// fs << "\t\t\t\t<div class=\"text\">Caption One</div>\n";
268 fs << "\t\t\t</div>\n";
269}

References slider_saveHtmlSlideNumber().

Referenced by slider_saveHtmlSlide().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slider_saveHtmlSlideNumber()

void slider_saveHtmlSlideNumber ( std::ofstream & fs,
long unsigned int slideNumber,
const PString & footPage )

Save the HTML slide number.

Parameters
[out]fs: file to be written
slideNumber: slide number
footPage: string to be written in the footpage of the slides

Definition at line 220 of file main.cpp.

220 {
221 if(slideNumber != 0lu){
222 fs << "\t\t\t\t<div class=\"numbertext\">"<<(slideNumber + 1lu)<<"</div>\n";
223
224 if(footPage != ""){
225 fs << "\t\t\t\t<div class=\"text\">"<<footPage<<"</div>\n";
226 }
227 }
228}

Referenced by slider_saveHtmlSlideHtml(), slider_saveHtmlSlideMp4(), and slider_saveHtmlSlidePng().

+ Here is the caller graph for this function:

◆ slider_saveHtmlSlidePng()

void slider_saveHtmlSlidePng ( std::ofstream & fs,
const PPath & filePng,
long unsigned int slideNumber,
const PString & footPage )

Make the html png slide.

Parameters
[out]fs: file to be completed
filePng: file png to be in the slide
slideNumber: slide number
footPage: string to be written in the footpage of the slides

Definition at line 236 of file main.cpp.

237{
238 fs << "\t\t\t<div class=\"mySlides\">\n";
239 slider_saveHtmlSlideNumber(fs, slideNumber, footPage);
240 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 fs << "\t\t\t</div>\n";
243}

References slider_saveHtmlSlideNumber().

Referenced by slider_saveHtmlSlide().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slider_saveJavascript()

void slider_saveJavascript ( std::ofstream & fs)

Make the HTML slider javascript.

Parameters
[out]fs: file to be completed

Definition at line 165 of file main.cpp.

165 {
166 fs << "<script>\n";
167 fs << "let slideIndex = 1;\n";
168 fs << "showSlides(slideIndex);\n";
169 fs << "\n";
170 fs << "// Next/previous controls\n";
171 fs << "function plusSlides(n){\n";
172 fs << "\tshowSlides(slideIndex += n);\n";
173 fs << "}\n";
174 fs << "\n";
175 fs << "// Thumbnail image controls\n";
176 fs << "function currentSlide(n){\n";
177 fs << "\tshowSlides(slideIndex = n);\n";
178 fs << "}\n";
179 fs << "\n";
180 fs << "function showSlides(n) {\n";
181 fs << "\tlet i;\n";
182 fs << "\tlet slides = document.getElementsByClassName(\"mySlides\");\n";
183// fs << "\t// let dots = document.getElementsByClassName(\"dot\");\n";
184 fs << "\tif(n > slides.length){slideIndex = 1}\n";
185 fs << "\tif(n < 1){slideIndex = slides.length}\n";
186 fs << "\tfor(i = 0; i < slides.length; i++){\n";
187 fs << "\t\tslides[i].style.display = \"none\";\n";
188 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 fs << "\tslides[slideIndex-1].style.display = \"block\";\n";
193// fs << "\t// dots[slideIndex-1].className += \" active\";\n";
194 fs << "}\n";
195 fs << "\n";
196 fs << "document.onkeydown = function(e){\n";
197 fs << "\tswitch(e.keyCode){\n";
198 fs << "\t\tcase 37:\n";
199 fs << "\t\t\t//left\n";
200 fs << "\t\t\te.preventDefault();\n";
201 fs << "\t\t\tslideIndex--;\n";
202 fs << "\t\t\tshowSlides(slideIndex);\n";
203 fs << "\t\t\tbreak;\n";
204 fs << "\t\tcase 39:\n";
205 fs << "\t\t\t//right\n";
206 fs << "\t\t\te.preventDefault();\n";
207 fs << "\t\t\tslideIndex++;\n";
208 fs << "\t\t\tshowSlides(slideIndex);\n";
209 fs << "\t\t\tbreak;\n";
210 fs << "\t}\n";
211 fs << "}\n";
212 fs << "</script>\n";
213}

Referenced by slider_makeHtmlSlides().

+ Here is the caller graph for this function: