mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
|
//--
|
||
|
//-- 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]));
|
||
|
}
|
||
|
};
|
||
|
|