Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var determineContainer = function(tiddler, fuzzy) { // TODO: expose?
var bag = tiddler.fields["server.bag"];
var recipe = tiddler.fields["server.recipe"]; // XXX: unused/irrelevant/redundant!?
if(bag) {
return { type: "bag", name: bag };
} else if(recipe) {
return { type: "recipe", name: recipe };
} else if(fuzzy) { // new tiddler
var workspace = tiddler.fields["server.workspace"];
if(workspace) {
var container = split(workspace, "/", "l");
return ["bags", "recipes"].contains(container.type) ? container : false;
} else {
return false;
}
} else {
return false;
}
};
(function($) {
var tweb = config.extensions.tiddlyweb;
var recipe = config.defaultCustomFields["server.workspace"].split("recipes/")[1];
var currentSpace; // assigned later
var disabledTabs = [];
var coreBags = ["system", "tiddlyspace"];
var systemSpaces = ["plugins", "info", "images", "theme"];
systemSpaces = $.map(systemSpaces, function(item, i) {
return "system-%0_public".format(item);
});
// hijack search macro to add custom attributes for mobile devices
var _search = config.macros.search.handler;
config.macros.search.handler = function(place, macroName, params) {
_search.apply(this, arguments);
$(".searchField:input", place).
attr({ autocapitalize: "off", autocorrect: "off" });
showRevisions: function(tiddlerElem, tiddler, pageSize) {
var context = {
host: tiddler.fields["server.host"],
workspace: tiddler.fields["server.workspace"]
};
$(tiddlerElem).addClass("revisions").attr("revName", tiddler.title);
// ensure toolbar commands deactivate RevisionsView
$("a", ".toolbar", tiddlerElem).each(function(index, btn) {
var _onclick = btn.onclick;
btn.onclick = function(e) {
me.closeRevisions(tiddlerElem);
_onclick.apply(this, arguments);
};
});
// ensure default action deactivates RevisionsView
var _ondblclick = tiddlerElem.ondblclick;
tiddlerElem.ondblclick = function(e) {
me.closeRevisions(tiddlerElem);
_ondblclick.apply(this, arguments);
};
config.commands.syncing.handlePopup = function(popup,title)
{
var me = config.commands.syncing;
var tiddler = store.fetchTiddler(title);
if(!tiddler)
return;
var serverType = tiddler.getServerType();
var serverHost = tiddler.fields["server.host"];
var serverWorkspace = tiddler.fields["server.workspace"];
if(!serverWorkspace)
serverWorkspace = "";
if(serverType) {
var e = createTiddlyElement(popup,"li",null,"popupMessage");
e.innerHTML = me.currentlySyncing.format([serverType,serverHost,serverWorkspace]);
} else {
createTiddlyElement(popup,"li",null,"popupMessage",me.notCurrentlySyncing);
}
if(serverType) {
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,me.onChooseServer);
btn.setAttribute("tiddler",title);
btn.setAttribute("server.type","");
}
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
createTiddlyElement(popup,"li",null,"popupMessage",me.chooseServer);
store.forEachTiddler(function(title,tiddler) {
var syncItem = {};
syncItem.serverType = tiddler.getServerType();
syncItem.serverHost = tiddler.fields['server.host'];
if(syncItem.serverType && syncItem.serverHost) {
syncItem.adaptor = new config.adaptors[syncItem.serverType]();
syncItem.serverHost = syncItem.adaptor.fullHostName(syncItem.serverHost);
syncItem.serverWorkspace = tiddler.fields['server.workspace'];
syncItem.tiddler = tiddler;
syncItem.title = tiddler.title;
syncItem.isTouched = tiddler.isTouched();
syncItem.selected = syncItem.isTouched;
syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"];
syncItem.status = syncItem.syncStatus.text;
list.push(syncItem);
}
});
list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
adaptor.prototype.putTiddler = function(tiddler, context, userParams, callback) {
var fields = tiddler.fields;
context = this.setContext(context, userParams, callback);
context.title = tiddler.title;
context.tiddler = tiddler;
context.host = context.host || this.fullHostName(fields["server.host"]);
context.workspace = context.workspace || fields["server.workspace"];
var payload = {
type: fields["server.content-type"] || null,
title: tiddler.title,
modified: tiddler.modified? tiddler.modified.convertToYYYYMMDDHHMM() : '',
created: tiddler.created? tiddler.created.convertToYYYYMMDDHHMM() : '',
creator: tiddler.creator,
modifier: tiddler.modifier,
text: tiddler.text,
tags: tiddler.tags,
fields: $.extend({}, fields)
};
if(tiddler.created) {
payload.created = tiddler.created;
}
if(tiddler.creator) {
payload.creator = tiddler.creator;
_scanCallback: function(place, jsontiddlers, options) {
var locale = followersMacro.locale;
var tiddlers = scanMacro._tiddlerfy(jsontiddlers, options);
if(options.sort) {
tiddlers = store.sortTiddlers(tiddlers, options.sort);
}
if(options.filter) {
var _store = new TiddlyWiki();
config.lastStore = _store;
for(var i = 0; i < tiddlers.length; i++) {
var clone = tiddlers[i];
clone.title = tiddlyspace.getLocalTitle(clone.title, clone.fields['server.workspace']);
_store.addTiddler(clone);
}
tiddlers = _store.filterTiddlers(options.filter);
}
if(place) {
$(place).empty();
var list = $("<ul>").appendTo(place)[0];
scanMacro.template(list, tiddlers, options.template);
if(tiddlers.length === 0) {
$("<li>").text(options.emptyMessage || locale.noone).appendTo(list);
$(list).addClass("emptyList");
}
}
if(options.callback) {
options.callback(tiddlers);
}</li></ul>
ccTiddlyAdaptor.prototype.getTiddler = function(title,context,userParams,callback){
context = this.setContext(context,userParams,callback);
if(title)
context.title = title;
if(context.revision){
var uriTemplate = '%0/handle/revisionDisplay.php?title=%2&workspace=%1&revision=%3';
}else{
var uriTemplate = '%0/handle/getTiddler.php?title=%2&workspace=%1';
}
uri = uriTemplate.format([context.host,context.workspace,ccTiddlyAdaptor.normalizedTitle(title),context.revision]);
context.tiddler = new Tiddler(title);
context.tiddler.fields['server.type'] = ccTiddlyAdaptor.serverType;
context.tiddler.fields['server.host'] = ccTiddlyAdaptor.minHostName(context.host);
context.tiddler.fields['server.workspace'] = context.workspace;
var req = httpReq('GET', uri,ccTiddlyAdaptor.getTiddlerCallback,context,{'accept':'application/json'});
return typeof req == 'string' ? req : true;
};
setupMarkupPreHead: function() {
var pubWorkspace = tiddlyspace.getCurrentWorkspace("public");
var existing = store.getTiddler("MarkupPreHead");
if(!existing || existing.fields["server.workspace"] != pubWorkspace) {
var tid = new Tiddler("MarkupPreHead");
tid.text = markupPreHead.format(currentSpace.name);
tid.tags = ["excludeLists"];
tid.fields = $.extend({}, config.defaultCustomFields);
tid.fields["server.workspace"] = pubWorkspace;
tid.fields["server.page.revision"] = "false";
tid = store.saveTiddler(tid);
autoSaveChanges(null, [tid]);
}
},
update: function(curVersion, flagTiddler) {
setupMarkupPreHead: function() {
var pubWorkspace = tiddlyspace.getCurrentWorkspace("public");
var existing = store.getTiddler("MarkupPreHead");
if(!existing || existing.fields["server.workspace"] != pubWorkspace) {
var tid = new Tiddler("MarkupPreHead");
tid.text = markupPreHead.format(currentSpace.name);
tid.tags = ["excludeLists"];
tid.fields = $.extend({}, config.defaultCustomFields);
tid.fields["server.workspace"] = pubWorkspace;
tid.fields["server.page.revision"] = "false";
tid = store.saveTiddler(tid);
autoSaveChanges(null, [tid]);
}
},
update: function(curVersion, flagTiddler) {