kookma / TW-Trashbin

Trash bin tools in Tiddlywiki. Delete tiddlers and restore them easily
https://kookma.github.io/TW-Trashbin/
16 stars 3 forks source link

delete revision tiddlers made by the plainrevs plugin by jd #1

Closed hchaase closed 5 years ago

hchaase commented 5 years ago

I use jd's revision plugin and also want to use your trash bin plugin, but that would leave revision tidderls "floating free" without any reference tiddler, thus I made your plugin delete them. I would be better to also move them to the trashbin, but I dont have the skills to do that, and this is better than letting them fill up your wiki.

I added a line to also delete any revision tiddlers made by the plainrevs plugin by jd.

NB: the revision tiddlers are NOT moved to trash, permanently deleted!! ( I dont have the insight to do that)

ps. sorry for the clumsy pr. I cant find the tiddler in your repo. I hope it makes sense for your. I just copied a line form jd's plugin into the tiddler.

kookma commented 5 years ago

I did not quite understand this! one reason is I did not tried the JD plugin! So, please let me exactly what trashbin should do? or what feature you like to add?

hchaase commented 5 years ago

of curse

this how jd revision plugin work

when I edit and save a tiddler, the old tiddler is saved with the title $:/rev/<<now YYYY0MM0DD.0hh:0MM:0ss>> with the original tiddler title in the field list.

Rev tiddler structure


title: $:/rev/<<now YYYY0MM0DD.0hh:0MM:0ss>>
list: [[Title of source tiddler]]
rev-list: listItems [[inside list field]] of [[source tiddler]]
rev-tags: [[tag 1]] tag2
rev-someotherfield: someotherfield's value
... and all other fields of source tiddler, to be prefixed 'rev-'

I can restore the previous versions from the info panel of the primary tiddler.

http://j.d.revisions.tiddlyspot.com/

The conflict

when I put a tiddler in the trash can the revision tiddlers are still there as shadow tiddlers, but not searchable by simple means (but you can use a complicated search that jd describes in the doc) and if you dont know what you are searching for because you trashed and deleted maybe 10 different tiddlers, it becomes quite impossible to find them.

my solution

my solution is very simple, to delete all the revisions for the primary tiddler permanently when the primary tiddler is put in the trach can. This is to make sure that I dont fill up my wiki with revisions of tiddlers that don't exist any more. But I loose the revisions.

I just pasted the line that deletes all the revisions from jd's plugin into $:/plugins/kookma/trashbin/macros/move-to-trashbin

<$action-deletetiddler $filter="[<currentTiddler>listed[]prefix[$:/rev]!has[pin]]"/>

better solution (that I can not do)

would be to also put the revision tiddlers in the trash can, so they follow the original tiddler. To do this, the restore and permanent delete should of course also be modified.

I tried to experiment a bit with it, but I am afraid I wild break stuff trying to do this, thats why I only did the simple mod.

kookma commented 5 years ago

@hchaase Yes, what you proposed is possible and I recommend to do it in you fork! I will help if you need more help on Trashbin side!

By the way, as this proposal is specific to JD plugin I am afraid it is not suitable to be added to the original Trashbin plugin! I think it is better to stick with standard TW distribution (standard core).

kookma commented 5 years ago

of curse

this how jd revision plugin work

when I edit and save a tiddler, the old tiddler is saved with the title $:/rev/<<now YYYY0MM0DD.0hh:0MM:0ss>> with the original tiddler title in the field list.

Rev tiddler structure


title: $:/rev/<<now YYYY0MM0DD.0hh:0MM:0ss>>
list: [[Title of source tiddler]]
rev-list: listItems [[inside list field]] of [[source tiddler]]
rev-tags: [[tag 1]] tag2
rev-someotherfield: someotherfield's value
... and all other fields of source tiddler, to be prefixed 'rev-'

I can restore the previous versions from the info panel of the primary tiddler.

http://j.d.revisions.tiddlyspot.com/

The conflict

when I put a tiddler in the trash can the revision tiddlers are still there as shadow tiddlers, but not searchable by simple means (but you can use a complicated search that jd describes in the doc) and if you dont know what you are searching for because you trashed and deleted maybe 10 different tiddlers, it becomes quite impossible to find them.

my solution

my solution is very simple, to delete all the revisions for the primary tiddler permanently when the primary tiddler is put in the trach can. This is to make sure that I dont fill up my wiki with revisions of tiddlers that don't exist any more. But I loose the revisions.

I just pasted the line that deletes all the revisions from jd's plugin into $:/plugins/kookma/trashbin/macros/move-to-trashbin

<$action-deletetiddler $filter="[<currentTiddler>listed[]prefix[$:/rev]!has[pin]]"/>

This should work for you!

better solution (that I can not do)

would be to also put the revision tiddlers in the trash can, so they follow the original tiddler. To do this, the restore and permanent delete should of course also be modified.

I tried to experiment a bit with it, but I am afraid I wild break stuff trying to do this, thats why I only did the simple mod.

hchaase commented 5 years ago

@hchaase Yes, what you proposed is possible and I recommend to do it in you fork! I will help if you need more help on Trashbin side!

Thanks

By the way, as this proposal is specific to JD plugin I am afraid it is not suitable to be added to the original Trashbin plugin! I think it is better to stick with standard TW distribution (standard core).

I understand. No feature creep. So maybe I shuould make a plugin to your plugin..

hchaase commented 5 years ago

I think I have found a good solution, but it doesn't work and I dont understand why. If you know why I would appreciate your help.

In the $:/plugins/kookma/trashbin/sidebar-tab tiddler there is a delete button defined. I want to modify it to not only delete the current tiddler but also to delete the revisions.

original code:

\define delete-button()
<$button class="tc-btn-invisible" tooltip="Delete permanently">
{{$:/plugins/kookma/trashbin/images/times.svg}}
<$action-deletetiddler $tiddler=<<currentTiddler>> />
</$button>
\end

instead of <$action-deletetiddler $tiddler=<<currentTiddler>> /> I put <$action-deletetiddler $filter="[<currentTiddler>listed[]prefix[$:/rev]!has[pin]]"/> This is the filter i have copied from jd's plugin. I would think that the delete button in trashbin now would delete the tiddler and the revisions as defined in the filter, but nothing happens.

thank you for your help

(oc this is only for my fork)

hchaase commented 5 years ago

ah I see-- the <currentTiddler> refers to the $:/trashbin/Title and not just Title. I am trying to use your code {{{ [<currentTiddler>removeprefix[$:/trashbin/]] }}} to remove the prefix for the filter but still no luck

hchaase commented 5 years ago

Aha I solved it with

<$action-deletetiddler $filter="[<currentTiddler>] [<currentTiddler>removeprefix[$:/trashbin/]listed[]prefix[$:/rev]!has[pin]]"/>

never mind all my questions.. thanks for the help and nice plugin

kookma commented 5 years ago

I understand. No feature creep. So maybe I shuould make a plugin to your plugin.. It is okay to have your own or simple give a new name like the Trashbin-mod I saw in the group

kookma commented 5 years ago

Aha I solved it with

<$action-deletetiddler $filter="[<currentTiddler>] [<currentTiddler>removeprefix[$:/trashbin/]listed[]prefix[$:/rev]!has[pin]]"/>

That is correct!

kookma commented 5 years ago

I think it is good to move all revision to trashbin when you move a tiddler to trashbin!

Still note that, when a tiddler is trashed (means moved to trash bin) you can create a new tiddler with same title and that may cause issues!