Fix generation of tags index page

Replace white-space in ID attributes with the underscore
character. Fix generation of tags that start with the letter
k. The tag, keys, caused issues when used as a hash key.
This commit is contained in:
Roan Horning 2024-09-17 23:03:52 -04:00
parent 70d5983ede
commit b17daba4ed
Signed by: rho_n
GPG Key ID: 234AEF20B72D5769

View File

@ -4,6 +4,7 @@
<!--% PERL %--> <!--% PERL %-->
$Template::Stash::PRIVATE = undef; # Allow . in tag $Template::Stash::PRIVATE = undef; # Allow . in tag
<!--% END %--> <!--% END %-->
<!--% USE String %-->
<!--% uniq_tag_count = 0 %--> <!--% uniq_tag_count = 0 %-->
<!--% FOREACH episode IN DBI.query(query_tags); <!--% FOREACH episode IN DBI.query(query_tags);
ep_id = episode.id; ep_id = episode.id;
@ -12,17 +13,18 @@ $Template::Stash::PRIVATE = undef; # Allow . in tag
NEXT UNLESS tag_str; NEXT UNLESS tag_str;
NEXT IF tag_str == ''; NEXT IF tag_str == '';
tag = tag_str.lower; tag = tag_str.lower;
tag_index = String.new(tag).push('_');
first_char = tag.substr(0,1); first_char = tag.substr(0,1);
IF first_char == '.'; IF first_char == '.';
first_char = '&#x0002E;'; # Unicode . first_char = '&#x0002E;'; # Unicode .
END; END;
IF all_tags.${first_char}.exists(tag); IF all_tags.${first_char}.exists(tag_index);
all_tags.${first_char}.${tag}.count = all_tags.${first_char}.${tag}.count + 1; all_tags.${first_char}.${tag_index}.count = all_tags.${first_char}.${tag_index}.count + 1;
all_tags.${first_char}.${tag}.urls.push(ep_id); all_tags.${first_char}.${tag_index}.urls.push(ep_id);
ELSE; ELSE;
all_tags.${first_char}.${tag}.count = 1; all_tags.${first_char}.${tag_index}.count = 1;
uniq_tag_count = uniq_tag_count + 1; uniq_tag_count = uniq_tag_count + 1;
all_tags.${first_char}.${tag}.urls = [ep_id]; all_tags.${first_char}.${tag_index}.urls = [ep_id];
END; END;
END; END;
END %--> END %-->
@ -51,7 +53,7 @@ END %-->
<ul class="columns3"> <ul class="columns3">
<!--% FOREACH first_char IN all_first %--> <!--% FOREACH first_char IN all_first %-->
<!--% IF all_tags.${first_char} %--> <!--% IF all_tags.${first_char} %-->
<li><a href="<!--% absolute_path(baseurl) %-->tags.html#<!--% all_tags.${first_char}.keys.sort.first %-->"><strong><!--% first_char %--></strong></a></li> <li><a href="<!--% absolute_path(baseurl) %-->tags.html#<!--% tag_to_id(String.new(all_tags.${first_char}.keys.sort.first).chop) %-->"><strong><!--% first_char %--></strong></a></li>
<!--% END %--> <!--% END %-->
<!--% END %--> <!--% END %-->
</ul> </ul>
@ -61,11 +63,12 @@ END %-->
<p class="ralign"><a href="<!--% absolute_path(baseurl) %-->tags.html#TOP">&UpArrow; Go to index</a></p> <p class="ralign"><a href="<!--% absolute_path(baseurl) %-->tags.html#TOP">&UpArrow; Go to index</a></p>
<h3>Tags beginning with '<!--% first_char %-->'</h3> <h3>Tags beginning with '<!--% first_char %-->'</h3>
<ul> <ul>
<!--% FOREACH tag IN all_tags.${first_char}.keys.sort %--> <!--% FOREACH tag_index IN all_tags.${first_char}.keys.sort %-->
<!--% tag = String.new(tag_index).chop; tag_id = String.new(tag_index).chop; %-->
<li> <li>
<a id="<!--% tag %-->"><strong><!--% tag %--></strong></a>: <a id="<!--% tag_to_id(tag_id) %-->"><strong><!--% tag %--></strong></a>:
<!--% ep_links = [] %--> <!--% ep_links = [] %-->
<!--% FOREACH ep_id IN all_tags.${first_char}.${tag}.urls.nsort; <!--% FOREACH ep_id IN all_tags.${first_char}.${tag_index}.urls.nsort;
ep_links.push("<a href=\"${absolute_path(baseurl)}eps/hpr" _ zero_pad_left(ep_id) _ '/index.html"' ep_links.push("<a href=\"${absolute_path(baseurl)}eps/hpr" _ zero_pad_left(ep_id) _ '/index.html"'
' target="_blank" aria-label="' _ tag _ ' target="_blank" aria-label="' _ tag _
' - show ' _ ep_id _ '">' _ ep_id _ '</a>'); ' - show ' _ ep_id _ '">' _ ep_id _ '</a>');