hmml_to_html.c: Coloured authors
This commit is contained in:
parent
0adb9bf45a
commit
20ae5e8c1d
|
@ -1,21 +1,20 @@
|
|||
#if 0
|
||||
ctime -begin ${0%.*}.ctm
|
||||
gcc -g -Wall -Wno-unused-variable -fsanitize=address $0 -o ${0%.*} hmml.a
|
||||
clang -g -Wall -Wno-unused-variable -fsanitize=address -std=c99 $0 -o ${0%.*} hmml.a
|
||||
ctime -end ${0%.*}.ctm
|
||||
exit
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "hmmlib.h"
|
||||
|
||||
#ifndef bool
|
||||
typedef bool unsigned int;
|
||||
#endif
|
||||
typedef unsigned int bool;
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "hmmlib.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *Location;
|
||||
|
@ -105,13 +104,13 @@ CopyBuffer(buffer *Src, buffer *Dest)
|
|||
}
|
||||
|
||||
void
|
||||
CopyStringToBuffer(char *Src, buffer *Dest)
|
||||
CopyStringToBuffer(buffer *Dest, char *Format, ...)
|
||||
{
|
||||
while(*Src)
|
||||
{
|
||||
*Dest->Ptr++ = *Src++;
|
||||
}
|
||||
*Dest->Ptr = '\0';
|
||||
va_list Args;
|
||||
va_start(Args, Format);
|
||||
int Length = vsprintf(Dest->Ptr, Format, Args);
|
||||
va_end(Args);
|
||||
Dest->Ptr += Length;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -211,21 +210,17 @@ main(int ArgC, char **Args)
|
|||
|
||||
if(HMML.well_formed)
|
||||
{
|
||||
int PrintLength;
|
||||
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Title, 1024 * 16);
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Player, 1024 * 256);
|
||||
|
||||
PrintLength = sprintf(Title.Ptr,
|
||||
CopyStringToBuffer(&Title,
|
||||
" <div class=\"title\">\n"
|
||||
" <span class=\"episode_name\">%s</span>\n", HMML.metadata.title);
|
||||
Title.Ptr += PrintLength;
|
||||
|
||||
PrintLength = sprintf(Player.Ptr,
|
||||
CopyStringToBuffer(&Player,
|
||||
" <div class=\"player_container\">\n"
|
||||
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
|
||||
" <div class=\"markers_container\">\n", HMML.metadata.id);
|
||||
Player.Ptr += PrintLength;
|
||||
|
||||
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
|
||||
{
|
||||
|
@ -233,14 +228,23 @@ main(int ArgC, char **Args)
|
|||
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationClass, 128);
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 1024 * 4);
|
||||
|
||||
PrintLength = sprintf(AnnotationHeader.Ptr,
|
||||
CopyStringToBuffer(&AnnotationHeader,
|
||||
" <div data-timestamp=\"%d\"",
|
||||
TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
|
||||
AnnotationHeader.Ptr += PrintLength;
|
||||
|
||||
PrintLength = sprintf(AnnotationClass.Ptr,
|
||||
CopyStringToBuffer(&AnnotationClass,
|
||||
" class=\"marker");
|
||||
AnnotationClass.Ptr += PrintLength;
|
||||
|
||||
#if 0
|
||||
if(HMML.annotations[AnnotationIndex].author)
|
||||
{
|
||||
CopyStringToBuffer(&AnnotationClass, " authored");
|
||||
CopyStringToBuffer(&Text,
|
||||
"<span class=\"author\" style=\"color: #%X;\">%s</span> ",
|
||||
StringToColourHash(HMML.annotations[AnnotationIndex].author),
|
||||
HMML.annotations[AnnotationIndex].author);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -248,46 +252,42 @@ TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
|
|||
|
||||
|
||||
//TODO(matt): Replace this CopyStringToBuffer() with real stuff!
|
||||
CopyStringToBuffer(HMML.annotations[AnnotationIndex].text,
|
||||
&Text);
|
||||
CopyStringToBuffer(&Text, HMML.annotations[AnnotationIndex].text);
|
||||
|
||||
|
||||
|
||||
|
||||
CopyStringToBuffer("\"", &AnnotationClass);
|
||||
CopyStringToBuffer(&AnnotationClass, "\"");
|
||||
CopyBuffer(&AnnotationClass, &AnnotationHeader);
|
||||
CopyStringToBuffer(">\n", &AnnotationHeader);
|
||||
CopyStringToBuffer(&AnnotationHeader, ">\n");
|
||||
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Annotation, 1024 * 4);
|
||||
|
||||
CopyBuffer(&AnnotationHeader, &Annotation);
|
||||
sprintf(AnnotationHeader.Location,
|
||||
CopyStringToBuffer(&Annotation,
|
||||
" <div class=\"content\"><span class=\"timecode\">%s</span>",
|
||||
HMML.annotations[AnnotationIndex].time);
|
||||
CopyBuffer(&AnnotationHeader, &Annotation);
|
||||
|
||||
CopyBuffer(&Text, &Annotation);
|
||||
|
||||
sprintf(AnnotationHeader.Location, "</div>\n"
|
||||
CopyStringToBuffer(&Annotation, "</div>\n"
|
||||
" <div class=\"progress faded\">\n"
|
||||
" <div class=\"content\"><span class=\"timecode\">%s</span>",
|
||||
HMML.annotations[AnnotationIndex].time);
|
||||
CopyBuffer(&AnnotationHeader, &Annotation);
|
||||
|
||||
CopyBuffer(&Text, &Annotation);
|
||||
|
||||
sprintf(AnnotationHeader.Location, "</div>\n"
|
||||
CopyStringToBuffer(&Annotation, "</div>\n"
|
||||
" </div>\n"
|
||||
" <div class=\"progress main\">\n"
|
||||
" <div class=\"content\"><span class=\"timecode\">%s</span>",
|
||||
HMML.annotations[AnnotationIndex].time);
|
||||
CopyBuffer(&AnnotationHeader, &Annotation);
|
||||
|
||||
CopyBuffer(&Text, &Annotation);
|
||||
|
||||
CopyStringToBuffer("</div>\n"
|
||||
CopyStringToBuffer(&Annotation, "</div>\n"
|
||||
" </div>\n"
|
||||
" </div>\n", &Annotation);
|
||||
" </div>\n");
|
||||
|
||||
CopyBuffer(&Annotation, &Player);
|
||||
|
||||
|
@ -297,18 +297,18 @@ HMML.annotations[AnnotationIndex].time);
|
|||
ClaimedMemory -= Annotation.Size;
|
||||
}
|
||||
|
||||
sprintf(Title.Ptr,
|
||||
CopyStringToBuffer(&Title,
|
||||
" <span class=\"annotator_container\">Annotator: <span class=\"annotator\">%s</span></span>\n"
|
||||
" </div>\n", HMML.metadata.annotator);
|
||||
|
||||
sprintf(Player.Ptr,
|
||||
CopyStringToBuffer(&Player,
|
||||
" </div>\n"
|
||||
" </div>\n");
|
||||
|
||||
//NOTE(matt): Collate the buffers!
|
||||
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Master, 1024 * 512);
|
||||
PrintLength = sprintf(Master.Ptr,
|
||||
CopyStringToBuffer(&Master,
|
||||
"<!DOCTYPE html>\n"
|
||||
" <head>\n"
|
||||
" <meta charset=\"UTF-8\">\n"
|
||||
|
@ -318,14 +318,13 @@ HMML.annotations[AnnotationIndex].time);
|
|||
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"
|
||||
" </head>\n"
|
||||
" <body>\n");
|
||||
Master.Ptr += PrintLength;
|
||||
|
||||
//NOTE(matt): Here is where we do all our CopyBuffer() calls
|
||||
CopyBuffer(&Title, &Master);
|
||||
CopyBuffer(&Player, &Master);
|
||||
//
|
||||
|
||||
PrintLength = sprintf(Master.Ptr,
|
||||
CopyStringToBuffer(&Master,
|
||||
" <script>\n"
|
||||
" var player = new Player(document.querySelector(\".player_container\"), onRefChanged);\n"
|
||||
" window.addEventListener(\"resize\", function() { player.updateSize(); });\n"
|
||||
|
@ -404,8 +403,6 @@ HMML.annotations[AnnotationIndex].time);
|
|||
" </body>\n"
|
||||
"</html>\n");
|
||||
|
||||
Master.Ptr += PrintLength;
|
||||
|
||||
FILE *OutFile;
|
||||
if(!(OutFile = fopen("out.html", "w")))
|
||||
{
|
||||
|
@ -614,7 +611,7 @@ HMML.annotations[AnnotationIndex].time);
|
|||
|
||||
*Out.Ptr++ = '>';
|
||||
*Out.Ptr++ = '\n';
|
||||
CopyStringToBuffer(InPtr, &Text);
|
||||
CopyStringToBuffer(&Text, InPtr);
|
||||
*Text.Ptr = '\0';
|
||||
|
||||
sprintf(Working.Location,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
.timecode {
|
||||
font-size: 9px;
|
||||
font-style: normal;
|
||||
padding-right: 8px;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
|
|
Loading…
Reference in New Issue