Ah right, I believe there is a race condition which is leading to the 
double save. 

On Tuesday, August 10, 2021 at 8:20:32 PM UTC+2 Saq Imtiaz wrote:

> Regarding: " It would be best if I could save only to github thus never 
> overriding my local wiki. Is that possible ?"
>
> Have you tried removing the second instance of  $action-sendmessage 
> $message="tm-save-wiki" in your code?
>
> On Tuesday, August 10, 2021 at 8:00:43 PM UTC+2 Télumire wrote:
>
>> Hi Saq, 
>>
>> The code I shared at the end of my post already use these shadow tiddlers.
>> Thanks for the google thread, I'll try again and ask him for help if need 
>> be. 
>>
>> I just hopped there was a way to do that in wiki text only, since I'm not 
>> very good with JavaScript ^^
>>
>> Le mardi 10 août 2021 à 19:46:26 UTC+2, [email protected] a écrit :
>>
>>> I think bimlas' code has most of what you need and could easily be 
>>> adapted for your purposes.
>>> You may want to consider speaking with him, see 
>>> https://groups.google.com/g/tiddlywiki/c/ZU_s6FdUy8Q/m/KeXVnOciBAAJ
>>>
>>> Also helpful might be the ability to create a custom save button that 
>>> does not include the public content. See the following shadow tiddlers:
>>> $:/core/ui/Buttons/save-wiki
>>> $:/config/SaveWikiButton/Template
>>> $:/core/save/all
>>>
>>>
>>> On Tuesday, August 10, 2021 at 7:09:58 PM UTC+2 Télumire wrote:
>>>
>>>>
>>>> Hello everyone,
>>>>
>>>> I wish to use tiddlywiki as a semi-private blog using GitHub Pages 
>>>> (with some of its content never going online until it's ready) and thought 
>>>> it would be nice to have a button that allow to choose what saver to use.
>>>>
>>>> For example, when I'm finished working on my article, I would hit the 
>>>> regular save button and the changes would be saved locally. Then, when I'm 
>>>> satisfied, I would click a button to save to GitHub.
>>>>
>>>> The interesting thing is that we can set a filter to exclude some 
>>>> tiddler from the save, so if I want to exclude an unfinished tiddler from 
>>>> the save to GitHub, I would simply tag it with “private” or something 
>>>> before saving the wiki.
>>>>
>>>> The issue is : tiddlywiki does not provide a mean to specify which 
>>>> saver to use when triggering a save. 
>>>>
>>>> I found a workaround : I use a button which first fill in the GitHub 
>>>> credential, increasing the priority of the GitHub saver, trigger the 
>>>> filtered save, then remove the credential, allowing the next regular save 
>>>> to be done with the local saver.
>>>>
>>>> The issue is that when I save to github this way, it also save locally. 
>>>> So to prevent my private tiddlers from getting overridden by the save, I 
>>>> need to trigger a complete save to finish the process. I think this is 
>>>> very 
>>>> risky because if the browser crash between the github save and the local 
>>>> save, all my private tiddlers will be lost. It would be best if I could 
>>>> save only to github thus never overriding my local wiki. Is that possible ?
>>>>
>>>> I've found this js code by bimlas showing how to select a saver : 
>>>> https://bimlas.gitlab.io/demo/tw5/preferred-saver.html#%24%3A%2Fbimlas%2Fpreferred-saver.js
>>>>  
>>>> but I don't know how to adapt it to my scenario.
>>>>
>>>> Here's the code that I use for now :
>>>>
>>>> <$button tooltip={{GithubSave/Hint}} aria-label={{GithubSave/Caption}}  
>>>> class=<<tv-config-toolbar-class>>>
>>>> <$action-listops $tiddler="github save button/private/username" 
>>>> $tags="[[private]] [[github save button]]"/>
>>>> <$action-listops $tiddler="github save button/private/state" 
>>>> $tags="[[private]] [[github save button]]"/>
>>>> <$action-setfield $tiddler="$:/GitHub/Username" text={{github save 
>>>> button/private/username}}/>
>>>> <$action-sendmessage $message="tm-save-wiki" $param="$:/core/save/all" 
>>>> publishFilter={{publishFilter}} />
>>>> <$action-setfield $tiddler="$:/GitHub/Username" text=""/>
>>>> <$action-sendmessage $message="tm-save-wiki" $param="$:/core/save/all"/>
>>>>
>>>> <span class="tc-dirty-indicator">
>>>> <$list filter="[<tv-config-toolbar-icons>match[yes]]">
>>>> {{$:/core/images/github}}
>>>> </$list>
>>>> <$list filter="[<tv-config-toolbar-text>match[yes]]">
>>>> <span class="tc-btn-text">save to github</span>
>>>> </$list>
>>>> </span>
>>>> </$button>
>>>>
>>>> Live demo : 
>>>>
>>>>
>>>> https://telumire.github.io/TW-tips/#Save%20a%20private%20copy%20to%20github%20(single%20file%20wiki)
>>>>
>>>> You can import it in your wiki by drag & drop "'open all in the current 
>>>> tab" in tiddlywiki. Click once on the button, then fill in the username in 
>>>> the tiddler "github save button/private/username". 
>>>>
>>>

-- 
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/7f2dd21e-e916-48db-8f4a-bdf673273ab8n%40googlegroups.com.

Reply via email to