Fixes bug from optimisation where deepest category was incorrectly calculated leading to misplaced pages in nav bar
This commit is contained in:
parent
8cfcf1a721
commit
7b7f967d74
10 changed files with 9 additions and 21 deletions
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<nav>
|
||||
<h1>Navigation</h1>
|
||||
|
||||
<li><a href=/TestFullArticle.html>Example Post</a></li>
|
||||
<li><a href=/index.html>Welcome!</a></li>
|
||||
|
||||
<h2>Newer Work</h2>
|
||||
|
@ -29,6 +28,7 @@
|
|||
|
||||
|
||||
<h2>Thoughts And Essays</h2>
|
||||
<li><a href=/permacomputing.html>Permacomputing</a></li>
|
||||
|
||||
|
||||
<h2>University</h2>
|
||||
|
|
|
@ -96,9 +96,7 @@ std::string NavBarGenerator::findDeepestCategory(std::string url)
|
|||
{
|
||||
int categoryEnd = url.rfind("/");
|
||||
int categoryStart = url.rfind("/", categoryEnd-1);
|
||||
if (categoryStart == -1)
|
||||
categoryStart = 0;
|
||||
return url.substr(categoryStart, categoryEnd);
|
||||
return url.substr(categoryStart+1, categoryEnd-categoryStart-1);
|
||||
}
|
||||
|
||||
std::string NavBarGenerator::insertPagesIntoCategories(std::string categories, std::vector<Page*> pages)
|
||||
|
@ -117,7 +115,7 @@ std::string NavBarGenerator::insertPagesIntoCategories(std::string categories, s
|
|||
+ "</a></li>\n");
|
||||
|
||||
std::string categoryOpening = "\n";
|
||||
int categoryStart = categories.find(findDeepestCategory(page->getRelativeInUrl()));
|
||||
int categoryStart = categories.find(findDeepestCategory(page->getInUrl()));
|
||||
int insertLocation = 0;
|
||||
if (categoryStart != -1)
|
||||
insertLocation = categories.find(categoryOpening, categoryStart) + categoryOpening.length();
|
||||
|
|
|
@ -59,15 +59,6 @@ std::string Page::getInUrl()
|
|||
return sourceFileUrl;
|
||||
}
|
||||
|
||||
// includes first /
|
||||
std::string Page::getRelativeInUrl()
|
||||
{
|
||||
int start = strlen(SOURCE_FILE_FOLDER)+1;
|
||||
std::string relativeUrl = std::string(sourceFileUrl).substr(start, sourceFileUrl.length()-start);
|
||||
relativeUrl.replace(relativeUrl.length()-3, 3, ".html");
|
||||
return relativeUrl;
|
||||
}
|
||||
|
||||
FileFlags Page::getPageFlags()
|
||||
{
|
||||
return flags;
|
||||
|
|
|
@ -50,7 +50,6 @@ public:
|
|||
std::string getSourceFileContents();
|
||||
|
||||
std::string getInUrl();
|
||||
std::string getRelativeInUrl();
|
||||
|
||||
std::string getOutUrl();
|
||||
std::string getRelativeOutUrl();
|
||||
|
|
Loading…
Add table
Reference in a new issue