Compare commits

..

6 Commits

Author SHA1 Message Date
73dd71f2f0 Merge pull request '[I132] tags page generation issues' (#205) from I132_tags_index_issues into main
Reviewed-on: #205
2024-09-28 15:49:44 +00:00
06601c5d20 Merge branch 'main' into I132_tags_index_issues 2024-09-28 15:49:25 +00:00
b17daba4ed
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.
2024-09-17 23:03:52 -04:00
70d5983ede
Parse db tag field with CSV parser module
The CSV parser module is being used in another
template. Make tag field parsing consistent.
2024-09-17 22:58:54 -04:00
31a5994731
Refactor template to use tag_to_id macro 2024-09-17 22:24:16 -04:00
aaaaa29d8e
Add macro tag_to_id 2024-09-15 15:42:46 -04:00
3 changed files with 23 additions and 13 deletions

View File

@ -4,27 +4,27 @@
<!--% PERL %-->
$Template::Stash::PRIVATE = undef; # Allow . in tag
<!--% END %-->
<!--% USE String %-->
<!--% uniq_tag_count = 0 %-->
<!--% comma_re = '(?x)(?:^|,\s*)(?:"((?>[^"]*)(?:""[^"]*)*)"|([^",]*))'; %-->
<!--# 'Moka5,interview, "computer science"' -->
<!--% FOREACH episode IN DBI.query(query_tags);
ep_id = episode.id;
ep_tags = episode.tags;
FOREACH tag_str IN ep_tags.split(comma_re);
FOREACH tag_str IN ep_tags.csv_parse;
NEXT UNLESS tag_str;
NEXT IF tag_str == '';
tag = tag_str.lower;
tag_index = String.new(tag).push('_');
first_char = tag.substr(0,1);
IF first_char == '.';
first_char = '&#x0002E;'; # Unicode .
END;
IF all_tags.${first_char}.exists(tag);
all_tags.${first_char}.${tag}.count = all_tags.${first_char}.${tag}.count + 1;
all_tags.${first_char}.${tag}.urls.push(ep_id);
IF all_tags.${first_char}.exists(tag_index);
all_tags.${first_char}.${tag_index}.count = all_tags.${first_char}.${tag_index}.count + 1;
all_tags.${first_char}.${tag_index}.urls.push(ep_id);
ELSE;
all_tags.${first_char}.${tag}.count = 1;
all_tags.${first_char}.${tag_index}.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 %-->
@ -53,7 +53,7 @@ END %-->
<ul class="columns3">
<!--% FOREACH first_char IN all_first %-->
<!--% 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 %-->
</ul>
@ -63,11 +63,12 @@ END %-->
<p class="ralign"><a href="<!--% absolute_path(baseurl) %-->tags.html#TOP">&UpArrow; Go to index</a></p>
<h3>Tags beginning with '<!--% first_char %-->'</h3>
<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>
<a id="<!--% tag %-->"><strong><!--% tag %--></strong></a>:
<a id="<!--% tag_to_id(tag_id) %-->"><strong><!--% tag %--></strong></a>:
<!--% 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"'
' target="_blank" aria-label="' _ tag _
' - show ' _ ep_id _ '">' _ ep_id _ '</a>');

View File

@ -14,7 +14,7 @@ from the series <em><a href="<!--% baseurl %-->series/<!--% zero_pad_left(series
<!--% MACRO display_tags(tags) BLOCK %-->
<span><label>Tags:</label> <em>
<!--% FOREACH tag IN tags.csv_parse %-->
<a href="<!--% absolute_path(baseurl) %-->tags.html#<!--% tag.lower %-->"><!--% tag %--></a><!--% IF loop.count == loop.size %-->.<!--% ELSE %-->,<!--% END %-->
<a href="<!--% absolute_path(baseurl) %-->tags.html#<!--% tag_to_id(tag) %-->"><!--% tag %--></a><!--% IF loop.count == loop.size %-->.<!--% ELSE %-->,<!--% END %-->
<!--% END %--></em>
</span>
<!--% END %-->

View File

@ -49,6 +49,15 @@
<!--% iso8601_date.format(date_to_format) %-->
<!--% END %-->
<!--% MACRO tag_to_id(tag, is_index) BLOCK %-->
<!--% tag = tag.replace('\s+','_') %-->
<!--% IF is_index %-->
<!--% tag.upper %-->
<!--% ELSE %-->
<!--% tag.lower %-->
<!--% END %-->
<!--% END %-->
<!--% MACRO absolute_url(base, path) BLOCK %-->
<!--% UNLESS base.empty %-->
<!--% UNLESS base.substr(-1) == '/' %-->