Welcome!
@@ -32,11 +43,18 @@
This site is generated procedurally from markdown though C++ code I've written and hosted using lighttpd on an old laptop through my router. You can find the code for it here and a more indepth talk about it on this blog post.
I'm currently studying at a small university in wales where I'm doing a BEng in software engineering whilst working on robotics and exploring my own interests on the side through various societies and personal projects.
-
+
Nowadays my interests lie mostly in low-power computing and electronics, experimenting with how computers can work in a more environmentally friendly manner. I find the environment is something I think about a lot and finding overlaps between it and my interests in computing has lead me to some really intersting communities.
On the side of this I also enjoy using code to create music through programming using Sonic-Pi and just creating programs in general with friends and colleagues. Most of my work can either be found in blog-posts here or on my github.
I've previously had interests in VR and XR and UI design, spending a lot of my secondary school years experimenting with both concepts so both websites also have a few probjects relating to those concepts.
-To see my work, check the navbox to the side
+
+If you want a basic outline of my work, here are a few interesting projects:
+
+To see all of my work, check the navbox to the side.
<-
DISCLAMER! SITE STILL IN PROGRESS
This is all a bit everywhere rn, the css will be given some frills at somepoint soon
diff --git a/Src/BlogPageBuilder.cpp b/Src/BlogPageBuilder.cpp
index 258aa89..01b041e 100644
--- a/Src/BlogPageBuilder.cpp
+++ b/Src/BlogPageBuilder.cpp
@@ -56,28 +56,79 @@ int BlogPageBuilder::calculateIdentifierLocation(std::string id, std::string tex
void BlogPageBuilder::collectPages()
{
- auto directoryIterator = std::filesystem::directory_iterator(inFolder);
+ auto directoryIterator = std::filesystem::recursive_directory_iterator(inFolder);
for(auto file : directoryIterator)
{
+ if (file.is_directory())
+ continue;
pages.push_back(new Page(file.path(), outFolder));
}
}
-std::string BlogPageBuilder::generateNavSection()
+std::string BlogPageBuilder::generateCategories(std::string rootFolderUrl)
{
std::stringstream buffer;
- buffer << "\nNavigation
\n\n";
+ auto directoryIterator = std::filesystem::directory_iterator(rootFolderUrl);
+ for (auto folder : directoryIterator)
+ {
+ if (folder.is_directory())
+ {
+ std::string path = folder.path();
+ std::string folderName = path.substr(path.find_last_of("/")+1, path.length()-path.find_last_of("/"));
+
+ buffer << "\n" << folderName << "
\n";
+ buffer << generateCategories(folder.path());
+ buffer << "\n";
+
+ }
+ }
+ return buffer.str();
+}
+
+std::string BlogPageBuilder::findDeepestCategory(std::string url)
+{
+ int categoryEnd = url.rfind("/");
+ int categoryStart = url.rfind("/", categoryEnd-1);
+ if (categoryStart == -1)
+ categoryStart = 0;
+ return url.substr(categoryStart, categoryEnd);
+}
+
+std::string BlogPageBuilder::insertPagesIntoCategories(std::string categories)
+{
for (Page* page : pages)
{
if (page->getPageFlags().hidden &&
isOptionEnabled(OptionFlags::HIDE_PRIVATE))
continue;
- buffer
- << ""
- << page->getPageTitle()
- << "\n";
+
+ std::string item;
+ item.append(""
+ + page->getPageTitle()
+ + "\n");
+
+ std::string categoryOpening = "\n";
+ int categoryStart = categories.find(findDeepestCategory(page->getRelativeInUrl()));
+ int insertLocation = 0;
+ if (categoryStart != -1)
+ insertLocation = categories.find(categoryOpening, categoryStart) + categoryOpening.length();
+ else
+ insertLocation = navHeader.length();
+
+
+ categories.insert(insertLocation, item);
}
- return buffer.str();
+
+ return categories;
+}
+
+std::string BlogPageBuilder::generateNavSection()
+{
+ std::string buffer;
+ buffer.append(navHeader);
+ buffer.append(generateCategories(SOURCE_FILE_FOLDER));
+ buffer = insertPagesIntoCategories(buffer);
+ return buffer;
}
std::string BlogPageBuilder::readFile(std::string fileUrl)
diff --git a/Src/BlogPageBuilder.h b/Src/BlogPageBuilder.h
index 06aa606..5aa2eed 100644
--- a/Src/BlogPageBuilder.h
+++ b/Src/BlogPageBuilder.h
@@ -42,7 +42,14 @@ private:
int calculateIdentifierLocation(std::string id, std::string text);
void collectPages();
+ // TODO separate these into a separate object
+ std::string navHeader = "\nNavigation
\n\n";
+
std::string generateNavSection();
+ std::string generateCategories(std::string rootFolderUrl);
+ std::string insertPagesIntoCategories(std::string categories);
+ std::string findDeepestCategory(std::string url);
+
void createPage(Page* page);
bool isOptionEnabled(int flag);
diff --git a/Src/Page.cpp b/Src/Page.cpp
index c45239e..df7c1ff 100644
--- a/Src/Page.cpp
+++ b/Src/Page.cpp
@@ -118,10 +118,6 @@ void Page::writePageToFile()
printf("failed to write file to %s \n", outFileUrl.c_str());
}
-
-
-
-
FileFlags FlagReader::readFlags(std::string flagString)
{
FileFlags flags;
diff --git a/Src/Page.h b/Src/Page.h
index f1d0274..7d4bee2 100644
--- a/Src/Page.h
+++ b/Src/Page.h
@@ -62,23 +62,3 @@ public:
void writePageToFile();
};
-
-/*
- * Class to represent the structure of the nav menu, the categories of the pages
- */
-// A node can either be a file or a folder, value for each possibility.
-struct PageTreeNode
-{
- std::vector branches;
- Page* pageValue;
- std::string folderValue;
-};
-
-class PageTree
-{
-private:
- PageTreeNode* rootNode;
-public:
- PageTreeNode* getNodeLinear(int x);
- std::vector getTreeAsList();
-};