How will I url encode the viewtemplate of a tiddler?

242 views
Skip to first unread message

Riz

unread,
Dec 27, 2016, 8:53:53 AM12/27/16
to TiddlyWiki
For eg; In tiddlywiki.com, let us take the tiddler titled "About". It lists a few links using list-links widget. I want to urlencode those links, how will I do that?

Mat

unread,
Dec 27, 2016, 11:42:27 AM12/27/16
to TiddlyWiki
Maybe:

\define foo(t)
<<makedatauri """$t$""" "text/plain">>
\end

<$list filter="[tag[About]]" variable="t">
<$macrocall $name="foo" t=<<t>>/><br>
</
$list>

<:-)

Thomas Elmiger

unread,
Dec 27, 2016, 12:02:04 PM12/27/16
to tiddl...@googlegroups.com
Hi Riz

For my tweet macro (http://tid.li/tw5/hacks.html#%24%3A%2F_telmiger%2Ftweet) I made this:

The text-urlencode macro

Returns the urlencoded text of a given field (defaults to "text") in a given tiddler.


\define text-urlencode(tiddler,field:"text")
<$view format="urlencoded" tiddler="""$tiddler$""" field="""$field$"""/>
\end

The view widget handles only fields, so maybe you want to use the tiddlers visible in http://tiddlywiki.com/prerelease/#Community for testing – they allready have a url field. – EDIT: on the other hand these allready are correct URLs, just use title fields from any tiddlers you like!

Good luck!
Thomas

Riz

unread,
Dec 27, 2016, 12:02:32 PM12/27/16
to TiddlyWiki
Interesting approach, will come handy for me in a few other places. But here it didn't fetch me the required results here. See, here we are recreting the list filter. The ideal workflow will be something like that of viewwidget
ie, <$view tiddler="About" format="urlencoded"/> only difference being that widget will fetch the text to encode from viewtemplate, not the edit template. The output will be

nformation%20about%20the%20making%20of%20TiddlyWiki%3A%0A%0A%20%20%20%20Acknowledgements%0A%0A%20%20%20%20Contributors%0A%0A%20%20%20%20History%20of%20TiddlyWiki%0A%0A%20%20%20%20Releases%0A%0A%20%20%20%20RoadMap%0A


The method given by mat will exclude the first line of text. I tried using the method by changing filter like [[About]get[text]] to no avail.

Riz

unread,
Dec 27, 2016, 12:11:52 PM12/27/16
to TiddlyWiki
@Thomas, actually this whole rabbit hole started with your macro. It was excellent that I wanted to adapt it to a wider area. If we use the text-urlencode macro in a tiddler like "About", the output is
Information%20about%20the%20making%20of%20TiddlyWiki%3A%0A%0A%3C%3Clist-links%20%22%5Btag%5BAbout%5D%5D%22%3E%3E%0A
it is encoding the list-links macro as if it was a piece of text.




Thomas Elmiger

unread,
Dec 27, 2016, 1:09:02 PM12/27/16
to TiddlyWiki
Hm, what *exactly* are you trying to do, Riz?

Could be you would have to send your tiddler through the view widget twice: render the plain text/html, save that in a field (e.g. of a temp tiddler) and urlencode it from there (that’s why my macro needs the button first, it saves the text in a field). Or have a look at the qr code machinery here: http://tiddlywiki.com/prerelease/#%24%3A%2Fplugins%2Ftiddlywiki%2Fqrcode – it seems it can output a tiddler as raw or rendered output.

All the best!
Thomas

Riz

unread,
Dec 27, 2016, 2:34:27 PM12/27/16
to TiddlyWiki
I am actually trying to do what you achieved, sans the actually specifying the content as a macro parameter part. Imagine the possibilities. If we are able to encode the rendered content, we would be able to share the content of a tiddler with any site that accepts prefilled posting of content. (basically almost all social networks except facebook and google plus.) the same way you did for twitter.

Riz

unread,
Dec 27, 2016, 2:35:14 PM12/27/16
to TiddlyWiki
QR code plugin is not letting me inspect it. Throws up lot of errors.

Thomas Elmiger

unread,
Dec 27, 2016, 2:56:16 PM12/27/16
to TiddlyWiki
Yep. Same here. (Reported in https://groups.google.com/forum/m/#!topic/tiddlywiki/sKv57A9-eCk)

Maybe the encodeuri operator from 5.1.14 will do the job:
http://tiddlywiki.com/prerelease/#encodeuri%20Operator

There is cool stuff ahead!

Thomas Elmiger

unread,
Dec 28, 2016, 6:02:50 PM12/28/16
to TiddlyWiki
Hi Riz,

Create a new tiddler on http://tid.li/tw5/hacks.html and try this:

How much can be transformed?

<$wikify name="testcontent" text={{Tweeting}}>
<$macrocall $name="tweet" text=<<testcontent>>/>
</
$wikify>

This should attempt to tweet all text* from http://tid.li/tw5/hacks.html#Tweeting
The Twitter-API accepts a lot of text here (you have to scroll through the tweet input).

*some formatting ist missing – see http://tiddlywiki.com/#WikifyWidget for other output options like html.

– Is this like the solution you are looking for?

Cheers, Thomas

Riz

unread,
Dec 29, 2016, 10:56:48 AM12/29/16
to TiddlyWiki

The formatting was the issue from the begining. I achieved the same result earlier which ends up in creating a blob using a different method. I was hoping it would be possible to have atleast paragraph separation saved.

Sigh, been working on this for some days now. I guess it is time to admit defeat. If anyone is curiious, whatever I achieved till now can be found in here

https://tesseract-index.bitbucket.io/socialmacros/

Josiah

unread,
Dec 29, 2016, 11:34:12 AM12/29/16
to TiddlyWiki
Ciao Riz

From my point of view seeing attempts to properly address social networking posting issues is great.

I saved your TW attempt. I note you have a Reddit option and it sorta works.

Even if its not there yet. I'm very thankful there is interest and effort going in this direction and grateful you and others are putting time into it.

Best wishes
Josiah

Riz

unread,
Dec 29, 2016, 12:09:14 PM12/29/16
to TiddlyWiki

Technically it is all Thomas' work.

Given that we are here, let me ask this question. This is one of the two stumbling blocks that stops me from sending a plain-text tiddler to reddit or twitter. The following code is from here.


\define step1()
<$action-setfield $tiddler="$:/state/title" sharetitle={{!!title}}/>
\end
\define step2()
<$tiddler tiddler={{$:/state/title!!sharetitle}}>
<$wikify name=content text=<<renderContent>>>
<$action-setfield $tiddler="$:/state/content" text=<<content>>/>
</
$wikify>
</$tiddler>
\end

<$button popup=<<qualify $:/
state/Social>> class="tc-btn-invisible">
<<step1>>
<<step2>>
{{$:/core/images/globe}}</$button>

Here, despite the fact that <<step1>> is called first, the <<step2>> is executed first. Why?


Josiah

unread,
Dec 29, 2016, 12:30:14 PM12/29/16
to TiddlyWiki
Ciao Thomas

The Twitter API is not fussy  whatever rubbish you put in the box :-) you will have to ruthlessly reduce it to 140. For Twitter the only special formatting worth having it supports is line breaks, which you already done.  You know all this anyway.

Your other threads that deal with "extraction" could support the standard way of dealing with Twitter's character limit. I.e.  Tiddlers be written to  have an initial demarcated short Summary text that would also constitute the Tweeted part. That's an author's job familiar with that network knowing if they don't they will have hassle when it comes to post-time :-).

That is a methodology I could use for a film site I so far developed off-line for TW.

The ADVANTAGE of that approach is it means I don't have to mess around with extra fields. The text is one and the selection for posting depending on the particular network. I very much like the whole approach of extracting from the Tiddler text field.

I don't actually write into umpteen fields. The structure emerges IN writing, not through slots. I write text and its easy for me to think and write: this is the "Summary" bit, this is the "Mid-Section" and this is the "Whole Tamoli".

I hope this is clear?

Anyway, for me there is a kinda intuitive fit with some of your recent work that I can already see I can use.

Best wishes
Josiah

Jeremy Ruston

unread,
Dec 29, 2016, 12:55:53 PM12/29/16
to tiddl...@googlegroups.com
Hi Riz

\define step1()
<$action-setfield $tiddler="$:/state/title" sharetitle={{!!title}}/>
\end
\define step2()
<$tiddler tiddler={{$:/state/title!!sharetitle}}>
<$wikify name=content text=<<renderContent>>>
<$action-setfield $tiddler="$:/state/content" text=<<content>>/>
</
$wikify>
</$tiddler>
\end

<$button popup=<<qualify $:/
state/Social>> class="tc-btn-invisible">
<<step1>>
<<step2>>
{{$:/core/images/globe}}</$button>

Here, despite the fact that <<step1>> is called first, the <<step2>> is executed first. Why?

The issue here is a subtle problem with the way that action widgets are triggered. The action in step1 changes the value of a tiddler that is referenced within step2. The action widgets within the button widget are invoked sequentially, but there is no refresh cycle in between. That means that even after the first action-setfield in step1, the compiled code for step 2 will still reference the previous value for the tiddler.

Here’s a snippet that shows an alternative approach that seems to work for Twitter. Rather than creating a button, we create a link — so this would be suitable for inclusion within your existing dropdown.

<$wikify name="tweet-text" text={{!!text}} type="formattedtext">
<a href={{{ [<tweet-text>encodeuri[]addprefix[https://twitter.com/intent/tweet?text=]] }}} target="_blank" rel="noopener noreferrer">
Tweet this!
</a>
</$wikify>

A couple of points to note:

* The “formattedtext” output type for the wikify widget attempts to create ASCII formatted output (eg inserting asterisks for bullet lists)
* The new triple brace syntax for a transcluded filtered attribute allows us to calculate the URL in one go. We could add other elements with the addsuffix operator too
* Including the above code in the tiddler to be output will cause an error

Best wishes

Jeremy.





--
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/71146e3a-8791-42e6-9d4b-c6acc1315ae3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Elmiger

unread,
Dec 29, 2016, 1:13:43 PM12/29/16
to TiddlyWiki
Hi Jeremy

If I understand this right, your link solution can be used as soon as TW5 is published in version 5.1.14. While the triple brace syntax is already available, we still have to wait for the encodeuri filter operator and the formattedtext option for the wikify widget output.

As I said: Great stuff ahead!

All the best,
Thomas

Riz

unread,
Dec 30, 2016, 9:51:23 AM12/30/16
to TiddlyWiki

Thanks Jeremy!!

And that did it. I managed to cook up the macro to share the raw content of any tiddler to a few sites and email them.

If anyone would prefer to use, you can see it in action in https://tesseract-index.bitbucket.io/socialmacros/

Thomas Elmiger

unread,
Dec 30, 2016, 2:13:13 PM12/30/16
to TiddlyWiki
Hi Riz, great to see your success!

BUT: I am getting way too much credit there, please ad your name (or remove mine)!

This is how I see our cooperation: http://twitter.com/telmiger/status/814909829017980928

All the best!
Thomas

Thomas Elmiger

unread,
Dec 30, 2016, 2:24:16 PM12/30/16
to TiddlyWiki
Ciao Josiah,

Good to see that we think along the same lines concerning (not) stuffing content in fields versus reusing parts of tiddlers by extraction ;–)

Thanks a lot for promoting our solutions on all cannels, I think communication is another field in which TiddlyWiki made a leap forward in 2016 and a lot of this is because of your efforts!

I am looking forward to getting inspired and contribute again next year.

All the best!
Thomas
Reply all
Reply to author
Forward
0 new messages