diff --git a/cinera/cinera.c b/cinera/cinera.c index e17809f..8a56577 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -14,7 +14,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 5 + .Patch = 6 }; #define CINERA_DB_VERSION 1 @@ -115,6 +115,8 @@ typedef struct char *OutLocation; char *OutIntegratedLocation; char *ProjectDir; + char *URLPrefix; /* NOTE(matt): This will become a full blown customisable output URL. + For now it simply replaces the ProjectID */ } config; typedef struct @@ -342,25 +344,28 @@ typedef struct char *ProjectID; char *FullName; 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 ProjectInfo[] = { - { "book", "Book Club", "Day", NS_LINEAR }, - { "riscy", "RISCY BUSINESS", "Day", NS_LINEAR }, + { "book", "Book Club", "Day", NS_LINEAR, "research", "" }, + { "pcalc", "pcalc", "Day", NS_LINEAR, "programming", "" }, + { "riscy", "RISCY BUSINESS", "Day", NS_LINEAR, "programming", "" }, - { "chat", "Handmade Chat", "Day", NS_LINEAR }, - { "code", "Handmade Hero", "Day", NS_LINEAR }, - { "intro-to-c", "Intro to C on Windows", "Day", NS_LINEAR }, - { "misc", "Handmade Miscellany", "", NS_LINEAR }, - { "ray", "Handmade Ray", "Day", NS_LINEAR }, + { "chat", "Handmade Chat", "Day", NS_LINEAR, "speech", "" }, + { "code", "Handmade Hero", "Day", NS_LINEAR, "programming", "day" }, + { "intro-to-c", "Intro to C on Windows", "Day", NS_LINEAR, "programming", "day" }, + { "misc", "Handmade Miscellany", "", NS_LINEAR, "admin", "" }, + { "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)) @@ -887,6 +892,62 @@ SanitisePunctuation(char *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 { CreditsError_NoHost, @@ -940,29 +1001,14 @@ SearchCredentials(buffer *CreditsMenu, bool *HasCreditsMenu, char *Person, char if(*Credentials[CredentialIndex].SupportIcon && *Credentials[CredentialIndex].SupportURL) { - char URLPrefix[1024] = { 0 }; - char *Ptr = URLPrefix; - 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); - } - + buffer URLPrefix; + ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_INDEX); CopyStringToBuffer(CreditsMenu, " \n", Credentials[CredentialIndex].SupportURL, - URLPrefix, + URLPrefix.Location, Credentials[CredentialIndex].SupportIcon); + DeclaimBuffer(&URLPrefix); } CopyStringToBuffer(CreditsMenu, @@ -1684,12 +1730,6 @@ DepartComment(buffer *Template) } } -enum -{ - PAGE_PLAYER = 1 << 0, - PAGE_INDEX = 1 << 1 -} pages; - int ValidateTemplate(buffer *Errors, template **Template, int PageType) { @@ -2609,31 +2649,16 @@ AppendedIdentifier: " };\n" " \n"); - char URLPrefix[1024] = { 0 }; - char *Ptr = URLPrefix; - 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); - } - + buffer URLPrefix; + ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_INDEX); CopyStringToBuffer(&FilterMenu, "