mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-02 04:46:57 +00:00
Revised test data
Testing against the output of cook.rb isn't satisfactory because of the bugs in it; instead we're now going to test against the tiddlywiki.com build products
This commit is contained in:
42
test/tiddlywiki.2.6.5/source/tiddlywiki/js/TW21Saver.js
Executable file
42
test/tiddlywiki.2.6.5/source/tiddlywiki/js/TW21Saver.js
Executable file
@@ -0,0 +1,42 @@
|
||||
//--
|
||||
//-- TW21Saver (inherits from SaverBase)
|
||||
//--
|
||||
|
||||
function TW21Saver() {}
|
||||
|
||||
TW21Saver.prototype = new SaverBase();
|
||||
|
||||
TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
|
||||
{
|
||||
try {
|
||||
var extendedAttributes = "";
|
||||
var usePre = config.options.chkUsePreForStorage;
|
||||
store.forEachField(tiddler,
|
||||
function(tiddler,fieldName,value) {
|
||||
// don't store stuff from the temp namespace
|
||||
if(typeof value != "string")
|
||||
value = "";
|
||||
if(!fieldName.match(/^temp\./))
|
||||
extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
|
||||
},true);
|
||||
var created = tiddler.created;
|
||||
var modified = tiddler.modified;
|
||||
var attributes = tiddler.creator ? ' creator="' + tiddler.creator.htmlEncode() + '"' : "";
|
||||
attributes += tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
|
||||
attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"';
|
||||
attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"';
|
||||
var tags = tiddler.getTags();
|
||||
if(!usePre || tags)
|
||||
attributes += ' tags="' + tags.htmlEncode() + '"';
|
||||
return ('<div %0="%1"%2%3>%4</'+'div>').format([
|
||||
usePre ? "title" : "tiddler",
|
||||
tiddler.title.htmlEncode(),
|
||||
attributes,
|
||||
extendedAttributes,
|
||||
usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
|
||||
]);
|
||||
} catch (ex) {
|
||||
throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user