projects
/
biaweb2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactored template loading to its own class for performance
[biaweb2.git]
/
biawebdocument.hpp
diff --git
a/biawebdocument.hpp
b/biawebdocument.hpp
index
65005dd
..
3972107
100644
(file)
--- a/
biawebdocument.hpp
+++ b/
biawebdocument.hpp
@@
-8,11
+8,11
@@
#include <iomanip>
#include <ctime>
#include <fmt/format.h>
#include <iomanip>
#include <ctime>
#include <fmt/format.h>
-#include <fmt/chrono.h>
#include "biawebutil.hpp"
#include "biawebsidebar.hpp"
#include "biawebstrings.hpp"
#include "biawebnavigationbit.hpp"
#include "biawebutil.hpp"
#include "biawebsidebar.hpp"
#include "biawebstrings.hpp"
#include "biawebnavigationbit.hpp"
+#include "biawebtemplate.hpp"
// class to represent a biaweb document which can have a file name, title, description,
// keywords, content and sidebar items
// class to represent a biaweb document which can have a file name, title, description,
// keywords, content and sidebar items
@@
-101,8
+101,8
@@
namespace biaweb {
return this->cdate;
}
return this->cdate;
}
- // output the document to HTML using the template
s in templatedir
- void output_to_html (
std::string templatedir
, std::string path);
+ // output the document to HTML using the template
specified
+ void output_to_html (
Template *t
, std::string path);
// set the content portion of document as raw HTML content
void set_content (std::string content) {
// set the content portion of document as raw HTML content
void set_content (std::string content) {
@@
-194,26
+194,20
@@
namespace biaweb {
}
// output the document using the provided template
}
// output the document using the provided template
- void Document::output_to_html (
std::string templatedir
, std::string path)
+ void Document::output_to_html (
Template *t
, std::string path)
{
{
- // read the main template file
- std::ifstream tpl (templatedir + "/main.tpl.html");
- std::string templstr ( (std::istreambuf_iterator<char> (tpl)),
- (std::istreambuf_iterator<char> ()) );
- tpl.close ();
+ std::string templstr = t->get_main_tpl ();
+
// read the style template file
// read the style template file
- std::ifstream style (templatedir + "/style.tpl.css");
- std::string stylesheet ( (std::istreambuf_iterator<char> (style)),
- (std::istreambuf_iterator<char> ()));
- style.close ();
+ std::string stylesheet = t->get_style_tpl ();
// first render the sidebars
std::string sidebartext;
for (SideBar bar : sidebars) {
// first render the sidebars
std::string sidebartext;
for (SideBar bar : sidebars) {
- sidebartext += bar.to_html (t
emplatedir
);
+ sidebartext += bar.to_html (t);
}
// render the navigation bit
}
// render the navigation bit
- std::string navbit_str = this->navbit.to_html (t
emplatedir
);
+ std::string navbit_str = this->navbit.to_html (t);
// time of creation and modification
struct std::tm c, m;
// time of creation and modification
struct std::tm c, m;