Revived share plugin

After reading this article earlier in the week: https://www.scottantipa.com/store-app-state-in-urls, I remembered the tiddlywiki share plugin which can read tiddler json from the url. I didn’t play with it several years ago when it was released (see discussion on google groups), but when I tried last week it didn’t work. Based on what I see in the git history, it has been broken for a long time.

Now it is fixed and working again. The share links I give below seem to work in the preview pane here on Discourse. I’m not sure if the links will survive through to the emailed version of the post.

Here is a simple share link example which embeds a simple tiddler in the url: hello world test

Another example containing a single tiddler. However, this tiddler generates an iframe for 10+ tiddlywiki editions, so loading this page is pretty heavyweight. Especially since one of the wikis demonstrates the innerwiki plugin which itself has a handful of wikis embedded:

10+ tiddlywiki editions embedded in iframes on the share site

Here is the content of the tiddler (the filter is much more complicated than it needs to be…I could have just explicitly listed all the urls…I was just experimenting):

<$list filter="""
/
/empty.html

"
/d3
/codemirror
/highlight
/innerwiki
/katex
/markdown
:and[addprefix[/plugins/tiddlywiki]]
"

/prerelease
/prerelease/parameterised-transclusions
/prerelease/share

:map:flat[subfilter<currentTiddler>]
:and[addprefix[https://tiddlywiki.com]]
""">

<a href=<<currentTiddler>>><<currentTiddler>></a>

<!--CSS from excellent article at https://www.smashingmagazine.com/2014/02/making-embedded-content-work-in-responsive-design/-->
<div style="top left; position: relative; padding-bottom: 56.25%; padding-top: 35px; height: 0; overflow: hidden;">
<iframe style="position: absolute; top:0; left: 0; width: 100%; height: 100%;"
src=<<currentTiddler>>/>
</$list>
2 Likes

Hi @btheado thanks for your help fixing things up. Both URLS work for me on an iPad when clicking directly from the talk.tiddlywiki.org website, but not when clicking on the link in the email.

Here’s the link from the website:

https://tiddlywiki.com/prerelease/share##%5B%7B%22title%22%3A%22%24%3A%2FStoryList%22%2C%22text%22%3A%22%22%2C%22list%22%3A%22%5B%5BHello%20share%20plugin%5D%5D%22%7D%2C%7B%22created%22%3A%2220230114171247560%22%2C%22text%22%3A%22Just%20a%20simple%20test%22%2C%22tags%22%3A%22%22%2C%22title%22%3A%22Hello%20share%20plugin%22%2C%22modified%22%3A%2220230114171303660%22%7D%5D

And here’s the link from the email:

https://tiddlywiki.com/prerelease/share#%23%5B%7B%22title%22%3A%22%24%3A%2FStoryList%22%2C%22text%22%3A%22%22%2C%22list%22%3A%22%5B%5BHello%20share%20plugin%5D%5D%22%7D%2C%7B%22created%22%3A%2220230114171247560%22%2C%22text%22%3A%22Just%20a%20simple%20test%22%2C%22tags%22%3A%22%22%2C%22title%22%3A%22Hello%20share%20plugin%22%2C%22modified%22%3A%2220230114171303660%22%7D%5D

It looks like the second hash character has been mangled.

That’s too bad. The output of encodeURIComponent("#") is %23. Maybe the mail client is mangling it. I notice if I paste the links into a gmail draft, the same mangling happens.

We could change the share plugin to look for either # or %23. The drawback of doing that is if someone has the share plugin installed and they also want to generate a permalink to a tiddler whose title begins with #, then the share plugin will incorrectly think there are tiddlers to parse.

I intended to make this tiddlyhost site https://shared.tiddlyhost.com/ a fairly light one to support using the share plugin. Let me know if you want me to configure it to support such sharing as a general utility service to the community.

1 Like

I think that would be very useful.

We might be able to fix it by extending the logic that reads the location hash to cope with the encoding.

I think you should upgrade the plugin on your site to the latest (https://tiddlywiki.com/prerelease/share). Looks like the version on your site suffers from the 3 bugs I fixed and so it doesn’t currently function properly on your site.

1 Like

Will do, later today after a bush walk :nerd_face:

I upgraded the https://shared.tiddlyhost.com/ wiki to TW 5.2.5 then for good measure went to reinstall the Share Plugin and got the following;

I am not sure what to do!

Check the url field of this tiddler: Shared — Near empty tiddlywiki on which to share content and you will see https://tiddlywiki.com/library/v5.1.22/index.html

But there hasn’t been any TW release since the share plugin fixes were merged to master, so the updated share plugin will not be in the official plugin library yet (I’m guessing the updated plugin is in the prerelease library, but your url for that library is also wrong).

Probably easiest to just drag and drop it from the https://tiddlywiki.com/prerelease/share site where the fixed version is already installed.

1 Like

Fixing it is one thing, but doing it without breaking some permalinks is another. For example:
https://tiddlywiki.com/#%23This%20tiddler%20starts%20with%20a%20hashtag (pretending a tiddler with the title " #This tiddler starts with a hashtag" exists on tiddlywiki.com).

Oh, but I guess in cases like this, the json parsing of the url would fail, so the share plugin would not end up intercepting the page load. The above permalink should still work.

This turned out to be straightforward; the commit with the fix is here. In 10 minutes or so the build should have completed and the links posted above will start working.

Thank you for picking this up @btheado. We originally somewhat lost interest in the share plugin because it didn’t work well with Google Groups. Getting it working here on Discourse opens up some interesting possibilities. I’m sure there’s potential to make things easier to use. For example, we could add an export option to advanced search “Share these tiddlers via tiddlywiki.com/share” that generates a shareable URL for tiddlers within your own wiki.

1 Like

Just to let you know https://shared.tiddlyhost.com/ is now TiddlyWiki version 5.2.5 + Share Plugin V5.2.6-prerelease

  • Any suggestions and feedback welcome
1 Like

Thanks @jeremyruston. The links from the original post work still fine for me, but when I manually change the second hash in the url to %23 (to simulate receiving through email), then there is some undesirable behavior. See hello world test using percent 23.

It seems that startup/storylist.js is also picking up the location hash and it opens a “Missing tiddler” with a title matching the json in the hash.

There is some code in boot.js ($tw.utils.getLocationHash) which is checking for ‘#’ which might be related. See also:

  1. Bug in location hash processing loses any characters after second # · Issue #3811 · Jermolene/TiddlyWiki5 · GitHub
  2. Fix bug when location hash contains a # by rmunn · Pull Request #4947 · Jermolene/TiddlyWiki5 · GitHub
  3. Document how to use double hashes for anchor links by rmunn · Pull Request #5149 · Jermolene/TiddlyWiki5 · GitHub

Maybe the share plugin can convert the %23 back into the ‘#’? That way the boot.js code will trigger and prevent startup/storylist.js from seeing the json?

Thanks @btheado that was exactly the issue. I’ve pushed a fix and the prerelease should be rebuilt in a few minutes.

My original two share links still work and so does the latest one I posted which wasn’t working before. Thanks for the fix.

1 Like