The tags on an episode should link to the tags page #152

Closed
opened 2023-08-07 08:22:09 +00:00 by ken_fallon · 4 comments
Owner
Tags: tag1,tag2	

should be

Tags: <a href="https://hackerpublicradio.org/tags.html#tag1">#tag1</a>, <a href="https://hackerpublicradio.org/tags.html#tag2">#tag2</a>, 
``` Tags: tag1,tag2 ``` should be ``` Tags: <a href="https://hackerpublicradio.org/tags.html#tag1">#tag1</a>, <a href="https://hackerpublicradio.org/tags.html#tag2">#tag2</a>, ```
Owner

I have a moderately usable solution.

I wrote a little addition to the display_tags macro in shared-episode-summary.tpl.html which cleans and splits the database tags field (with a regex) then runs a loop on the result, generating links. It works in my tests but this database field really needs to be parsed with a CSV-aware parser since there's some weird and wacky stuff in there. Plus my basic "parser" would not manage embedded commas, and I know there are some in there!

I'd prefer to create a more robust solution.

I have a moderately usable solution. I wrote a little addition to the `display_tags` macro in `shared-episode-summary.tpl.html` which cleans and splits the database `tags` field (with a regex) then runs a loop on the result, generating links. It works in my tests but this database field really needs to be parsed with a CSV-aware parser since there's some weird and wacky stuff in there. Plus my basic "parser" would not manage embedded commas, and I know there are some in there! I'd prefer to create a more robust solution.
Owner

There's a fair bit to do still:

  • Given that anchor ids are limited in what they can contain (start with a letter, alphanumerics and underscores, etc) we need to generate them with an algorithm.
  • The ids can be generated with a Perl function in the site-generator, which is called when creating an episode page, or list of episode summaries. A Perl function callable in TT² might be more efficient than a TT² macro.
  • The id generation function also needs to be called when building the tags page
There's a fair bit to do still: - Given that anchor ids are limited in what they can contain (start with a letter, alphanumerics and underscores, etc) we need to generate them with an algorithm. - The ids can be generated with a Perl function in the `site-generator`, which is called when creating an episode page, or list of episode summaries. A Perl function callable in TT² might be more efficient than a TT² macro. - The id generation function also needs to be called when building the tags page
Owner

The "more robust" solution was added in the last few days. It consists of a TT² vmethod called csv_parse which uses the module Text::CSV_XS to take the CSV tags from the database, split them, and use the resulting list to generate a series of links.

This is not the end of the story however, we need a better anchor id generator, as noted above.

The "more robust" solution was added in the last few days. It consists of a TT² `vmethod` called `csv_parse` which uses the module `Text::CSV_XS` to take the CSV tags from the database, split them, and use the resulting list to generate a series of links. This is not the end of the story however, we need a better anchor id generator, as noted above.
Owner

This has been implemented and merged into main

This has been implemented and merged into main
rho_n closed this issue 2024-09-29 18:32:12 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: HPR/hpr_generator#152
No description provided.