The old setup uses numbers to identify specific snippets. These are assigned by the SSG.
The new deployment won't have this, but it's quite a useful way to be able to refer to items where a search returns multiple results:
$ sbt_cli lua
Search results - String: lua, title: False, lang: False, similarto: False
| Snippet ID | Title | Language |
|-----------------------------------------------------------------------|
| 142 | Check if value exists in table | LUA |
| 133 | Connect to HTTPS upstream with lua-resty-http | LUA |
| 101 | Check if variable is numeric | LUA |
| 96 | Urldecode string | LUA |
| 83 | Recursively print table (print_r equivalent) | LUA |
| 40 | Check if variable is table | LUA |
| 26 | Imploding a table | LUA |
| 18 | Trim whitespace from string | LUA |
| 17 | Trim whitespace from beginning of string | LUA |
| 14 | Trim whitespace from end of string | LUA |
| 13 | Split string on Delimiter | LUA |
| 12 | Check if table has element | LUA |
-------------------------------------------------------------------------
To view "Split string on Delimiter" I'd run sbt_cli 13
.
This new utility needs to do the same, but will need to allocate numbers itself.
Requirements:
Activity
27-Sep-24 10:19
assigned to @btasker
27-Sep-24 10:22
We could probably implement this by iterating through the feed to build a slice.
However, that feels more than a little inefficient (because we'll be iterating through again to run the search).
So, there are two other ways we could run at this
go-feed
a custom translator which allocates an IDAlthough the second could be fun, I think the first is probably the better one.
27-Sep-24 10:25
mentioned in commit f975c94f0ef5a719dbbb81102bd2f5311edca092
Message
feat: assign an ID to each entry (utilities/snippets_cli_go#5)
27-Sep-24 10:25
This turned out to be much easier than expected:
gofeed
has aLen()
function which tells you how many items there are in the feed. So it's easy to have a decrementing counter27-Sep-24 10:28
mentioned in issue #6