Commit f4217d50 authored by Matt Mascarenhas's avatar Matt Mascarenhas

hmml_to_html.c: Coloured authors [#3]

parent f7181c18
......@@ -97,6 +97,41 @@ StringsDiffer(char *A, char *B)
return *A - *B;
}
int
CharToColour(char Char)
{
if(Char >= 'a' && Char <= 'z')
{
return (((float)Char - 'a') / ('z' - 'a') * 0xFFFFFF);
}
else if(Char >= 'A' && Char <= 'Z')
{
return (((float)Char - 'A') / ('Z' - 'A') * 0xFFFFFF);
}
else if(Char >= '0' && Char <= '9')
{
return (((float)Char - '0') / ('9' - '0') * 0xFFFFFF);
}
else
{
return 0x777777;
}
}
int
StringToColourHash(char *String)
{
int Result = 0;
int i;
for(i = 0; String[i]; ++i)
{
Result += CharToColour(String[i]);
}
return Result / i;
}
int
main(int ArgC, char **Args)
{
......@@ -139,7 +174,7 @@ main(int ArgC, char **Args)
if(HMML.well_formed)
{
ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024);
ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024 * 4);
sprintf(Working.Location,
"<html>\n"
......@@ -223,6 +258,19 @@ HMML.annotations[AnnotationIndex].time);
" <div class=\"marker");
CopyBuffer(&Working, &Out);
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 1024);
int Inc = 0;
if(HMML.annotations[AnnotationIndex].author)
{
sprintf(Working.Location, " authored");
CopyBuffer(&Working, &Out);
Inc = sprintf(Text.Ptr, "<span class=\"author\" style=\"color: #%X;\">%s</span> ",
StringToColourHash(HMML.annotations[AnnotationIndex].author), HMML.annotations[AnnotationIndex].author);
Text.Ptr += Inc;
}
if(HMML.annotations[AnnotationIndex].marker_count)
{
for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex)
......@@ -241,8 +289,6 @@ HMML.annotations[AnnotationIndex].time);
InPtr = HMML.annotations[AnnotationIndex].text;
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 256);
if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote)
{
sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex);
......@@ -255,7 +301,6 @@ HMML.annotations[AnnotationIndex].time);
*Text.Ptr++ = *InPtr++;
}
int Inc = 0;
if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2)
{
if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].page)
......@@ -291,7 +336,6 @@ HMML.annotations[AnnotationIndex].time);
Text.Ptr += Inc;
++DataRef;
}
CopyStringToBuffer(InPtr, &Text);
}
*Out.Ptr++ = '>';
......
......@@ -44,20 +44,23 @@
.marker:hover.blackboard > .content {
background-color: #FFF8E7;
background-size: 12px 12px;
background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
background-image: linear-gradient(to right , rgba(51, 153, 255, .16) 1px, transparent 1px),
linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
}
.marker:hover.blackboard .faded .content {
background-color: rgba(42, 49, 114, 0.7);
background-size: 12px 12px;
background-image: linear-gradient(to right, rgba(0, 0, 0, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px);
background-image: linear-gradient(to right , rgba(0, 0, 0, .16) 1px, transparent 1px),
linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px)
color: #FFFFFF;
}
.marker.blackboard > .content {
background-color: #FFFFFF;
background-size: 12px 12px;
background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
background-image: linear-gradient(to right , rgba(51, 153, 255, .16) 1px, transparent 1px),
linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
color: black;
}
......@@ -68,10 +71,19 @@
.marker.blackboard .progress .content {
background-color: #2A3172;
background-size: 12px 12px;
background-image: linear-gradient(to right, rgba(255, 255, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(255, 255, 255, .16) 1px, transparent 1px);
background-image: linear-gradient(to right , rgba(255, 255, 255, .16) 1px, transparent 1px),
linear-gradient(to bottom, rgba(255, 255, 255, .16) 1px, transparent 1px);
color: #FFFFFF;
}
.marker.authored .content .author {
font-style: normal;
}
.marker.authored {
font-style: oblique;
}
/* MANDATORY */
.player_container {
......
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