cinera.c: Add support for alternative URL prefixes
This is hardcoded for now, for ease of use, pending the config system Also add Medium to the ProjectInfo array, to save users having to set this with -m (which option remains available to them) Reorganise the CSS, Images and JS files back to their location in the same directory, since a default invocation of the program assumes they are in the same directory as the Root Directory, to hopefully alleviate some potential user frustration thanks to the requirement to set their locations (with -c, -i and -j) before any usable output is produced
This commit is contained in:
parent
f454e01e28
commit
6f751dd2b2
297
cinera/cinera.c
297
cinera/cinera.c
|
@ -14,7 +14,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 5,
|
.Minor = 5,
|
||||||
.Patch = 5
|
.Patch = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CINERA_DB_VERSION 1
|
#define CINERA_DB_VERSION 1
|
||||||
|
@ -115,6 +115,8 @@ typedef struct
|
||||||
char *OutLocation;
|
char *OutLocation;
|
||||||
char *OutIntegratedLocation;
|
char *OutIntegratedLocation;
|
||||||
char *ProjectDir;
|
char *ProjectDir;
|
||||||
|
char *URLPrefix; /* NOTE(matt): This will become a full blown customisable output URL.
|
||||||
|
For now it simply replaces the ProjectID */
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -342,25 +344,28 @@ typedef struct
|
||||||
char *ProjectID;
|
char *ProjectID;
|
||||||
char *FullName;
|
char *FullName;
|
||||||
char *Unit; // e.g. Day, Episode, Session
|
char *Unit; // e.g. Day, Episode, Session
|
||||||
int NumberingScheme;
|
int NumberingScheme; // numbering_schemes
|
||||||
|
char *Medium;
|
||||||
|
char *AltURLPrefix; // NOTE(matt): This currently just straight up replaces the ProjectID in the player pages' output directories
|
||||||
} project_info;
|
} project_info;
|
||||||
|
|
||||||
project_info ProjectInfo[] =
|
project_info ProjectInfo[] =
|
||||||
{
|
{
|
||||||
{ "book", "Book Club", "Day", NS_LINEAR },
|
{ "book", "Book Club", "Day", NS_LINEAR, "research", "" },
|
||||||
{ "riscy", "RISCY BUSINESS", "Day", NS_LINEAR },
|
{ "pcalc", "pcalc", "Day", NS_LINEAR, "programming", "" },
|
||||||
|
{ "riscy", "RISCY BUSINESS", "Day", NS_LINEAR, "programming", "" },
|
||||||
|
|
||||||
{ "chat", "Handmade Chat", "Day", NS_LINEAR },
|
{ "chat", "Handmade Chat", "Day", NS_LINEAR, "speech", "" },
|
||||||
{ "code", "Handmade Hero", "Day", NS_LINEAR },
|
{ "code", "Handmade Hero", "Day", NS_LINEAR, "programming", "day" },
|
||||||
{ "intro-to-c", "Intro to C on Windows", "Day", NS_LINEAR },
|
{ "intro-to-c", "Intro to C on Windows", "Day", NS_LINEAR, "programming", "day" },
|
||||||
{ "misc", "Handmade Miscellany", "", NS_LINEAR },
|
{ "misc", "Handmade Miscellany", "", NS_LINEAR, "admin", "" },
|
||||||
{ "ray", "Handmade Ray", "Day", NS_LINEAR },
|
{ "ray", "Handmade Ray", "Day", NS_LINEAR, "programming", "" },
|
||||||
|
|
||||||
{ "hmdshow", "HandmadeDev Show", "", NS_SEASONAL },
|
{ "hmdshow", "HandmadeDev Show", "", NS_SEASONAL, "speech", "" },
|
||||||
|
|
||||||
{ "obbg", "Open Block Building Game", "Episode", NS_LINEAR },
|
{ "obbg", "Open Block Building Game", "Episode", NS_LINEAR, "programming", "" },
|
||||||
|
|
||||||
{ "sysadmin", "SysAdmin", "Session", NS_LINEAR },
|
{ "sysadmin", "SysAdmin", "Session", NS_LINEAR, "admin", "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ArrayCount(A) sizeof(A)/sizeof(*(A))
|
#define ArrayCount(A) sizeof(A)/sizeof(*(A))
|
||||||
|
@ -887,6 +892,62 @@ SanitisePunctuation(char *String)
|
||||||
return String;
|
return String;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
INCLUDE_CSS,
|
||||||
|
INCLUDE_Images,
|
||||||
|
INCLUDE_JS,
|
||||||
|
} include_types;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PAGE_PLAYER = 1 << 0,
|
||||||
|
PAGE_INDEX = 1 << 1
|
||||||
|
} pages;
|
||||||
|
|
||||||
|
void
|
||||||
|
ConstructURLPrefix(buffer *URLPrefix, int IncludeType, int PageType)
|
||||||
|
{
|
||||||
|
ClaimBuffer(URLPrefix, "URLPrefix", 1024);
|
||||||
|
if(StringsDiffer(Config.RootURL, ""))
|
||||||
|
{
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.RootURL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(Config.Edition == EDITION_PROJECT)
|
||||||
|
{
|
||||||
|
if(PageType == PAGE_PLAYER)
|
||||||
|
{
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "../");
|
||||||
|
}
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "../");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(IncludeType)
|
||||||
|
{
|
||||||
|
case INCLUDE_CSS:
|
||||||
|
if(StringsDiffer(Config.CSSDir, ""))
|
||||||
|
{
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.CSSDir);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case INCLUDE_Images:
|
||||||
|
if(StringsDiffer(Config.ImagesDir, ""))
|
||||||
|
{
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.ImagesDir);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case INCLUDE_JS:
|
||||||
|
if(StringsDiffer(Config.JSDir, ""))
|
||||||
|
{
|
||||||
|
URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.JSDir);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CreditsError_NoHost,
|
CreditsError_NoHost,
|
||||||
|
@ -940,29 +1001,14 @@ SearchCredentials(buffer *CreditsMenu, bool *HasCreditsMenu, char *Person, char
|
||||||
|
|
||||||
if(*Credentials[CredentialIndex].SupportIcon && *Credentials[CredentialIndex].SupportURL)
|
if(*Credentials[CredentialIndex].SupportIcon && *Credentials[CredentialIndex].SupportURL)
|
||||||
{
|
{
|
||||||
char URLPrefix[1024] = { 0 };
|
buffer URLPrefix;
|
||||||
char *Ptr = URLPrefix;
|
ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_INDEX);
|
||||||
if(StringsDiffer(Config.RootURL, ""))
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "%s/", Config.RootURL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Config.Edition == EDITION_PROJECT)
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "../");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(StringsDiffer(Config.ImagesDir, ""))
|
|
||||||
{
|
|
||||||
CopyString(Ptr, "%s/", Config.ImagesDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyStringToBuffer(CreditsMenu,
|
CopyStringToBuffer(CreditsMenu,
|
||||||
" <a class=\"support\" href=\"%s\" target=\"_blank\"><div class=\"support_icon\" style=\"background-image: url(%s%s);\"></div></a>\n",
|
" <a class=\"support\" href=\"%s\" target=\"_blank\"><div class=\"support_icon\" style=\"background-image: url(%s%s);\"></div></a>\n",
|
||||||
Credentials[CredentialIndex].SupportURL,
|
Credentials[CredentialIndex].SupportURL,
|
||||||
URLPrefix,
|
URLPrefix.Location,
|
||||||
Credentials[CredentialIndex].SupportIcon);
|
Credentials[CredentialIndex].SupportIcon);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyStringToBuffer(CreditsMenu,
|
CopyStringToBuffer(CreditsMenu,
|
||||||
|
@ -1684,12 +1730,6 @@ DepartComment(buffer *Template)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PAGE_PLAYER = 1 << 0,
|
|
||||||
PAGE_INDEX = 1 << 1
|
|
||||||
} pages;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ValidateTemplate(buffer *Errors, template **Template, int PageType)
|
ValidateTemplate(buffer *Errors, template **Template, int PageType)
|
||||||
{
|
{
|
||||||
|
@ -2609,31 +2649,16 @@ AppendedIdentifier:
|
||||||
" };\n"
|
" };\n"
|
||||||
" </script>\n");
|
" </script>\n");
|
||||||
|
|
||||||
char URLPrefix[1024] = { 0 };
|
buffer URLPrefix;
|
||||||
char *Ptr = URLPrefix;
|
ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_INDEX);
|
||||||
if(StringsDiffer(Config.RootURL, ""))
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "%s/", Config.RootURL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Config.Edition == EDITION_PROJECT)
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "../");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(StringsDiffer(Config.ImagesDir, ""))
|
|
||||||
{
|
|
||||||
CopyString(Ptr, "%s/", Config.ImagesDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyStringToBuffer(&FilterMenu,
|
CopyStringToBuffer(&FilterMenu,
|
||||||
" <div class=\"menu filter\">\n"
|
" <div class=\"menu filter\">\n"
|
||||||
" <span><img src=\"%scinera_icon_filter.png\"></span>\n"
|
" <span><img src=\"%scinera_icon_filter.png\"></span>\n"
|
||||||
" <div class=\"filter_container\">\n"
|
" <div class=\"filter_container\">\n"
|
||||||
" <div class=\"filter_mode inclusive\">Filter mode: </div>\n"
|
" <div class=\"filter_mode inclusive\">Filter mode: </div>\n"
|
||||||
" <div class=\"filters\">\n",
|
" <div class=\"filters\">\n",
|
||||||
URLPrefix);
|
URLPrefix.Location);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
|
|
||||||
if(Topics.Count > 0)
|
if(Topics.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -2977,24 +3002,8 @@ AppendedIdentifier:
|
||||||
|
|
||||||
// TODO(matt): Maybe do something about indentation levels
|
// TODO(matt): Maybe do something about indentation levels
|
||||||
|
|
||||||
char URLPrefix[1024] = { 0 };
|
buffer URLPrefix;
|
||||||
char *Ptr = URLPrefix;
|
ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_INDEX);
|
||||||
if(StringsDiffer(Config.RootURL, ""))
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "%s/", Config.RootURL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Config.Edition == EDITION_PROJECT)
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "../");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(StringsDiffer(Config.CSSDir, ""))
|
|
||||||
{
|
|
||||||
CopyString(Ptr, "%s/", Config.CSSDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyStringToBuffer(&CollationBuffers->IncludesIndex,
|
CopyStringToBuffer(&CollationBuffers->IncludesIndex,
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera.css\">\n"
|
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera.css\">\n"
|
||||||
" <link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera__%s.css\">\n"
|
" <link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera__%s.css\">\n"
|
||||||
|
@ -3003,24 +3012,16 @@ AppendedIdentifier:
|
||||||
"\n"
|
"\n"
|
||||||
" <meta charset=\"UTF-8\">\n"
|
" <meta charset=\"UTF-8\">\n"
|
||||||
" <meta name=\"generator\" content=\"Cinera %d.%d.%d\">\n",
|
" <meta name=\"generator\" content=\"Cinera %d.%d.%d\">\n",
|
||||||
URLPrefix,
|
URLPrefix.Location,
|
||||||
URLPrefix, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project,
|
URLPrefix.Location, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project,
|
||||||
URLPrefix,
|
URLPrefix.Location,
|
||||||
|
|
||||||
CINERA_APP_VERSION.Major,
|
CINERA_APP_VERSION.Major,
|
||||||
CINERA_APP_VERSION.Minor,
|
CINERA_APP_VERSION.Minor,
|
||||||
CINERA_APP_VERSION.Patch);
|
CINERA_APP_VERSION.Patch);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
|
|
||||||
if(Config.Edition == EDITION_PROJECT)
|
ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_PLAYER);
|
||||||
{
|
|
||||||
if(!StringsDiffer(Config.RootURL, ""))
|
|
||||||
{
|
|
||||||
char Temp[1027];
|
|
||||||
CopyString(Temp, "../%s", URLPrefix);
|
|
||||||
CopyString(URLPrefix, Temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyStringToBuffer(&CollationBuffers->IncludesPlayer,
|
CopyStringToBuffer(&CollationBuffers->IncludesPlayer,
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera.css\">\n"
|
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera.css\">\n"
|
||||||
" <link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera__%s.css\">\n"
|
" <link rel=\"stylesheet\" type=\"text/css\" href=\"%scinera__%s.css\">\n"
|
||||||
|
@ -3028,13 +3029,14 @@ AppendedIdentifier:
|
||||||
"\n"
|
"\n"
|
||||||
" <meta charset=\"UTF-8\">\n"
|
" <meta charset=\"UTF-8\">\n"
|
||||||
" <meta name=\"generator\" content=\"Cinera %d.%d.%d\">\n",
|
" <meta name=\"generator\" content=\"Cinera %d.%d.%d\">\n",
|
||||||
URLPrefix,
|
URLPrefix.Location,
|
||||||
URLPrefix, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project,
|
URLPrefix.Location, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project,
|
||||||
URLPrefix,
|
URLPrefix.Location,
|
||||||
|
|
||||||
CINERA_APP_VERSION.Major,
|
CINERA_APP_VERSION.Major,
|
||||||
CINERA_APP_VERSION.Minor,
|
CINERA_APP_VERSION.Minor,
|
||||||
CINERA_APP_VERSION.Patch);
|
CINERA_APP_VERSION.Patch);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
|
|
||||||
if(Topics.Count || Media.Count)
|
if(Topics.Count || Media.Count)
|
||||||
{
|
{
|
||||||
|
@ -3061,30 +3063,15 @@ AppendedIdentifier:
|
||||||
CopyStringToBuffer(&CollationBuffers->IncludesPlayer, "\">\n\n");
|
CopyStringToBuffer(&CollationBuffers->IncludesPlayer, "\">\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr = URLPrefix;
|
ConstructURLPrefix(&URLPrefix, INCLUDE_JS, PAGE_PLAYER);
|
||||||
if(StringsDiffer(Config.RootURL, ""))
|
|
||||||
{
|
|
||||||
Ptr += StringLength(Config.RootURL) + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Config.Edition == EDITION_PROJECT)
|
|
||||||
{
|
|
||||||
Ptr += StringLength("../");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(StringsDiffer(Config.JSDir, ""))
|
|
||||||
{
|
|
||||||
CopyString(Ptr, "%s/", Config.JSDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyStringToBuffer(&CollationBuffers->IncludesPlayer,
|
CopyStringToBuffer(&CollationBuffers->IncludesPlayer,
|
||||||
" <script type=\"text/javascript\" src=\"%scinera_player_pre.js\"></script>\n",
|
" <script type=\"text/javascript\" src=\"%scinera_player_pre.js\"></script>\n",
|
||||||
URLPrefix);
|
URLPrefix.Location);
|
||||||
|
|
||||||
CopyStringToBuffer(&CollationBuffers->ScriptPlayer,
|
CopyStringToBuffer(&CollationBuffers->ScriptPlayer,
|
||||||
" <script type=\"text/javascript\" src=\"%scinera_player_post.js\"></script>\n",
|
" <script type=\"text/javascript\" src=\"%scinera_player_post.js\"></script>\n",
|
||||||
URLPrefix);
|
URLPrefix.Location);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
|
|
||||||
if(HasFilterMenu)
|
if(HasFilterMenu)
|
||||||
{
|
{
|
||||||
|
@ -3764,31 +3751,23 @@ IndexToBuffer(buffers *CollationBuffers)
|
||||||
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID,
|
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID,
|
||||||
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID);
|
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID);
|
||||||
|
|
||||||
char URLPrefix[1024] = { 0 };
|
buffer URLPrefix;
|
||||||
char *Ptr = URLPrefix;
|
ClaimBuffer(&URLPrefix, "URLPrefix", 1024);
|
||||||
if(StringsDiffer(Config.RootURL, ""))
|
ConstructURLPrefix(&URLPrefix, INCLUDE_JS, PAGE_INDEX);
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "%s/", Config.RootURL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "../");
|
|
||||||
}
|
|
||||||
if(StringsDiffer(Config.JSDir, ""))
|
|
||||||
{
|
|
||||||
Ptr += CopyString(Ptr, "%s/", Config.JSDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
char Script[512 + StringLength(URLPrefix) + (StringLength(Config.ProjectID) * 2)];
|
char Script[512 + StringLength(URLPrefix.Location) + (StringLength(Config.ProjectID) * 2)];
|
||||||
CopyString(Script, " </dl>\n"
|
CopyString(Script, " </dl>\n"
|
||||||
" <script type=\"text/javascript\">\n"
|
" <script type=\"text/javascript\">\n"
|
||||||
" var indexLocation = \"%s.index\";\n"
|
|
||||||
" var projectID = \"%s\";\n"
|
" var projectID = \"%s\";\n"
|
||||||
|
" var theme = \"%s\";\n"
|
||||||
|
" var outputURLPrefix = \"%s\";\n"
|
||||||
" </script>\n"
|
" </script>\n"
|
||||||
" <script type=\"text/javascript\" src=\"%scinera_search.js\"></script>\n",
|
" <script type=\"text/javascript\" src=\"%scinera_search.js\"></script>\n",
|
||||||
Config.ProjectID,
|
Config.ProjectID,
|
||||||
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID,
|
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID,
|
||||||
URLPrefix);
|
StringsDiffer(Config.URLPrefix, "") ? Config.URLPrefix : Config.ProjectID,
|
||||||
|
URLPrefix.Location);
|
||||||
|
DeclaimBuffer(&URLPrefix);
|
||||||
|
|
||||||
int EntryLength = 32 + StringLength(ProjectInfo[ProjectIndex].Unit) + 16 + 256;
|
int EntryLength = 32 + StringLength(ProjectInfo[ProjectIndex].Unit) + 16 + 256;
|
||||||
|
|
||||||
|
@ -3822,16 +3801,34 @@ IndexToBuffer(buffers *CollationBuffers)
|
||||||
CopyStringNoFormatT(Title, Index.File.Buffer.Ptr, '\n');
|
CopyStringNoFormatT(Title, Index.File.Buffer.Ptr, '\n');
|
||||||
Title[StringLength(Title) - 1] = '\0';
|
Title[StringLength(Title) - 1] = '\0';
|
||||||
|
|
||||||
|
char BaseFilename[255];
|
||||||
|
if(StringsDiffer(Config.URLPrefix, ""))
|
||||||
|
{
|
||||||
|
char *Ptr = This.BaseFilename + StringLength(Config.ProjectID);
|
||||||
|
CopyString(BaseFilename, "%s%s", Config.URLPrefix, Ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CopyString(BaseFilename, "%s", This.BaseFilename);
|
||||||
|
}
|
||||||
|
|
||||||
if(StringsDiffer(ProjectInfo[ProjectIndex].Unit, ""))
|
if(StringsDiffer(ProjectInfo[ProjectIndex].Unit, ""))
|
||||||
{
|
{
|
||||||
CopyStringToBuffer(&CollationBuffers->Index,
|
CopyStringToBuffer(&CollationBuffers->Index,
|
||||||
" <dt>\n"
|
" <dt>\n"
|
||||||
" <a href=\"%s\">%s %s: %s</a>\n"
|
" <a href=\"%s\">", BaseFilename);
|
||||||
" </dt>\n",
|
|
||||||
This.BaseFilename,
|
char Text[1024]; // NOTE(matt): Surely this will be big enough
|
||||||
|
CopyString(Text, "%s %s: %s",
|
||||||
ProjectInfo[ProjectIndex].Unit, // TODO(matt): Do we need to special-case the various numbering schemes?
|
ProjectInfo[ProjectIndex].Unit, // TODO(matt): Do we need to special-case the various numbering schemes?
|
||||||
Number,
|
Number,
|
||||||
Title);
|
Title);
|
||||||
|
|
||||||
|
CopyStringToBufferHTMLSafe(&CollationBuffers->Index, Text);
|
||||||
|
|
||||||
|
CopyStringToBuffer(&CollationBuffers->Index,
|
||||||
|
"</a>\n"
|
||||||
|
" </dt>\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3839,7 +3836,7 @@ IndexToBuffer(buffers *CollationBuffers)
|
||||||
" <dt>\n"
|
" <dt>\n"
|
||||||
" <a href=\"%s\">%s</a>\n"
|
" <a href=\"%s\">%s</a>\n"
|
||||||
" </dt>\n",
|
" </dt>\n",
|
||||||
This.BaseFilename,
|
BaseFilename,
|
||||||
Title);
|
Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3863,7 +3860,15 @@ int
|
||||||
GeneratePlayerPage(buffers *CollationBuffers, template *PlayerTemplate, char *BaseFilename)
|
GeneratePlayerPage(buffers *CollationBuffers, template *PlayerTemplate, char *BaseFilename)
|
||||||
{
|
{
|
||||||
char OutputDir[256];
|
char OutputDir[256];
|
||||||
CopyString(OutputDir, "%s/%s", Config.BaseDir, BaseFilename);
|
if(StringsDiffer(Config.URLPrefix, ""))
|
||||||
|
{
|
||||||
|
char *Ptr = BaseFilename + StringLength(Config.ProjectID);
|
||||||
|
CopyString(OutputDir, "%s/%s%s", Config.BaseDir, Config.URLPrefix, Ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CopyString(OutputDir, "%s/%s", Config.BaseDir, BaseFilename);
|
||||||
|
}
|
||||||
char PlayerPagePath[256];
|
char PlayerPagePath[256];
|
||||||
CopyString(PlayerPagePath, "%s/index.html", OutputDir);
|
CopyString(PlayerPagePath, "%s/index.html", OutputDir);
|
||||||
|
|
||||||
|
@ -3899,7 +3904,15 @@ DeletePlayerPageFromFilesystem(char *BaseFilename)
|
||||||
{
|
{
|
||||||
// NOTE(matt): Once we have the notion of an output filename format, we'll need to use that here
|
// NOTE(matt): Once we have the notion of an output filename format, we'll need to use that here
|
||||||
char PlayerDirPath[256];
|
char PlayerDirPath[256];
|
||||||
CopyString(PlayerDirPath, "%s/%s", Config.BaseDir, BaseFilename);
|
if(StringsDiffer(Config.URLPrefix, ""))
|
||||||
|
{
|
||||||
|
char *Ptr = BaseFilename + StringLength(Config.ProjectID);
|
||||||
|
CopyString(PlayerDirPath, "%s/%s%s", Config.BaseDir, Config.URLPrefix, Ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CopyString(PlayerDirPath, "%s/%s", Config.BaseDir, BaseFilename);
|
||||||
|
}
|
||||||
DIR *PlayerDir;
|
DIR *PlayerDir;
|
||||||
|
|
||||||
if((PlayerDir = opendir(PlayerDirPath))) // There is a directory for the Player, which there probably should be if not for manual intervention
|
if((PlayerDir = opendir(PlayerDirPath))) // There is a directory for the Player, which there probably should be if not for manual intervention
|
||||||
|
@ -4163,7 +4176,8 @@ main(int ArgC, char **Args)
|
||||||
.Theme = "",
|
.Theme = "",
|
||||||
.TemplatePlayerLocation = "template_player.html",
|
.TemplatePlayerLocation = "template_player.html",
|
||||||
.TemplateIndexLocation = "template_index.html",
|
.TemplateIndexLocation = "template_index.html",
|
||||||
.UpdateInterval = 4
|
.UpdateInterval = 4,
|
||||||
|
.URLPrefix = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
if(getenv("XDG_CACHE_HOME"))
|
if(getenv("XDG_CACHE_HOME"))
|
||||||
|
@ -4253,6 +4267,21 @@ main(int ArgC, char **Args)
|
||||||
if(StringsDiffer(Config.ProjectID, ""))
|
if(StringsDiffer(Config.ProjectID, ""))
|
||||||
{
|
{
|
||||||
Config.Edition = EDITION_PROJECT;
|
Config.Edition = EDITION_PROJECT;
|
||||||
|
for(int ProjectInfoIndex = 0; ProjectInfoIndex < ArrayCount(ProjectInfo); ++ProjectInfoIndex)
|
||||||
|
{
|
||||||
|
if(!StringsDiffer(Config.ProjectID, ProjectInfo[ProjectInfoIndex].ProjectID))
|
||||||
|
{
|
||||||
|
if(StringsDiffer(ProjectInfo[ProjectInfoIndex].Medium, ""))
|
||||||
|
{
|
||||||
|
Config.DefaultMedium = ProjectInfo[ProjectInfoIndex].Medium;
|
||||||
|
}
|
||||||
|
if(StringsDiffer(ProjectInfo[ProjectInfoIndex].AltURLPrefix, ""))
|
||||||
|
{
|
||||||
|
Config.URLPrefix = ProjectInfo[ProjectInfoIndex].AltURLPrefix;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidDefaultMedium = FALSE;
|
bool ValidDefaultMedium = FALSE;
|
||||||
|
@ -4405,6 +4434,7 @@ main(int ArgC, char **Args)
|
||||||
" ID:\t\t\t\t%s\n"
|
" ID:\t\t\t\t%s\n"
|
||||||
" Input Directory:\t\t%s\n"
|
" Input Directory:\t\t%s\n"
|
||||||
" Output Base Directory:\t%s\n"
|
" Output Base Directory:\t%s\n"
|
||||||
|
" Player Page URL Prefix:\t%s\n"
|
||||||
" Default Medium:\t\t%s\n"
|
" Default Medium:\t\t%s\n"
|
||||||
" Style / Theme:\t\t%s\n"
|
" Style / Theme:\t\t%s\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -4413,6 +4443,7 @@ main(int ArgC, char **Args)
|
||||||
Config.ProjectID,
|
Config.ProjectID,
|
||||||
Config.ProjectDir,
|
Config.ProjectDir,
|
||||||
Config.BaseDir,
|
Config.BaseDir,
|
||||||
|
StringsDiffer(Config.URLPrefix, "") ? Config.URLPrefix : Config.ProjectID,
|
||||||
Config.DefaultMedium,
|
Config.DefaultMedium,
|
||||||
StringsDiffer(Config.Theme, "") ? Config.Theme: Config.ProjectID);
|
StringsDiffer(Config.Theme, "") ? Config.Theme: Config.ProjectID);
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
@ -17,7 +17,7 @@ var rendering = false;
|
||||||
|
|
||||||
var dayContainerPrototype = document.createElement("DIV");
|
var dayContainerPrototype = document.createElement("DIV");
|
||||||
dayContainerPrototype.classList.add("dayContainer");
|
dayContainerPrototype.classList.add("dayContainer");
|
||||||
dayContainerPrototype.classList.add(projectID);
|
dayContainerPrototype.classList.add(theme);
|
||||||
|
|
||||||
var dayNamePrototype = document.createElement("SPAN");
|
var dayNamePrototype = document.createElement("SPAN");
|
||||||
dayNamePrototype.classList.add("dayName");
|
dayNamePrototype.classList.add("dayName");
|
||||||
|
@ -25,7 +25,7 @@ dayContainerPrototype.appendChild(dayNamePrototype);
|
||||||
|
|
||||||
var markerListPrototype = document.createElement("DIV");
|
var markerListPrototype = document.createElement("DIV");
|
||||||
markerListPrototype.classList.add("markerList");
|
markerListPrototype.classList.add("markerList");
|
||||||
markerListPrototype.classList.add(projectID);
|
markerListPrototype.classList.add(theme);
|
||||||
dayContainerPrototype.appendChild(markerListPrototype);
|
dayContainerPrototype.appendChild(markerListPrototype);
|
||||||
|
|
||||||
var markerPrototype = document.createElement("A");
|
var markerPrototype = document.createElement("A");
|
||||||
|
@ -206,7 +206,12 @@ xhr.addEventListener("load", function() {
|
||||||
episode = {};
|
episode = {};
|
||||||
mode = "none";
|
mode = "none";
|
||||||
} else if (line.startsWith("name:")) {
|
} else if (line.startsWith("name:")) {
|
||||||
episode.name = line.slice(6);
|
if(projectID != outputURLPrefix) {
|
||||||
|
episode.name = line.slice(6).replace(projectID, outputURLPrefix);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
episode.name = line.slice(6);
|
||||||
|
}
|
||||||
} else if (line.startsWith("title:")) {
|
} else if (line.startsWith("title:")) {
|
||||||
episode.title = line.slice(7).replace(/"/g, "");
|
episode.title = line.slice(7).replace(/"/g, "");
|
||||||
} else if (line.startsWith("markers")) {
|
} else if (line.startsWith("markers")) {
|
||||||
|
@ -233,7 +238,7 @@ xhr.addEventListener("load", function() {
|
||||||
xhr.addEventListener("error", function() {
|
xhr.addEventListener("error", function() {
|
||||||
console.error("Failed to load content");
|
console.error("Failed to load content");
|
||||||
});
|
});
|
||||||
xhr.open("GET", indexLocation);
|
xhr.open("GET", projectID + ".index");
|
||||||
xhr.setRequestHeader("Content-Type", "text/plain");
|
xhr.setRequestHeader("Content-Type", "text/plain");
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|
Before Width: | Height: | Size: 881 B After Width: | Height: | Size: 881 B |
Loading…
Reference in New Issue