hmml_to_html.c: Simplify InsertCategory()
Basically just relive it of taking HasTopic and HasCategory
This commit is contained in:
parent
f3899c2f35
commit
928d639c41
|
@ -737,7 +737,7 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM
|
|||
}
|
||||
|
||||
void
|
||||
InsertCategory(categories *Topics, categories *Media, bool *HasTopic, bool *HasMedium, char *Marker)
|
||||
InsertCategory(categories *Topics, categories *Media, char *Marker)
|
||||
{
|
||||
bool IsMedium = FALSE;
|
||||
|
||||
|
@ -747,7 +747,6 @@ InsertCategory(categories *Topics, categories *Media, bool *HasTopic, bool *HasM
|
|||
if(!StringsDiffer(CategoryMedium[CategoryMediumIndex].Medium, Marker))
|
||||
{
|
||||
IsMedium = TRUE;
|
||||
*HasMedium = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +785,6 @@ InsertCategory(categories *Topics, categories *Media, bool *HasTopic, bool *HasM
|
|||
}
|
||||
else
|
||||
{
|
||||
*HasTopic = TRUE;
|
||||
for(CategoryIndex = 0; CategoryIndex < Topics->Count; ++CategoryIndex)
|
||||
{
|
||||
if(!StringsDiffer(Marker, Topics->Category[CategoryIndex].Marker))
|
||||
|
@ -1909,9 +1907,7 @@ goto Cleanup;
|
|||
#endif
|
||||
HMML_Annotation *Anno = HMML.annotations + AnnotationIndex;
|
||||
categories LocalTopics = { 0 };
|
||||
bool HasTopic = FALSE;
|
||||
categories LocalMedia = { 0 };
|
||||
bool HasMedium = FALSE;
|
||||
bool HasQuote = FALSE;
|
||||
bool HasReference = FALSE;
|
||||
|
||||
|
@ -1943,7 +1939,7 @@ goto Cleanup;
|
|||
{
|
||||
HasFilterMenu = TRUE;
|
||||
}
|
||||
InsertCategory(&Topics, &Media, &HasTopic, &HasMedium, "authored");
|
||||
InsertCategory(&Topics, &Media, "authored");
|
||||
CopyStringToBuffer(&AnnotationClass, " authored");
|
||||
hsl_colour AuthorColour;
|
||||
StringToColourHash(&AuthorColour, Anno->author);
|
||||
|
@ -1967,10 +1963,6 @@ goto Cleanup;
|
|||
Anno->author);
|
||||
}
|
||||
|
||||
if(!HasMedium)
|
||||
{
|
||||
HasMedium = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
InPtr = Anno->text;
|
||||
|
@ -2044,8 +2036,8 @@ goto Cleanup;
|
|||
{
|
||||
HasFilterMenu = TRUE;
|
||||
}
|
||||
InsertCategory(&Topics, &Media, &HasTopic, &HasMedium, Anno->markers[MarkerIndex].marker); // Global
|
||||
InsertCategory(&LocalTopics, &LocalMedia, &HasTopic, &HasMedium, Anno->markers[MarkerIndex].marker); // Local
|
||||
InsertCategory(&Topics, &Media, Anno->markers[MarkerIndex].marker); // Global
|
||||
InsertCategory(&LocalTopics, &LocalMedia, Anno->markers[MarkerIndex].marker); // Local
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2308,16 +2300,16 @@ goto Cleanup;
|
|||
}
|
||||
if(Anno->markers[MarkerIndex].marker)
|
||||
{
|
||||
InsertCategory(&Topics, &Media, &HasTopic, &HasMedium, Anno->markers[MarkerIndex].marker);
|
||||
InsertCategory(&Topics, &Media, Anno->markers[MarkerIndex].marker);
|
||||
}
|
||||
InsertCategory(&LocalTopics, &LocalMedia, &HasTopic, &HasMedium, Anno->markers[MarkerIndex].marker);
|
||||
InsertCategory(&LocalTopics, &LocalMedia, Anno->markers[MarkerIndex].marker);
|
||||
++MarkerIndex;
|
||||
}
|
||||
|
||||
if(!HasMedium)
|
||||
if(LocalMedia.Count == 0)
|
||||
{
|
||||
InsertCategory(&Topics, &Media, &HasTopic, &HasMedium, DefaultMedium);
|
||||
InsertCategory(&LocalTopics, &LocalMedia, &HasTopic, &HasMedium, DefaultMedium);
|
||||
InsertCategory(&Topics, &Media, DefaultMedium);
|
||||
InsertCategory(&LocalTopics, &LocalMedia, DefaultMedium);
|
||||
}
|
||||
|
||||
BuildCategories(&AnnotationClass, &TopicDots, LocalTopics, LocalMedia, &MarkerIndex);
|
||||
|
@ -2337,7 +2329,7 @@ goto Cleanup;
|
|||
|
||||
CopyBuffer(&Annotation, &Text);
|
||||
|
||||
if(HasTopic)
|
||||
if(LocalTopics.Count > 0)
|
||||
{
|
||||
CopyBuffer(&Annotation, &TopicDots);
|
||||
}
|
||||
|
@ -2469,20 +2461,14 @@ goto Cleanup;
|
|||
" <div class=\"filter_mode inclusive\">Filter mode: </div>\n"
|
||||
" <div class=\"filters\">\n", ImagesDir);
|
||||
|
||||
{
|
||||
bool HasTopic = FALSE;
|
||||
bool HasMedium = FALSE;
|
||||
|
||||
for(int i = 0; i < Topics.Count; ++i)
|
||||
{
|
||||
if(!HasTopic)
|
||||
if(Topics.Count > 0)
|
||||
{
|
||||
CopyStringToBuffer(&FilterMenu,
|
||||
" <div class=\"filter_topics\">\n"
|
||||
" <div class=\"filter_title\">Topics</div>\n");
|
||||
|
||||
HasTopic = TRUE;
|
||||
}
|
||||
for(int i = 0; i < Topics.Count; ++i)
|
||||
{
|
||||
CopyStringToBuffer(&FilterTopics,
|
||||
" <div class=\"filter_content %s\">\n"
|
||||
" <span class=\"icon category %s\"></span><span class=\"text\">%s</span>\n"
|
||||
|
@ -2491,18 +2477,18 @@ goto Cleanup;
|
|||
Topics.Category[i].Marker,
|
||||
Topics.Category[i].Marker);
|
||||
}
|
||||
CopyStringToBuffer(&FilterTopics,
|
||||
" </div>\n");
|
||||
CopyBuffer(&FilterMenu, &FilterTopics);
|
||||
}
|
||||
|
||||
for(int i = 0; i < Media.Count; ++i)
|
||||
{
|
||||
if(!HasMedium)
|
||||
if(Media.Count > 0)
|
||||
{
|
||||
CopyStringToBuffer(&FilterMedia,
|
||||
" <div class=\"filter_media\">\n"
|
||||
" <div class=\"filter_title\">Media</div>\n");
|
||||
|
||||
HasMedium = TRUE;
|
||||
}
|
||||
|
||||
for(int i = 0; i < Media.Count; ++i)
|
||||
{
|
||||
int j;
|
||||
for(j = 0; j < ArrayCount(CategoryMedium); ++j)
|
||||
{
|
||||
|
@ -2521,30 +2507,20 @@ goto Cleanup;
|
|||
CategoryMedium[j].WrittenName
|
||||
);
|
||||
}
|
||||
|
||||
if(HasTopic)
|
||||
{
|
||||
CopyStringToBuffer(&FilterTopics,
|
||||
" </div>\n");
|
||||
CopyBuffer(&FilterMenu, &FilterTopics);
|
||||
}
|
||||
if(HasMedium)
|
||||
{
|
||||
CopyStringToBuffer(&FilterMedia,
|
||||
" </div>\n");
|
||||
CopyBuffer(&FilterMenu, &FilterMedia);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CopyStringToBuffer(&FilterMenu,
|
||||
" </div>\n"
|
||||
" </div>\n"
|
||||
" </div>\n");
|
||||
}
|
||||
|
||||
CopyBuffer(&Menus, &FilterMenu);
|
||||
|
||||
}
|
||||
|
||||
if(HasCreditsMenu)
|
||||
{
|
||||
CopyBuffer(&Menus, &CreditsMenu);
|
||||
|
|
Loading…
Reference in New Issue