[tw5] Re: Embedding tiddler title in image URL

2021-06-23 Thread PMario
Hi,
The docs can be found at: 
https://tiddlywiki.com/#Transclusion%20in%20WikiText  Also click the links 
at the end of the tiddler!!
-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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1a811b34-a175-4fb0-bee6-63c25367a6aen%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-23 Thread PMario
On Wednesday, June 23, 2021 at 9:17:46 AM UTC+2 cjec...@gmail.com wrote:

Mini-rant: all these different syntaxes are just a tad confusing :) 
> Sometimes {{..}}, sometimes {{{..}}}, sometimes <<..>>, sometimes $(..)$, 
> probably others I haven't stumbled on yet. Hard to keep track.
>

We do have to do different things, that doesn't work with the same syntax. 
The parser needs differences to decide what to do. 

{{title}} ... is the *convenience shortcut* for <$transclude tiddler=title 
/> and it produces the exact same output.

{{{ [[filter string]] }}} is the *shortcut* for  <$list filter="[[filter 
string]]"><$link />

-

<>  is the syntax to call a macro that has to be defined with:

\define macro-name() some text

macros do only 1 thing. They substitute text. 

-

\define build-url(title) https://tiddlywiki.com/#$title$

<>

With this example the parameter that is given to the macro call, will 
replace the string $title$. Then the macro output is used. 



\define build-url(title:Plugins) 
[[https://tiddlywiki.com/#:$(currentTiddler)$ $(a)$ $(b)$ $title$]]

<$vars a=Learning b=Features>
<$tiddler tiddler="HelloThere">
<>



The code above does a similar thing. It replaces $(currentTiddler)$ with 
the variable currentTiddler, that is defined by the tiddler-widget. The 
same is true for "a" and "b" ... title is from the first example

The outer [[]] is needed, to be able to uses spaces between the elements. 
.. If you don't have the braces the link would need to look like this.

https://tiddlywiki.com/#:$(currentTiddler)$%20$(a)$%20$(b)$%20$title$

Hope that helps a bit
-mario

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/66918be2-5aed-495c-859f-8d92399f5285n%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-23 Thread cjec...@gmail.com
Hey, cool! The $(..)$ syntax was the key. It also works within tiddler 
transclusion, e.g., {{$(currentTiddler)$ Discussion}}, which allowed me to 
finished the template. My main tiddlers now just have the single line 
<> and everything works.

Mini-rant: all these different syntaxes are just a tad confusing :) 
Sometimes {{..}}, sometimes {{{..}}}, sometimes <<..>>, sometimes $(..)$, 
probably others I haven't stumbled on yet. Hard to keep track.

Thanks to both of you for your help!

--nathanael

On Wednesday, June 23, 2021 at 12:51:52 PM UTC+8 Eric Shulman wrote:

> On Tuesday, June 22, 2021 at 7:45:51 PM UTC-7 cjec...@gmail.com wrote:
>
>> ...embed the tiddler title in the url, i.e.:
>>
> [img[images/{{!!title}}.jpg]]
>> But of course that just gets read literally. I've also tried using a 
>> variable with the same result:
>> <$set name="image" value="images/{{!!title}}.jpg">
>> [image[<>]]
>> 
>>
>
> The problem is that you can't directly mix field transclusion syntax, 
> e.g., {{!!fieldname}}, within other wiki syntax, e.g., [img[...]]
>
> The solution is to define a macro that constructs the desired wiki image 
> syntax, like this:
> \define showImage() [img[images/$(currentTiddler)$.jpg]]
> Then, invoke it like this:
> <>
>
> Notes:
> * By default, within each tiddler, the variable "currentTiddler" holds the 
> name of the tiddler
> * In normal tiddler content, you can use either {{!!title}} or 
> <> to *display* the name of the tiddler
> * Within the macro definition, $(...)$ does a *text substitution* of the 
> indicated variable, where the variable is defined *outside* the macro
> * After variable substitutions are done, the resulting macro content is 
> "returned" for rendering
> * Thus, if the above macro is invoked within a tiddler named "Tiddler1", 
> the macro content returned by <> will be: 
> [img[images/Tiddler1.jpg]], which is the syntax you want.
> * To use <> in multiple tiddlers, just place the showImage() 
> macro definition in a tiddler by itself (e.g., "ShowImageMacro"), and then 
> tag that tiddler with *$:/tags/Macro*.
>
> Also, as an alternative to using a macro definition to construct the 
> desired syntax, you could use the <$image> widget with a parameter value 
> that is assembled using "filtered transclusion", like this:
><$image source={{{ [[images/]addsuffixaddsuffix[.jpg]] 
> }}} />
> However, this syntax is obviously more complex to produce the exact same 
> result.
>
> enjoy,
> -e
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1e273193-745a-4283-94b4-ab2343f231ebn%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-22 Thread Darth Mole
Ok so I was kind of close lol. I didn't use the $(...)$ because I thought 
the vars that created that in the code I had seen was specific to the 
buttons. I also didn't realize that with core variables they didn't need to 
be set if you were using the same name. Thanks Eric!

On Wednesday, June 23, 2021 at 12:51:52 AM UTC-4 Eric Shulman wrote:

> On Tuesday, June 22, 2021 at 7:45:51 PM UTC-7 cjec...@gmail.com wrote:
>
>> ...embed the tiddler title in the url, i.e.:
>>
> [img[images/{{!!title}}.jpg]]
>> But of course that just gets read literally. I've also tried using a 
>> variable with the same result:
>> <$set name="image" value="images/{{!!title}}.jpg">
>> [image[<>]]
>> 
>>
>
> The problem is that you can't directly mix field transclusion syntax, 
> e.g., {{!!fieldname}}, within other wiki syntax, e.g., [img[...]]
>
> The solution is to define a macro that constructs the desired wiki image 
> syntax, like this:
> \define showImage() [img[images/$(currentTiddler)$.jpg]]
> Then, invoke it like this:
> <>
>
> Notes:
> * By default, within each tiddler, the variable "currentTiddler" holds the 
> name of the tiddler
> * In normal tiddler content, you can use either {{!!title}} or 
> <> to *display* the name of the tiddler
> * Within the macro definition, $(...)$ does a *text substitution* of the 
> indicated variable, where the variable is defined *outside* the macro
> * After variable substitutions are done, the resulting macro content is 
> "returned" for rendering
> * Thus, if the above macro is invoked within a tiddler named "Tiddler1", 
> the macro content returned by <> will be: 
> [img[images/Tiddler1.jpg]], which is the syntax you want.
> * To use <> in multiple tiddlers, just place the showImage() 
> macro definition in a tiddler by itself (e.g., "ShowImageMacro"), and then 
> tag that tiddler with *$:/tags/Macro*.
>
> Also, as an alternative to using a macro definition to construct the 
> desired syntax, you could use the <$image> widget with a parameter value 
> that is assembled using "filtered transclusion", like this:
><$image source={{{ [[images/]addsuffixaddsuffix[.jpg]] 
> }}} />
> However, this syntax is obviously more complex to produce the exact same 
> result.
>
> enjoy,
> -e
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1e5d1b89-2517-4704-a1b1-98045f357756n%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-22 Thread Darth Mole
wow, I'm really sorry. If you remove the enclosing [ and ] on the img tag 
code and save it, at least on mine, it displays the tiddler title. So when 
it was a broken img after I added the [ ] on either end I didn't think to 
check to see if it was still working. Sorry about that. Also it seems that 
while I was close, I think, it didn't work out too well.

On Wednesday, June 23, 2021 at 12:24:32 AM UTC-4 cjec...@gmail.com wrote:

> Thanks for the quick reply, and for the code.
>
> Unfortunately, it's not working for me. Here's what I've done.
>
> 1. Download a fresh copy of Tiddlywiki
> 2. Create a tiddler called "Test".
> 3. Copy/paste your code into "Test" and save.
>
> I end up with a broken image icon. When I right click and choose "open 
> image in new tab", I get the link:
>
> http://mysite.com/dir/images/%7B%7B!!title%7D%7D.jpg
>
> It's still interpreting {{!!title}} literally.
>
>  --Nathanael
> On Wednesday, June 23, 2021 at 11:14:15 AM UTC+8 iamdar...@gmail.com 
> wrote:
>
>> I think this is what you're looking for? There may be a better way to do 
>> it, but it seems to function based on my tests. Thanks to everyone over the 
>> last two weeks that have helped me so much! I wouldn't have been able to 
>> answer someone's question like this otherwise.
>>
>> \define linkcreation()
>> [img[images/{{!!title}}.jpg]]
>> \end
>>
>> <>
>>
>> On Tuesday, June 22, 2021 at 10:45:51 PM UTC-4 cjec...@gmail.com wrote:
>>
>>> Long time lurker, first time poster.
>>>
>>> I've a wiki with a couple of hundred tiddlers all of the same format, 
>>> just different content, so I'm trying to develop a tiddler template.
>>>
>>> Each tiddler displays an image specific to that tiddler. I've a 
>>> directory in which all the images are kept, each with the same name as the 
>>> tiddler {{!!title}} field. E.g.:
>>>
>>> images/Tiddler1.jpg
>>> images/Tiddler2.jpg
>>> images/Tiddler3.jpg
>>>
>>> They idea is to then embed the tiddler title in the url, i.e.:
>>>
>>> [img[images/{{!!title}}.jpg]]
>>>
>>> But of course that just gets read literally. I've also tried using a 
>>> variable with the same result:
>>>
>>> <$set name="image" value="images/{{!!title}}.jpg">
>>> [image[<>]]
>>> 
>>>
>>> How can I do this?
>>>
>>> --Nathanael
>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/05540918-c388-4bcf-a2ce-291092690cdcn%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-22 Thread Eric Shulman
On Tuesday, June 22, 2021 at 7:45:51 PM UTC-7 cjec...@gmail.com wrote:

> ...embed the tiddler title in the url, i.e.:
> [img[images/{{!!title}}.jpg]]
> But of course that just gets read literally. I've also tried using a 
> variable with the same result:
> <$set name="image" value="images/{{!!title}}.jpg">
> [image[<>]]
> 
>

The problem is that you can't directly mix field transclusion syntax, e.g., 
{{!!fieldname}}, within other wiki syntax, e.g., [img[...]]

The solution is to define a macro that constructs the desired wiki image 
syntax, like this:
\define showImage() [img[images/$(currentTiddler)$.jpg]]
Then, invoke it like this:
<>

Notes:
* By default, within each tiddler, the variable "currentTiddler" holds the 
name of the tiddler
* In normal tiddler content, you can use either {{!!title}} or 
<> to *display* the name of the tiddler
* Within the macro definition, $(...)$ does a *text substitution* of the 
indicated variable, where the variable is defined *outside* the macro
* After variable substitutions are done, the resulting macro content is 
"returned" for rendering
* Thus, if the above macro is invoked within a tiddler named "Tiddler1", 
the macro content returned by <> will be: 
[img[images/Tiddler1.jpg]], which is the syntax you want.
* To use <> in multiple tiddlers, just place the showImage() 
macro definition in a tiddler by itself (e.g., "ShowImageMacro"), and then 
tag that tiddler with *$:/tags/Macro*.

Also, as an alternative to using a macro definition to construct the 
desired syntax, you could use the <$image> widget with a parameter value 
that is assembled using "filtered transclusion", like this:
   <$image source={{{ [[images/]addsuffixaddsuffix[.jpg]] 
}}} />
However, this syntax is obviously more complex to produce the exact same 
result.

enjoy,
-e

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ce26fb82-dc11-433d-b5b4-0f614a7e6dccn%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-22 Thread cjec...@gmail.com
Thanks for the quick reply, and for the code.

Unfortunately, it's not working for me. Here's what I've done.

1. Download a fresh copy of Tiddlywiki
2. Create a tiddler called "Test".
3. Copy/paste your code into "Test" and save.

I end up with a broken image icon. When I right click and choose "open 
image in new tab", I get the link:

http://mysite.com/dir/images/%7B%7B!!title%7D%7D.jpg

It's still interpreting {{!!title}} literally.

 --Nathanael
On Wednesday, June 23, 2021 at 11:14:15 AM UTC+8 iamdar...@gmail.com wrote:

> I think this is what you're looking for? There may be a better way to do 
> it, but it seems to function based on my tests. Thanks to everyone over the 
> last two weeks that have helped me so much! I wouldn't have been able to 
> answer someone's question like this otherwise.
>
> \define linkcreation()
> [img[images/{{!!title}}.jpg]]
> \end
>
> <>
>
> On Tuesday, June 22, 2021 at 10:45:51 PM UTC-4 cjec...@gmail.com wrote:
>
>> Long time lurker, first time poster.
>>
>> I've a wiki with a couple of hundred tiddlers all of the same format, 
>> just different content, so I'm trying to develop a tiddler template.
>>
>> Each tiddler displays an image specific to that tiddler. I've a directory 
>> in which all the images are kept, each with the same name as the tiddler 
>> {{!!title}} field. E.g.:
>>
>> images/Tiddler1.jpg
>> images/Tiddler2.jpg
>> images/Tiddler3.jpg
>>
>> They idea is to then embed the tiddler title in the url, i.e.:
>>
>> [img[images/{{!!title}}.jpg]]
>>
>> But of course that just gets read literally. I've also tried using a 
>> variable with the same result:
>>
>> <$set name="image" value="images/{{!!title}}.jpg">
>> [image[<>]]
>> 
>>
>> How can I do this?
>>
>> --Nathanael
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c7e86735-4c08-4392-a2de-1b929ab48936n%40googlegroups.com.


[tw5] Re: Embedding tiddler title in image URL

2021-06-22 Thread Darth Mole
I think this is what you're looking for? There may be a better way to do 
it, but it seems to function based on my tests. Thanks to everyone over the 
last two weeks that have helped me so much! I wouldn't have been able to 
answer someone's question like this otherwise.

\define linkcreation()
[img[images/{{!!title}}.jpg]]
\end

<>

On Tuesday, June 22, 2021 at 10:45:51 PM UTC-4 cjec...@gmail.com wrote:

> Long time lurker, first time poster.
>
> I've a wiki with a couple of hundred tiddlers all of the same format, just 
> different content, so I'm trying to develop a tiddler template.
>
> Each tiddler displays an image specific to that tiddler. I've a directory 
> in which all the images are kept, each with the same name as the tiddler 
> {{!!title}} field. E.g.:
>
> images/Tiddler1.jpg
> images/Tiddler2.jpg
> images/Tiddler3.jpg
>
> They idea is to then embed the tiddler title in the url, i.e.:
>
> [img[images/{{!!title}}.jpg]]
>
> But of course that just gets read literally. I've also tried using a 
> variable with the same result:
>
> <$set name="image" value="images/{{!!title}}.jpg">
> [image[<>]]
> 
>
> How can I do this?
>
> --Nathanael
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fdfffe7a-4ed4-43c4-a9aa-9cde8b98116an%40googlegroups.com.