Fix global search page generation and filter
This change makes GenerateGlobalSearchPage() pass the Config to BuffersToHTML(), which in turn passes it on to GenerateNavigation(), thus preventing a null-pointer deference when setting the Theme. It also fixes the filter by using all three of baseURL, searchLocation and playerLocation to associate the filter and index elements.
This commit is contained in:
parent
9dfdc117be
commit
877dbab5bd
|
@ -23,7 +23,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 7,
|
||||
.Patch = 8
|
||||
.Patch = 9
|
||||
};
|
||||
|
||||
#include <stdarg.h> // NOTE(matt): varargs
|
||||
|
@ -10376,7 +10376,7 @@ GenerateNavigation(config *C, project *Target, navigation_buffer *NavBuffer)
|
|||
}
|
||||
|
||||
int
|
||||
BuffersToHTML(project *Project, buffers *CollationBuffers, template *Template, char *OutputPath, page_type PageType, unsigned int *PlayerOffset)
|
||||
BuffersToHTML(config *C, project *Project, buffers *CollationBuffers, template *Template, char *OutputPath, page_type PageType, unsigned int *PlayerOffset)
|
||||
{
|
||||
MEM_TEST_INITIAL();
|
||||
#if DEBUG
|
||||
|
@ -10525,7 +10525,7 @@ BuffersToHTML(project *Project, buffers *CollationBuffers, template *Template, c
|
|||
{
|
||||
if(!Tag->Nav->Buffer.Location)
|
||||
{
|
||||
GenerateNavigation(0, Project, Tag->Nav);
|
||||
GenerateNavigation(Config, Project, Tag->Nav);
|
||||
}
|
||||
|
||||
// TODO(matt): If we add project icons to the nav - and, frankly, we will want project art at some
|
||||
|
@ -12951,7 +12951,7 @@ GeneratePlayerPage(neighbourhood *N, buffers *CollationBuffers, template *Player
|
|||
}
|
||||
MEM_TEST_MID("GeneratePlayerPage4");
|
||||
|
||||
BuffersToHTML(CurrentProject, CollationBuffers, PlayerTemplate, PlayerPath, PAGE_PLAYER, &N->This->LinkOffsets.PrevStart);
|
||||
BuffersToHTML(0, CurrentProject, CollationBuffers, PlayerTemplate, PlayerPath, PAGE_PLAYER, &N->This->LinkOffsets.PrevStart);
|
||||
MEM_TEST_MID("GeneratePlayerPage5");
|
||||
Free(PlayerPath);
|
||||
// NOTE(matt): A previous InsertNeighbourLink() call will have done SnipeEntryIntoMetadataBuffer(), but we must do it here now
|
||||
|
@ -12996,7 +12996,7 @@ GenerateSearchPage(neighbourhood *N, buffers *CollationBuffers, db_header_projec
|
|||
{
|
||||
case RC_SUCCESS:
|
||||
{
|
||||
BuffersToHTML(P, CollationBuffers, &P->SearchTemplate, SearchPath, PAGE_SEARCH, 0);
|
||||
BuffersToHTML(0, P, CollationBuffers, &P->SearchTemplate, SearchPath, PAGE_SEARCH, 0);
|
||||
UpdateLandmarksForSearch(N, P->Index);
|
||||
break;
|
||||
}
|
||||
|
@ -13038,7 +13038,7 @@ GenerateGlobalSearchPage(neighbourhood *N, buffers *CollationBuffers)
|
|||
{
|
||||
case RC_SUCCESS:
|
||||
{
|
||||
BuffersToHTML(0, CollationBuffers, &Config->SearchTemplate, SearchPath, PAGE_SEARCH, 0);
|
||||
BuffersToHTML(Config, 0, CollationBuffers, &Config->SearchTemplate, SearchPath, PAGE_SEARCH, 0);
|
||||
UpdateLandmarksForSearch(N, GLOBAL_SEARCH_PAGE_INDEX);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,10 +35,11 @@ function hideEntriesOfProject(ProjectElement)
|
|||
}
|
||||
var baseURL = ProjectElement.attributes.getNamedItem("data-baseURL").value;
|
||||
var searchLocation = ProjectElement.attributes.getNamedItem("data-searchLocation").value;
|
||||
var playerLocation = ProjectElement.attributes.getNamedItem("data-playerLocation").value;
|
||||
for(var i = 0; i < projects.length; ++i)
|
||||
{
|
||||
var ThisProject = projects[i];
|
||||
if(baseURL === ThisProject.baseURL && searchLocation === ThisProject.searchLocation)
|
||||
if(baseURL === ThisProject.baseURL && searchLocation === ThisProject.searchLocation && playerLocation === ThisProject.playerLocation)
|
||||
{
|
||||
ThisProject.filteredOut = true;
|
||||
if(ThisProject.entriesContainer != null)
|
||||
|
@ -58,10 +59,11 @@ function showEntriesOfProject(ProjectElement)
|
|||
}
|
||||
var baseURL = ProjectElement.attributes.getNamedItem("data-baseURL").value;
|
||||
var searchLocation = ProjectElement.attributes.getNamedItem("data-searchLocation").value;
|
||||
var playerLocation = ProjectElement.attributes.getNamedItem("data-playerLocation").value;
|
||||
for(var i = 0; i < projects.length; ++i)
|
||||
{
|
||||
var ThisProject = projects[i];
|
||||
if(baseURL === ThisProject.baseURL && searchLocation === ThisProject.searchLocation)
|
||||
if(baseURL === ThisProject.baseURL && searchLocation === ThisProject.searchLocation && playerLocation === ThisProject.playerLocation)
|
||||
{
|
||||
ThisProject.filteredOut = false;
|
||||
if(ThisProject.entriesContainer != null)
|
||||
|
@ -73,7 +75,7 @@ function showEntriesOfProject(ProjectElement)
|
|||
}
|
||||
}
|
||||
|
||||
function hideProjectSearchResults(baseURL, playerLocation)
|
||||
function hideProjectSearchResults(baseURL, searchLocation, playerLocation)
|
||||
{
|
||||
var cineraResults = document.getElementById("cineraResults");
|
||||
if(cineraResults)
|
||||
|
@ -82,8 +84,9 @@ function hideProjectSearchResults(baseURL, playerLocation)
|
|||
for(var i = 0; i < cineraResultsProjects.length; ++i)
|
||||
{
|
||||
var resultBaseURL = cineraResultsProjects[i].attributes.getNamedItem("data-baseURL").value;
|
||||
var resultSearchLocation = cineraResultsProjects[i].attributes.getNamedItem("data-searchLocation").value;
|
||||
var resultPlayerLocation = cineraResultsProjects[i].attributes.getNamedItem("data-playerLocation").value;
|
||||
if(baseURL === resultBaseURL && playerLocation === resultPlayerLocation)
|
||||
if(baseURL === resultBaseURL && searchLocation === resultSearchLocation && playerLocation === resultPlayerLocation)
|
||||
{
|
||||
cineraResultsProjects[i].style.display = "none";
|
||||
return;
|
||||
|
@ -92,7 +95,7 @@ function hideProjectSearchResults(baseURL, playerLocation)
|
|||
}
|
||||
}
|
||||
|
||||
function showProjectSearchResults(baseURL, playerLocation)
|
||||
function showProjectSearchResults(baseURL, searchLocation, playerLocation)
|
||||
{
|
||||
var cineraResults = document.getElementById("cineraResults");
|
||||
if(cineraResults)
|
||||
|
@ -101,8 +104,9 @@ function showProjectSearchResults(baseURL, playerLocation)
|
|||
for(var i = 0; i < cineraResultsProjects.length; ++i)
|
||||
{
|
||||
var resultBaseURL = cineraResultsProjects[i].attributes.getNamedItem("data-baseURL").value;
|
||||
var resultSearchLocation = cineraResultsProjects[i].attributes.getNamedItem("data-searchLocation").value;
|
||||
var resultPlayerLocation = cineraResultsProjects[i].attributes.getNamedItem("data-playerLocation").value;
|
||||
if(baseURL === resultBaseURL && playerLocation === resultPlayerLocation)
|
||||
if(baseURL === resultBaseURL && searchLocation === resultSearchLocation && playerLocation === resultPlayerLocation)
|
||||
{
|
||||
cineraResultsProjects[i].style.display = "flex";
|
||||
return;
|
||||
|
@ -115,6 +119,7 @@ function toggleEntriesOfProjectAndChildren(ProjectFilterElement)
|
|||
{
|
||||
var baseURL = ProjectFilterElement.attributes.getNamedItem("data-baseURL").value;
|
||||
var searchLocation = ProjectFilterElement.attributes.getNamedItem("data-searchLocation").value;
|
||||
var playerLocation = ProjectFilterElement.attributes.getNamedItem("data-playerLocation").value;
|
||||
var shouldShow = ProjectFilterElement.classList.contains("off");
|
||||
if(shouldShow)
|
||||
{
|
||||
|
@ -131,7 +136,7 @@ function toggleEntriesOfProjectAndChildren(ProjectFilterElement)
|
|||
{
|
||||
var ThisProject = projects[i];
|
||||
|
||||
if(ThisProject.baseURL === baseURL && ThisProject.searchLocation === searchLocation)
|
||||
if(baseURL === ThisProject.baseURL && searchLocation === ThisProject.searchLocation && playerLocation === ThisProject.playerLocation)
|
||||
{
|
||||
if(shouldShow)
|
||||
{
|
||||
|
@ -141,7 +146,7 @@ function toggleEntriesOfProjectAndChildren(ProjectFilterElement)
|
|||
{
|
||||
ThisProject.entriesContainer.style.display = "flex";
|
||||
}
|
||||
showProjectSearchResults(ThisProject.baseURL, ThisProject.playerLocation);
|
||||
showProjectSearchResults(ThisProject.baseURL, ThisProject.searchLocation, ThisProject.playerLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -151,7 +156,7 @@ function toggleEntriesOfProjectAndChildren(ProjectFilterElement)
|
|||
{
|
||||
ThisProject.entriesContainer.style.display = "none";
|
||||
}
|
||||
hideProjectSearchResults(ThisProject.baseURL, ThisProject.playerLocation);
|
||||
hideProjectSearchResults(ThisProject.baseURL, ThisProject.searchLocation, ThisProject.playerLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,16 +167,17 @@ function toggleEntriesOfProjectAndChildren(ProjectFilterElement)
|
|||
{
|
||||
var ThisElement = indexChildFilterProjects[j];
|
||||
var baseURL = ThisElement.attributes.getNamedItem("data-baseURL").value;
|
||||
var searchLocation = ThisElement.attributes.getNamedItem("data-searchLocation").value;
|
||||
var playerLocation = ThisElement.attributes.getNamedItem("data-playerLocation").value;
|
||||
if(shouldShow)
|
||||
{
|
||||
showEntriesOfProject(ThisElement);
|
||||
showProjectSearchResults(baseURL, playerLocation);
|
||||
showProjectSearchResults(baseURL, searchLocation, playerLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
hideEntriesOfProject(ThisElement);
|
||||
hideProjectSearchResults(baseURL, playerLocation);
|
||||
hideProjectSearchResults(baseURL, searchLocation, playerLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue