#dev 2024-03-24

2024-03-24 UTC
BinarySavior, to2ds and [tantek] joined the channel
#
[tantek]
Where you see half empty flaws I see half full good ideas that were reused in other contexts [benatwork]. Everything has flaws, what matters is does something have enough goodness to grow and contribute to further goodness
to2ds joined the channel
#
to2ds
[tantek]++
#
Loqi
[tantek] has 24 karma in this channel over the last year (103 in all channels)
claudinec_away, mahboubine, to2ds, bterry, [aciccarello], wagle and [qubyte] joined the channel
#
[qubyte]
Today I decided to finally convert my internal representation of notes/likes/links/replies from a broken (because of my broken understanding at the time) mf2 implementation to a normalized jf2. It’s actually not been that hard. Only a few edge cases. I have a parsing layer which was responsible for turning mf2 JSON into JS objects, and it turns out that the JS objects are pretty much just jf2 anyway.
#
[qubyte]
The micropub endpoint still has to receive mf2, but it already does internal normalization to mf2 JSON, and the conversion to jf2 looks like:
#
[qubyte]
```function mf2tojf2(mf2) {
#
[qubyte]
if (Object.prototype.toString.call(mf2) !== '[object Object]' || !mf2.type) {
#
[qubyte]
return mf2;
#
[qubyte]
const jf2 = {};
#
[qubyte]
for (const [key, value] of Object.entries(mf2)) {
#
[qubyte]
if (key === 'type') {
#
[qubyte]
jf2.type = value[0].slice(2);
#
[qubyte]
} else if (key === 'properties') {
#
[qubyte]
for (const [pkey, pvalue] of Object.entries(value)) {
#
[qubyte]
jf2[pkey] = mf2tojf2(pvalue[0]);
#
[qubyte]
} else {
#
[qubyte]
jf2[key] = value[0];
#
[qubyte]
(not watertight, but’s enough for my uses)
#
capjamesg
That code actually answers an entirely separate problem I have been facing. Thank you!
#
mahboubine
[qubyte]: what's jf2?
#
capjamesg
What is jf2?
#
Loqi
jf2 is a W3C Note and a JSON Post Serialization Format of microformats2 for that is optimized for h-entry consuming code, as compared to the standard microformats JSON representation https://indieweb.org/JF2
#
mahboubine
capjamesg: cool, why would I use this instead of microformats?
box464 joined the channel
#
mahboubine
I guess the wiki already answers that
#
capjamesg
It is another way of representing microformats.
#
capjamesg
It’s easier to handle.
#
capjamesg
As a developer.
#
capjamesg
You might use it in a feed reader to save entries.
box464 joined the channel
#
[KevinMarks]
It is less flexible, but easier to read as JSON.
box464 and [Paul_Robert_Ll] joined the channel
#
[Paul_Robert_Ll]
[qubyte] Don’t know if you looked at https://github.com/getindiekit/mf2tojf2; hopefully covers a few more edge cases, and also provides a mechanism for referencing.
#
Loqi
[preview] [getindiekit] mf2tojf2: Convert MF2 to JF2.
ttybitnik and mahboubine joined the channel
#
[qubyte]
lol it even has the same name as the function I wrote 😅
#
[qubyte]
I might use this instead, for the micropub endpoint. Thanks for the link!
#
[qubyte]
[Paul_Robert_Ll]++
#
Loqi
[Paul_Robert_Ll] has 3 karma in this channel over the last year (52 in all channels)
#
[qubyte]
Yes, in mf2 lists abound, and they hurt mine eyes. For example, when will an h-geo have more than one latitude? It’s general, but in a way which sometimes doesn’t make sense to me (and fills my code with `[0]`).
#
[Paul_Robert_Ll]
The mf2 → JF2 ← mf2 conversion is the bane of my ~life~ time developing Indiekit. And having to work with both means I’m often confused by the slight differences in the 2 specs.
#
[qubyte]
Yes, I don’t envy you this. Luckily for me, the only place where it’ll be an issue is said micropub endpoint. The templates are isolated from either, and the loaders will deserialize from jf2 now.
#
[qubyte]
There’s already a lot of that sort of thing in the endpoint because it handles the various encodings (JSON/URL encoded body/multipart), so it’s not gross stuff like this sort of already belongs there.
macram_, geoffo, nertzy and [snarfed] joined the channel; macram_ left the channel
#
[snarfed]
is the mf2 => jf2 algorithm deterministic?
#
[snarfed]
most mf2 is predictably shaped, but it _can_ be shaped so many different ways
#
[snarfed]
oh wait hah, joke's on me, looks like there is no formal/standard mf2 => jf2 conversion algorithm? 😆
geoffo and [Joao_Paulo_Pes] joined the channel
#
[tantek]
jf2 needs an active editor btw, it's much less mature than mf2 or mf2json, and could very much use processing of open issues, both editorial and substantive
#
[tantek]
[snarfed] a "formal/standard mf2 => jf2 conversion algorithm" would depend on an updated jf2 to reflect modern jf2-consuming implementations and process other issues as well: https://github.com/indieweb/jf2/issues
#
[tantek]
[snarfed] I suggest you file an issue requesting that the spec https://jf2.spec.indieweb.org/ document an explicit / precise "mf2 => jf2 conversion algorithm"
#
Loqi
[preview] Kyle Mahan
#
[tantek]
well that's odd/ironic
#
[tantek]
aaronpk is the first h-card, I wonder why/how Loqi came up with Kyle as the [preview] 🤔
#
aaronpk
that's the only h-card without a u-url
#
aaronpk
so it knows the other ones aren't that page
#
aaronpk
weird side effect of guessing the primary object of the page tho
#
[tantek]
well that's not represenative h-card
#
aaronpk
the problem is it doesn't know what it's looking for when you just give it a URL and no context
#
aaronpk
the thing that should cause it to reject that h-card is that the only objects on the page are h-cards and none have the URL of the page
#
aaronpk
i already have some logic like that in there, but the list just keeps getting bigger
#
aaronpk
what's actually happening is it's removing all the other h-cards because they don't match the page URL, then there is only one object left so it thinks that's the primary object of the page
#
[qubyte]
Yeah, a lot of my converter (it evolved since the snippet I shared) is inferred from the examples in the jf2 spec draft (I’m probably using the wrong terminology there). It amounts to:
#
[qubyte]
• trim h- off of the type
#
[qubyte]
• discard empty arrays
#
[qubyte]
• hoist stuff in properties to the parent
#
[qubyte]
• unwrap arrays of just one entry
#
[qubyte]
• recurse
#
[qubyte]
which doesn’t capture everything, but gets me as far as it needs to for now.
#
[tantek]
aaronpk I think that logic is flawed because an h-card with a URL should be seen as more "real" than an h-card without.
#
aaronpk
sure but not if the URL is different from the page URL
#
[tantek]
also the larger approach of process of elimination is likely what is at fault here, because that's absolute reasoning for what may be a probabilistic or heuristic question and answer
#
aaronpk
everything in there has tests based on real world examples
#
aaronpk
but yes i agree the actual problem is removing the objects rather than looking at the whole page
#
aaronpk
it's just worked very well for most things so far
#
[tantek]
I think W3C specs are a very good real world example that demonstrates a flaw in the algorithm, that's my point
#
[tantek]
and another point is that there is probably a larger set of "there is no primary object" answers than the current algorithm allows for
#
aaronpk
sort of, but most of this code is here because there _is_ a primary object that isn't well marked up
#
[tantek]
yeah a better approach than any kind of "removing the objects" approach would be sorting the top level objects based on a set of heuristic criteria assigned point values
#
aaronpk
definitely the easier thing to do is only find a well marked up primary object, but that was not working well because there's so much poorly marked up stuff
#
[tantek]
i.e. if you can find a representative h-card or other directly algorithmic primary object, then use that, else fallback to a sorting heuristic of sorts of the top-level objects
#
[tantek]
aaronpk, this use-case (primary object for a page) is a strong enough use-case that it really should be part of a more formally specified algorithm. can you file Feature Request issue on mf2 parsing spec to document an algorithm to determine the primary object (if there are more than one) of a page, either for mf2 parsers or consumers of mf2json?
#
[tantek]
and definitely cite your prior work https://github.com/aaronpk/XRay/blob/main/lib/XRay/Formats/Mf2.php#L36 and the test cases it's been built from
#
[tantek]
I have a feeling this combined with metaformats might produce better results
#
aaronpk
hmm not a bad idea
#
[tantek]
it impacts things like showing link-previews too
#
[tantek]
it's a big use-case
#
[tantek]
has anyone played with the new (to iOS 17.4.1) "Journal" app and seen if it supports any APIs or protocols to connect to a personal site or otherwise make exporting seamless?
#
[tantek]
user docs don't say anything about import/export or APIs/protocols: https://support.apple.com/guide/iphone/get-started-with-journal-iph0e5ca7dd3/ios
AramZS joined the channel
#
[tantek]
hmm it looks like the only way to get things "out" is into iCloud: https://support.apple.com/guide/iphone/change-journal-settings-iphf965002cf/17.0/ios/17.0
nertzy and mahboubine joined the channel
#
[tantek]
has anyone built auto-emoji support into their authoring tool or presentation code? e.g. turning a variety of emoticons into equivalent emoji?
#
[tantek]
or :text: expressions like `😄` into 😄 ? I think Mastodon does this somewhat, especially with custom emoji
#
capjamesg
I have.
#
capjamesg
Reference dictionary for autocomplete: https://gist.github.com/rxaviers/7360908
#
capjamesg
(I converted that to JSON, but I can't seem to find the file.)
#
capjamesg
I don't have a demo. I haven't run the code in at least a year.
#
Loqi
capjamesg has 46 karma in this channel over the last year (181 in all channels)
#
[tantek]
capjamesg++ great! that's enough to start a page on it!
#
[tantek]
do you have an example post that shows/embeds them?
#
capjamesg
No 😄
#
capjamesg
Those would probably all be on my Known site that I shut down last week.
#
[tantek]
whoa you had a Known site?!? had no idea
#
capjamesg
Ah!!! But...
#
capjamesg
I have something arguably better.
#
capjamesg
It turns out I wrote a blog post on it: https://jamesg.blog/2021/10/25/reacjis/
#
Loqi
[preview] Adding Reacji support to my Micropub editor
#
[tantek]
yes! even better!
#
[tantek]
the :emoji-name: microsyntax is completely independent right? like it's not part of Markdown or anything else
#
[tantek]
capjamesg, do you only support standard emoji characters or do you have any custom emojis the way some Mastodon (and Discord!) servers do?
#
[aciccarello]
I wish the Mac emoji picker was easier to use. It never works how/when I expect it to.
#
[aciccarello]
I'd rather use the Unicode symbol than the microsyntax. But having suggestions when typing : is nice.
#
[aciccarello]
Slack and markdown are the two contexts I've seen it used.
#
capjamesg
Discord has it too.
#
capjamesg
And I feel like other places do, too.
#
capjamesg
[tantek] Only standard emojis.
#
[tantek]
microsyntax << [[emoji]] text syntax of ":" (emoji-name) ":" like <code> `😄` </code> for 😄 and other standard Unicode emoji, as well as other custom names for custom emoji in software like [[Mastodon]], and services like [[Discord]] and [[Slack]]. Related: [[auto-emoji]]
#
Loqi
ok, I added "[[emoji]] text syntax of ":" (emoji-name) ":" like <code> `😄` </code> for 😄 and other standard Unicode emoji, as well as other custom names for custom emoji in software like [[Mastodon]], and services like [[Discord]] and [[Slack]]. Related: [[auto-emoji]]" to the "See Also" section of /microsyntax https://indieweb.org/wiki/index.php?diff=94349&oldid=86814
#
[tantek]
aciccarello, except the :something: syntax is not part of Markdown right? my understanding is that they're called emoji shortcodes
#
[tantek]
auto-emoji << IndieWeb Example: {{capjamesg}} has supported auto-emoji via emoji shortcodes [https://jamesg.blog/2021/10/25/reacjis/ since at least 2021-10-25], using his code https://github.com/capjamesg/cinnamon/blob/main/static/js/editor.js#L319 and reference shortcode dictionary https://gist.github.com/rxaviers/7360908
#
Loqi
ok, I added "IndieWeb Example: {{capjamesg}} has supported auto-emoji via emoji shortcodes [https://jamesg.blog/2021/10/25/reacjis/ since at least 2021-10-25], using his code https://github.com/capjamesg/cinnamon/blob/main/static/js/editor.js#L319 and reference shortcode dictionary https://gist.github.com/rxaviers/7360908" to a brand new "See Also" section of /auto-emoji https://indieweb.org/wiki/index.php?diff=94350&oldid=94348
#
[tantek]
aciccarello, as in, some context support both Markdown and emoji shortcodes, e.g. GitHub and GitLab, however, seeing feature requests like this makes me think emoji shortcodes are not actually part of Markdown: https://github.com/executablebooks/MyST-Parser/issues/565
#
Loqi
[preview] [updiversity] #565 Support emojis in Markdown
#
[tantek]
e.g. "emoji" is not mentioned in the latest CommonMark spec either: https://spec.commonmark.org/0.31.2/
#
capjamesg
I wonder if it came from the fact that the smiley emoji starts with :.
#
capjamesg
: ), : D, :P, etc.
#
capjamesg
In any case, I think this is a messaging / commenting thing.
#
capjamesg
GitHub comments support it, too.
#
capjamesg
Discourse forums.
#
capjamesg
I have seen this in many places.
#
capjamesg
Mastodon.
#
capjamesg
(I just noticed you included some of those in your wiki contribution -- great!)
#
[tantek]
auto-emoji << Services support: [[GitHub]], [[GitLab]]
#
Loqi
ok, I added "Services support: [[GitHub]], [[GitLab]]" to the "See Also" section of /auto-emoji https://indieweb.org/wiki/index.php?diff=94351&oldid=94350
#
capjamesg
Notion, too.
#
capjamesg
Typora editor.
#
capjamesg
Google Docs.
#
[tantek]
auto-emoji << Hypothesis: the colon delimiting syntax came from auto-converting emoticons which often start with a ':' (like : ) or : D or : P ) into emoji.
#
Loqi
ok, I added "Hypothesis: the colon delimiting syntax came from auto-converting emoticons which often start with a ':' (like : ) or : D or : P ) into emoji." to the "See Also" section of /auto-emoji https://indieweb.org/wiki/index.php?diff=94352&oldid=94351
#
[tantek]
auto-emoji << emoji shortcodes are their own [[microsyntax]] (see https://emojipedia.org/shortcodes) and are not actually part of [[Markdown]] (no mention of emoji in https://spec.commonmark.org/). They happen to be supported in many text-entry boxes, some of which also support Markdown (e.g. [[GitHub]]), and thus are mistakenly thought of as part of Markdown, or even part of GitHub Flavored Markdown, despite that spec also having no mention
#
Loqi
ok, I added "emoji shortcodes are their own [[microsyntax]] (see https://emojipedia.org/shortcodes) and are not actually part of [[Markdown]] (no mention of emoji in https://spec.commonmark.org/). They happen to be supported in many text-entry boxes, some of which also support Markdown (e.g. [[GitHub]]), and thus are mistakenly thought of as part of Markdown, or even part of GitHub Flavored Markdown, despite that spec also having no mention" to the "See Also" section of /auto-emoji https://indieweb.org/wiki/index.php?diff=94353&oldid=94352
#
[tantek]
Thanks capjamesg, as I have not used some of those services, please feel free to add the ones you have experience with (or can quickly test) to /auto-emoji
#
capjamesg
I tested them all before sending messages.