X-Git-Url: https://harishankar.org/repos/?p=biaweb2.git;a=blobdiff_plain;f=biawebdocumenttree.hpp;h=c58a534ec29fc87fcd8b19195883b5c0b9c6bc89;hp=66dcd9f7eea322b22e2a9c2a31c431997bf62e09;hb=26b38b4a38c24955293a7144f1e1d74676601caf;hpb=fe9a0fef0b31ee3b94b3e73b7e319087a49a3054 diff --git a/biawebdocumenttree.hpp b/biawebdocumenttree.hpp index 66dcd9f..c58a534 100644 --- a/biawebdocumenttree.hpp +++ b/biawebdocumenttree.hpp @@ -163,6 +163,7 @@ namespace biaweb { // create the tree - the index file for this tree and all the documents and // the child trees recursively - using the template specified void DocumentTree::create_tree_html (std::string templatedir, std::string destdir) { + // create a document to represent the index of the tree. std::unique_ptr index (new Document (this->title)); index.get()->set_index (); // set the file name path @@ -227,6 +228,7 @@ namespace biaweb { // index should contain the summary followed by the article list index.get()->set_content (this->summary + article_list.get()->to_html(templatedir)); + // output the index file index.get()->output_to_html (templatedir, filepath); // recursively create index for children @@ -253,30 +255,28 @@ namespace biaweb { } // add the regular files as documents in the tree else if (fsitem.is_regular_file ()) { - // read the contents of the file - std::ifstream infile (fsitem.path().string()); - std::string infilestr ((std::istreambuf_iterator (infile)), - (std::istreambuf_iterator ())); - // if it is an index file (specially named index) add + // if it is an index file (specially named as index + // or index.md or whatever) directly add // the contents to the summary of the Doctree if (fsitem.path().stem().string() == "index") { + std::ifstream infile (fsitem.path()); + std::string infilestr ( (std::istreambuf_iterator (infile)), + (std::istreambuf_iterator ()) ); this->set_markdown_summary (infilestr); } // else it is a non-index file- // create a Document and add it to the tree else { + std::ifstream infile (fsitem.path ()); std::shared_ptr doc - (new Document (fsitem.path().stem().string())); + (new Document (infile)); + infile.close (); - // file creation/modified date from system + // file modified date from system struct stat buf; if (stat (fsitem.path().string().c_str(), &buf) == 0) - { - doc.get()->set_creation_date (buf.st_ctim.tv_sec); doc.get()->set_modified_date (buf.st_mtim.tv_sec); - } - doc.get()->set_markdown_content (infilestr); this->add_document (doc.get()); }