186 lines
5.2 KiB
C++
186 lines
5.2 KiB
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include "GeneralBuilder.h"
|
|
#include "ThePraDev.h"
|
|
|
|
GeneralBuilder::GeneralBuilder()
|
|
{
|
|
}
|
|
|
|
|
|
GeneralBuilder::~GeneralBuilder()
|
|
{
|
|
}
|
|
|
|
list<Document> GeneralBuilder::BuildThePraSite(Sites site)
|
|
{
|
|
Utilities tool{Utilities()};
|
|
string cPath{tool.GetCurrentPath()};
|
|
switch (site)
|
|
{
|
|
case DEV:
|
|
{
|
|
ThePraDev a{ThePraDev()};
|
|
string link = "https://www.thepra-dev.com/", html = ".html";
|
|
|
|
Document index = Document();
|
|
Head(index, link + "index" + html, "ThePra WebSite");
|
|
Body(index, cPath + a.contentLinks[0], site);
|
|
|
|
Document code = Document();
|
|
Head(code, link + "code" + html, "ThePra Code");
|
|
Body(code, cPath + a.contentLinks[1], site);
|
|
|
|
Document blog = Document();
|
|
Head(blog, link + "blog" + html, "ThePra Blog");
|
|
Body(blog, cPath + a.contentLinks[2], site);
|
|
|
|
Document about = Document();
|
|
Head(about, link + "about" + html, "ThePra About");
|
|
Body(about, cPath + a.contentLinks[3], site);
|
|
|
|
Document contact = Document();
|
|
Head(contact, link + "contact" + html, "ThePra Contact");
|
|
Body(contact, cPath + a.contentLinks[4], site);
|
|
|
|
return{index,code,blog,about,contact};
|
|
}
|
|
break;
|
|
case ART:
|
|
{
|
|
string link = "http://art.thepra-dev.com/", html = ".html";
|
|
|
|
Document index = Document();
|
|
Head(index, link + "index" + html, "title");
|
|
Body(index, cPath, site);
|
|
|
|
Document aboutme = Document();
|
|
Head(aboutme, link + "aboutme" + html, "title");
|
|
Body(aboutme, cPath, site);
|
|
|
|
Document twitch = Document();
|
|
Head(twitch, link + "twitch" + html, "title");
|
|
Body(twitch, cPath, site);
|
|
|
|
Document twitter = Document();
|
|
Head(twitter, link + "twitter" + html, "title");
|
|
Body(twitter, cPath, site);
|
|
|
|
Document youtubePosts = Document();
|
|
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,
|
|
string canonicalURL,
|
|
string title,
|
|
Levels level,
|
|
string description,
|
|
list<string> cssStyles)
|
|
{
|
|
string whichLevel = ChooseLevel(level);
|
|
// ESSENTIAL
|
|
Node charset = Node(meta).SetAttribute("charset", "utf-8").UseClosingTag(false);
|
|
Node edge = Node(meta).SetAttribute(http_equiv, "x-ua-compatible").SetAttribute(content, "ie=edge").UseClosingTag(false);
|
|
Node viewport = Node(meta).SetAttribute(name, "viewport").SetAttribute(content, "width=device-width, initial-scale=1").UseClosingTag(false);
|
|
Node titleP = Node("title", title);
|
|
// OTHER
|
|
Node canon = Node(link).SetAttribute(rel, "canonical").SetAttribute(href, canonicalURL).UseClosingTag(false);
|
|
Node base = Node("base").SetAttribute(href, canonicalURL).UseClosingTag(false);
|
|
Node contentSecurityPolicy = Node(meta).SetAttribute(http_equiv, "Content-Security-Policy").SetAttribute(content, "default-src 'self'").UseClosingTag(false);
|
|
Node descriptionP = Node(meta).SetAttribute(name, "description").SetAttribute(content, description).UseClosingTag(false);
|
|
Node robots = Node(meta).SetAttribute(name, "robots").SetAttribute(content, "index,follow,noodp").UseClosingTag(false);
|
|
Node googleBot = Node(meta).SetAttribute(name, "googlebot").SetAttribute(content, "index,follow").UseClosingTag(false);
|
|
Node referrer = Node(meta).SetAttribute(name, "referrer").SetAttribute(content, "no-referrer").UseClosingTag(false);
|
|
Node icon = Node(link).SetAttribute(rel, "icon").SetAttribute(href, whichLevel + "icon/favicon.png").SetAttribute("type", "image/png").UseClosingTag(false);
|
|
|
|
file.AddNodeToHead(charset);
|
|
file.AddNodeToHead(edge);
|
|
file.AddNodeToHead(viewport);
|
|
file.AddNodeToHead(titleP);
|
|
file.AddNodeToHead(base);
|
|
file.AddNodeToHead(canon);
|
|
if (cssStyles.front() == "")
|
|
{
|
|
Node style = Node(link).SetAttribute(rel, "stylesheet").SetAttribute(href, whichLevel + "style.css").UseClosingTag(false);
|
|
file.AddNodeToHead(style);
|
|
}
|
|
else
|
|
{
|
|
for each (string s in cssStyles)
|
|
{
|
|
Node style = Node(link).SetAttribute(rel, "stylesheet").SetAttribute(href, whichLevel + s).UseClosingTag(false);
|
|
file.AddNodeToHead(style);
|
|
}
|
|
}
|
|
file.AddNodeToHead(contentSecurityPolicy);
|
|
file.AddNodeToHead(descriptionP);
|
|
file.AddNodeToHead(robots);
|
|
file.AddNodeToHead(googleBot);
|
|
file.AddNodeToHead(referrer);
|
|
file.AddNodeToHead(icon);
|
|
}
|
|
|
|
|
|
void GeneralBuilder::Body(Document &file, string cPath, Sites site, PageType type)
|
|
{
|
|
switch (site)
|
|
{
|
|
case DEV:
|
|
{
|
|
ThePraDev::BuildBody(file, cPath, ROOT, type);
|
|
}
|
|
case ART:
|
|
{
|
|
|
|
}
|
|
|
|
default:// I'm drunk
|
|
break;
|
|
}
|
|
}
|
|
|
|
void GeneralBuilder::BuildHTMLFiles(Sites site, list<Document> rootFiles, list<Document> postFiles)
|
|
{
|
|
string cDevOutputPath{Utilities::GetCurrentPath() + "\\output_thepradev\\"};
|
|
string postcDevOutputPath{cDevOutputPath + "postsContent\\"};
|
|
path dir = current_path();
|
|
cout << dir.string() << endl;
|
|
for (auto& p : directory_iterator(dir))
|
|
{
|
|
path asd = p.path();
|
|
|
|
if (!is_directory(p))
|
|
cout << p.path().filename().string() << endl;
|
|
}
|
|
switch (site)
|
|
{
|
|
case Utilities::DEV:
|
|
{
|
|
dir.append("thepradev");
|
|
path contentDir{dir.append("content")};
|
|
path postsContentDir{dir.append("postsContent")};
|
|
|
|
}
|
|
break;
|
|
case Utilities::ART:
|
|
{
|
|
dir.append("thepraart\\");
|
|
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|