Added summary to the document tree index
[biaweb2.git] / biawebdocument.hpp
index f001373..b79b346 100644 (file)
@@ -41,7 +41,7 @@ namespace biaweb {
             this->meta_keywords = meta_keywords;
             this->content = content;
             this->is_index = is_index;
-            if (is_index)
+            if (is_index)
                 this->filename = convert_title (title);
             else 
                 this->filename = "index";
@@ -52,6 +52,8 @@ namespace biaweb {
         // set whether this is the index document
         void set_index (bool index = true) {
             this->is_index = index; 
+            index == true ? this->filename = "index" : 
+                            this->filename = convert_title (this->title);
         }
 
         // get whether this is the index document
@@ -59,6 +61,11 @@ namespace biaweb {
             return this->is_index;
         }
 
+        // get the file name
+        std::string get_filename () {
+            return this->filename;
+        }
+
         // set the document modification date
         void set_modified_date (std::time_t modif) {
             this->mdate = modif;
@@ -129,34 +136,7 @@ namespace biaweb {
     };
 
     void Document::set_markdown_content (std::string str) {
-        // discount is a C library and it doesn't work well with C++ streams
-        // and there seems no way to get the output of any of these functions
-        // into an std::string. 
-        // the only option seems to be to write the output of the markdown()
-        // function to a temporary working file and then read it back into C++ 
-        // with the normal std::ifstream and feed it into the std::string 
-        // till a cleaner solution can be found. 
-        MMIOT *doc;
-        doc = mkd_string (str.c_str(), str.size(), 0);
-        FILE *f = fopen (".biaweb.tmp", "w");
-        markdown (doc, f, 0);
-        fclose (f);
-        std::ifstream ftmp (".biaweb.tmp");
-        std::string tmpl ( (std::istreambuf_iterator<char> (ftmp)),
-                            (std::istreambuf_iterator<char> ())
-                                );
-
-        while (! ftmp.eof ())
-        {
-                std::string line;
-                ftmp >> line;
-            tmpl.append (line);
-            tmpl.append (" ");
-        }
-        ftmp.close ();
-        remove (".biaweb.tmp");
-        this->content.append (tmpl);
-        mkd_cleanup (doc);                
+        this->content = convert_to_markdown (str);
     }
     
     void Document::output_to_html (std::string path)