thepra 5 years ago
parent
commit
f06ec5fe78
  1. 36
      TestWebGen/GeneralBuilder.cpp
  2. 3
      TestWebGen/GeneralBuilder.h
  3. 27
      TestWebGen/TestWebGen.cpp
  4. 30
      TestWebGen/ThePraDev.h
  5. 2
      TestWebGen/Utilities.h

36
TestWebGen/GeneralBuilder.cpp

@ -12,10 +12,11 @@ GeneralBuilder::~GeneralBuilder()
{
}
list<Document> GeneralBuilder::BuildThePraSite(Sites site)
void GeneralBuilder::BuildThePraSite(Sites site)
{
Utilities tool{Utilities()};
string cPath{tool.GetCurrentPath()};
cout << cPath << endl;
switch (site)
{
case DEV:
@ -26,24 +27,33 @@ list<Document> GeneralBuilder::BuildThePraSite(Sites site)
Document index = Document();
Head(index, link + "index" + html, "ThePra WebSite");
Body(index, cPath + a.contentLinks[0], site);
cout << cPath + a.contentLinks[0] << endl;
WriteToFile(index, a.outputLinks[0]);
Document code = Document();
Head(code, link + "code" + html, "ThePra Code");
Body(code, cPath + a.contentLinks[1], site);
cout << cPath + a.contentLinks[1] << endl;
WriteToFile(code, a.outputLinks[1]);
Document blog = Document();
Head(blog, link + "blog" + html, "ThePra Blog");
Body(blog, cPath + a.contentLinks[2], site);
cout << cPath + a.contentLinks[2] << endl;
WriteToFile(blog, a.outputLinks[2]);
Document about = Document();
Head(about, link + "about" + html, "ThePra About");
Body(about, cPath + a.contentLinks[3], site);
cout << cPath + a.contentLinks[3] << endl;
WriteToFile(about, a.outputLinks[3]);
Document contact = Document();
Head(contact, link + "contact" + html, "ThePra Contact");
Body(contact, cPath + a.contentLinks[4], site);
cout << cPath + a.contentLinks[4] << endl;
WriteToFile(contact, a.outputLinks[4]);
return{index,code,blog,about,contact};
}
break;
case ART:
@ -70,13 +80,11 @@ list<Document> GeneralBuilder::BuildThePraSite(Sites site)
Head(youtubePosts, link + "youtubePosts" + html, "title");
Body(youtubePosts, cPath, site);
return{index,aboutme,twitch,twitter,youtubePosts};
}
break;
default:
break;
}
return list<Document>();
}
void GeneralBuilder::Head(Document &file,
@ -121,7 +129,7 @@ void GeneralBuilder::Head(Document &file,
file.AddNodeToHead(style);
}
}
file.AddNodeToHead(contentSecurityPolicy);
//file.AddNodeToHead(contentSecurityPolicy);
file.AddNodeToHead(descriptionP);
file.AddNodeToHead(robots);
file.AddNodeToHead(googleBot);
@ -171,7 +179,7 @@ void GeneralBuilder::BuildHTMLFiles(Sites site, list<Document> rootFiles, list<D
path postsContentDir{devDir.append("postsContent")};
path outputDir{dir}; outputDir.append("output_thepradev");
path posts{outputDir}; posts.append("posts");
}
break;
@ -189,6 +197,20 @@ void GeneralBuilder::BuildHTMLFiles(Sites site, list<Document> rootFiles, list<D
default:
break;
}
}
void GeneralBuilder::WriteToFile(Document doc, string p)
{
path PathToCheck = path(p);
if (exists(PathToCheck))
{
remove(PathToCheck);
doc.WriteToFile(p, Readability::MULTILINE);
}
else
{
doc.WriteToFile(p, Readability::MULTILINE);
}
}

3
TestWebGen/GeneralBuilder.h

@ -12,7 +12,7 @@ class GeneralBuilder : Utilities
public:
GeneralBuilder();
~GeneralBuilder();
list<Document> BuildThePraSite(Sites site);
void BuildThePraSite(Sites site);
void Head(Document &file,
string canonicalURL,
string title,
@ -24,5 +24,6 @@ public:
Sites site,
PageType type = NORMAL);
void BuildHTMLFiles(Sites site, list<Document> rootFiles, list<Document> postFiles = {{}});
void WriteToFile(Document doc, string path);
};

27
TestWebGen/TestWebGen.cpp

@ -18,33 +18,8 @@ using namespace CTML;
int main()
{
path dir{current_path()};
cout << dir << endl;
auto entries{list<directory_entry>()};
for (auto p : directory_iterator(dir))
{
if (is_regular_file(p))
{
entries.push_back(p);
cout << p.path().string() << endl;
}
}
for (list<directory_entry>::iterator iterator = entries.begin(), end = entries.end(); iterator != end; ++iterator)
{
directory_entry a{*iterator};
cout << a.path().filename() << " *" << endl;
}
/*int i = 0;
list<Document> wholeSite = list<Document>();
GeneralBuilder dev;
wholeSite = dev.BuildThePraSite(Utilities::DEV);
for each (Document page in wholeSite)
{
page.WriteToFile(cDevOutputPath + n.pages[i++], Readability::MULTILINE);
}*/
dev.BuildThePraSite(Utilities::DEV);
cout << "DONE";
getchar();
return 0;

30
TestWebGen/ThePraDev.h

@ -26,20 +26,15 @@ public:
contentFolder + "about.txt",
contentFolder + "contact.txt"
};
string pages[5]{
"index.html",
"code.html",
"blog.html",
"about.html",
"contact.html"
};
static tuple<string, string, string> links[5]{
{"index","index.txt","index.html"},
{"code","code.txt","code.html"},
{"blog","blog.txt","blog.html"},
{"about","about.txt","about.html"},
{"contact","contact.txt","contact.html"}
string outputPath{current_path().append("output_thepradev\\").string()};
string outputLinks[5]{
outputPath + "index.html",
outputPath + "code.html",
outputPath + "blog.html",
outputPath + "about.html",
outputPath + "contact.html"
};
static void BuildBody(Document &file, string cPath, Levels level, PageType ptype = NORMAL);
@ -89,7 +84,8 @@ inline list<Node> ThePraDev::NavigationBar(Levels level, DeskOrMob mtype)
{
case D:
{
Node elem0 = Node("div.navigation_bar");
Node elem0 = Node("div#header");
Node elem05 = Node("div.navigation_bar");
Node elem1 = Node("img").SetAttribute(a.src, whichLevel + "icon/up.png").SetAttribute(a.alt, "Upper Decoration").UseClosingTag(false);
Node elem2 = Node("ul.bortrr.borbrr");
Node elem3 = Node("li.bortrr").AppendChild(Node(a.a, a.Home).SetAttribute(a.href, whichLevel + a.index));
@ -100,7 +96,7 @@ inline list<Node> ThePraDev::NavigationBar(Levels level, DeskOrMob mtype)
Node elem8 = Extra(level);
Node elem9 = Node("img").SetAttribute(a.src, whichLevel + "icon/down.png").SetAttribute(a.alt, "Down Decoration").UseClosingTag(false);
elem0.AppendChild(elem1)
elem05.AppendChild(elem1)
.AppendChild(elem2
.AppendChild(elem3)
.AppendChild(elem4)
@ -109,7 +105,9 @@ inline list<Node> ThePraDev::NavigationBar(Levels level, DeskOrMob mtype)
.AppendChild(elem7)
.AppendChild(elem8))
.AppendChild(elem9);
elem0.AppendChild(elem05);
cout << elem0.ToString(Readability::MULTILINE,5)<<endl;
return{{elem0}};
}
break;

2
TestWebGen/Utilities.h

@ -102,7 +102,7 @@ inline string Utilities::GetCurrentPath()
{
path current = current_path();
string pathString = current.string();
//cout << pathString << endl;
cout << pathString << endl;
return pathString;
}

Loading…
Cancel
Save