hmml_to_html.c: Generate topics.css [#22]
This commit is contained in:
parent
ed4b8de12d
commit
5d495a9997
|
@ -225,6 +225,8 @@ SanitisePunctuation(char *String)
|
|||
char *CategoryMedium[] =
|
||||
{
|
||||
"blackboard",
|
||||
"owl",
|
||||
"rant",
|
||||
"research",
|
||||
"run",
|
||||
};
|
||||
|
@ -256,6 +258,73 @@ BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, boo
|
|||
return;
|
||||
}
|
||||
|
||||
void
|
||||
GenerateTopicColours(char *Topic)
|
||||
{
|
||||
for(int i = 0; i < ArrayCount(CategoryMedium); ++i)
|
||||
{
|
||||
if(!StringsDiffer(Topic, CategoryMedium[i]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *TopicsFile;
|
||||
char *TopicsBuffer;
|
||||
char *TopicsPtr;
|
||||
int PersistentLength = 89;
|
||||
if((TopicsFile = fopen("topics.css", "r")))
|
||||
{
|
||||
fseek(TopicsFile, 0, SEEK_END);
|
||||
int TopicsLength = ftell(TopicsFile);
|
||||
fseek(TopicsFile, 0, SEEK_SET);
|
||||
|
||||
if(!(TopicsBuffer = malloc(TopicsLength + StringLength(Topic) + PersistentLength)))
|
||||
{
|
||||
perror("hmml_to_html");
|
||||
return;
|
||||
}
|
||||
|
||||
fread(TopicsBuffer, TopicsLength, 1, TopicsFile);
|
||||
fclose(TopicsFile);
|
||||
|
||||
TopicsPtr = TopicsBuffer;
|
||||
|
||||
while(TopicsPtr - TopicsBuffer < TopicsLength)
|
||||
{
|
||||
TopicsPtr += 39;
|
||||
if(!strncmp(SanitisePunctuation(Topic), TopicsPtr, StringLength(Topic)))
|
||||
{
|
||||
free(TopicsBuffer);
|
||||
return;
|
||||
}
|
||||
while(TopicsPtr - TopicsBuffer < TopicsLength && *TopicsPtr != '\n')
|
||||
{
|
||||
++TopicsPtr;
|
||||
}
|
||||
++TopicsPtr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(TopicsBuffer = malloc(StringLength(Topic) + PersistentLength)))
|
||||
{
|
||||
perror("hmml_to_html");
|
||||
return;
|
||||
}
|
||||
TopicsPtr = TopicsBuffer;
|
||||
}
|
||||
|
||||
int PrintLength = sprintf(TopicsPtr, ".marker .content .categories .category.%s { border-color: #%X; background: #%X; }\n",
|
||||
SanitisePunctuation(Topic), StringToColourHash(Topic), StringToColourHash(Topic));
|
||||
TopicsPtr += PrintLength;
|
||||
|
||||
TopicsFile = fopen("topics.css", "w");
|
||||
fwrite(TopicsBuffer, TopicsPtr - TopicsBuffer, 1, TopicsFile);
|
||||
fclose(TopicsFile);
|
||||
free(TopicsBuffer);
|
||||
}
|
||||
|
||||
int
|
||||
main(int ArgC, char **Args)
|
||||
{
|
||||
|
@ -389,6 +458,7 @@ Readable);
|
|||
}
|
||||
else if(Anno->markers[MarkerIndex].type == HMML_CATEGORY)
|
||||
{
|
||||
GenerateTopicColours(Anno->markers[MarkerIndex].marker);
|
||||
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, Anno->markers[MarkerIndex].marker);
|
||||
}
|
||||
}
|
||||
|
@ -519,6 +589,7 @@ Anno->time);
|
|||
|
||||
while(MarkerIndex < Anno->marker_count)
|
||||
{
|
||||
GenerateTopicColours(Anno->markers[MarkerIndex].marker);
|
||||
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, Anno->markers[MarkerIndex].marker);
|
||||
}
|
||||
|
||||
|
@ -598,7 +669,7 @@ Anno->time);
|
|||
// TODO(matt): Fill the div class="ref_indices" with <= 3 span
|
||||
// class="ref_index" and ensure to put these <=3 spans on the same line without
|
||||
// a space between them
|
||||
" <div class=\"ref_indices\">\n",
|
||||
" <div class=\"ref_indices\">\n ",
|
||||
ReferencesArray[i].ID,
|
||||
"http://example.com/",
|
||||
"Source",
|
||||
|
@ -606,14 +677,14 @@ ReferencesArray[i].ID,
|
|||
for(int j = 0; j < ReferencesArray[i].IdentifierCount; ++j)
|
||||
{
|
||||
CopyStringToBuffer(&ReferenceMenu,
|
||||
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n",
|
||||
"<span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>",
|
||||
TimecodeToSeconds(ReferencesArray[i].Identifier[j].Timecode),
|
||||
ReferencesArray[i].Identifier[j].Identifier,
|
||||
ReferencesArray[i].Identifier[j].Timecode);
|
||||
}
|
||||
|
||||
CopyStringToBuffer(&ReferenceMenu,
|
||||
" </div>\n"
|
||||
"\n </div>\n"
|
||||
" </a>\n");
|
||||
}
|
||||
|
||||
|
@ -642,6 +713,7 @@ ReferencesArray[i].Identifier[j].Timecode);
|
|||
" <!-- Load the player -->\n"
|
||||
" <script type=\"text/javascript\" src=\"player.js\"></script>\n"
|
||||
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"
|
||||
" <link rel=\"stylesheet\" type=\"text/css\" href=\"topics.css\">\n"
|
||||
" </head>\n"
|
||||
" <body>\n");
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<!-- Load the player -->
|
||||
<script type="text/javascript" src="player.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="topics.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="title">
|
||||
|
@ -52,8 +53,7 @@
|
|||
<div class="ref_title">Title</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="60" class="timecode"><span class="ref_index">[2]</span><span class="time">1:00</span></span>
|
||||
<span data-timestamp="624" class="timecode"><span class="ref_index">[3]</span><span class="time">10:24</span></span>
|
||||
<span data-timestamp="60" class="timecode"><span class="ref_index">[2]</span><span class="time">1:00</span></span><span data-timestamp="624" class="timecode"><span class="ref_index">[3]</span><span class="time">10:24</span></span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -98,31 +98,6 @@
|
|||
width: 8px;
|
||||
}
|
||||
|
||||
.marker .content .categories .category.hardware {
|
||||
border-color: #FF3333;
|
||||
background: #FF3333;
|
||||
}
|
||||
|
||||
.marker .content .categories .category.mathematics {
|
||||
border-color: #5E0595;
|
||||
background: #5E0595;
|
||||
}
|
||||
|
||||
.marker .content .categories .category.memory {
|
||||
border-color: #3399FF;
|
||||
background: #3399FF;
|
||||
}
|
||||
|
||||
.marker .content .categories .category.rendering {
|
||||
border-color: #60B60A;
|
||||
background: #60B60A;
|
||||
}
|
||||
|
||||
.marker .content .categories .category.research {
|
||||
border-color: #5851EB;
|
||||
background: #5851EB;
|
||||
}
|
||||
|
||||
/* MANDATORY */
|
||||
|
||||
.player_container {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
.marker .content .categories .category.rendering { border-color: #60B60A; background: #60B60A; }
|
||||
.marker .content .categories .category.mesh-building { border-color: #609FA2; background: #609FA2; }
|
||||
.marker .content .categories .category.physics { border-color: #869535; background: #869535; }
|
||||
.marker .content .categories .category.threading { border-color: #579BDF; background: #579BDF; }
|
||||
.marker .content .categories .category.procedural-generation { border-color: #67B347; background: #67B347; }
|
||||
.marker .content .categories .category.optimisation { border-color: #7E4B17; background: #7E4B17; }
|
||||
.marker .content .categories .category.experience { border-color: #604188; background: #604188; }
|
||||
.marker .content .categories .category.language { border-color: #4CCCCC; background: #4CCCCC; }
|
||||
.marker .content .categories .category.memory { border-color: #8DA740; background: #8DA740; }
|
||||
.marker .content .categories .category.demo { border-color: #547AE0; background: #547AE0; }
|
||||
.marker .content .categories .category.networking { border-color: #810623; background: #810623; }
|
||||
.marker .content .categories .category.simulation { border-color: #7DF3B5; background: #7DF3B5; }
|
||||
.marker .content .categories .category.profiling { border-color: #6E5D4B; background: #6E5D4B; }
|
||||
.marker .content .categories .category.trivia { border-color: #7C962E; background: #7C962E; }
|
||||
.marker .content .categories .category.mathematics { border-color: #5E0595; background: #5E0595; }
|
Loading…
Reference in New Issue