Separated the strings used for document tree generation from code
[biaweb2.git] / biawebdocument.hpp
index 221bc4f..65005dd 100644 (file)
@@ -12,6 +12,7 @@
 #include "biawebutil.hpp"
 #include "biawebsidebar.hpp"
 #include "biawebstrings.hpp"
+#include "biawebnavigationbit.hpp"
 
 // class to represent a biaweb document which can have a file name, title, description, 
 // keywords, content and sidebar items
@@ -24,7 +25,8 @@ namespace biaweb {
         std::string meta_desc;
         std::string meta_keywords;
         std::string content;
-        std::list<SideBar> sidebars; 
+        std::list<SideBar> sidebars;
+        NavigationBit navbit; 
         std::time_t cdate;
         std::time_t mdate;
         bool is_index;
@@ -57,6 +59,11 @@ namespace biaweb {
         // fourth line onwards: Markdown contents
         Document (std::istream &file) ;
 
+        // set the navigation bit
+        void set_navigation_bit (NavigationBit navbit) {
+            this->navbit = navbit;
+        }
+
         // set whether this is the index document
         void set_index (bool index = true) {
             this->is_index = index; 
@@ -175,10 +182,9 @@ namespace biaweb {
         this->mdate = this->cdate;
         // read the rest of contents
         std::string line;
-        std::getline (infile, line);
         while (! infile.eof ()) {
-            contents.append (line + "\n");
             std::getline (infile, line);
+            contents.append (line + "\n");
         }
         this->set_markdown_content (contents);
     }
@@ -206,6 +212,9 @@ namespace biaweb {
             sidebartext += bar.to_html (templatedir);
         }
 
+        // render the navigation bit
+        std::string navbit_str = this->navbit.to_html (templatedir);
+
         // time of creation and modification 
         struct std::tm c, m;
         c = *std::localtime (&this->cdate);
@@ -219,6 +228,7 @@ namespace biaweb {
                                     fmt::arg ("description", this->meta_desc),
                                     fmt::arg ("cdate", c),
                                     fmt::arg ("mdate", m),
+                                    fmt::arg ("navbit", navbit_str),
                                     fmt::arg ("contents", this->content),
                                     fmt::arg ("sidebar", sidebartext)
                                     );