Functionality for generating website completed
[biaweb2.git] / biawebdocumenttree.hpp
index 608b702..7c44634 100644 (file)
@@ -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:
@@ -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<DocList> 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);
     }