+ // Create the list of documents in this tree with links
+ std::unique_ptr<DocList> article_list (new DocList ());
+ article_list.get()->set_title (this->title + ": " + tpl->get_stringbit (ARTICLES_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 ();
+
+ // create the navigation bit
+ std::shared_ptr<NavigationBit> navbit (new NavigationBit ());
+ auto par1 = this;
+ // get the link to each level in the hierarchy and add it as
+ // an inline list
+ while (par1 != nullptr) {
+ if (par1->parent != nullptr)
+ navbit.get()->add_link_item (GenericLinkItem(par1->title,
+ par1->stub_hierarchy() + par1->stub + "/index.html"));
+ else
+ navbit.get()->add_link_item (GenericLinkItem(tpl->get_stringbit(HOME), "index.html"));
+ par1 = par1->parent;
+ }
+
+ // rss feed
+ std::unique_ptr<RSSFeed> feed (new RSSFeed ());
+ feed.get()->set_pub_date (index.get()->get_creation_date());
+ feed.get()->set_title (this->get_title());
+
+ // iterate through the documents and generate the document
+ for (Document doc : this->docs) {
+ // Add the document to RSS feed
+ RSSFeedItem fitem (doc.get_title(), doc.get_meta_desc (),
+ urlpath + doc.get_filename() + ".html",
+ doc.get_creation_date());
+ // If the items don't exceed max size of RSS feed
+ if (feed.get()->get_num_items() < MAX_RSS_FEED)
+ feed.get()->add_rss_item (fitem);
+ // Add the document details to the document list
+ DocListItem item (&doc, urlpath);
+ article_list.get()->add_document_item (item);
+ // output the document also, add the navigation bit and side bars
+
+ doc.set_navigation_bit (*navbit.get());
+ doc.add_side_bar (*bar1.get());
+ doc.add_side_bar (*bar2.get());
+ doc.output_to_html (tpl, filepath);
+ }
+
+ // output the rss feed
+ feed.get()->output_to_html (tpl, filepath);
+
+ // add the side bars
+ index.get()->add_side_bar (*bar1.get());
+ index.get()->add_side_bar (*bar2.get());
+
+ // sidebar for RSS feed
+ // if there are are items in the feed add the link
+ if (feed.get()->get_num_items () > 0) {
+ std::unique_ptr<SideBar> bar3 (new SideBar ());
+ bar3.get()->set_title (tpl->get_stringbit (SUBSCRIBE));
+ bar3.get()->add_sidebar_item (
+ GenericLinkItem (tpl->get_stringbit(RSS_FEED), urlpath + "feed.xml"));
+ index.get()->add_side_bar (*bar3.get());
+ }
+
+ // add the navigation bit
+ index.get()->set_navigation_bit (*navbit.get());
+ // index should contain the summary followed by the the article list
+ // and the sub categories
+ index.get()->set_content (this->summary +
+ article_list.get()->to_html(tpl) +
+ bar2.get()->to_html (tpl));
+
+ // output the index file
+ index.get()->output_to_html (tpl, filepath);
+
+ // recursively create index for children