[TW5] Transclusion on demand

158 views
Skip to first unread message

Ulrik Stervbo

unread,
May 9, 2014, 4:31:56 AM5/9/14
to tiddl...@googlegroups.com
Hello group,

I include quite a few pdfs in my tiddlers and this has seems to cause huge memory usage - not so much by TW but more the many instanced pdf.js (well around 7 pdf.js instances per tiddler).

Each pdf is transcluded from their own tiddler, which looks like this:

\define linkpdf(projectid, path, file, title, description)
<center>
<iframe src="./attachments/$projectid$/$path$/$file$" type="application/pdf" width="100%" height="500px"/><br>
//[[$title$]]// -- <br>$description$<br>
</center>
\end

<$macrocall $name=linkpdf projectid = {{!!project-id}} path={{!!path}} file={{!!file-name}} title={{!!title}} description={{!!description}}/>


Project-id, path, file-name and title are all fields in the tiddler.

In the main tiddler the pdf is transcluded by {{pdf tiddler}}.

Is there a way of triggering the transclusion?

I could replace transclusions with links and that way open the tiddlers by demand, but I would prefer to keep them in the same tiddler where additional attached is displayed. Also, the title of the pdf-tiddlers are meant to be unique rather than human readable since they contain the result of some analysis. Is there an easy way of providing a link title, for instance the '//[[$title$]]// -- $description$' in the code above, or must I always do [Readable|non readable tiddler title]?

One way could be to include some javascript in the pdf-tiddler where the source of the iframe is loaded onclick, but it would be nicer if this is handled else where - I imagine there may be times when a single tiddler transcludes just two pdfs for comparison, and that this should be onload. Is transclusion through a template possible? The template could then contain an onclick macro using elements from the transcluded pdf tiddler for meaning full display?

Are there any suggestions?

Thanks.
Cheers,
Ulrik

PMario

unread,
May 9, 2014, 5:51:34 AM5/9/14
to tiddl...@googlegroups.com
On Friday, May 9, 2014 10:31:56 AM UTC+2, Ulrik Stervbo wrote:
One way could be to include some javascript in the pdf-tiddler where the source of the iframe is loaded onclick, but it would be nicer if this is handled else where

This is no option, since TW already includes simple "code sanitation" so inline javascript / onclick() is removed because of security concerns.
 
- I imagine there may be times when a single tiddler transcludes just two pdfs for comparison, and that this should be onload. Is transclusion through a template possible? The template could then contain an onclick macro using elements from the transcluded pdf tiddler for meaning full display?

You could try to use the <<tabs ..>> macro. see: tiddlywiki.com - TabsMacro
It should remove the "hidden" tabs from the DOM, so it should reduce the memory footprint of one tiddler with many pdf links.
You could add some "manual" links that open single PDFs. So it would be possible to open several of them if really needed.

-mario

PMario

unread,
May 9, 2014, 5:53:16 AM5/9/14
to tiddl...@googlegroups.com
Ulrik,
How big are your PDFs?
-m

Ulrik Stervbo

unread,
May 9, 2014, 6:15:03 AM5/9/14
to tiddl...@googlegroups.com
Thanks - I'll look into that.


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/GnMyObOhPbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Ulrik Stervbo

unread,
May 9, 2014, 6:15:39 AM5/9/14
to tiddl...@googlegroups.com
The pdfs are between 6 and 1000 kb in size and all external

Cheers,
Ulrik


--

Ulrik Stervbo

unread,
May 9, 2014, 9:57:37 AM5/9/14
to tiddl...@googlegroups.com
The <<tabs ..>> macro seems appropriate (and would also make each tiddler better organised), but it would not work well because I have at least 15 tiddlers containing the same information with small variation (the result of different analysis), so the tabs would contain hard to read information.

That is, unless I can delete part of the displayed tiddler title or pass a tag to a tiddler which based on the passed tag finds the appropriate tiddlers to transclude.

Is this possible?

Cheers,
Ulrik

PMario

unread,
May 9, 2014, 4:38:31 PM5/9/14
to tiddl...@googlegroups.com, ulrik....@gmail.com
I think you could create a custom tab macro, that contains more info in the button.

The <<tabs ...>> macro is part of the core shadow tiddler named:   $:/core/ui/PageMacros.

So you can copy paste it to a sandbox tiddler and adjust it to your needs.

Have a look at the "TabsMacro" docs tiddler.
T
he "tab tiddlers" can contain a custom field named: "caption", that is used to label the tab. ....
The same mechanism could be used to add additional content to the tabs, to make it more readable for users.

Does this make sense to you?

have fun!
-mario

Ulrik Stervbo

unread,
May 10, 2014, 1:43:06 AM5/10/14
to PMario, tiddl...@googlegroups.com

Sounds like it could be very useful.  I'll look into it.

Cheers,
Ulrik

Reply all
Reply to author
Forward
0 new messages