X-Git-Url: https://harishankar.org/repos/?p=biaweb2.git;a=blobdiff_plain;f=biawebdocumenttree.hpp;h=66dcd9f7eea322b22e2a9c2a31c431997bf62e09;hp=608b70242179dc0056c8ada7318983891bd40812;hb=fe9a0fef0b31ee3b94b3e73b7e319087a49a3054;hpb=1d1f04629b04c7e7efd14d8f281e17f5e491c888 diff --git a/biawebdocumenttree.hpp b/biawebdocumenttree.hpp index 608b702..66dcd9f 100644 --- a/biawebdocumenttree.hpp +++ b/biawebdocumenttree.hpp @@ -8,8 +8,9 @@ #include "biawebdocument.hpp" #include "biawebstrings.hpp" #include "biawebutil.hpp" +#include "biawebdoclist.hpp" -// to implement a document tree - both with or without subtrees +// class to implement a document tree - both with or without subtrees namespace biaweb { class DocumentTree { protected: @@ -38,7 +39,7 @@ namespace biaweb { // create new top level document tree DocumentTree (std::string title, std::string stub = "") { - this->title = title; + this->title = escape_html (title); // if stub is not empty set it if (stub != "") this->stub = stub; @@ -73,7 +74,7 @@ namespace biaweb { // set the title void set_title (std::string title) { - this->title = title; + this->title = escape_html (title); // if no stub is set if (this->stub == "") this->stub = convert_title (title); @@ -208,29 +209,27 @@ namespace biaweb { std::filesystem::create_directories (filepath); // Create the list of documents in this tree with links - // Reuse the sidebar class and sidebaritem class which is - // basically a list of links but instead of adding a sidebar - // add it to the content portion - SideBar article_list; - article_list.set_title (this->title + ": " + ART_LIST); + std::unique_ptr article_list (new DocList ()); + article_list.get()->set_title (this->title + ": " + ART_LIST); // sort the documents as per creation time and then add the document // links - newest documents should appear above older ones. sort_documents_creation_time (); for (Document doc : this->docs) { - SideBarItem item; - item.set_sidebar_text (doc.get_title()); - item.set_sidebar_url (urlpath + doc.get_filename() + ".html"); - article_list.add_sidebar_item (item); + DocListItem item (doc.get_title(), + urlpath + doc.get_filename() + ".html", + doc.get_creation_date(), doc.get_modified_date ()); + article_list.get()->add_document_item (item); // output the document also, add the side bars doc.add_side_bar (*bar1.get()); doc.add_side_bar (*bar2.get()); doc.output_to_html (templatedir, filepath); } - index.get()->set_content (this->summary + article_list.to_html(templatedir)); + // index should contain the summary followed by the article list + index.get()->set_content (this->summary + article_list.get()->to_html(templatedir)); index.get()->output_to_html (templatedir, filepath); - // create index for children + // recursively create index for children for (DocumentTree tree : this->children) tree.create_tree_html (templatedir, destdir); }