Thanks so much, Saq!

I may look into this later, but when I implemented your approach, it 
generated exactly what I wanted, for instance (that's from the static 
website output):

<a 
href="https://twitter.com/intent/tweet?source=https://www.mentalnodes.com/Folders-kill-creativity&amp;text=Folders
 
kill 
creativity:%20https://www.mentalnodes.com/Folders-kill-creativity&amp;via=anthilemoon&amp;hashtags=mentalnodes";
 
target="_blank" title="Tweet"><img alt="Tweet" 
src="social-icons/Twitter.png"></a>


(not sure why the URL says "Folders" and not "folders" but that's minor)

Very grateful!

On Saturday, April 25, 2020 at 10:37:13 AM UTC+1, Saq Imtiaz wrote:
>
> @Anne-Laure we should have asked you for those files from the beginning! 
> That would have made helping you out a lot easier all along :)
>
> Those instructions for regex use one of the other three variables that I 
> mentioned, tv-get-export-link instead of tv-filter-export-link, which 
> requires javascript.
>
> You can mix and match both approaches but then it can be a little tricky 
> to ensure that both always return the exact same filenames and 
> corresponding links. This may not be an issue, but there is a chance it 
> might cause problems at some point. Basically its a case of making sure the 
> filter in tv-filter-export-link does the exact same thing as the javascript.
>
> With the way I outlined, you use the same filters for both and there is no 
> javascript involved, so there are no chances of such issues. Or 
> alternatively one could write another javascript macro that defines the url 
> variable, using the same javascript logic.
> For a non-developer I think the non-javascript based approach will be 
> easiest in the long run.
>
> Regards,
> Saq
>
> On Saturday, April 25, 2020 at 11:11:56 AM UTC+2, Anne-Laure Le Cunff 
> wrote:
>>
>> Hi Saq,
>>
>> First, thanks so much for your help!
>>
>> Yes, I have modified *static.tiddler.html* - it looks like this 
>> <https://github.com/anthilemoon/tw-experiments/blob/master/%24__ness_labs_template_static-view-template.tid>
>>  
>> in my setup — and it looks like your approach is working! Thank you! Will 
>> keep on tweaking, but if you're curious you can see here 
>> <https://github.com/anthilemoon/tw-experiments> the files where I did 
>> the regex edits. (following these instructions 
>> <https://www.didaxy.com/exporting-static-sites-from-tiddlywiki-part-5>)
>>
>> Many thanks!
>>
>> On Saturday, April 25, 2020 at 9:37:44 AM UTC+1, Saq Imtiaz wrote:
>>>
>>> @Anne-Laure : I suspect we have been overcomplicating a bit because most 
>>> of us are not familiar with the static site generation process. If you can 
>>> walk us through a few details of your setup I think we are close a 
>>> solution. Short instructions at the end, but please read through everything.
>>>
>>> Have you modified this template
>>>  static.tiddler.html
>>>
>>> from the folder 
>>> /core/templates?
>>>
>>> If so, please post your customized template. If not, where exactly are 
>>> you using regexp to replace the spaces in file names, and the links to 
>>> them, with hyphens?
>>>
>>> TiddlyWiki defines three variables that can be used to tweak the 
>>> structure of url's in the static files generated:
>>>
>>> https://tiddlywiki.com/#tv-wikilink-template%20Variable:%5B%5Btv-wikilink-template%20Variable%5D%5D%20%5B%5Btv-filter-export-link%20Variable%5D%5D%20%5B%5Btv-get-export-link%20Variable%5D%5D
>>>
>>> You said you have replaced the spaces in tiddler names with hyphens, the 
>>> correct way to do this in links would be via the variable
>>> tv-filter-export-link
>>>
>>> https://tiddlywiki.com/#tv-filter-export-link%20Variable used at the 
>>> top of static.tiddler.html as follows:
>>>
>>> \define tv-filter-export-link() [split[ ]join[-]encodeuricomponent[]]
>>>
>>> Assuming it is setup this way, the following filter will get you the 
>>> file name portion of the url:
>>> [<currentTiddler>subfilter<tv-filter-export-link>]
>>>
>>> Since TW doesn't know where your files will be served we need to add in 
>>> the domain name:
>>> [<currentTiddler>subfilter<tv-filter-export-link>addprefix[https://
>>> www.mentalnodes.com/]]
>>>
>>> a better way to do this would be to create a tiddler called something 
>>> like $:/config/static/domain and give it the text value 
>>> https://mentalnodes.com/ so that we can re-use and easily change the 
>>> domain name.
>>> Then the filter for the URL becomes:
>>> [<currentTiddler>subfilter<tv-filter-export-link>addprefix{$:/config/
>>> static/domain}]
>>>
>>>
>>> *Putting it all together: (and assuming you aren't doing anything 
>>> elsewhere to tweak the file names)*
>>> At the top of your template:
>>>
>>> \define tv-filter-export-link() [split[ ]join[-]encodeuricomponent[]]
>>>
>>> \define tweet-this(url,title,description)
>>> <a href="
>>> https://twitter.com/intent/tweet?source=$url$&text=$title$%20$description$&via=anthilemoon
>>> " target="_blank" title="Tweet"><img alt="Tweet" src=
>>> "social-icons/Twitter.png" /></a>
>>> \end
>>>
>>>
>>> Use as: 
>>>
>>> <$macrocall $name="tweet-this" url={{{ [<currentTiddler>subfilter
>>> <tv-filter-export-link>addprefix{$:/config/static/domain}] }}} 
>>> title={{!!title}} description={{!!description}} />
>>>
>>> To get your file names to match, you can use this filter with the 
>>> RenderCommand when generating static files:
>>> https://tiddlywiki.com/#RenderCommand
>>>
>>> "[split[ ]join[-]encodeuricomponent[]addsuffix[.html]addprefix[static/]]"
>>>
>>> For easier access to the url in the template, you can wrap a set widget 
>>> around the entirety of the html portion of your template:
>>> \define macros go here
>>>
>>> <$set name="url" filter=
>>> """[<currentTiddler>subfilter<tv-filter-export-link>addprefix{$:/config/static/domain}]"""
>>> >
>>> <!------html starts here-->
>>>
>>>
>>> <<url>> will give you the url, relies on tv-filter-export-link being 
>>> defined in the template
>>>
>>>
>>> </$set>
>>>
>>>
>>> Please let us know if that works. If so, it can likely be further 
>>> simplified for re-use.
>>>
>>> Regards,
>>> Saq
>>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/aa821bdd-3bda-46d3-9924-f79d831ffe03%40googlegroups.com.

Reply via email to