Query: Is it possible to copy RENDERED HTML of a Tiddler to a new Tiddler?

689 views
Skip to first unread message

@TiddlyTweeter

unread,
May 25, 2017, 1:32:01 PM5/25/17
to TiddlyWiki
Q: Is it possible to copy RENDERED HTML of a Tiddler to a new Tiddler?

I've asked about this before but I think my question was not so clear. I'm trying again, here is a Use Case ...
  • Fred has a large allotment on which he grows leeks for vegetable competitions;

  • Fred uses TiddlyWiki to log, daily, the various nutrients he feeds his leeks; he also makes notes on weather conditions; as well as leek girth;

  • Monthly, Fred uses a list filter to produce a report on the state of his leeks.

  • One morning Fred went into shock as he realised he had NO copy of his previous reports. Since the Leek Exhibition Certification Board requires ARCHIVES of previous reports in order to exhibit he got into a depressed state.

This jovial example is not entirely mad. "Fred's" life would a lot easier IF he had a simple way to capture the RENDERED HTML of his dynamically created reports to a New Tiddler on the day he made one. Then he could have his needed archive of results ready and to hand.


---


Technically what I can see is the "Export" to HTML does produce rendered pages. But for this purpose only the contents of the <body> section would be needed for a Tiddler since everything else needed for layout is already there.


Has anyone ever dealt with this issue, i.e. capture Rendered HTML of a dynamic Tiddler and copy it to a New Tiddler?


Please ask me to clarify if my question is not clear.


Best wishes

Josiah

Jed Carty

unread,
May 25, 2017, 1:43:21 PM5/25/17
to TiddlyWiki
The wikify widget probably does what you want it to do. I used it to save old invoices in the invoice creator I made.

Conner Phillips

unread,
May 25, 2017, 1:46:11 PM5/25/17
to tiddl...@googlegroups.com
If you need it to be archived, why are you doing it in a single dynamic tiddler? Simplest but less streamlined: screencap and include the image.

However my suggestion would be to keep ALL of the data and give each data tiddler a field referring to the 'batch number' or calendar week-- however you delimite when these reports are generated. Then, create a template for your reports and use a fresh new tiddler for each report which only lists filtering based on the "report number" field.

Note: Not a TW expert, just trying to think through the issue with what I have learned.

Mark S.

unread,
May 25, 2017, 1:56:11 PM5/25/17
to TiddlyWiki
When you say used a list filter to produce a report, what do you mean? If he had exported the report as a static file, he'd have a copy on his hard drive. If he wanted it saved as a tiddler, he could drag and drop the report back into his TW, give it a new name (e.g. 2017-05 Leek Report) and tag it as "Report". Takes only a couple seconds.

But I understand that one of Fred's competitors got the jump on him. Apparently his report was leeked.

Mark

@TiddlyTweeter

unread,
May 25, 2017, 3:19:54 PM5/25/17
to TiddlyWiki
Ciao all,

Thanks for your helpful & fun (Mark S.) comments ... My response ...

Why save Rendered HTML to file if you can save it to a Tiddler? --- I think that's a pretty fine question by me :-).

There are real efficiency benefits in capturing rendered HTML directly to a Tiddler ...

(1) Most importantly, easy organisation of Fred's reports within his TiddlyWiki: HugeLeeks;

(2) Fred is using TW list filters to compose Fred's Leeks Monthly, before passing it to Gmail. Often he wants to make some manual changes to the text he sees on screen first. He can't do that in a dynamic Tiddler, he needs a Rendered version to be able to edit anything.

[BTW: Fred, was very surprised to see, when he first used a list filter and opened it and it read "<$list This bit is made by another bit>" rather than "My greatest Leek was ..." that showed on-screen.]

(3) Fred needs to edit Old Reports on occasion--as the standards required by the The Leek Examination Board change the rules (again).

(4) Dragging an html into #TiddlyWiki is a kind of solution (one I use already) BUT to integrate it back, if its an export, you have to do quite a lot of editing to reduce to ONLY the section needed by a standard tiddler type.

Best wishes
Josiah


Mark S. wrote:
Apparently his report was leeked.

LOL!

@TiddlyTweeter

unread,
May 25, 2017, 6:41:28 PM5/25/17
to TiddlyWiki
Ciao Jed

I tried searching your site for "invoice creator" but didn't have any luck. Maybe I wasn't looking in the right place? It would be interesting to see a working example, even if incomplete. If it still exists could you point me?

Best wishes
Josiah

Birthe C

unread,
May 25, 2017, 7:10:13 PM5/25/17
to TiddlyWiki
Hi Josiah,

Jed's invoice creator here: http://ooktech.com/jed/ExampleWikis/InvoiceCreator/


Birthe

@TiddlyTweeter

unread,
May 25, 2017, 7:19:58 PM5/25/17
to TiddlyWiki
B, thankyou very much, J.

RichardWilliamSmith

unread,
May 25, 2017, 10:58:06 PM5/25/17
to TiddlyWiki
I think this is quite an interesting problem. I don't have it worked out yet, but I think it's possible.

If you want to play around with this I suggest you be VERY CAREFUL! because there is a good chance of getting the wiki into an infinite loop, which will crash it. Obviously, don't do this with your 'real' wiki.

A tiddler with this code
 
\define getsnaptitle()
$(currentTiddler)$ Snapshot
\end 

<$wikify name="outputter" text={{!!text}} output="html">

<$button>
<$set name=snaptitle value=<<getsnaptitle>>>
<$action-sendmessage $message="tm-new-tiddler" title=<<snaptitle>> tags="Snapshot" text=<<outputter>>/>
SNAP
</$set>
</$button>

</$wikify>

and tagged with $:/tags/ViewToolbar will add a (big, ugly) button to the view toolbar that, when clicked will generate a new tiddler (in edit mode) which contains the text of the original one, but encoded in static html.

The reason you need to be careful (afaict) is that, if THAT tiddler is open anywhere it will try to generate a wikified copy of itself, which will generate a wikified copy of itself which will.... overflow the stack and crash your wiki.

I ended up creating the tiddler I needed through an edit text widget in another tiddler...

<$edit-text tiddler="$:/core/ui/Buttons/snapshot"/>

All a bit hacky and sub-optimal but it might get you going in the right direction. Obviously it can be neatened up and brought into line with the other page controls (an icon, ability to show/hide it etc.). Not sure how we preclude the possibility of a recursive loop (this problem must be solved elsewhere, right?)

I was trying to get it to save the tiddler after creating it, something like 

<$action-sendmessage $message="tm-save-tiddler" title=<<snaptitle>>/>


But I couldn't get this to work and I'm not sure why.

Regards,
Richard 

Mark S.

unread,
May 25, 2017, 11:47:02 PM5/25/17
to TiddlyWiki
My code is similar to Richard's except that it assumes you want to create a tiddler containing the output of many tiddlers.  I used it with TiddlyWiki.com and filtered on tag=HelloThere. The results break at some point in terms of formatting but hopefully the report you create would be based on simpler tiddlers.  The results from a static export will be cleaner at least with some data.

\define report()
Report: {{$:/temp/reporttitle}}

<$list filter="[tag[HelloThere]]">

! <$view field="title"/>

<$view field="text"/>
</$list>
\end

<$edit-text tiddler="$:/
temp/reporttitle" tag="input" size="50" default="Your Title Here"/>

<$wikify name="
snapshot" text="<<report>>" output="html">
<$button>
<$action-sendmessage $message="
tm-new-tiddler" title={{$:/temp/reporttitle}}  tags="Snapshot" text=<<snapshot>>/>
Make Snapshot
</$button>
</$wikify>

Your report will look something like the information below:


----

<<report>>

On Thursday, May 25, 2017 at 10:32:01 AM UTC-7, @TiddlyTweeter wrote:

@TiddlyTweeter

unread,
May 26, 2017, 9:23:21 AM5/26/17
to tiddl...@googlegroups.com
Ciao RichardWS
  • On first putting it into an empty TW the Javascript did not like it & threw a recursion error

  • It was not fatal. And I not yet seen another.

I did a test of a WikiText tiddler of this table ...



Then did the SNAP and got this HTML version ...


DEFINITELY its in the right direction.

I'll do more testing to see how robust it is.

Best wishes
Josiah
Auto Generated Inline Image 1
Auto Generated Inline Image 2

@TiddlyTweeter

unread,
May 26, 2017, 10:38:10 AM5/26/17
to tiddl...@googlegroups.com
Ciao RichardWS

UPDATE: It works well capturing Rendered HTML. But I'm hitting walls to full testing. Errors like ...

When trying to delete one Tiddler I got this: TypeError: this.wikifyWidgetNode is undefined. I can no longer delete it or close it, and trying to locks the wiki.

On Refresh ... too much recursion ... I assume that is the gizmo loading. Its not always fatal.

On a much larger TW copy I tested it on I got Error: Stack overflow and couldn't get further.

Best wishes
Josiah

RichardWilliamSmith wrote:

@TiddlyTweeter

unread,
May 26, 2017, 11:21:06 AM5/26/17
to TiddlyWiki
Ciao Mark S.

I'm maybe not using this correctly?
I simply pasted the code into a tiddler at tiddlywiki.com and clicked "Make Snapshot". The returned tiddler is not Rendered HTML. ??


Best wishes
Josiah

Mark S. wrote:

Mark S.

unread,
May 26, 2017, 2:10:16 PM5/26/17
to TiddlyWiki
Hmm... You can try this version

\define report()
Report: {{$:/temp/reporttitle}}

<$list filter="[tag[HelloThere]]">

! <$view field="title"/>

{{!!text}}

</$list>
\end

<$edit-text tiddler="$:/
temp/reporttitle" tag="input" size="50" default="Your Title Here"/>

<$wikify name="
snapshot" text="<<report>>" output="html">
<$button>
<$action-sendmessage $message="
tm-new-tiddler" title={{$:/temp/reporttitle}}  tags="Snapshot" text=<<snapshot>>/>
Make Snapshot
</$button>
</$wikify>

Your report will look something like the information below:


----

<<report>>

I would suggest trying it with the actual data you might be thinking of.  I used HelloThere because it was quick and easy, but the tiddlers it returns have a lot of complicated formatting. The above code returns (I think) the same thing you would get if you selected the text of the report, right-clicked, inspected the source, and then copied the selection source into a tiddler. In other words, it may be broken, but it's broken just like the original HTML pulled out of context would be.

Fred may just be out of leek. Er, luck.

Mark

Mark S.

unread,
May 26, 2017, 2:39:08 PM5/26/17
to TiddlyWiki
Hi Josiah,

If you like Richard's version, then I think this will run safer. First create a tiddler (open, close, open) called "R" (for Richard). Then paste in the code and tag for the toolbar. You can change the tiddler name if you also change it in the list filter (the list filter prevents the recursion).

But some things will still not capture nicely. If you try it on "A Gentle Guide to TiddlyWiki" you'll see that that tiddler gets broken just like it did in my report-based version.

Good luck,
Mark

\define getsnaptitle()
$
(currentTiddler)$ Snapshot
\end

<$list filter="[all[current]!has[draft.of]] -[[R]]">

<$wikify name="outputter" text={{!!text}} output="html">

<$button>
<$set name=snaptitle value=<<getsnaptitle>>>
<$action-sendmessage $message="tm-new-tiddler" title=<<snaptitle>> tags="Snapshot" text=<<outputter>>/>
SNAP
</
$set>
</$button>

</
$wikify>
</$list>

@TiddlyTweeter

unread,
May 26, 2017, 3:17:50 PM5/26/17
to TiddlyWiki
Ciao Mark S.

WHOAH!!! Brilliant! It's alive!


Its working perfectly so far for my local stuff that doesn't have complex CSS dependencies.

I will work with it a couple of days and report back on both your and Richard's gizmo's.

BTW, Fred: says "Leeks will triumph!"

Many many thanks
Josiah

@TiddlyTweeter

unread,
Jun 17, 2017, 5:55:04 AM6/17/17
to TiddlyWiki
Ciao Mark S & RichardWS

I want to both thank both of you, report back, and seek a bit more help.

After trail and error I found Mark's version below the most pertinent to my needs. On reflection, I realised its better as a stand alone tool for occasional use, rather than embedded via an icon on all Tiddlers.

It works well. But I want to, ideally, upgrade the filter to have an input field so I'd enter the Title of the Tiddler I need a snapshot of, so I don't have to manually edit the macro everytime I use it. How do I do that? Is it difficult? Would the recursion problem come back?

Mark S.

unread,
Jun 17, 2017, 1:27:38 PM6/17/17
to TiddlyWiki
I think this will do what you want, if that is literally what you meant:

\define report()
Report: {{$:/temp/reporttitle}}

<$list filter="[{$:/temp/myfilter}]">


! <$view field="title"/>

{{!!text}}
<
/$list>
\end

<$edit-text tiddler="$:/
temp/myfilter" tag="input" size="50" default="Name of field to copy"/><br/>

<$edit-text tiddler="
$:/temp/reporttitle" tag="input" size="50" default="Your New Title Here"/>

<$wikify name="
snapshot" text="<<report>>" output="html">
<$button>
<$action-sendmessage $message="
tm-new-tiddler" title={{$:/temp/reporttitle}}  tags="Snapshot" text=<<snapshot>>/>
Make Snapshot
</$button>
</$wikify>

Good luck!
Mark

@TiddlyTweeter

unread,
Jun 17, 2017, 2:18:40 PM6/17/17
to TiddlyWiki
Its likely what I wrote, but not what I need.

Test case "Community" on tw.com (includes transclusions). Result from Version 1, correct ...


Result from version 2, not it...


I guess I meant the facility of V.1 with the specificity of named tiddlers (though could be transcluding) V.2.

Fred is hopeful for Leek Supremacy yet :-)


Josiah
Auto Generated Inline Image 1
Auto Generated Inline Image 2

ste...@gmail.com

unread,
Jun 17, 2017, 2:21:15 PM6/17/17
to TiddlyWiki
Hi Josiah,

I'm not sure whether this helps, but the following code creates a new journal tiddler, tagged with "My Reports", and populates it with a wikified version of whatever you put into the tiddler MyReport:

\define journalButton()
<$wikify name="outputter" text={{MyReport}} output="html">
<$button tooltip={{$:/language/Buttons/NewJournal/Hint}} aria-label={{$:/language/Buttons/NewJournal/Caption}}>
<$action-sendmessage $message="tm-new-tiddler" title=<<now "$(journalTitleTemplate)$">> tags="$(journalTags)$" text=<<outputter>>/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
Create Report!
</
$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/NewJournal/Caption}}/></span>
</$list>
</
$button>
</$wikify>
\end
<$set name="journalTitleTemplate" value={{$:/
config/NewJournal/Title}}>
<$set name="journalTags" value="[[My Reports]]">
<<journalButton>>
</$set></$set>

Cheers,

Stef

Mark S.

unread,
Jun 17, 2017, 2:44:39 PM6/17/17
to TiddlyWiki
Hi Josiah,

CaPiTaLiZation Is ImporTanT.

When I plugged in the name of the tiddler, with caps: Community

I got the result you got in image #1. When I plugged in the word "community", I got the result you got in #2.

Good luck,
Mark

@TiddlyTweeter

unread,
Jun 17, 2017, 2:52:01 PM6/17/17
to TiddlyWiki
I am an IDioT and that is Brilliant!

Thanks a ton!

Mark S. wrote:
CaPiTaLiZation Is ImporTanT.

ste...@gmail.com

unread,
Jun 17, 2017, 2:56:19 PM6/17/17
to TiddlyWiki
Some explanation why I created the code below:
  • Fred might not want to worry about how to name each archived report, therefore the current date might do just fine
  • the dynamically generated (non-wikified) reports are probably always in the same place; this place could be the tiddler MyReport (alternatively, the actual report tiddler could be transcluded there)
  • my solution avoids the recursion problem
Cheers,

Stef

@TiddlyTweeter

unread,
Jun 17, 2017, 3:30:42 PM6/17/17
to tiddl...@googlegroups.com
I want to make some general comments about the value of capturing Rendered HTML and where its utility lays. The solutions already generously given to me are really good. HOW is it helpful? Here is one serious example ... there are others ...

It allows you to ITERATE presentation.

A major annoyance with doing NEAT EMAIL is that email programs are in the Dark Ages as far as CSS formatting is concerned.

I like to send email from TiddlyWiki for some mailing lists (usually via Gmail). I want the emails to look good. Being able to capture rendered HTML allows you to put it through services like Mail Chimp to make the layout universally email friendly. The steps being: (a) Capture Rendered HTML from TW. (b) Pass it through Mail Chimp to embed inline styles (adding those is another story). (c) Re-wikitext part of Mail Chimp's output HTML it so you can use it again as a TW template. (d) Pass a well laid out email to your mail client via encoded URL for broader mailing. The point is being able to capture rendered HTML in TW you can iterate this process and repeat it and add refinement as needed.

It works well.

Best wishes
Josiah



Reply all
Reply to author
Forward
0 new messages