Commit 93fa77b0 authored by Matt Mascarenhas's avatar Matt Mascarenhas

cinera.c: Correct template buffers

The template buffers no longer contain indentation spaces at the start
or a \n at the end. This removes any weirdness from template composition

Also remove the cleanup code added in 0.5.22
parent 6b115629
......@@ -14,7 +14,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 5,
.Patch = 22
.Patch = 23
};
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
......@@ -122,7 +122,6 @@ typedef struct
buffer IncludesIndex;
buffer Search;
buffer Index; // NOTE(matt): This buffer is malloc'd separately, rather than claimed from the memory_arena
buffer ScriptIndex;
buffer IncludesPlayer;
buffer Menus;
buffer Player;
......@@ -2220,7 +2219,6 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
RewindBuffer(&CollationBuffers->Player);
RewindBuffer(&CollationBuffers->ScriptPlayer);
RewindBuffer(&CollationBuffers->IncludesIndex);
RewindBuffer(&CollationBuffers->ScriptIndex);
*CollationBuffers->Title = '\0';
*CollationBuffers->ProjectName = '\0';
......@@ -2395,14 +2393,14 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
int UniqueRefs = 0;
CopyStringToBuffer(&CollationBuffers->Menus,
" <div class=\"cineraMenus %s\">\n"
"<div class=\"cineraMenus %s\">\n"
" <span class=\"episode_name\">", StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project);
CopyStringToBufferHTMLSafe(&CollationBuffers->Menus, HMML.metadata.title);
CopyStringToBuffer(&CollationBuffers->Menus, "</span>\n"
" <span id=\"focus-warn\">⚠ Click here to regain focus ⚠</span>\n");
CopyStringToBuffer(&CollationBuffers->Player,
" <div class=\"cineraPlayerContainer\">\n"
"<div class=\"cineraPlayerContainer\">\n"
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
" <div class=\"markers_container %s\">\n", HMML.metadata.id, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project);
......@@ -3014,7 +3012,7 @@ AppendedIdentifier:
if(HasFilterMenu)
{
CopyStringToBuffer(&FilterState, "<script>\n"
CopyStringToBuffer(&FilterState, "\n<script>\n"
" var filterInitState = {\n");
for(int i = 0; i < Topics.Count; ++i)
{
......@@ -3059,7 +3057,7 @@ AppendedIdentifier:
CopyStringToBuffer(&FilterState,
" };\n"
" </script>\n");
" </script>");
buffer URLPrefix;
ClaimBuffer(&URLPrefix, "URLPrefix", 1024);
......@@ -3483,11 +3481,11 @@ AppendedIdentifier:
ConstructURLPrefix(&URLPrefix, INCLUDE_JS, PAGE_PLAYER);
CopyStringToBuffer(&CollationBuffers->IncludesPlayer,
" <script type=\"text/javascript\" src=\"%scinera_player_pre.js\"></script>\n",
" <script type=\"text/javascript\" src=\"%scinera_player_pre.js\"></script>",
URLPrefix.Location);
CopyStringToBuffer(&CollationBuffers->ScriptPlayer,
" <script type=\"text/javascript\" src=\"%scinera_player_post.js\"></script>\n",
"<script type=\"text/javascript\" src=\"%scinera_player_post.js\"></script>",
URLPrefix.Location);
DeclaimBuffer(&URLPrefix);
......@@ -3669,20 +3667,24 @@ BuffersToHTML(buffers *CollationBuffers, template *Template, char *OutputPath, i
CopyStringToBuffer(&Master,
"<html>\n"
" <head>\n");
" <head>\n"
" ");
CopyBuffer(&Master, PageType == PAGE_PLAYER ? &CollationBuffers->IncludesPlayer : &CollationBuffers->IncludesIndex);
CopyStringToBuffer(&Master, "\n");
CopyStringToBuffer(&Master,
" </head>\n"
" <body>\n");
" <body>\n"
" ");
if(PageType == PAGE_PLAYER)
{
CopyBuffer(&Master, &CollationBuffers->Menus);
CopyStringToBuffer(&Master, "\n");
CopyStringToBuffer(&Master, "\n"
" ");
CopyBuffer(&Master, &CollationBuffers->Player);
CopyStringToBuffer(&Master, "\n");
CopyStringToBuffer(&Master, "\n"
" ");
CopyBuffer(&Master, &CollationBuffers->ScriptPlayer);
CopyStringToBuffer(&Master, "\n");
}
......@@ -3899,31 +3901,6 @@ InsertIntoIndex(buffers *CollationBuffers, template **BespokeTemplate, char *Bas
break;
}
// TODO(matt): Remove this little scope after 0.5.22 has been run once and all the searches are working correctly
if(IndexMetadataFileReadCode == RC_SUCCESS)
{
Index.Header = *(index_header *)Index.Metadata.Buffer.Ptr;
if(Index.Header.AppVersion.Major < 0 ||
Index.Header.AppVersion.Minor < 5 ||
Index.Header.AppVersion.Patch < 22)
{
CopyString(Index.File.Path, "%s/%s.index", Config.BaseDir, Config.ProjectID);
fprintf(stderr, "\e[1;31mRemoving %s and %s generated by Cinera version %d.%d.%d\n"
"prior to the index reinsertion fix implemented in version 0.5.22\e[0m\n",
Index.Metadata.Path, Index.File.Path,
Index.Header.AppVersion.Major,
Index.Header.AppVersion.Minor,
Index.Header.AppVersion.Patch);
FreeBuffer(&Index.Metadata.Buffer);
IndexMetadataFileReadCode = RC_ERROR_FILE;
remove(Index.Metadata.Path);
remove(Index.File.Path);
}
}
//
Index.File.Buffer.ID = "IndexFile";
CopyString(Index.File.Path, "%s/%s.index", Config.BaseDir, Config.ProjectID);
......@@ -5114,7 +5091,6 @@ main(int ArgC, char **Args)
if(ClaimBuffer(&CollationBuffers.IncludesIndex, "IncludesIndex", Kilobytes(1)) == RC_ARENA_FULL) { goto RIP; };
if(ClaimBuffer(&CollationBuffers.Search, "Search", Kilobytes(32)) == RC_ARENA_FULL) { goto RIP; };
if(ClaimBuffer(&CollationBuffers.ScriptIndex, "ScriptIndex", 256) == RC_ARENA_FULL) { goto RIP; };
// NOTE(matt): Templating
//
......@@ -5325,7 +5301,6 @@ NextFile:
DeclaimTemplate(IndexTemplate);
}
DeclaimBuffer(&CollationBuffers.ScriptIndex);
DeclaimBuffer(&CollationBuffers.Search);
DeclaimBuffer(&CollationBuffers.IncludesIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment