What coding can make TW render a "local" {{imagefile}} substitute image when OFFLINE one won't deliver?

189 views
Skip to first unread message

John Newell

unread,
Sep 28, 2016, 7:25:27 AM9/28/16
to TiddlyWiki
Apologies as I am clumsy around the terms to appropriately use among the more knowledgeable....

Scenario:
  • I have created a TW ebook 
    • the TW ebook is downloaded and opened by the reader ( assume on mobile device / ipad or equiv )
    • there is no editing at reader's end as it is "READ-ONLY"
    • the TW ebook presents images via s3.amazonaws... which is OK when they are connected online...

  • Is the code ( or another avenue ) that can
    • recognise when READER is offline ( ie image presentation cannot be fulfilled )
    • and DELIVER a local, identified alternative image tiddler - eg via {{image-5}} or another way

Background ( as several of you are aware of this project ) and many are not ....

  • This project is creation and delivery of a DIRECTORY website and mirrored eBOOK ( TW ebook )
  • The ebook:
    • contains all the relevant content that exists on the Website
    • can be downloaded and "kept" locally on the user's device ( targeted at iphone / ipads and their equivalents )
    • delivers images and other dynamic content via external feeds off the internet
      • updates, live content, responsive maps, interactive content etc

What I want to deliver within the TW ebook is a suitable alternative when the the reader is NOT connected to the internet ( which will happen in certain pockets where they will be referring to the book - like up to 20% of all wineries signed up.


Is there a plugin or code that can substitute a failed image delivery ( or similar ) with a local TW image

My first thought is delivering smaller / lower res images that are saved as tiddlers and can be delivered via {{tiddler-image-name}} usage.


any and all help appreciated !


cheers

John


PMario

unread,
Sep 28, 2016, 9:50:32 AM9/28/16
to TiddlyWiki
Hi John,


My first thought is delivering smaller / lower res images that are saved as tiddlers and can be delivered via {{tiddler-image-name}} usage.

try this:
 - define a tiddler eg: myImageMacro and tag it: $:/tags/Macro

\define image(uri, tiddler, altOnline:"online image not found" altOffline:"offline image not found")
<$reveal state="offline" type="match" text="">
<$image source="""$uri$""" alt="""$altOnline$"""/>
</$reveal>
<$reveal state=offline type=match text="offline">
<$image source="""$tiddler$""" alt="""$altOffline$"""/>
</$reveal>
\end

Usage:

<<image uri:"https://example.com/your-image.jpg" tiddler:"your-tiddler-small.jpg">>

You'll need 2 buttons somewhere to activate and deactivate offline mode eg:

<$button set="offline" setTo="offline" >
Activate Offline mode!
</$button>
<$button>
<$action-deletetiddler $tiddler="offline"/>
Activate online mode!
</$button>


have fun!
mario

PMario

unread,
Sep 28, 2016, 9:51:47 AM9/28/16
to TiddlyWiki
Unfortunately, I don't know a possibility to auto-detect online offline mode. So the user needs to set it.
-m

Jeremy Ruston

unread,
Sep 28, 2016, 10:25:17 AM9/28/16
to tiddl...@googlegroups.com
Unfortunately, I don't know a possibility to auto-detect online offline mode. So the user needs to set it.

We could add a tiny bit of code to mirror the offline/online status in a browser status tiddler:


Best wishes

Jeremy

-m

--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/34e66ebf-f214-40f0-b69e-ad2fbe8be424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Newell

unread,
Sep 28, 2016, 11:16:57 AM9/28/16
to TiddlyWiki
Mario - you are a genius ( at least from where I sit ) in a monster storm without power and happy as !!!! Seeing my problem now being a positive solution!!! Kudos and thanks - it works a treat !!! I will just "tart up" the button icons. and place them appropriately - and I am one BIG STEP closer to taking this LIVE!!

No storm is going to stop my thanks - as long as the Internet tower stays up.

Count on me sending you one of the first copies when ready.

You will see :
!! Your solution in action - onscreen, appropriate deliverables when offline

!! LIVE CHANGES to client offerings - on their pages - that they add themselves -as often as they like ( c/- padlet.com embeds )

!! JOURNAL / key points / notes able to be added in book for readers

!! In-book purchase of tickets, gift certificates Etc

!! Local event notifications of music festivals, sports, international cycling tours, degustation events, Grape Grazing, shedFests and even live submissions of GarageSales......

!! TIDDLYWIKI GETTING USED BY MORE PEOPLE FOR ACTIVE PARTICIPATION AND ENJOYMENT

Thanks again ! Cheers John

John Newell

unread,
Sep 28, 2016, 11:29:25 AM9/28/16
to TiddlyWiki
Hi Jeremy

Mario ( see recent Comms ) gave me the solution, which aligns with your point : a SWITCH / CHOICE via button selection for online or offline status - which the reader would know anyway and simply select to update....

Excellent.

Will post you a copy link to download when ready. If this comes off as planned - this is going to be "significant" in putting it into the hands of end users in a very different way.

First milestone is 10,000 copies downloaded, with 60,000 challenged in first 12 months. Should be achievable as it is FREE into user ( tourist and local 's hands )

Should confirm billboard access at the most visible entry point to the Yarra Valley in next 10 days (pivotal) - driver download via QR / shortURL as they enter the region!!! Plus into 15,000 monthly magazine fully page adverts c/- the Realtor who is co-promoting.

I am also open to all TW GGroup participation with ideas and concepts that can find their way into mainstream.

Cheers
John

Tobias Beer

unread,
Sep 28, 2016, 4:12:26 PM9/28/16
to TiddlyWiki
Hi Mario / John,

Unfortunately, I don't know a possibility to auto-detect online offline mode. So the user needs to set it.

tobibeer/sysinfo provides some means to detect the kind of environment you're in, i.e. offline (local) vs. online (http).

Best wishes,

Tobias.

PMario

unread,
Sep 28, 2016, 5:44:02 PM9/28/16
to TiddlyWiki
On Wednesday, September 28, 2016 at 4:25:17 PM UTC+2, Jeremy Ruston wrote:
Unfortunately, I don't know a possibility to auto-detect online offline mode. So the user needs to set it.

We could add a tiny bit of code to mirror the offline/online status in a browser status tiddler:


Hi,
That's interesting. ... So our <$image> widget could get an additional parameter, that contains an "offlineSource" attribute, that is used in case of "source" being unavailable.
What do you think?
-m

John Newell

unread,
Sep 28, 2016, 11:45:29 PM9/28/16
to tiddl...@googlegroups.com
Hi Tobias / Mario 

I may not have communicated this objective clearly - for which I apologise - but the solution provided by Mario works perfectly.

The issue is not whether TW needs to detect online connection - as the TWebook will have (on probably its FIRST SCREEN) the option of online / offline delivery....
THAT STATUS will be known by the user - 
as the target for these TWebooks is for USE on mobile devices. 
The user will know whether they are online or offline - 
and even if they aren't sure - the lack of imagery ( or the note that does appear where an image should be when offline )  
will prompt them to click "the OFFLINE button" )

THIS series of regional tourism directories IS targetted at People on the move:
tourists, locals, vacationers, etc - roaming between venues and events over a week or just a weekend - MOBILE in-hand.

If someone wants to look at the TW Yarra Valley Ddirectory content on a laptop, desktop or bigscreen -
they can do so by simply opening www.yarravalley.directory as the full website.
The content there is essentially the same - though ...

the website has these important differences :
  • it satisfies those who prefer to view on a bigger screen 
  • it allows for easier use of several interactive components better used where mouse and keyboard are avaiable / preferred
  • importantly - creates Search engine listings results, links, traffic and other benefits - such as new customers / users of the TWebook
  • it continues to find new people who will download the APP

This has brought up a realisation for me

TW  - in the way I will deliver THIS project  - is far more like an APP than an ebook.

In the same way an APP works - TW - as a READ ONLY version has these similarities in the "YarraValley.directory" TWebook:
  • The "package" is downloaded FULLY by the user.
  • Most of what is needed to deliver the content is now native to the user's device ( IN their iphone / ipad or equivalents )
  • External content can be utilised
TWebook - as an APP - has these benefits OVER a website -
  • The current number of mobile users EXCEEDS the number of desktop users.
  • Mobile APPS work faster that mobile websites as the native content delivers faster and more reliably
  • Brand Presence is enhanced within a "closed environment" (app) which obviates the need for other search options.
  • Unlike a website than can suffer (in search) from bad "bounce rates" - embedded, pulled and referred links can boost the website's search collateral.
  • There is a higher likelihood of social sharing as a result of "App Connectedness"
  • ( in this "collective case" - cost of advertiser access is low compared to beuild own website or app )
  • Leaner, cleaner, faster to produce. 
  • App-opening frequency exceeds most website performances
  • App ownership - where it REPLACES the option of a website visitation - INCREASES user access frequency and time on site.
  • and ..... of course ..... works online or offline !
TWebook - as an APP - has these benefits OVER an APP BUILDER -
  • Product Cost - free
  • Cheap to host
  • Easy to distribute
  • Support & innovation ( certainly in my experience ) - I feel part of something growing and emerging...
  • Online reliance and frustrations in building an app. ( TW : build offline )

In other cases that I am working on for clients - the use of TW5 is more like that of an eBook - BUT - 
with far more elements that make it more attractive and dynamic.

These include :
  • a "children's book", 
  • a "Wedding Brochure"
  • a Retailer's catalogue 
  • a Winery's "Annual Report" and "Vintage Reports" ( a collective using content such as this : http://helenshill.com.au/2013-vintage-report/ ) and "Wine Range Brochures"
  • Artist's portfolios

In respect of the ebooks that are novels ...... they are just a variant to EPUBs and PDFs etc

Keen to hear :
  • comments
  • what the TW community can suggest as app-like options for inclusion in my projects
  • any small groups wanting to explore these adventures together

John

PMario

unread,
Sep 29, 2016, 4:34:50 AM9/29/16
to TiddlyWiki
On Thursday, September 29, 2016 at 5:45:29 AM UTC+2, John Newell wrote:
I may not have communicated this objective clearly - for which I apologise - but the solution provided by Mario works perfectly.

That's cool.
 
The issue is not whether TW needs to detect online connection - as the TWebook will have (on probably its FIRST SCREEN) the option of online / offline delivery....
THAT STATUS will be known by the user - 

I know. That's why I did include some "online/offline" messages. So you can see, what's possible, to tell the users manual action is needed.
 
as the target for these TWebooks is for USE on mobile devices. 
The user will know whether they are online or offline - 
and even if they aren't sure - the lack of imagery ( or the note that does appear where an image should be when offline )  
will prompt them to click "the OFFLINE button" )

That's right. ... but if TW can detect the status, we could implement some magic behind the scenes and let the <$image> widget decide, what to show. For TW imo this is a very common use-case, because our initial focus is "offline first".
 
This has brought up a realisation for me

TW  - in the way I will deliver THIS project  - is far more like an APP than an ebook.

Yea, TiddlyWiki is a "chameleon" 

have fun!
mario

BJ

unread,
Sep 29, 2016, 6:06:58 AM9/29/16
to tiddl...@googlegroups.com
I think there should be some system tiddlers that are updated with these type of state changes - this would allow widgets to listen for changes through the refresh mechanism.

Mark S.

unread,
Sep 29, 2016, 9:49:41 AM9/29/16
to TiddlyWiki
You have expressed a great deal of enthusiasm for TW as an ebook replacement and now as an app replacement. I'm learning app programming now, and can vouch that it's ridiculously complicated.

But I wonder how most publishers would view TW in terms of DRM and IP protection. There really isn't much in the way of data protection in TW. The read-only modes aren't really modes at all and can be quickly removed. There's encryption, but a password could just be passed along with the base TW.

Of course not all publishers are obsessed with DRM, especially if the material is going to change rapidly. O'Reilly, for instance, doesn't lock down their epublications.

Mark


On Wednesday, September 28, 2016 at 8:45:29 PM UTC-7, John Newell wrote:
Hi Tobias / Mario 

Thomas Elmiger

unread,
Sep 29, 2016, 2:11:17 PM9/29/16
to TiddlyWiki
This seems not to be totally save. I noticed a hint on http://caniuse.com/#feat=online-status that states:
<<<
"online" does not always mean connection to the internet, it can also just mean connection to some network
<<<
Maybe Tobi Beer has a better solution?
Good luck!
Thomas

Mark S.

unread,
Sep 29, 2016, 2:37:06 PM9/29/16
to TiddlyWiki
I've noticed this with other apps. You can be connected to your local wifi, and apps will attempt to connect to the net. But if the wifi isn't connected to the net, the app will time out.

It seems to me that it's better to leave it up to the user. Only the user can determine if the connection is useful (intranet vs internet) or if data charges are reasonable or if a signal is too marginal to be useful.

Mark

BJ

unread,
Sep 29, 2016, 4:51:14 PM9/29/16
to TiddlyWiki
here is a fiddle that shows the logic of a possible solution, it should be straight forward to put this kind of logic into a widget

http://codepen.io/jmperez/pen/yYjPER

all the best
BJ
Reply all
Reply to author
Forward
0 new messages