PhoenixLecture  2.0.0
Set of tools to make lectures
platexobj_html_book.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "phoenix_system.h"
8 #include "platexobj_html.h"
9 #include "platexobj_menu.h"
10 #include "platexobj_rawtext.h"
11 
12 #include "platexobj_html_book.h"
13 
14 
16 
24 bool platexobj_book_createPage(POutoutMode & outputMode, const PLatexObj & obj,
25  const PString & baliseName, const PString & cssClassName, const PString & prefixTitle, bool isBibliography)
26 {
27  PString body("");
28  const PVecLatexObj & vecObj = obj.getVecContent();
29  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
30  body += platexobj_bookHtml(outputMode, *it, isBibliography, true);
31  }
32  PString objTitle(getSectionTitle(outputMode, obj)); //Content of the section title
34  obj.getPrevSec().getLink(), obj.getPrevSec().getText(),
35  obj.getNextSec().getLink(), obj.getNextSec().getText(),
36  obj.getParentSec().getLink(), obj.getParentSec().getText(),
37  obj.getSourceFile(), obj.getSourceLine());
38 
39  outputMode.mapVar["${MAIN_TITLE}"] = "\t\t" + platexobj_createTitle(obj, baliseName, cssClassName, objTitle, prefixTitle, true);
40 // outputMode.mapVar["${SUB_MENU}"] = vecMenuToHtml(obj.getVecMenu());
41  outputMode.mapVar["${SUB_MENU}"] = "";
42  outputMode.mapVar["${PAGE_CONTENT}"] = body;
43 
44  PPath fileName(obj.getLink());
45  if(!fileName.saveFileContent(platexobj_theme_createPage(outputMode))){
46  std::cerr << "platexobj_book_createPage : can't save file '"<<fileName<<"' for object '" << obj.getName() << "'" << std::endl;
47  return false;
48  }else{
49 // std::cout << "platexobj_book_createPage : save file '"<<fileName<<"'" << std::endl;
50  return true;
51  }
52 }
53 
55 
59 PString platexobj_bookIndexHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography){
60  PString body("");
61  const PVecLatexObj & vecObj = obj.getVecContent();
62  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
63  body += platexobj_bookHtml(outputMode, *it, isBibliography, true);
64  }
65  PString objTitle(obj.getName()); //Content of the section title
66  platexobj_theme_update_var(outputMode, obj.getLink(), objTitle,
67  obj.getPrevSec().getLink(), obj.getPrevSec().getText(),
68  obj.getNextSec().getLink(), obj.getNextSec().getText(),
69  obj.getParentSec().getLink(), obj.getParentSec().getText(),
70  obj.getSourceFile(), obj.getSourceLine());
71  PString bodyTitle("");
72  bodyTitle += platexobj_htmlMainTitle(obj.getName(), "h1", "mainTitle");
73  bodyTitle += platexobj_htmlMainTitle(obj.getSubTitle(), "h2", "mainSubTitle");
74  bodyTitle += platexobj_htmlMainTitle(obj.getAuthor(), "h5", "author");
75  bodyTitle += platexobj_htmlMainTitle(obj.getDate(), "h6", "date");
76  outputMode.mapVar["${MAIN_TITLE}"] = bodyTitle;
77 // outputMode.mapVar["${SUB_MENU}"] = vecMenuToHtml(obj.getVecMenu());
78  outputMode.mapVar["${SUB_MENU}"] = "";
79  outputMode.mapVar["${PAGE_CONTENT}"] = body;
80  return platexobj_theme_createPage(outputMode);
81 }
82 
84 
90 PString platexobj_bookHtml(POutoutMode & outputMode, const std::vector<PLatexObj> & vecObj, bool isBibliography, bool allowText){
91  PString body("");
92  for(std::vector<PLatexObj>::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
93  body += platexobj_bookHtml(outputMode, *it, isBibliography, allowText);
94  }
95  return body;
96 }
97 
99 
105 PString platexobj_bookHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography, bool allowText){
106  PString body("");
107  PLatexType::PLatexType type(obj.getType());
108  if(type == PLatexType::PART){platexobj_book_createPage(outputMode, obj, "h1", "ptexpart", "Part", isBibliography);}
109  else if(type == PLatexType::CHAPTER){platexobj_book_createPage(outputMode, obj, "h2", "ptexchapter", "Chapter", isBibliography);}
110  else if(type == PLatexType::SECTION){platexobj_book_createPage(outputMode, obj, "h3", "ptexsection", "", isBibliography);}
111  else if(type == PLatexType::SUBSECTION){platexobj_book_createPage(outputMode, obj, "h4", "ptexsubsection", "", isBibliography);}
112  else if(type == PLatexType::SUBSUBSECTION){platexobj_book_createPage(outputMode, obj, "h5", "ptexsubsubsection", "", isBibliography);}
113  else if(type == PLatexType::FILE){body = platexobj_bookIndexHtml(outputMode, obj, isBibliography);}
114  else if(!platexobj_htmlStrBase(body, outputMode, obj, isBibliography, allowText)){
115  body = platexobj_bookHtml(outputMode, obj.getVecContent(), isBibliography, allowText);
116  }
117  return body;
118 }
119 
120 
121 
const PString & getText() const
Gets the text of the PLatexMenu.
Definition: PLatexObj.cpp:69
const PString & getLink() const
Gets the link of the PLatexMenu.
Definition: PLatexObj.cpp:55
Describe a latex object.
Definition: PLatexObj.h:40
const PLatexMenu & getNextSec() const
Gets the nextSec of the PLatexObj.
Definition: PLatexObj.cpp:480
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
const std::vector< PLatexObj > & getComplexTitle() const
Gets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:396
const PString & getSubTitle() const
Gets the subTitle of the PLatexObj.
Definition: PLatexObj.cpp:340
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
const PString & getName() const
Gets the name of the PLatexObj.
Definition: PLatexObj.cpp:326
const PString & getLink() const
Gets the link of the PLatexObj.
Definition: PLatexObj.cpp:368
const PLatexMenu & getParentSec() const
Gets the parentSec of the PLatexObj.
Definition: PLatexObj.cpp:494
const PString & getAuthor() const
Gets the author of the PLatexObj.
Definition: PLatexObj.cpp:508
const PString & getSourceFile() const
Gets the sourceFile of the PLatexObj.
Definition: PLatexObj.cpp:536
size_t getSourceLine() const
Gets the sourceLine of the PLatexObj.
Definition: PLatexObj.cpp:550
const PString & getDate() const
Gets the date of the PLatexObj.
Definition: PLatexObj.cpp:522
const PLatexMenu & getPrevSec() const
Gets the prevSec of the PLatexObj.
Definition: PLatexObj.cpp:466
Path of a directory or a file.
Definition: PPath.h:17
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
Extends the std::string.
Definition: PString.h:16
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
@ SUBSUBSECTION
Definition: PLatexType.h:54
PString platexobj_theme_createPage(POutoutMode &outputMode)
Create the page from variables in POutoutMode.
void platexobj_theme_update_var(POutoutMode &outputMode, const PString &pageLink, const PString &pageTitle, const PString &prevSecLink, const PString &prevSecTitle, const PString &nextSecLink, const PString &nextSecTitle, const PString &parentSecLink, const PString &parentSecTitle, const PPath &currentSourceFile, size_t currentSourceLine)
Update var of POutoutMode for current section.
PString platexobj_createTitle(const PLatexObj &obj, const PString &baliseName, const PString &cssClassName, const PString objTitle, const PString &prefixTitle, bool addLinkLabel)
Create a title.
PString platexobj_htmlMainTitle(const PString &title, const PString &hLevel, const PString &cssClassName)
bool platexobj_htmlStrBase(PString &body, POutoutMode &outputMode, const PLatexObj &obj, bool isBibliography, bool allowText)
PString platexobj_bookHtml(POutoutMode &outputMode, const std::vector< PLatexObj > &vecObj, bool isBibliography, bool allowText)
Convert a PLatexObj into a string with book theme.
bool platexobj_book_createPage(POutoutMode &outputMode, const PLatexObj &obj, const PString &baliseName, const PString &cssClassName, const PString &prefixTitle, bool isBibliography)
Create a page with book theme.
PString platexobj_bookIndexHtml(POutoutMode &outputMode, const PLatexObj &obj, bool isBibliography)
Save the index.html file.
PString platexobj_rawtext(const std::vector< PLatexObj > &vecObj)
Convert a PLatexObj in text.
PString getSectionTitle(POutoutMode &outputMode, const PLatexObj &obj)
Get the title of a part/chapter/section etc.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
Output mode of the html backend.
PMapKnownVar mapVar
Map of output var which are use to fill the output themes.