PhoenixLecture  2.0.0
Set of tools to make lectures
pbiblio_html.cpp File Reference
#include "convertToString.h"
#include "platexobj_html.h"
#include "pbiblio_html.h"
+ Include dependency graph for pbiblio_html.cpp:

Go to the source code of this file.

Functions

PString createNavigationMenuBiblio (const PString &cssClassName, const POutoutMode &outputMode)
 Create the navigation menu. More...
 
PString pbiblio_attributeHtml (const PString &attrValue, const PString &balise, const PString &extraText)
 Convert a biblio attribute in html. More...
 
PString pbiblio_attributeUrlHtml (const PString &attrValue, const PString &balise)
 Convert a biblio attribute in html. More...
 
PString pbiblio_entryHtml (const PBiblioEntry &bibEntry)
 Convert a PBiblioEntry in html. More...
 
bool pbiblio_entryPage (const PBiblioEntry &bibEntry, const POutoutMode &outputMode)
 Convert a PBiblioEntry in html. More...
 
PString pbiblio_entryPageHtml (const PBiblioEntry &bibEntry)
 Convert a PBiblioEntry in html. More...
 
PString pbiblio_entryTypeToHtml (PBiblioEntryType::PBiblioEntryType type)
 Convert a string into an entry type. More...
 
PString pbiblio_html (const PMapBiblioEntry &mapBiblioEntry, const POutoutMode &outputMode)
 Save the bibliography in string. More...
 
bool pbiblio_html (const PPath &fileName, const PMapBiblioEntry &mapBiblioEntry, const POutoutMode &outputMode)
 Save the bibliography in html. More...
 

Function Documentation

◆ createNavigationMenuBiblio()

PString createNavigationMenuBiblio ( const PString cssClassName,
const POutoutMode outputMode 
)

Create the navigation menu.

Parameters
cssClassName: css class name to be used
outputMode: mode to be used to generate the site
Returns
output html string

Definition at line 16 of file pbiblio_html.cpp.

16  {
17  PString body("");
18  body += "\t\t<table class=\""+cssClassName+"\">\n";
19  body += "\t\t\t<tr>\n";
20  body += "\t\t\t<td><a href=\"index.html\">Main Page</a></td>\n";
21  body += "\t\t\t<td><a href=\"bibliography.html\">Bibliographie</a></td>\n";
22  if(!outputMode.isBookTheme){
23  body += "\t\t\t<td><a href=\"outline.html\">Outline</a></td>\n";
24  }
25  body += "\t\t\t</tr>\n";
26  body += "\t\t</table>\n";
27  return body;
28 }
Extends the std::string.
Definition: PString.h:16
bool isBookTheme
True to activate the book theme.

References POutoutMode::isBookTheme.

Referenced by pbiblio_entryPage(), and pbiblio_html().

+ Here is the caller graph for this function:

◆ pbiblio_attributeHtml()

PString pbiblio_attributeHtml ( const PString attrValue,
const PString balise,
const PString extraText 
)

Convert a biblio attribute in html.

Parameters
attrValue: value of the attribute
balise: balise used to display this attribute
extraText: extra text to be printed
Returns
html

Definition at line 50 of file pbiblio_html.cpp.

50  {
51  if(attrValue == ""){return "";}
52  PString body("");
53  body += "\t<"+balise+">";
54  if(extraText != ""){
55  body += extraText + " : ";
56  }
57  body += convertStrToHtml(attrValue)+"</"+balise+">\n";
58  return body;
59 }
PString convertStrToHtml(const PString &str)
fonction qui converti une chaîne de caractères en html (elle remplace les caractères spéciaux)

References convertStrToHtml().

Referenced by pbiblio_entryHtml(), and pbiblio_entryPageHtml().

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

◆ pbiblio_attributeUrlHtml()

PString pbiblio_attributeUrlHtml ( const PString attrValue,
const PString balise 
)

Convert a biblio attribute in html.

Parameters
attrValue: value of the attribute
balise: balise used to display this attribute
Returns
html

Definition at line 66 of file pbiblio_html.cpp.

66  {
67  if(attrValue == ""){return "";}
68  PString body("");
69  body += "\t<"+balise+"><a href=\""+attrValue+"\">"+attrValue+"</a></"+balise+">\n";
70  return body;
71 }

Referenced by pbiblio_entryHtml(), and pbiblio_entryPageHtml().

+ Here is the caller graph for this function:

◆ pbiblio_entryHtml()

PString pbiblio_entryHtml ( const PBiblioEntry bibEntry)

Convert a PBiblioEntry in html.

Parameters
bibEntry: entry to be converted in html
Returns
string

Definition at line 129 of file pbiblio_html.cpp.

129  {
130  PString body("");
131  body += "<div class=\""+pbiblio_entryTypeToHtml(bibEntry.getType())+"\" id=\""+valueToString(bibEntry.getId())+"\">\n";
132  body += pbiblio_attributeHtml(bibEntry.getTitle(), "h1", "Title");
133  body += pbiblio_attributeHtml(bibEntry.getAuthor(), "h2", "Authors");
134  body += pbiblio_attributeHtml(bibEntry.getJournal(), "h3", "Journal");
135  body += pbiblio_attributeHtml(bibEntry.getVolume(), "h3", "Volume");
136  body += pbiblio_attributeHtml(bibEntry.getYear(), "h3", "Year");
137  body += pbiblio_attributeHtml(bibEntry.getPages(), "h3", "Pages");
138  body += pbiblio_attributeUrlHtml(bibEntry.getUrl(), "h3");
139  body += "\t<a href=\"bib_"+valueToString(bibEntry.getId())+".html\">+ informations</a>\n";
140  body += "</div>\n";
141  return body;
142 }
const PString & getUrl() const
Gets the url of the PBiblioEntry.
Definition: PLatexObj.cpp:2075
const PBiblioEntryType::PBiblioEntryType & getType() const
Gets the type of the PBiblioEntry.
Definition: PLatexObj.cpp:1907
const PString & getAuthor() const
Gets the author of the PBiblioEntry.
Definition: PLatexObj.cpp:1935
const PString & getTitle() const
Gets the title of the PBiblioEntry.
Definition: PLatexObj.cpp:1949
const PString & getVolume() const
Gets the volume of the PBiblioEntry.
Definition: PLatexObj.cpp:1991
const PString & getJournal() const
Gets the journal of the PBiblioEntry.
Definition: PLatexObj.cpp:1963
const PString & getPages() const
Gets the pages of the PBiblioEntry.
Definition: PLatexObj.cpp:2061
const PString & getYear() const
Gets the year of the PBiblioEntry.
Definition: PLatexObj.cpp:2033
size_t getId() const
Gets the id of the PBiblioEntry.
Definition: PLatexObj.cpp:1893
std::string valueToString(const T &val)
Convert a type into a string.
PString pbiblio_attributeHtml(const PString &attrValue, const PString &balise, const PString &extraText)
Convert a biblio attribute in html.
PString pbiblio_entryTypeToHtml(PBiblioEntryType::PBiblioEntryType type)
Convert a string into an entry type.
PString pbiblio_attributeUrlHtml(const PString &attrValue, const PString &balise)
Convert a biblio attribute in html.

References PBiblioEntry::getAuthor(), PBiblioEntry::getId(), PBiblioEntry::getJournal(), PBiblioEntry::getPages(), PBiblioEntry::getTitle(), PBiblioEntry::getType(), PBiblioEntry::getUrl(), PBiblioEntry::getVolume(), PBiblioEntry::getYear(), pbiblio_attributeHtml(), pbiblio_attributeUrlHtml(), pbiblio_entryTypeToHtml(), and valueToString().

Referenced by pbiblio_html().

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

◆ pbiblio_entryPage()

bool pbiblio_entryPage ( const PBiblioEntry bibEntry,
const POutoutMode outputMode 
)

Convert a PBiblioEntry in html.

Parameters
bibEntry: entry to be converted in html
outputMode: output mode to get info about html page
Returns
true on success, false otherwise

Definition at line 101 of file pbiblio_html.cpp.

101  {
102  PString body(getHtmlHeader(bibEntry.getTitle(), false, false, outputMode.currentStyle));
103  body += createNavigationMenuBiblio("navigationMenu", outputMode);
104  body += "\t\t<div class=\"biblioContent\">\n";
105 
106  body += "\t\t\t<div class=\""+pbiblio_entryTypeToHtml(bibEntry.getType())+"\">\n";
107  body += pbiblio_entryPageHtml(bibEntry);
108  body += "\t\t\t</div>\n";
109 
110  body += "\t\t</div>\n";
111  body += createNavigationMenuBiblio("navigationMenuBottom", outputMode);
112  body += getHtmlFooter();
113 
114  PPath fileName("bib_"+valueToString(bibEntry.getId())+".html");
115  if(!fileName.saveFileContent(body)){
116  std::cerr << "pbiblio_entryPage : can't save file '"<<fileName<<"'" << std::endl;
117  return false;
118  }
119 // else{
120 // std::cerr << "pbiblio_entryPage : save file '"<<fileName<<"'" << std::endl;
121 // }
122  return true;
123 }
Path of a directory or a file.
Definition: PPath.h:17
PString pbiblio_entryPageHtml(const PBiblioEntry &bibEntry)
Convert a PBiblioEntry in html.
PString createNavigationMenuBiblio(const PString &cssClassName, const POutoutMode &outputMode)
Create the navigation menu.
PString getHtmlHeader(const PString &title, bool useMathJax, bool useRemoteMathjax, const PString &currentStyle)
Get the html header.
PString getHtmlFooter()
PString currentStyle
Current style to be used for the generated pages of the site.

References createNavigationMenuBiblio(), POutoutMode::currentStyle, getHtmlFooter(), getHtmlHeader(), PBiblioEntry::getId(), PBiblioEntry::getTitle(), PBiblioEntry::getType(), pbiblio_entryPageHtml(), pbiblio_entryTypeToHtml(), PPath::saveFileContent(), and valueToString().

Referenced by pbiblio_html().

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

◆ pbiblio_entryPageHtml()

PString pbiblio_entryPageHtml ( const PBiblioEntry bibEntry)

Convert a PBiblioEntry in html.

Parameters
bibEntry: entry to be converted in html
Returns
string

Definition at line 77 of file pbiblio_html.cpp.

77  {
78  PString fileName("bib_"+valueToString(bibEntry.getId())+".html");
79  PString body("");
80  body += pbiblio_attributeHtml(bibEntry.getTitle(), "h1", "Title");
81  body += pbiblio_attributeHtml(bibEntry.getAuthor(), "h2", "Authors");
82  body += pbiblio_attributeHtml(bibEntry.getJournal(), "h3", "Journal");
83  body += pbiblio_attributeHtml(bibEntry.getVolume(), "h3", "Volume");
84  body += pbiblio_attributeHtml(bibEntry.getYear(), "h3", "Year");
85  body += pbiblio_attributeHtml(bibEntry.getPages(), "h3", "Pages");
86  body += pbiblio_attributeUrlHtml(bibEntry.getUrl(), "h3");
87  //TODO : Add more info there
88  if(bibEntry.getAbstract() != ""){
89  body += "<h3>Abstract</h3>\n";
90  body += bibEntry.getAbstract() + "\n";
91  }
92 
93  return body;
94 }
const PString & getAbstract() const
Gets the abstract of the PBiblioEntry.
Definition: PLatexObj.cpp:2173

References PBiblioEntry::getAbstract(), PBiblioEntry::getAuthor(), PBiblioEntry::getId(), PBiblioEntry::getJournal(), PBiblioEntry::getPages(), PBiblioEntry::getTitle(), PBiblioEntry::getUrl(), PBiblioEntry::getVolume(), PBiblioEntry::getYear(), pbiblio_attributeHtml(), pbiblio_attributeUrlHtml(), and valueToString().

Referenced by pbiblio_entryPage().

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

◆ pbiblio_entryTypeToHtml()

PString pbiblio_entryTypeToHtml ( PBiblioEntryType::PBiblioEntryType  type)

Convert a string into an entry type.

Parameters
type: type to be used
Returns
corresponding entry type

Definition at line 34 of file pbiblio_html.cpp.

34  {
35  if(type == PBiblioEntryType::ARTICLE){return "bibarticle";}
36  else if(type == PBiblioEntryType::BOOK){return "bibbook";}
37  else if(type == PBiblioEntryType::SOFTWARE){return "bibsoftware";}
38  else if(type == PBiblioEntryType::INPROCEEDINGS){return "bibinproceedings";}
39  else if(type == PBiblioEntryType::PHDTHESIS){return "bibphdthesis";}
40  else if(type == PBiblioEntryType::TECHREPORT){return "bibtechreport";}
41  else {return "bibarticle";}
42 }

References PBiblioEntryType::ARTICLE, PBiblioEntryType::BOOK, PBiblioEntryType::INPROCEEDINGS, PBiblioEntryType::PHDTHESIS, PBiblioEntryType::SOFTWARE, and PBiblioEntryType::TECHREPORT.

Referenced by pbiblio_entryHtml(), and pbiblio_entryPage().

+ Here is the caller graph for this function:

◆ pbiblio_html() [1/2]

PString pbiblio_html ( const PMapBiblioEntry mapBiblioEntry,
const POutoutMode outputMode 
)

Save the bibliography in string.

Parameters
mapBiblioEntry: full bibliography to be saved
outputMode: output mode to get info about html page
Returns
string

Definition at line 149 of file pbiblio_html.cpp.

149  {
150  PString body(getHtmlHeader("Bibliography", false, false, outputMode.currentStyle));
151  body += createNavigationMenuBiblio("navigationMenu", outputMode);
152  body += "\t\t<div class=\"biblioContent\">\n";
153 
154  for(PMapBiblioEntry::const_iterator it(mapBiblioEntry.begin()); it != mapBiblioEntry.end(); ++it){
155  body += pbiblio_entryHtml(it->second);
156  pbiblio_entryPage(it->second, outputMode);
157  }
158 
159  body += "\t\t</div>\n";
160  body += createNavigationMenuBiblio("navigationMenuBottom", outputMode);
161  body += getHtmlFooter();
162  return body;
163 }
PString pbiblio_entryHtml(const PBiblioEntry &bibEntry)
Convert a PBiblioEntry in html.
bool pbiblio_entryPage(const PBiblioEntry &bibEntry, const POutoutMode &outputMode)
Convert a PBiblioEntry in html.

References createNavigationMenuBiblio(), POutoutMode::currentStyle, getHtmlFooter(), getHtmlHeader(), pbiblio_entryHtml(), and pbiblio_entryPage().

Referenced by pbiblio_html(), and processAllFile().

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

◆ pbiblio_html() [2/2]

bool pbiblio_html ( const PPath fileName,
const PMapBiblioEntry mapBiblioEntry,
const POutoutMode outputMode 
)

Save the bibliography in html.

Parameters
fileName: name of the file to be saved
mapBiblioEntry: full bibliography to be saved
outputMode: output mode to get info about html page
Returns
true on success, false otherwise

Definition at line 171 of file pbiblio_html.cpp.

171  {
172  PString fileContent(pbiblio_html(mapBiblioEntry, outputMode));
173  if(!fileName.saveFileContent(fileContent)){
174  std::cerr << "platexobj_html : can't save file '"<<fileName<<"'" << std::endl;
175  return false;
176  }else{
177  std::cerr << "platexobj_html : save file '"<<fileName<<"'" << std::endl;
178  }
179  return true;
180 
181 
182 }
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
PString pbiblio_html(const PMapBiblioEntry &mapBiblioEntry, const POutoutMode &outputMode)
Save the bibliography in string.

References pbiblio_html(), and PPath::saveFileContent().

+ Here is the call graph for this function: