#5 implemented the association of an ID to an entry.
So, the next thing that we need to do is to implement support for fetching an item by its ID.
Because IDs are associated whilst iterating during a search, it probably makes most sense to adjust searchFeed
so that it can also match on ID.
Activity
27-Sep-24 10:28
assigned to @btasker
27-Sep-24 10:40
mentioned in commit acd7154b282edcae99079122b0c4f3c306e07b0e
Message
feat: introduce ID matching mode (utilities/snippets_cli_go#6)
This doesn't currently do much more than note that the ID matched
27-Sep-24 10:41
The commit above introduces the matching logic.
What we need now is a function which can print the item. I think it makes sense to do it under this ticket so I'll update the title
27-Sep-24 10:41
changed title from Fetch item by ID to Fetch item by ID{+ and print+}
27-Sep-24 10:43
This is where we're going to diverge, quite significantly, from the original script.
The old script fetched JSON which had an attribute for each of the sections. We're going to be fetching HTML and parsing that out.
Obviously, this is also going to mean that we need to define the structure that the site should use once migrated.
27-Sep-24 10:46
The old script's output looks like this
On some snippets there's also an
example
section.27-Sep-24 11:40
mentioned in commit 694e17d54fd6fa031bbffbddb64388a4df647b62
Message
feat: fetch page and start extracting info (utilities/snippets_cli_go#6)
27-Sep-24 11:44
This, not unexpectedly, is quite complicated and will rely entirely on the structure we end up using for snippets.
With the current setup, each section will need to be wrapped in a div:
etc.
Although it's workable, that doesn't lend itself particularly well to the markdown template that I was hoping to use.
One option might be to swap from the
html.Parser
tohtml.Tokeniser
so that I can look for an attribute with an id (the section heading) and then scoop up everything between it and the next known heading.I think what we probably need to do next is stand up a local Nikola site so there's something to play around with.
Note: there's a big
TODO
here - the code currently looks forh4
's because I was testing it against a blog post and looking for a heading (because those have IDs).27-Sep-24 12:26
Actually, thinking about it, do we actually want to make it reliant on that level of granularity?
It might be better to look at how things render if we were to grab a single div (which could be put into the template) and text-ise everything under it. That way minor changes to layout don't lead to us having to update/change this tool.
27-Sep-24 13:08
mentioned in commit 4cc5bed47123aea62361a8520e8fa91bfee0ad8a
Message
feat: output upstream page as markdown (utilities/snippets_cli_go#6)
I think, though, that we should remove links etc
27-Sep-24 13:08
mentioned in commit a02d007b4287ba310818564d7622fedc25cd2e0f
Message
feat: adjust markdown output for readability (utilities/snippets_cli_go#6)
This prevents inclusion of markdown markup for images and links
The aim here is to generate something that can be read by a human in the console so we want something a little closer to plain text
TODO: tidy up
27-Sep-24 13:26
Re-opening: I forgot to add a print of the full link at the end
27-Sep-24 13:28
mentioned in commit ea2de286cf9c6e54d36abc1f26b2f4a0104cf474
Message
feat: include page link at bottom of output (utilities/snippets_cli_go#6)
27-Sep-24 13:36
mentioned in issue #8