TiddlyWiki.org

Ticket #313 (closed enhancement: fixed)

Opened 1 year ago

Last modified 5 months ago

Temporary Tiddlers

Reported by: UdoBorkowski Assigned to: SaqImtiaz
Priority: major Milestone: 2.3.1
Component: core Version:
Severity: medium Keywords:
Cc:

Description

Eric recently introduced the idea of "temporary tiddlers" (tiddlers that are not saved) and provided a plugin for that purpose.

For his implementation he had to copy the complete SaverBase.prototype.externalize and modify it. This make it likely the plugin code will break as soon as we touch the original SaverBase.prototype.externalize function.

Since having "temporary tiddlers" seems to be a quite general feature I suggest we change the TiddlyWiki code to make it easier and more robust to get this feature.

Therefore the Tiddler class defines a new function isTemporary() that returns false by default. In the SaverBase.prototype.externalize this function is used to check what tiddlers must not be saved (one extra line).

Here the code:

//# returns true when this tiddler is a temporary tiddler (i.e. must not be saved).
Tiddler.prototype.isTemporary = function() {
	return false;
}

SaverBase.prototype.externalize = function(store)
{
	var results = [];
	var tiddlers = store.getTiddlers("title");
	for(var t = 0; t < tiddlers.length; t++)
		if (!tiddlers[t].isTemporary())  //#THIS IS THE NEW LINE
			results.push(this.externalizeTiddler(store,tiddlers[t]));
	return results.join("\n");
};

Attachments

Ticket313.patch (1.0 kB) - added by SaqImtiaz on 27/02/08 12:11:40.

Change History

15/04/07 20:56:08 changed by JeremyRuston

  • milestone changed from 2.2 to 2.3.

12/10/07 16:42:50 changed by MartinBudden

  • milestone changed from 2.3 to soon.

27/02/08 12:11:40 changed by SaqImtiaz

  • attachment Ticket313.patch added.

27/02/08 12:13:37 changed by SaqImtiaz

  • owner changed from JeremyRuston to SaqImtiaz.
  • status changed from new to assigned.
  • milestone changed from soon to 2.3.1.

The attached patch implements this feature and treats all tiddlers with the field 'temporary' has being temporary and they are thus not save. Plugin writers can easily override or enhance the criteria for temporary tiddlers by overriding the method Tiddler.prototype.isTemporary.

This is a potentially very useful feature which has been ticket for some time, and should now be fast tracked unless there is some pressing reason not to.

28/02/08 16:22:42 changed by JeremyRuston

This approach is a reasonable hack for supporting the explicit feature of temporary tiddlers. Another approach would be just to refactor the function like this:

SaverBase.prototype.externalize = function(store)
{
	var results = [];
	var tiddlers = store.getTiddlers("title");
	if(this.filterForSaving)
		this.filterForSaving();
	for(var t = 0; t < tiddlers.length; t++)
		results.push(this.externalizeTiddler(store,tiddlers[t]));
	return results.join("\n");
};

The idea would be that Eric could implement the function filterForSaving() to remove any temporary tiddlers from the list. This approach is a wee bit less code, and perhaps is more flexible because it's less specific to the particular issue of implementing temporary tiddlers.

18/03/08 11:30:36 changed by JeremyRuston

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in changeset:4040