X-Git-Url: https://harishankar.org/repos/?p=biaweb2.git;a=blobdiff_plain;f=biawebdoclist.hpp;h=8a92cddfbe4453130e2ca3174c96ceab23804f36;hp=547664a12be50fefe331e4dedd29a25aec88ebfd;hb=eda0b06c5328e232e12e0535528a528493caa90a;hpb=44d5fb1ff24147859c5f198dd47f6956ec5fea51 diff --git a/biawebdoclist.hpp b/biawebdoclist.hpp index 547664a..8a92cdd 100644 --- a/biawebdoclist.hpp +++ b/biawebdoclist.hpp @@ -10,6 +10,7 @@ #include #include "biawebstrings.hpp" #include "biawebdocument.hpp" +#include "biawebtemplate.hpp" // to implement a list of items (documents) with creation/modified date/time display namespace biaweb { @@ -59,16 +60,12 @@ namespace biaweb { } // output to HTML vide the template - std::string to_html (std::string templatedir); + std::string to_html (Template *t); }; // output to HTML vide the template - std::string DocListItem::to_html (std::string templatedir) { - std::ifstream templ (templatedir + "/doclistitem.tpl.html"); - std::string templstr ((std::istreambuf_iterator (templ)), - (std::istreambuf_iterator ()) ); - templ.close (); - + std::string DocListItem::to_html (Template *t) { + std::string templstr = t->get_doclistitem_tpl (); std::tm c, m; c = *std::localtime (&this->ctime); m = *std::localtime (&this->mtime); @@ -95,22 +92,18 @@ namespace biaweb { this->items.insert (this->items.cend(), docitem); } // render to HTML from a template - std::string to_html (std::string templatedir); + std::string to_html (Template *t); }; - std::string DocList::to_html (std::string templatedir) { - std::ifstream templ (templatedir + "/doclist.tpl.html"); - std::string templstr ( (std::istreambuf_iterator (templ) ), - (std::istreambuf_iterator ())); - - templ.close (); + std::string DocList::to_html (Template *t) { + std::string templstr = t->get_doclist_tpl (); std::string outputhtml = ""; // if the number of elements is non zero if (this->items.size () != 0) { std::string docitems = ""; for (DocListItem item : this->items) - docitems += item.to_html (templatedir); + docitems += item.to_html (t); outputhtml = fmt::format (templstr, fmt::arg ("title", this->title),