Refactored template loading to its own class for performance
[biaweb2.git] / biaweb.cpp
1 #include <iostream>
2 #include <fstream>
3 #include "biawebdocumenttree.hpp"
4 using namespace biaweb;
5
6 int main (int argc, char *argv[]) {
7
8 // if (argc == 2)
9 // {
10 // std::shared_ptr<DocumentTree> tree (new DocumentTree (argv[1]));
11 // tree.get()->set_stub ("");
12 // tree.get()->set_markdown_summary ("# Hello there\n\n\
13 // These are some contents for this page.");
14
15 // std::shared_ptr<DocumentTree> a1 (new DocumentTree("Child a1"));
16 // std::shared_ptr<DocumentTree> a2 (new DocumentTree("Child a2"));
17 // std::shared_ptr<DocumentTree> a3 (new DocumentTree("Child a3"));
18 // std::shared_ptr<DocumentTree> a4 (new DocumentTree("Child a4"));
19 // std::shared_ptr<Document> d2 (new Document ("Another document"));
20 // d2.get()->set_creation_date (124012);
21 // std::shared_ptr<Document> d1 (new Document("Test Document"));
22 // d1.get()->set_creation_date (100000);
23 // d1.get()->set_markdown_content ("# Heading \n\nThis is some text, hello world");
24 // d2.get()->set_markdown_content ("Some document \n\nThis is some document");
25 // a1.get()->add_document (d2.get());
26 // a1.get()->add_document (d1.get());
27 // a3.get()->add_child (a4.get());
28 // a1.get()->add_child (a2.get());
29 // a1.get()->add_child (a3.get());
30 // tree.get()->add_child (a1.get());
31 // std::cout << a3.get()->stub_hierarchy () << a3.get()->get_stub () << std::endl;
32 // tree.get()->visualize_tree ();
33 // tree.get()->create_tree_html ("/home/hari/Projects/BiaWeb2/templates",
34 // convert_title (argv[1]));
35 // }
36 // // else {
37 // // std::cout << "Usage: " << argv[0] << " <main tree>" << std::endl;
38
39 std::chrono::steady_clock::time_point t1 (std::chrono::steady_clock::now());
40 DocumentTree tree ("");
41 tree.document_tree_builder ("Test/Reviews");
42 tree.visualize_tree ();
43 Template tpl ("templates");
44 tree.create_tree_html (&tpl, "Test/Out");
45 std::chrono::steady_clock::time_point t2 (std::chrono::steady_clock::now());
46 std::chrono::duration<double> dur (t2 - t1);
47 std::cout << dur.count () << std::endl;
48
49 // // }
50
51 // Document doc;
52 // SideBar items;
53 // std::string title, contents, sidetitle;
54 // std::cout << "Enter document title: ";
55 // std::getline (std::cin, title);
56 // std::cout << "Enter markdown file of document: ";
57 // std::getline (std::cin, contents);
58 // while (1) {
59 // std::string name, url;
60 // std::cout << "Enter a sidebar item text (empty to end): ";
61 // std::getline (std::cin, name);
62 // if (name.empty()) break;
63 // std::cout << "Enter a sidebar item URL: ";
64 // std::getline (std::cin, url);
65 // SideBarItem item (name, url);
66 // items.add_sidebar_item (item);
67 // }
68 // std::cout << "Enter heading for sidebar: ";
69 // std::getline (std::cin, sidetitle);
70 // items.set_title (sidetitle);
71 // doc.set_title (title);
72 // std::ifstream f (contents);
73 // std::string markdown_contents ( (std::istreambuf_iterator<char> (f)),
74 // (std::istreambuf_iterator<char> ()) );
75
76 // doc.set_markdown_content (markdown_contents);
77 // doc.add_side_bar (items);
78
79 // doc.output_to_html ();
80
81 return 0;
82 }