cinera.c: Add new reference combination
This commit is contained in:
parent
1efd808783
commit
4b9e1a2fa0
|
@ -14,7 +14,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 5,
|
.Minor = 5,
|
||||||
.Patch = 42
|
.Patch = 43
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
|
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
|
||||||
|
@ -1559,20 +1559,22 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta
|
||||||
return RC_SUCCESS;
|
return RC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
REF_SITE = 1 << 0,
|
||||||
|
REF_PAGE = 1 << 1,
|
||||||
|
REF_URL = 1 << 2,
|
||||||
|
REF_TITLE = 1 << 3,
|
||||||
|
REF_ARTICLE = 1 << 4,
|
||||||
|
REF_AUTHOR = 1 << 5,
|
||||||
|
REF_EDITOR = 1 << 6,
|
||||||
|
REF_PUBLISHER = 1 << 7,
|
||||||
|
REF_ISBN = 1 << 8,
|
||||||
|
} reference_fields;
|
||||||
|
|
||||||
int
|
int
|
||||||
BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMML_Reference *Ref, HMML_Annotation *Anno)
|
BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMML_Reference *Ref, HMML_Annotation *Anno)
|
||||||
{
|
{
|
||||||
|
|
||||||
#define REF_SITE (1 << 0)
|
|
||||||
#define REF_PAGE (1 << 1)
|
|
||||||
#define REF_URL (1 << 2)
|
|
||||||
#define REF_TITLE (1 << 3)
|
|
||||||
#define REF_ARTICLE (1 << 4)
|
|
||||||
#define REF_AUTHOR (1 << 5)
|
|
||||||
#define REF_EDITOR (1 << 6)
|
|
||||||
#define REF_PUBLISHER (1 << 7)
|
|
||||||
#define REF_ISBN (1 << 8)
|
|
||||||
|
|
||||||
int Mask = 0;
|
int Mask = 0;
|
||||||
|
|
||||||
if(Ref->site) { Mask |= REF_SITE; }
|
if(Ref->site) { Mask |= REF_SITE; }
|
||||||
|
@ -1585,82 +1587,90 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM
|
||||||
if(Ref->publisher) { Mask |= REF_PUBLISHER; }
|
if(Ref->publisher) { Mask |= REF_PUBLISHER; }
|
||||||
if(Ref->isbn) { Mask |= REF_ISBN; }
|
if(Ref->isbn) { Mask |= REF_ISBN; }
|
||||||
|
|
||||||
if((REF_URL | REF_TITLE | REF_AUTHOR | REF_PUBLISHER | REF_ISBN) == Mask)
|
// TODO(matt): Consider handling the various combinations more flexibly
|
||||||
|
switch(Mask)
|
||||||
|
{
|
||||||
|
case (REF_URL | REF_TITLE | REF_AUTHOR | REF_PUBLISHER | REF_ISBN):
|
||||||
{
|
{
|
||||||
CopyString(ReferencesArray[UniqueRefs].ID, Ref->isbn);
|
CopyString(ReferencesArray[UniqueRefs].ID, Ref->isbn);
|
||||||
CopyString(ReferencesArray[UniqueRefs].Source, "%s (%s)", Ref->author, Ref->publisher);
|
CopyString(ReferencesArray[UniqueRefs].Source, "%s (%s)", Ref->author, Ref->publisher);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_AUTHOR | REF_SITE | REF_PAGE | REF_URL) == Mask)
|
case (REF_AUTHOR | REF_SITE | REF_PAGE | REF_URL):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
||||||
CopyString(ReferencesArray[UniqueRefs].RefTitle, "%s: \"%s\"", Ref->author, Ref->page);
|
CopyString(ReferencesArray[UniqueRefs].RefTitle, "%s: \"%s\"", Ref->author, Ref->page);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_PAGE | REF_URL | REF_TITLE) == Mask)
|
case (REF_PAGE | REF_URL | REF_TITLE):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->title);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_SITE | REF_PAGE | REF_URL) == Mask)
|
case (REF_SITE | REF_PAGE | REF_URL):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_SITE | REF_URL | REF_TITLE) == Mask)
|
case (REF_SITE | REF_URL | REF_TITLE):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_TITLE | REF_AUTHOR | REF_ISBN) == Mask)
|
case (REF_TITLE | REF_AUTHOR | REF_ISBN):
|
||||||
{
|
{
|
||||||
CopyString(ReferencesArray[UniqueRefs].ID, Ref->isbn);
|
CopyString(ReferencesArray[UniqueRefs].ID, Ref->isbn);
|
||||||
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
CopyString(ReferencesArray[UniqueRefs].URL, "http://www.openisbn.com/isbn/%s", Ref->isbn);
|
CopyString(ReferencesArray[UniqueRefs].URL, "http://www.openisbn.com/isbn/%s", Ref->isbn);
|
||||||
}
|
} break;
|
||||||
else if((REF_URL | REF_ARTICLE | REF_AUTHOR) == Mask)
|
case (REF_URL | REF_ARTICLE | REF_AUTHOR):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->article);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->article);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_URL | REF_TITLE | REF_AUTHOR) == Mask)
|
case (REF_URL | REF_TITLE | REF_AUTHOR):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
CopyString(ReferencesArray[UniqueRefs].Source, Ref->author);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_URL | REF_TITLE) == Mask)
|
case (REF_URL | REF_TITLE | REF_PUBLISHER):
|
||||||
|
{
|
||||||
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
|
CopyString(ReferencesArray[UniqueRefs].Source, Ref->publisher);
|
||||||
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
|
} break;
|
||||||
|
case (REF_URL | REF_TITLE):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else if((REF_SITE | REF_URL) == Mask)
|
case (REF_SITE | REF_URL):
|
||||||
{
|
{
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->site);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->site);
|
||||||
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url);
|
||||||
}
|
} break;
|
||||||
else
|
default: return RC_INVALID_REFERENCE; break;
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, Anno->time);
|
CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, Anno->time);
|
||||||
ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Identifier = RefIdentifier;
|
ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Identifier = RefIdentifier;
|
||||||
return 0;
|
return RC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -3399,7 +3409,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
||||||
" <div class=\"mouse_catcher\"></div>\n"
|
" <div class=\"mouse_catcher\"></div>\n"
|
||||||
" <div class=\"refs references_container\">\n");
|
" <div class=\"refs references_container\">\n");
|
||||||
|
|
||||||
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, CurrentRef, Anno) == 1)
|
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, CurrentRef, Anno) == RC_INVALID_REFERENCE)
|
||||||
{
|
{
|
||||||
LogError(LOG_ERROR, "Reference combination processing failed: %s:%d", Filename, Anno->line);
|
LogError(LOG_ERROR, "Reference combination processing failed: %s:%d", Filename, Anno->line);
|
||||||
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n"
|
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n"
|
||||||
|
@ -3455,7 +3465,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, CurrentRef, Anno) == 1)
|
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, CurrentRef, Anno) == RC_INVALID_REFERENCE)
|
||||||
{
|
{
|
||||||
LogError(LOG_ERROR, "Reference combination processing failed: %s:%d", Filename, Anno->line);
|
LogError(LOG_ERROR, "Reference combination processing failed: %s:%d", Filename, Anno->line);
|
||||||
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n"
|
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n"
|
||||||
|
|
Loading…
Reference in New Issue