This commit is contained in:
thepra 2017-05-01 12:50:38 +02:00
parent 64d592f02b
commit f06ec5fe78
5 changed files with 47 additions and 51 deletions

View File

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

View File

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

View File

@ -18,33 +18,8 @@ using namespace CTML;
int main() 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; GeneralBuilder dev;
wholeSite = dev.BuildThePraSite(Utilities::DEV); dev.BuildThePraSite(Utilities::DEV);
for each (Document page in wholeSite)
{
page.WriteToFile(cDevOutputPath + n.pages[i++], Readability::MULTILINE);
}*/
cout << "DONE"; cout << "DONE";
getchar(); getchar();
return 0; return 0;

View File

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

View File

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