Discussion:
[tw] Tobias' Delete All Tiddlers By Filter
Add Reply
c***@outlook.com
2017-08-10 16:21:29 UTC
Reply
Permalink
Raw Message
I stumbled across this
<http://tobibeer.github.io/tb5/#Delete%20All%20Tiddlers%20By%20Filter>and
thought it would make a good starting point for a JS macro. Having tried
it on a couple of TWs (where I had a ton of archaic temp/state tiddlers I
wanted to remove) it seems there is a very destructive bug in there
somewhere -- it destroys the TW (and since the wikis have passwords, they
will no longer decrypt). The size of one of the wikis went from ~6.5KB to
103KB. Ouch.

Here is Tobias' original code:

var filter = "tag[FOO]";
filter = "[all[tiddlers]!prefix[$]" + subfilter + "]";
var tids = $tw.wiki.filterTiddlers(filter, null);
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
for(var t=0; t<tids.length; t++) {
$tw.wiki.deleteTiddler(tids[t]);
}
}


Noticing the stray subfilter variable, I cleaned it up and then used this:

var filter = "[prefix[$:/temp/state/1]]";
var tids = $tw.wiki.filterTiddlers(filter, null);
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
for(var t=0; t<tids.length; t++) {
$tw.wiki.deleteTiddler(tids[t]);
}
}


If I use that filter in the filter search input in TW, it works as expected. When running the code above, it lists the exact same tiddlers (AFAICT), yet, it destroys the TW on confirming the dialog.

Anyone see a problem? What am I missing?

TIA
--
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 ***@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/c9982b8b-35c9-408a-b293-f5687c9ddae2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-08-10 16:50:39 UTC
Reply
Permalink
Raw Message
Hi,
Try this one: https://wikilabs.github.io/editions/remove-states/ ... it
shouldn't be that destructive, because you can see, what you delete.
-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+***@googlegroups.com.
To post to this group, send email to ***@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/1dd0e5fb-0a17-4f70-bd3b-951605b64821%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
c***@outlook.com
2017-08-10 17:27:46 UTC
Reply
Permalink
Raw Message
Cool. Thanks Mario!
Post by PMario
Hi,
Try this one: https://wikilabs.github.io/editions/remove-states/ ... it
shouldn't be that destructive, because you can see, what you delete.
-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+***@googlegroups.com.
To post to this group, send email to ***@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/09c7b2b2-622c-417b-8d22-efcd4763cc43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-14 09:49:00 UTC
Reply
Permalink
Raw Message
Ciao PMario

First time I ever seen that. So much good stuff has been written you can't
find ...

Tobias also did a similar thing with individually clickable items to
delete--however that has NO option to delete ALL, unlike yours.

Could yours (its just a single macro, right, not a plugin with
dependencies?) be re-factored to accept ANY filter through an input field?

Just wishes :-)
Best
Josiah
https://wikilabs.github.io/editions/remove-states/ ... it shouldn't be
that destructive, because you can see, what you delete.
--
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 ***@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/c9ec2191-11d9-44c1-afc7-d107f19ca2a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-08-14 11:01:53 UTC
Reply
Permalink
Raw Message
Post by @TiddlyTweeter
Could yours (its just a single macro, right, not a plugin with
dependencies?) be re-factored to accept ANY filter through an input field?
Sure, ...
_but_ it would be very destructive and error prone.

eg: If there is a typo.

- Let's imagine a filter like: [prefix[$:/temp]]
- it will also delete $:/temptation
- which may not be intended.

... Do you see the the missing char in the filter variable? .. and this
example contains an obvious problem. Filters can have side-effects, that
are much harder to spot.

I know, that's a user problem, if s/he creates a filter that dosn't do what
is intended, or if a filter has unintended side-effects ... I think the
plugin contains enough info, that users can create their own variations of
the macro, that work for their specific usecase.

I personally don't want to be responsible, if *my plugin* deletes stuff
that the user wanted to keep.

So everyone, which wants to be responsible can jump in here.

have fun!
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+***@googlegroups.com.
To post to this group, send email to ***@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/47a7c4d6-c123-409f-baa5-aabdda0021d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-14 11:17:25 UTC
Reply
Permalink
Raw Message
Its an interesting point you bring up.

IMO if you don't constantly backup your TW you are asking for
trouble--sooner or later.

I have experienced a couple of macros that ATE MY WIKI.

I'm not sure that the line of defence is to NOT give us The Powerful Wizard
Of Utility. But, rather, perhaps, to deliver the Wizard with levels of
warnings ... (1) Do NOT do this unless you have a backup. So don't blame me
if it eats your Wiki. (2) Are you REALLY sure you want to do this?

There needs to be room for brave people too.

Josiah, x
Post by PMario
Post by @TiddlyTweeter
Could yours (its just a single macro, right, not a plugin with
dependencies?) be re-factored to accept ANY filter through an input field?
Sure, ...
_but_ it would be very destructive and error prone.
eg: If there is a typo.
- Let's imagine a filter like: [prefix[$:/temp]]
- it will also delete $:/temptation
- which may not be intended.
... Do you see the the missing char in the filter variable? .. and this
example contains an obvious problem. Filters can have side-effects, that
are much harder to spot.
I know, that's a user problem, if s/he creates a filter that dosn't do
what is intended, or if a filter has unintended side-effects ... I think
the plugin contains enough info, that users can create their own variations
of the macro, that work for their specific usecase.
I personally don't want to be responsible, if *my plugin* deletes stuff
that the user wanted to keep.
So everyone, which wants to be responsible can jump in here.
have fun!
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+***@googlegroups.com.
To post to this group, send email to ***@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/85035565-6786-46a2-afb6-46ce1f3507c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-08-14 11:52:55 UTC
Reply
Permalink
Raw Message
Post by @TiddlyTweeter
IMO if you don't constantly backup your TW you are asking for
trouble--sooner or later.
That's right. ... 3 weeks ago my win HD died. Luckily I did back up the
data partition some days earlier. Now I have a physical system and 2
mirrored data drives. plus the existing backup solution :)
Post by @TiddlyTweeter
I have experienced a couple of macros that ATE MY WIKI.
Then you know what I mean :)
Post by @TiddlyTweeter
I'm not sure that the line of defence is to NOT give us The Powerful
Wizard Of Utility. But, rather, perhaps, to deliver the Wizard with levels
of warnings ... (1) Do NOT do this unless you have a backup. So don't blame
me if it eats your Wiki. (2) Are you REALLY sure you want to do this?
That's exactly the point.

As a developer I don't want to do harm. So if I would release a plugin that
can have destructive side effects, I need / want to take care, that the
user knows, what is going on. So it needs to be configurable: Similar to
the "bundler plugin
<https://wikilabs.github.io/editions/bundler/#%24%3A%2Fplugins%2Fwikilabs%2Fbundler%2Fui%2FControlPanel%2Fbundler-config>".
Bundler even doesn't delete stuff, but imports can overwrite existing
tiddlers ...
Post by @TiddlyTweeter
There needs to be room for brave people too.
Sure. ... If there wouldn't be murphy's law: "Anything that can go wrong
will go wrong!"

At the moment we don't have a "tm-ask-and-delete-message" needed for your
"(2) Are you REALLY sure you want to do this?" ... At least I think there
isn't. ... So may be we need one. ... But for my personal usage the
security questions would need to be switched off. ... because I hate popups
;)

have fun!
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+***@googlegroups.com.
To post to this group, send email to ***@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/eed70df8-15b5-40ae-b2e5-43cba96363aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-08-14 12:03:28 UTC
Reply
Permalink
Raw Message
Post by PMario
At the moment we don't have a "tm-ask-and-delete-message" needed for your
"(2) Are you REALLY sure you want to do this?" ... At least I think there
isn't. ...
I was wrong:
http://tiddlywiki.com/prerelease/#%24%3A%2Fcore%2Fui%2FAdvancedSearch%2FFilter%2FFilterButtons%2Fdelete
...
*So just open the control panel: select filter: .... and hit the delete
button*.

Just checked my plugin, and saw, that I deprecated it already. ... That's
probably the reason.

-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+***@googlegroups.com.
To post to this group, send email to ***@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/25caccd0-0f3d-43fa-8140-e1afed2f1cf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-14 12:13:31 UTC
Reply
Permalink
Raw Message
Ciao PMario,

HA!

My point is YOUR approach is LESS dangerous than that in the actual release
under Advanced Search > Filter > Delete.

SO, your gizmo revised to allow filters would be a plus IMO. I'd trust it
MORE than the Standard.

Best wishes
Josiah
Post by PMario
Post by PMario
At the moment we don't have a "tm-ask-and-delete-message" needed for your
"(2) Are you REALLY sure you want to do this?" ... At least I think there
isn't. ...
http://tiddlywiki.com/prerelease/#%24%3A%2Fcore%2Fui%2FAdvancedSearch%2FFilter%2FFilterButtons%2Fdelete
...
*So just open the control panel: select filter: .... and hit the delete
button*.
Just checked my plugin, and saw, that I deprecated it already. ... That's
probably the reason.
-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+***@googlegroups.com.
To post to this group, send email to ***@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/14e6de8b-db12-4d0f-ab39-0833670103af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2017-08-16 02:14:46 UTC
Reply
Permalink
Raw Message
Mario,

Actually your bundler pluginhttps://wikilabs.github.io/editions/bundler/
.goes a long way to showing how you can reduce the effect or stray filters
by counting the number of tiddlers selected. I could see an option to
delete the same filtered set of tiddlers after export. This would mean
forcing a group of tiddlers to be exported before deletion so there will be
no regrets. I used to do that in TWC exporting TRASHED items before I
emptied the Trash.

PS Condolences on the loss of a HD. Very sad event. :)

Tony

.
Post by PMario
Post by @TiddlyTweeter
IMO if you don't constantly backup your TW you are asking for
trouble--sooner or later.
That's right. ... 3 weeks ago my win HD died. Luckily I did back up the
data partition some days earlier. Now I have a physical system and 2
mirrored data drives. plus the existing backup solution :)
Post by @TiddlyTweeter
I have experienced a couple of macros that ATE MY WIKI.
Then you know what I mean :)
Post by @TiddlyTweeter
I'm not sure that the line of defence is to NOT give us The Powerful
Wizard Of Utility. But, rather, perhaps, to deliver the Wizard with levels
of warnings ... (1) Do NOT do this unless you have a backup. So don't blame
me if it eats your Wiki. (2) Are you REALLY sure you want to do this?
That's exactly the point.
As a developer I don't want to do harm. So if I would release a plugin
that can have destructive side effects, I need / want to take care, that
the user knows, what is going on. So it needs to be configurable: Similar
to the "bundler plugin
<https://wikilabs.github.io/editions/bundler/#%24%3A%2Fplugins%2Fwikilabs%2Fbundler%2Fui%2FControlPanel%2Fbundler-config>".
Bundler even doesn't delete stuff, but imports can overwrite existing
tiddlers ...
Post by @TiddlyTweeter
There needs to be room for brave people too.
Sure. ... If there wouldn't be murphy's law: "Anything that can go wrong
will go wrong!"
At the moment we don't have a "tm-ask-and-delete-message" needed for your
"(2) Are you REALLY sure you want to do this?" ... At least I think there
isn't. ... So may be we need one. ... But for my personal usage the
security questions would need to be switched off. ... because I hate popups
;)
have fun!
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+***@googlegroups.com.
To post to this group, send email to ***@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/11c637ff-f1a3-4cc0-8f0c-27fe678a5e4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 10:02:32 UTC
Reply
Permalink
Raw Message
Ciao PMario & Tony M

I agree with Tony. As I mentioned before in the Bundler thread using the
"Bundle List" rapidly makes you aware that its approach (its precision in
listing, its persistence, its ease of use) illustrates a way of working
that great enhances import/export.

Whether a DESTROYER could be integrated with it, or whether a similar
complementary approach could be done for deletion I don't know. What I can
see is that that Bundler & Destroyer in harmony could really ease bulk
procedures and make them a lot safer.

Mario, I like your https://wikilabs.github.io/editions/remove-states/
(example approach) over the Advanced Search delete button because its
offers both BULK & individual item control whilst deleting. Perhaps
something like that could be scaled of the Bundler approach?
your bundler pluginhttps://wikilabs.github.io/editions/bundler/ .goes a
long way to showing how you can reduce the effect or stray filters by
counting the number of tiddlers selected. I could see an option to delete
the same filtered set of tiddlers after export.
Buongiorno
Josiah
--
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 ***@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/2c659b23-8655-4c7b-8b6f-600128647b6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-08-16 10:15:07 UTC
Reply
Permalink
Raw Message
Post by @TiddlyTweeter
Mario, I like your https://wikilabs.github.io/editions/remove-states/
(example approach) over the Advanced Search delete button because its
offers both BULK & individual item control whilst deleting. Perhaps
something like that could be scaled of the Bundler approach?
I think, I can add a DESTROYER function, and reuse the core "Are you sure"
dialog. ..

I also consider to implement a possibility to "comment" in bunder config
tiddlers. .. TW can handle the .multids tiddler format
"application/x-tiddlers", which already knows, how to deal with comments.
... BUT I'm not sure atm, how I want to implement it. .. I'd like to
improve the "enlist" operator
<https://github.com/Jermolene/TiddlyWiki5/issues/2958>, so the bundler
plugin can stay simple. We'll have to see, what Jeremy says.

In the mean time I could implement a temporary operator for testing.

-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+***@googlegroups.com.
To post to this group, send email to ***@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/4a736ef8-aa3d-45c3-9e71-aea11e71d8a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...