Service worker

332 views
Skip to first unread message

Nick

unread,
Dec 5, 2020, 7:44:20 AM12/5/20
to TiddlyWiki
I now have my tiddlywiki working as a online PWA saved to my IOS homescreen. 

I wanted to be able to open this and read online, I thought a service worker would be the way, is this right?

I found this article:

However I cannot figure out how to add it to TW

Any ideas, or how to achieve this without a SW?

Cheers

Nick

unread,
Dec 5, 2020, 7:52:03 AM12/5/20
to TiddlyWiki
Correction: To read offline, not online

Jed Carty

unread,
Dec 5, 2020, 10:46:28 AM12/5/20
to TiddlyWiki
Nick,

In my experience, the promise of service workers and the reality are very different. I spent a few days trying to figure out how to use a service worker to do anything useful for tiddlywiki and was unable to come up with anything.
They can not serve the page itself, and because tiddlywiki is a singe page application it can't load itself using the service worker.

I wanted to make a worker that could let you download a wiki locally and then when a remote server was available it would sync with the server, but service workers are only available on https domains and loading a file locally isn't https. I spent way too long trying to find a way around that and only succeeded in finding a very deep hatred for the design principles used for what passes for online security and giving privileged access to remote servers while removing it for local sources.

I wasn't able to find any way to handle this situation in iOS without an app, and I got distracted by other work before finishing the app. Maybe someone else made a solution but I haven't heard of any.

Saq Imtiaz

unread,
Dec 5, 2020, 10:52:46 AM12/5/20
to TiddlyWiki
I have similar feelings about service workers as Jed... 
That said, I know LinOneTwo has done some work with service worker and TW but I am not familiar with the details: https://github.com/linonetwo/tiddlywiki-plugins

Jeremy Ruston

unread,
Dec 5, 2020, 11:36:05 AM12/5/20
to TiddlyWiki Group
Indeed. Service workers were intended to help re-engineer existing server-based applications to work offline. The main feature is a background thread that can fake network requests when the system is offline. It still uses the same LocalStorage as an ordinary web page. So there’s not really anything to be gained for an application like TiddlyWiki that was designed from the ground up to work offline. It’s a shame.

Best wishes

Jeremy



On 5 Dec 2020, at 15:52, Saq Imtiaz <saq.i...@gmail.com> wrote:

I have similar feelings about service workers as Jed... 
That said, I know LinOneTwo has done some work with service worker and TW but I am not familiar with the details: https://github.com/linonetwo/tiddlywiki-plugins

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d9724b43-6651-48f9-b966-a4af79f97853n%40googlegroups.com.

Nick

unread,
Dec 5, 2020, 12:15:34 PM12/5/20
to TiddlyWiki
Thanks to all, It seems SWs' are really not the way forward. The 'offline' feature was the appeal of TW, but as an app on my home screen, the offline function is not working. It does not open from files either on IOS. Its works in apps like quine but I need it to be its own app. Maybe i've missed something, but there must be a way to view a TW file offline on mobiles with only the .html file"?

Thanks
Nick

Jeremy Ruston

unread,
Dec 5, 2020, 12:20:18 PM12/5/20
to TiddlyWiki Group
Thanks to all, It seems SWs' are really not the way forward. The 'offline' feature was the appeal of TW, but as an app on my home screen, the offline function is not working.

You could experiment with using the "browser-storage" plugin from the official plugin library to store changes in local storage but I’d be worried that it would be brittle, and the data might be removed by the system without warning.

It does not open from files either on IOS. Its works in apps like quine but I need it to be its own app. Maybe i've missed something, but there must be a way to view a TW file offline on mobiles with only the .html file"?

As far as I have been able to discover, there’s no built in way on iOS/iPadOS to view a locally stored HTML file with JavaScript enabled.

I don’t think it’s quite what you’re after but I have successfully run the Node.js configuration of TiddlyWiki on iPadOS using both JSBox and Play.js.

Best wishes

Jeremy.


Thanks
Nick

On Saturday, 5 December 2020 at 16:36:05 UTC jeremy...@gmail.com wrote:
Indeed. Service workers were intended to help re-engineer existing server-based applications to work offline. The main feature is a background thread that can fake network requests when the system is offline. It still uses the same LocalStorage as an ordinary web page. So there’s not really anything to be gained for an application like TiddlyWiki that was designed from the ground up to work offline. It’s a shame.

Best wishes

Jeremy



On 5 Dec 2020, at 15:52, Saq Imtiaz <saq.i...@gmail.com> wrote:

I have similar feelings about service workers as Jed... 
That said, I know LinOneTwo has done some work with service worker and TW but I am not familiar with the details: https://github.com/linonetwo/tiddlywiki-plugins

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d9724b43-6651-48f9-b966-a4af79f97853n%40googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Nick

unread,
Dec 5, 2020, 12:42:37 PM12/5/20
to TiddlyWiki
Great stuff Jeremy,

I'll take a look at those options, hopefully one may just work out.

Cheers
nick

TW Tones

unread,
Dec 5, 2020, 3:34:27 PM12/5/20
to TiddlyWiki
Nick et al,

I have always wondered if this problem can be turned upside down.

  • Load a prepared wiki either from the internet or by opening a local file (the base wiki). 
  • In both cases you can make use of local storage and returning to that (address) or tab, the original "file" and in browser changes will (typically) be there.
  • However since this is a little brittle;
    • Export the changes from the Wiki in the browser to a file, eg download the changes (at the end of a user session, or occasionally)
    • Include in the base wiki a mechaisium to check if its has any changes from base
      • If on loading there no changes from base, it is either a new wiki or has lost its changes, prompt to load from local backup (of accumulated changes only)
    • Anything that can be done to download or upload from a known filetype or location will make this activity smoother. 
      • If you know where this should occur on a particular device the base wiki can provide the instructions so you do not have to remember.
  • Arguably any local, or internet source, or backup location could be used to store the base wiki and changes backup, with the whole wiki remaining in the browser and the ability to encode the backup location and automate restore if changes are lost.
    • If the changes only ever take place on the one device this should be a safe bet.
  • Other opportunities exist for multi-device access, but by definition they more likely to be online solutions.
Regards
Tones

Ed Heil

unread,
Dec 5, 2020, 11:48:44 PM12/5/20
to TiddlyWiki
Nick,

Have you looked at Quine2? 

Nick

unread,
Dec 6, 2020, 5:44:59 AM12/6/20
to TiddlyWiki
Interesting Tony, Would this be done using browser storage plugin? 

To make life easier, I only require a read-only only version for this case. So no changes will be needed. But for a solution for others, it would I guess. This is why I thought just loading the TW to read offline would be a simple affair! 

@Ed Thanks, yes I use Quine alot for my TW on my phone, and it's excellent. But I need a separate branded PWA/APP on the home screen. I have the PWA part, and now need the storage/cache part.


Best
Nick

Jeremy Ruston

unread,
Dec 6, 2020, 5:56:44 AM12/6/20
to TiddlyWiki Group
Hi Nick

To make life easier, I only require a read-only only version for this case. So no changes will be needed. But for a solution for others, it would I guess. This is why I thought just loading the TW to read offline would be a simple affair! 

I misunderstood, and thought you were wanting to make changes while offline.

In my tests, adding a TW to the iOS/iPadOS home screen does subsequently work while offline. Here’s what I tried on iOS 14:

1. Visit https://tiddlywiki.com in Safari while online
2. Tap the export button in the bottom toolbar, and scroll down to find the “Add to home screen” action
3. You’ll be taken back to the homescreen where there will be a new icon
4. Tap the icon to launch TW as a standalone app and verify that it works
5. Engage airplane mode
6. Use the task switcher to quit the TW standalone app
7. Return to the home screen and tap the TW shortcut again

Best wishes

Jeremy




Nick

unread,
Dec 6, 2020, 7:19:30 AM12/6/20
to TiddlyWiki
This solution is almost perfect and just whats needed. It however doesn't have a search function. Is there a way of including the search?

Thanks
Nick

Jeremy Ruston

unread,
Dec 6, 2020, 8:01:26 AM12/6/20
to TiddlyWiki Group
If you’re using a phone you’ll need to scroll up to get to the search box.

Best wishes

Jeremy

Nick

unread,
Dec 6, 2020, 9:04:05 AM12/6/20
to TiddlyWiki
It doesen't seem to work for me, with getting an offline screen. 

I can export all the tiddlers and upload this to a host, then save as app on the homescreen which works offline. However no search. You can use 'Find on page' but this doesn't give the app like feel i'm after. 

I'll keep looking, and maybe its a cache problem with my device. 

Thanks for all the suggestions

On Sunday, 6 December 2020 at 10:56:44 UTC jeremy...@gmail.com wrote:

TW Tones

unread,
Dec 6, 2020, 6:25:47 PM12/6/20
to TiddlyWiki
Nick,

Perhaps you can find the search due to mobile layout, create a tiddler and transclude the sidebar search in it and see if that works.

I assume you are talking about the TW5 internal search.

{{$:/core/ui/SideBarSegments/search}}

Tones

Nick

unread,
Dec 7, 2020, 9:28:48 AM12/7/20
to TiddlyWiki
Hi Tone,

Yep, looking for the TW5 internal search. I'll give this a go

Cheers
Nick

Jeremy Ruston

unread,
Dec 7, 2020, 9:39:13 AM12/7/20
to tiddl...@googlegroups.com
Hi Nick

Are you perhaps generating a static rendering of the wiki, and then uploading that? The process I described works with an ordinary TiddlyWiki standalone HTML file, you don't need to export anything. If you're using the Node.js configuration you can save a snapshot of the wiki as an HTML file by clicking the "save" icon in the sidebar.

Best wishes

Jeremy


On 7 Dec 2020, at 14:28, Nick <nic...@gmail.com> wrote:

Hi Tone,

林东吴

unread,
Dec 7, 2020, 9:48:07 PM12/7/20
to tiddl...@googlegroups.com

But it requires additional setup, and only work in nodejs wiki that is bundled to HTML wiki when publish to github pages or vercel.

It surely boost the open speed of my wiki onetwo.ren/wiki  , but no additional feature. I think it is somehow useless.

Jeremy Ruston <jeremy...@gmail.com> 于2020年12月7日周一 下午10:39写道:

Nick

unread,
Dec 8, 2020, 6:46:00 AM12/8/20
to TiddlyWiki
@Jeremy

I am not using node.js,( I will read up on this) but after a lot of tinkering, I still couldn't get the empty TW to save to the home screen and still be viewable offline.Maybe available once but then  disappears. I tried exporting it as a static site with all the tiddlers, but then this gives no search function. 

alas, It must be my phone, but I think for this case it's just not possible with my tech level. I'll use Quine for now, and try to find another way.

Thanks Jeremy

@Lin

Thanks, But with the additional setup, I'm not sure my technical ability will be enough. I was looking for a plugin to install, or just add a service worker easily as adding a manifest and sw.js file.


Thanks
Nick

Reply all
Reply to author
Forward
0 new messages