Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
Think of the [[Archive]] as a way to to mark tiddlers for export and eventually for deletion in the current wiki.
To delete archived tiddlers <html><a href="javascript:;" title="Click here to delete archived tiddlers." class="button" onclick="
var t,tgt,ca,ar,clean=[];
ar=store.getTaggedTiddlers('Archive');
for(ca=0;ca<ar.length;ca++){
tgt=store.getTaggedTiddlers(ar[ca].title);
for(t=0;t<tgt.length;t++)clean.pushUnique(tgt[t].title);
}
if(clean.length>0){
if(!confirm('Do you really want to delete '+clean.length+' archived items?\n'+clean))return;
for(t=0;t<clean.length;t++){
store.removeTiddler(clean[t]);
story.closeTiddler(clean[t],true);
}
story.refreshTiddler('clean archived...',null,true);
}else alert('Nothing to be deleted.');">
click here!</a></html> ...you will be asked to confirm tiddlers to be deleted.
Ask Eric to kindly integrate the {{title{notify mechanism}}} into the official GotoPlugin release. See the overwritten function {{title{processItem}}} at the bottom of both TagSearchPlugin and GotoPlugin, it's no more than two additional lines of code...
{{{
var n=here.getAttribute('notify');
if(n)n.call(this,title,here); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
}}}
That way, plugins can leverage the almighty searchbox of GotoPlugin and be notified of any selection!
{{{
Background:#FFF
Foreground:#000
PrimaryPale:#999
PrimaryLight:#777
PrimaryMid:#111
PrimaryDark:#000
SecondaryPale:#CCF
SecondaryLight:#9AF
SecondaryMid:#69C
SecondaryDark:#05A
TertiaryPale:#EEE
TertiaryLight:#CCC
TertiaryMid:#999
TertiaryDark:#333
Error:#F88
}}}
/***
|''Name:''|FE2|
|''Description:''|create, edit, view and delete commands in toolbar <<toolbar fields>>|
|''Version:''|1.0.2|
|''Date:''|Oct. 21,2009|
|''Source:''|http://tbGTD.tiddlyspot.com|
|''Author:''|Tobias Beer|
|''License:''|[[BSD open source license|License]]|
|''~CoreVersion:''|2.5.3|
|''Browser:''|Firefox 2.0; InternetExplorer 6.0, others|
!Note
This is a refactored version of [[FieldsEditorPlugin|http://visualtw.ouvaton.org/VisualTW.html#FieldsEditorPlugin]] by Pascal Collin
!Installation:
*import this tiddler, keep tagged as systemConfig, save and reload
!Code
***/
//{{{
//language settings for header, also see language options for macro.FE2 below!
config.commands.fields.lang={field:"field",actions:"actions",value:"value"};
config.commands.fields.handlePopup=function(popup,title){
addClass(popup,'FE2');
var tid=store.fetchTiddler(title);
if(!tid)return;
var t='[['+title+']]';
var fields={};
store.forEachField(tid,function(tid,field,v){fields[field]=v;},true);
var list=[];
for(var f in fields){
var e='[['+f+']]';
list.push({
field:f,
value:fields[f],
actions:"<<FE2 "+t+" rename "+e+">> <<FE2 "+t+" delete "+e+">> <<FE2 "+t+" edit "+e+">>"
});
}
list.sort(function(a,b){return a.field<b.field?-1:(a.field==b.field?0:+1);});
list.push({field:'',value:"",actions:"<<FE2 "+t+" create>>"});
var table=ListView.create(popup,list,{
columns:[
{name:'Field',field:'field',title:this.lang.field,type:'String'},
{name: 'Actions',field:'actions',title:this.lang.actions,type: 'WikiText'},
{name:'Value',field:'value',title:this.lang.value,type:'WikiText'}
],
rowClasses:[
{field:'actions'}
],
buttons:[ //can't use button for selected then delete, because click on checkbox will hide the popup
]
});
}
config.macros.FE2={
//language options
lang:{
'delete':'delete', //string since keyword!
rename:'<rename',
create:'Create a new field...',
edit:'edit>',
lineBreaks:"The field value contains linebreaks.\nEditing here will convert it to a single line!\nProceed?",
enterName:"Enter new field name...",
enterNewName:"Enter new name for '%1'...",
enterVal:"Enter field value for '%1'...",
enterNewVal:"Enter new value for '%1'..",
doDelete:"Delete field '%1' from tiddler '%2' ?",
existing:"This field already exists! "
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
if(!readOnly){
var tid=params[0];
var mode=params[1];
var field=params[2];
var btn=createTiddlyButton(place,this.lang[mode],this.lang[mode]+" "+field,this.clicked);
btn.setAttribute("tiddler",tid);
btn.setAttribute("field",field);
btn.setAttribute("mode",mode);
}
},
clicked:function(){
var lng=config.macros.FE2.lang;
var title=this.getAttribute("tiddler");
var field=this.getAttribute("field");
var mode=this.getAttribute("mode");
var tid=store.getTiddler(title);
if(!tid)return;
switch(mode){
case'create':
var first="";
do{
field=prompt(first+ lng.enterName,"");
first=lng.existing;
}while(store.getValue(tid,field));
if(field){
var v=prompt(lng.enterVal.replace(/%1/,field),"");
if(v)tid.fields[field]=v;else return;
}else return;
break;
case'delete':
if(confirm(lng.doDelete.replace(/%1/,field).replace(/%2/,title))){
delete tid.fields[field];
}else return;
break;
case'edit':
var v=tid.fields[field]||'';
if(!v.match(/\n/mg)||confirm(lng.lineBreaks)){
var v=prompt(lng.enterNewVal.replace(/%1/,field),v);
if(v||v=='')tid.fields[field]=v;else return;
}else return;
break;
case'rename':
var name=prompt(lng.enterNewName.replace(/%1/,field),field);
if(name){
tid.fields[name]=tid.fields[field];
delete tid.fields[field];
}else return;
break;
default:return;
}
store.saveTiddler(tid.title,tid.title,tid.text,tid.modifier,tid.modified,tid.tags,tid.fields);
story.refreshTiddler(title,null,true);
return false;
}
}
config.shadowTiddlers.StyleSheetFE2=
".FE2 td br{display:block;}\n"+
".FE2 td {font-size:12px;padding:1px 3px}\n"+
".FE2 .button {border:0;padding:0 0.2em;}\n"+
".FE2 .twtable,.FE2 .twtable thead, .FE2 .twtable tr{border:0}\n"+
".FE2 .twtable tr:hover{background:"+store.getTiddlerSlice('ColorPalette','TertiaryLight')+"}\n"+
".FE2 .twtable thead{font-size:13px;}";
store.addNotification("StyleSheetFE2",refreshStyles);
//}}}
Ufff, that one was a monster.
//{{{
//
// source: http://plugins.jquery.com/project/floatobject
//
// usage: jQuery(selector).makeFloat(params);
//
// where params is an object:
// x: number of pixels from the left of the window, or the string 'current' to use the current object location
// y: the same is x but for the Y axis
// speed: 'slow' , 'normal', 'fast'
//
// example: jQuery('#mydiv').makeFloat({x:'current',y:'100',speed:'normal'});
//
(function($){
/*----------------------------------------------------------------------------------
Class: FloatObject
-------------------------------------------------------------------------------------*/
function FloatObject(jqObj, params)
{
this.jqObj = jqObj;
switch(params.speed)
{
case 'fast': this.steps = 5; break;
case 'normal': this.steps = 10; break;
case 'slow': this.steps = 20; break;
default: this.steps = 10;
};
var offset = this.jqObj.offset();
this.currentX = (params.x.substr(0,5)=='right')?this.jqObj.css('right'):offset.left;
this.currentY = offset.top;
this.width = this.jqObj.width();
this.height = this.jqObj.height();
this.alwaysVisible = params.alwaysVisible;
this.alwaysTop = params.alwaysTop;
this.origX = typeof(params.x) == "string" ? this.currentX : params.x;
this.origY = typeof(params.y) == "string" ? this.currentY : params.y;
//now we make sure the object is in absolute positions.
this.jqObj.css({'position':'absolute' , 'top':this.currentY ,'left':this.currentX});
}
FloatObject.prototype.updateLocation = function()
{
this.updatedX = $(window).scrollLeft() + this.origX;
if( this.alwaysTop == false ){
this.updatedY = $(window).scrollTop()+ this.origY;
if( this.alwaysVisible ){
if( this.origX + this.width > this.windowWidth() )
this.updatedX = this.windowWidth() - this.width + $(window).scrollLeft();
if( this.origY + this.height > this.windowHeight() )
{
this.updatedY = $(window).scrollTop() + this.windowHeight() - this.height;
if( this.updatedY < this.origY ) this.updatedY = this.origY;
}
}
}
else
{
if( $(window).scrollTop() > this.origY )
{
this.updatedY = $(window).scrollTop() + 5;
}
else
{
this.updatedY = this.origY + 5;
}
}
this.dx = Math.abs(this.updatedX - this.currentX );
this.dy = Math.abs(this.updatedY - this.currentY );
return this.dx || this.dy;
}
FloatObject.prototype.windowHeight = function()
{
var de = document.documentElement;
return self.innerHeight ||
(de && de.clientHeight) ||
document.body.clientHeight;
}
FloatObject.prototype.windowWidth = function()
{
var de = document.documentElement;
return self.innerWidth ||
(de && de.clientWidth) ||
document.body.clientWidth;
}
FloatObject.prototype.move = function()
{
if( this.jqObj.css("position") != "absolute" ) return;
var cx = 0;
var cy = 0;
if( this.dx > 0 )
{
if( this.dx < this.steps / 2 )
cx = (this.dx >= 1) ? 1 : 0;
else
cx = Math.round(this.dx/this.steps);
if( this.currentX < this.updatedX )
this.currentX += cx;
else
this.currentX -= cx;
}
if( this.dy > 0 )
{
if( this.dy < this.steps / 2 )
cy = (this.dy >= 1) ? 1 : 0;
else
cy = Math.round(this.dy/this.steps);
if( this.currentY < this.updatedY )
this.currentY += cy;
else
this.currentY -= cy;
}
this.jqObj.css({'left':this.currentX, 'top': this.currentY });
}
/*----------------------------------------------------------------------------------
Object: floatMgr
-------------------------------------------------------------------------------------*/
$.floatMgr = {
FOArray: new Array() ,
timer: null ,
initializeFO: function(jqObj,params)
{
var settings = $.extend({
x: 0 ,
y: 0 ,
speed: 'normal' ,
alwaysVisible: false ,
alwaysTop: false},params||{});
var newFO = new FloatObject(jqObj,settings);
$.floatMgr.FOArray.push(newFO);
if( !$.floatMgr.timer ) $.floatMgr.adjustFO();
//now making sure we are registered to all required window events
if( !$.floatMgr.registeredEvents )
{
$(window).bind("resize", $.floatMgr.onChange);
$(window).bind("scroll", $.floatMgr.onChange);
$.floatMgr.registeredEvents = true;
}
} ,
adjustFO: function() {
$.floatMgr.timer = null;
var moveFO = false;
for( var i = 0 ; i < $.floatMgr.FOArray.length ; i++ )
{
FO = $.floatMgr.FOArray[i];
if( FO.updateLocation() ) moveFO = true;
}
if( moveFO )
{
for( var i = 0 ; i < $.floatMgr.FOArray.length ; i++ )
{
FO = $.floatMgr.FOArray[i];
FO.move();
}
if( !$.floatMgr.timer ) $.floatMgr.timer = setTimeout($.floatMgr.adjustFO,50);
}
} ,
stopFloatChk: false ,
onChange: function()
{
if( !$.floatMgr.timer && !$.floatMgr.stopFloatChk ) $.floatMgr.adjustFO();
}
};
/*----------------------------------------------------------------------------------
Function: makeFloat
-------------------------------------------------------------------------------------*/
$.fn.makeFloat = function(params) {
var obj = this.eq(0); //we only operate on the first selected object;
$.floatMgr.initializeFO(obj,params);
if( $.floatMgr.timer == null ) $.floatMgr.adjustFO();
return obj;
};
$.fn.stopFloat = function(params) {
$.floatMgr.stopFloatChk = true;
};
$.fn.restartFloat = function(params) {
$.floatMgr.stopFloatChk = false;
};
})(jQuery);
//}}}
/***
|Name|GotoPlugin|
|Source|http://www.TiddlyTools.com/#GotoPlugin|
|Documentation|http://www.TiddlyTools.com/#GotoPluginInfo|
|Version|1.9.2|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|view any tiddler by entering it's title - displays list of possible matches|
''View a tiddler by typing its title and pressing //enter//.'' As you type, a list of possible matches is displayed. You can scroll-and-click (or use arrows+enter) to select/view a tiddler, or press escape to close the listbox to resume typing. When the listbox is not displayed, pressing //escape// clears the current input.
!!!Documentation
>see [[GotoPluginInfo]]
!!!Configuration
<<<
*Match titles only after {{twochar{<<option txtIncrementalSearchMin>>}}} or more characters are entered.<br>Use down-arrow to start matching with shorter input. //Note: This option value is also set/used by [[SearchOptionsPlugin]]//.
*To set the maximum height of the listbox, you can create a tiddler tagged with <<tag systemConfig>>, containing:
//{{{
config.macros.gotoTiddler.listMaxSize=10; // change this number
//}}}
<<<
!!!Revisions
<<<
2009.05.22 [1.9.2] use reverseLookup() for IncludePlugin
|please see [[GotoPluginInfo]] for additional revision details|
2006.05.05 [0.0.0] started
<<<
!!!Code
***/
//{{{
version.extensions.GotoPlugin= {major: 1, minor: 9, revision: 2, date: new Date(2009,5,22)};
// automatically tweak shadow SideBarOptions to add <<gotoTiddler>> macro above <<search>>
config.shadowTiddlers.SideBarOptions=config.shadowTiddlers.SideBarOptions.replace(/<<search>>/,"{{button{goto}}}\n<<gotoTiddler>><<search>>");
if (config.options.txtIncrementalSearchMin===undefined) config.options.txtIncrementalSearchMin=3;
config.macros.gotoTiddler= {
listMaxSize: 10,
listHeading: 'Found %0 matching title%1...',
searchItem: "Search for '%0'...",
handler:
function(place,macroName,params,wikifier,paramString,tiddler) {
var quiet =params.contains("quiet");
var showlist =params.contains("showlist");
var search =params.contains("search");
params = paramString.parseParams("anon",null,true,false,false);
var instyle =getParam(params,"inputstyle","");
var liststyle =getParam(params,"liststyle","");
var filter =getParam(params,"filter","");
var html=this.html;
var keyevent=window.event?"onkeydown":"onkeypress"; // IE event fixup for ESC handling
html=html.replace(/%keyevent%/g,keyevent);
html=html.replace(/%search%/g,search);
html=html.replace(/%quiet%/g,quiet);
html=html.replace(/%showlist%/g,showlist);
html=html.replace(/%display%/g,showlist?'block':'none');
html=html.replace(/%position%/g,showlist?'static':'absolute');
html=html.replace(/%instyle%/g,instyle);
html=html.replace(/%liststyle%/g,liststyle);
html=html.replace(/%filter%/g,filter);
if (config.browser.isIE) html=this.IEtableFixup.format([html]);
var span=createTiddlyElement(place,'span');
span.innerHTML=html; var form=span.getElementsByTagName("form")[0];
if (showlist) this.fillList(form.list,'',filter,search,0);
},
html:
'<form onsubmit="return false" style="display:inline;margin:0;padding:0">\
<input name=gotoTiddler type=text autocomplete="off" accesskey="G" style="%instyle%"\
title="Enter title text... ENTER=goto, SHIFT-ENTER=search for text, DOWN=select from list"\
onfocus="this.select(); this.setAttribute(\'accesskey\',\'G\');"\
%keyevent%="return config.macros.gotoTiddler.inputEscKeyHandler(event,this,this.form.list,%search%,%showlist%);"\
onkeyup="return config.macros.gotoTiddler.inputKeyHandler(event,this,%quiet%,%search%,%showlist%);">\
<select name=list style="display:%display%;position:%position%;%liststyle%"\
onchange="if (!this.selectedIndex) this.selectedIndex=1;"\
onblur="this.style.display=%showlist%?\'block\':\'none\';"\
%keyevent%="return config.macros.gotoTiddler.selectKeyHandler(event,this,this.form.gotoTiddler,%showlist%);"\
onclick="return config.macros.gotoTiddler.processItem(this.value,this.form.gotoTiddler,this,%showlist%);">\
</select><input name="filter" type="hidden" value="%filter%">\
</form>',
IEtableFixup:
"<table style='width:100%;display:inline;padding:0;margin:0;border:0;'>\
<tr style='padding:0;margin:0;border:0;'><td style='padding:0;margin:0;border:0;'>\
%0</td></tr></table>",
getItems:
function(list,val,filter) {
if (!list.cache || !list.cache.length || val.length<=config.options.txtIncrementalSearchMin) {
// starting new search, fetch and cache list of tiddlers/shadows/tags
list.cache=new Array();
if (filter.length) {
var fn=store.getMatchingTiddlers||store.getTaggedTiddlers;
var tiddlers=store.sortTiddlers(fn.apply(store,[filter]),'title');
} else
var tiddlers=store.reverseLookup('tags','excludeLists');
for(var t=0; t<tiddlers.length; t++) list.cache.push(tiddlers[t].title);
if (!filter.length) {
for (var t in config.shadowTiddlers) list.cache.pushUnique(t);
var tags=store.getTags();
for(var t=0; t<tags.length; t++) list.cache.pushUnique(tags[t][0]);
}
}
var found = [];
var match=val.toLowerCase();
for(var i=0; i<list.cache.length; i++)
if (list.cache[i].toLowerCase().indexOf(match)!=-1) found.push(list.cache[i]);
return found;
},
getItemSuffix:
function(t) {
if (store.tiddlerExists(t)) return ""; // tiddler
if (store.isShadowTiddler(t)) return " (shadow)"; // shadow
return " (tag)"; // tag
},
fillList:
function(list,val,filter,search,key) {
if (list.style.display=="none") return; // not visible... do nothing!
var indent='\xa0\xa0\xa0';
var found = this.getItems(list,val,filter); // find matching items...
found.sort(); // alpha by title
while (list.length > 0) list.options[0]=null; // clear list
var hdr=this.listHeading.format([found.length,found.length==1?"":"s"]);
list.options[0]=new Option(hdr,"",false,false);
for (var t=0; t<found.length; t++) list.options[list.length]=
new Option(indent+found[t]+this.getItemSuffix(found[t]),found[t],false,false);
if (search)
list.options[list.length]=new Option(this.searchItem.format([val]),"*",false,false);
list.size=(list.length<this.listMaxSize?list.length:this.listMaxSize); // resize list...
list.selectedIndex=key==38?list.length-1:key==40?1:0;
},
keyProcessed:
function(ev) { // utility function
ev.cancelBubble=true; // IE4+
try{event.keyCode=0;}catch(e){}; // IE5
if (window.event) ev.returnValue=false; // IE6
if (ev.preventDefault) ev.preventDefault(); // moz/opera/konqueror
if (ev.stopPropagation) ev.stopPropagation(); // all
return false;
},
inputEscKeyHandler:
function(event,here,list,search,showlist) {
if (event.keyCode==27) {
if (showlist) { // clear input, reset list
here.value=here.defaultValue;
this.fillList(list,'',here.form.filter.value,search,0);
}
else if (list.style.display=="none") // clear input
here.value=here.defaultValue;
else list.style.display="none"; // hide list
return this.keyProcessed(event);
}
return true; // key bubbles up
},
inputKeyHandler:
function(event,here,quiet,search,showlist) {
var key=event.keyCode;
var list=here.form.list;
var filter=here.form.filter;
// non-printing chars bubble up, except for a few:
if (key<48) switch(key) {
// backspace=8, enter=13, space=32, up=38, down=40, delete=46
case 8: case 13: case 32: case 38: case 40: case 46: break; default: return true;
}
// blank input... if down/enter... fall through (list all)... else, and hide or reset list
if (!here.value.length && !(key==40 || key==13)) {
if (showlist) this.fillList(here.form.list,'',here.form.filter.value,search,0);
else list.style.display="none";
return this.keyProcessed(event);
}
// hide list if quiet, or below input minimum (and not showlist)
list.style.display=(!showlist&&(quiet||here.value.length<config.options.txtIncrementalSearchMin))?'none':'block';
// non-blank input... enter=show/create tiddler, SHIFT-enter=search for text
if (key==13 && here.value.length) return this.processItem(event.shiftKey?'*':here.value,here,list,showlist);
// up or down key, or enter with blank input... shows and moves to list...
if (key==38 || key==40 || key==13) { list.style.display="block"; list.focus(); }
this.fillList(list,here.value,filter.value,search,key);
return true; // key bubbles up
},
selectKeyHandler:
function(event,list,editfield,showlist) {
if (event.keyCode==27) // escape... hide list, move to edit field
{ editfield.focus(); list.style.display=showlist?'block':'none'; return this.keyProcessed(event); }
if (event.keyCode==13 && list.value.length) // enter... view selected item
{ this.processItem(list.value,editfield,list,showlist); return this.keyProcessed(event); }
return true; // key bubbles up
},
processItem:
function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
story.displayTiddler(null,title); // show selected tiddler
return false;
}
}
//}}}
/***
|Name:|HideWhenPlugin|
|Description:|Allows conditional inclusion/exclusion in templates|
|Version:|3.1 ($Rev: 3919 $)|
|Date:|$Date: 2008-03-13 02:03:12 +1000 (Thu, 13 Mar 2008) $|
|Source:|http://mptw.tiddlyspot.com/#HideWhenPlugin|
|Author:|Simon Baird <simon.baird@gmail.com>|
|License:|http://mptw.tiddlyspot.com/#TheBSDLicense|
For use in ViewTemplate and EditTemplate. Example usage:
{{{<div macro="showWhenTagged Task">[[TaskToolbar]]</div>}}}
{{{<div macro="showWhen tiddler.modifier == 'BartSimpson'"><img src="bart.gif"/></div>}}}
***/
//{{{
window.hideWhenLastTest = false;
window.removeElementWhen = function(test,place) {
window.hideWhenLastTest = test;
if (test) {
removeChildren(place);
place.parentNode.removeChild(place);
}
};
merge(config.macros,{
hideWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( eval(paramString), place);
}},
showWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !eval(paramString), place);
}},
hideWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAll(params), place);
}},
showWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAll(params), place);
}},
hideWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAny(params), place);
}},
showWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAny(params), place);
}},
hideWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAll(params), place);
}},
showWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAll(params), place);
}},
hideWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0]), place);
}},
showWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !(store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0])), place);
}},
hideWhenTitleIs: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.title == params[0], place);
}},
showWhenTitleIs: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.title != params[0], place);
}},
'else': { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !window.hideWhenLastTest, place);
}}
});
//}}}
/***
|Name:|LessBackupsPlugin|
|Description:|Intelligently limit the number of backup files you create|
|Version:|3.0.1 ($Rev: 2320 $)|
|Date:|$Date: 2007-06-18 22:37:46 +1000 (Mon, 18 Jun 2007) $|
|Source:|http://mptw.tiddlyspot.com/#LessBackupsPlugin|
|Author:|Simon Baird|
|Email:|simon.baird@gmail.com|
|License:|http://mptw.tiddlyspot.com/#TheBSDLicense|
!!Description
You end up with just backup one per year, per month, per weekday, per hour, minute, and second. So total number won't exceed about 200 or so. Can be reduced by commenting out the seconds/minutes/hours line from modes array
!!Notes
Works in IE and Firefox only. Algorithm by Daniel Baird. IE specific code by by Saq Imtiaz.
***/
//{{{
var MINS = 60 * 1000;
var HOURS = 60 * MINS;
var DAYS = 24 * HOURS;
if (!config.lessBackups) {
config.lessBackups = {
// comment out the ones you don't want or set config.lessBackups.modes in your 'tweaks' plugin
modes: [
["YYYY", 365*DAYS], // one per year for ever
["MMM", 31*DAYS], // one per month
["ddd", 7*DAYS], // one per weekday
//["d0DD", 1*DAYS], // one per day of month
["h0hh", 24*HOURS], // one per hour
//["m0mm", 1*HOURS], // one per minute
//["s0ss", 1*MINS], // one per second
["latest",0] // always keep last version. (leave this).
]
};
}
window.getSpecialBackupPath = function(backupPath) {
var now = new Date();
var modes = config.lessBackups.modes;
for (var i=0;i<modes.length;i++) {
// the filename we will try
var specialBackupPath = backupPath.replace(/(\.)([0-9]+\.[0-9]+)(\.html)$/,
'$1'+now.formatString(modes[i][0]).toLowerCase()+'$3')
// open the file
try {
if (config.browser.isIE) {
var fsobject = new ActiveXObject("Scripting.FileSystemObject")
var fileExists = fsobject.FileExists(specialBackupPath);
if (fileExists) {
var fileObject = fsobject.GetFile(specialBackupPath);
var modDate = new Date(fileObject.DateLastModified).valueOf();
}
}
else {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(specialBackupPath);
var fileExists = file.exists();
if (fileExists) {
var modDate = file.lastModifiedTime;
}
}
}
catch(e) {
// give up
return backupPath;
}
// expiry is used to tell if it's an 'old' one. Eg, if the month is June and there is a
// June file on disk that's more than an month old then it must be stale so overwrite
// note that "latest" should be always written because the expiration period is zero (see above)
var expiry = new Date(modDate + modes[i][1]);
if (!fileExists || now > expiry)
return specialBackupPath;
}
}
// hijack the core function
window.getBackupPath_mptw_orig = window.getBackupPath;
window.getBackupPath = function(localPath) {
return getSpecialBackupPath(getBackupPath_mptw_orig(localPath));
}
//}}}
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
major: 1, minor: 1, revision: 0,
date: new Date("mar 17, 2007"),
source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};
if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};
bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){
url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
}
return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
[[Home|Welcome]][[TagSearchPlugin]][[TagSearchConfig]][[ToolbarCommands]][[StyleSheetTagSearch]]
<html><a class="tiddlyLink tiddlyLinkExisting" href="javascript:;" onclick="window.scroll(0,0);">▲ to top ▲</a></html><<toolbar jump>><<rB ' ▲ jump to ▼'>><<closeAll>><<rB 'X close all X'>>
[[? help ?|MainMenu Help]]
Thanks to [[a jquery script|FloatObject]] this MainMenu is floatable. Floating is initiated in the PageTemplate via...
{{{<span macro="tiddler {{jQuery('#mainMenu').makeFloat({x:'current',y:65,speed:'fast'});'';}}"></span>}}}
//{{{
config.options.txtFadeTimer = 5000; // 5 seconds
window.displayMessage=function(text,linkText,fadeTimer) {
var e = getMessageDiv();
if(!e) {
alert(text);
return;
}
if(linkText) {
var link = createTiddlyElement(e,"a",null,null,text);
link.href = linkText;
link.target = "_blank";
} else {
e.appendChild(document.createTextNode(text));
}
if(config.options.txtFadeTimer > 0) {
setTimeout(clearMessage, config.options.txtFadeTimer);
}
}
//}}}
<!--{{{-->
<div class='header'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
<span class='toggleButton' refresh='content' tiddler='toggleLeft'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<div id='search' refresh='content' tiddler='Search'></div>
<span macro="tiddler {{jQuery('#mainMenu').makeFloat({x:'right:current',y:63,speed:'fast'});'';}}"></span>
<!--}}}-->
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
major: 1, minor: 0, revision: 2,
date: new Date("Apr 19, 2007"),
source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
coreVersion: '2.2.0 (Beta 5)'
};
config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");
merge(config.macros.option.types, {
'pas': {
elementType: "input",
valueField: "value",
eventName: "onkeyup",
className: "pasOptionInput",
typeValue: config.macros.option.passwordInputType,
create: function(place,type,opt,className,desc) {
// password field
config.macros.option.genericCreate(place,'pas',opt,className,desc);
// checkbox linked with this password "save this password on this computer"
config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);
// text savePasswordCheckboxLabel
place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
},
onChange: config.macros.option.genericOnChange
}
});
merge(config.optionHandlers['chk'], {
get: function(name) {
// is there an option linked with this chk ?
var opt = name.substr(3);
if (config.options[opt])
saveOptionCookie(opt);
return config.options[name] ? "true" : "false";
}
});
merge(config.optionHandlers, {
'pas': {
get: function(name) {
if (config.options["chk"+name]) {
return encodeCookie(config.options[name].toString());
} else {
return "";
}
},
set: function(name,value) {config.options[name] = decodeCookie(value);}
}
});
// need to reload options to load passwordOptions
loadOptionsCookie();
/*
if (!config.options['pasPassword'])
config.options['pasPassword'] = '';
merge(config.optionsDesc,{
pasPassword: "Test password"
});
*/
//}}}
/***
|Name:|QuickOpenTagPlugin|
|Description:|Changes tag links to make it easier to open tags as tiddlers|
|Version:|3.0.1 ($Rev: 3861 $)|
|Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $|
|Source:|http://mptw.tiddlyspot.com/#QuickOpenTagPlugin|
|Author:|Simon Baird <simon.baird@gmail.com>|
|License:|http://mptw.tiddlyspot.com/#TheBSDLicense|
@@color:red; ((modified for tbGTD(^mod by Tobias Beer ...optionally does not show ~QuickOpenTag-button if there are no tagging tiddlers)))@@
***/
//{{{
config.quickOpenTag = {
hideIfNoneTagging:true,
dropdownChar: "\u25be", //(document.all ? "\u25bc" : "\u25be"), // the little one doesn't work in IE?
createTagButton: function(place,tag,excludeTiddler) {
// little hack so we can do this: <<tag PrettyTagName|RealTagName>>
var splitTag = tag.split("|");
var pretty = tag;
if (splitTag.length == 2) {
tag = splitTag[1];
pretty = splitTag[0];
}
var sp = createTiddlyElement(place,"span",null,"quickopentag");
createTiddlyText(createTiddlyLink(sp,tag,false),pretty);
if(config.quickOpenTag.hideIfNoneTagging&&store.getTaggedTiddlers(tag).length==0)return; //tbGTD
var theTag = createTiddlyButton(sp,config.quickOpenTag.dropdownChar,
config.views.wikified.tag.tooltip.format([tag]),onClickTag);
theTag.setAttribute("tag",tag);
if (excludeTiddler)
theTag.setAttribute("tiddler",excludeTiddler);
return(theTag);
},
miniTagHandler: function(place,macroName,params,wikifier,paramString,tiddler) {
var tid=params[0]?params[0]:tiddler;
if (!store.getValue(tid,'nominitag')&&store.getTaggedTiddlers(tid.title).length>0) {
var theTag = createTiddlyButton(place,config.quickOpenTag.dropdownChar,
config.views.wikified.tag.tooltip.format([tid.title]),onClickTag);
theTag.setAttribute("tag",tid.title);
theTag.className = "miniTag";
}
},
allTagsHandler: function(place,macroName,params) {
var tags = store.getTags(params[0]);
var filter = params[1]; // new feature
var ul = createTiddlyElement(place,"ul");
if(tags.length == 0)
createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
for(var t=0; t<tags.length; t++) {
var title = tags[t][0];
if (!filter || (title.match(new RegExp('^'+filter)))) {
var info = getTiddlyLinkInfo(title);
var theListItem =createTiddlyElement(ul,"li");
var theLink = createTiddlyLink(theListItem,tags[t][0],true);
var theCount = " (" + tags[t][1] + ")";
theLink.appendChild(document.createTextNode(theCount));
var theDropDownBtn = createTiddlyButton(theListItem," " +
config.quickOpenTag.dropdownChar,this.tooltip.format([tags[t][0]]),onClickTag);
theDropDownBtn.setAttribute("tag",tags[t][0]);
}
}
},
// todo fix these up a bit
styles: [
"/*{{{*/",
"/* created by QuickOpenTagPlugin */",
".tagglyTagged .quickopentag, .tagged .quickopentag {margin-right:1.2em; border:1px solid [[ColorPalette::TertiaryPale]]; padding:2px 0 2px 1px;}",
".quickopentag .tiddlyLink, .quickopentag a.button {padding:1px;margin:0;}",
".miniTag:hover {background:[[ColorPalette::SecondaryLight]]}",
"#displayArea .viewer .quickopentag a.button, ",
"#displayArea .viewer .quickopentag a.tiddyLink {border:0px solid [[ColorPalette::Foreground]];}",
"/*}}}*/",
""].join("\n"),
init: function() {
// we fully replace these builtins. can't hijack them easily
window.createTagButton = this.createTagButton;
config.macros.allTags.handler = this.allTagsHandler;
config.macros.miniTag = { handler: this.miniTagHandler };
config.shadowTiddlers["StyleSheetQuickOpenTag"] = this.styles;
store.addNotification("StyleSheetQuickOpenTag",refreshStyles);
}
}
config.quickOpenTag.init();
//}}}
/***
|Name:|RenameTagsPlugin|
|Description:|Allows you to easily rename or delete tags across multiple tiddlers|
|Version:|3.0 ($Rev: 3861 $)|
|Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $|
|Source:|http://mptw.tiddlyspot.com/#RenameTagsPlugin|
|Author:|Simon Baird <simon.baird@gmail.com>|
|License|http://mptw.tiddlyspot.com/#TheBSDLicense|
Rename a tag and you will be prompted to rename it in all its tagged tiddlers.
***/
//{{{
config.renameTags = {
prompts: {
rename: "Rename the tag '%0' to '%1' in %2 tidder%3?",
remove: "Remove the tag '%0' from %1 tidder%2?"
},
removeTag: function(tag,tiddlers) {
store.suspendNotifications();
for (var i=0;i<tiddlers.length;i++) {
store.setTiddlerTag(tiddlers[i].title,false,tag);
}
store.resumeNotifications();
store.notifyAll();
},
renameTag: function(oldTag,newTag,tiddlers) {
store.suspendNotifications();
for (var i=0;i<tiddlers.length;i++) {
store.setTiddlerTag(tiddlers[i].title,false,oldTag); // remove old
store.setTiddlerTag(tiddlers[i].title,true,newTag); // add new
}
store.resumeNotifications();
store.notifyAll();
},
storeMethods: {
saveTiddler_orig_renameTags: TiddlyWiki.prototype.saveTiddler,
saveTiddler: function(title,newTitle,newBody,modifier,modified,tags,fields) {
if (title != newTitle) {
var tagged = this.getTaggedTiddlers(title);
if (tagged.length > 0) {
// then we are renaming a tag
if (confirm(config.renameTags.prompts.rename.format([title,newTitle,tagged.length,tagged.length>1?"s":""])))
config.renameTags.renameTag(title,newTitle,tagged);
if (!this.tiddlerExists(title) && newBody == "")
// dont create unwanted tiddler
return null;
}
}
return this.saveTiddler_orig_renameTags(title,newTitle,newBody,modifier,modified,tags,fields);
},
removeTiddler_orig_renameTags: TiddlyWiki.prototype.removeTiddler,
removeTiddler: function(title) {
var tagged = this.getTaggedTiddlers(title);
if (tagged.length > 0)
if (confirm(config.renameTags.prompts.remove.format([title,tagged.length,tagged.length>1?"s":""])))
config.renameTags.removeTag(title,tagged);
return this.removeTiddler_orig_renameTags(title);
}
},
init: function() {
merge(TiddlyWiki.prototype,this.storeMethods);
}
}
config.renameTags.init();
//}}}
<<toggleSideBarTB right hide>><<gotoTiddler search liststyle:"display:block;position:absolute;right:0em;top:20px;z-index:100;border:1px solid #ccc;padding:0;width:auto;display:none;">>
<<permaview>><<newTiddler>><<tiddler TspotSidebar>><<slider chkSliderOptionsPanel OptionsPanel "options »" "Change TiddlyWiki advanced options">>
<<slider chkSidebarTabs SideBarTabs##SHOW "lists »" "show SideBarTabs">><<tiddler {{
jQuery('#sidebarTabs > a').addClass('buttontabs');
'';}}>>/%
!SHOW
<<tabs txtMainTab recent "list tiddlers by date" SideBarTabs##RECENT tags "list of tags" TabTags more "standard lists and more" TabMore>>
!RECENT
{{recent{<<timeline "modified" "17" "YYYY-0MM-0DD">>
----
@@padding-left:10px;[[::Complete Timeline::|Timeline]]@@}}}
!end%/
/***
|''Name''|SimpleSearchPlugin|
|''Description''|displays search results as a simple list of matching tiddlers|
|''Authors''|FND|
|''Version''|0.4.1|
|''Status''|stable|
|''Source''|http://devpad.tiddlyspot.com/#SimpleSearchPlugin|
|''CodeRepository''|http://svn.tiddlywiki.org/Trunk/contributors/FND/plugins/SimpleSearchPlugin.js|
|''License''|[[Creative Commons Attribution-ShareAlike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|''Keywords''|search|
!Code
***/
//{{{
if(!version.extensions.SimpleSearchPlugin) { //# ensure that the plugin is only installed once
version.extensions.SimpleSearchPlugin = { installed: true };
if(!config.extensions) { config.extensions = {}; }
config.extensions.SimpleSearchPlugin = {
heading: "Search Results",
containerId: "searchResults",
btnCloseLabel: "close",
btnCloseTooltip: "dismiss search results",
btnCloseId: "search_close",
btnOpenLabel: "open all",
btnOpenTooltip: "open all search results",
btnOpenId: "search_open",
displayResults: function(matches, query) {
story.refreshAllTiddlers(true); // update highlighting within story tiddlers
var el = document.getElementById(this.containerId);
query = '"""' + query + '"""'; // prevent WikiLinks
if(el) {
removeChildren(el);
} else { //# fallback: use displayArea as parent
var container = document.getElementById("displayArea");
el = document.createElement("div");
el.id = this.containerId;
el = container.insertBefore(el, container.firstChild);
}
var msg = "!" + this.heading + "\n";
if(matches.length > 0) {
msg += "''" + config.macros.search.successMsg.format([matches.length.toString(), query]) + ":''\n";
this.results = [];
for(var i = 0 ; i < matches.length; i++) {
this.results.push(matches[i].title);
msg += "* [[" + matches[i].title + "]]\n";
}
} else {
msg += "''" + config.macros.search.failureMsg.format([query]) + "''"; // XXX: do not use bold here!?
}
createTiddlyButton(el, this.btnCloseLabel, this.btnCloseTooltip, config.extensions.SimpleSearchPlugin.closeResults, "button", this.btnCloseId);
if(matches.length > 0) { // XXX: redundant!?
createTiddlyButton(el, this.btnOpenLabel, this.btnOpenTooltip, config.extensions.SimpleSearchPlugin.openAll, "button", this.btnOpenId);
}
wikify(msg, el);
},
closeResults: function() {
var el = document.getElementById(config.extensions.SimpleSearchPlugin.containerId);
removeNode(el);
config.extensions.SimpleSearchPlugin.results = null;
highlightHack = null;
},
openAll: function(ev) {
story.displayTiddlers(null, config.extensions.SimpleSearchPlugin.results);
return false;
}
};
// override Story.search()
Story.prototype.search = function(text, useCaseSensitive, useRegExp) {
highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(), useCaseSensitive ? "mg" : "img");
var matches = store.search(highlightHack, null, "excludeSearch");
var q = useRegExp ? "/" : "'";
config.extensions.SimpleSearchPlugin.displayResults(matches, q + text + q);
};
// override TiddlyWiki.search() to sort by relevance
TiddlyWiki.prototype.search = function(searchRegExp, sortField, excludeTag, match) {
var candidates = this.reverseLookup("tags", excludeTag, !!match);
var primary = [];
var secondary = [];
var tertiary = [];
for(var t = 0; t < candidates.length; t++) {
if(candidates[t].title.search(searchRegExp) != -1) {
primary.push(candidates[t]);
} else if(candidates[t].tags.join(" ").search(searchRegExp) != -1) {
secondary.push(candidates[t]);
} else if(candidates[t].text.search(searchRegExp) != -1) {
tertiary.push(candidates[t]);
}
}
var results = primary.concat(secondary).concat(tertiary);
if(sortField) {
results.sort(function(a, b) {
return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);
});
}
return results;
};
} //# end of "install only once"
//}}}
/*{{{*/
/*
BigRound:-moz-border-radius:15px; -webkit-border-radius:15px;border-radius:15px;
*/
.header{height:5.5em;border-bottom:5px solid [[ColorPalette::SecondaryDark]];}
.headerForeground{display:none;}
.headerForeground, .headerShadow{padding:1em;margin:0;}
.headerShadow,.headerShadow .tiddlyLink{color:white;}
.siteTitle{padding-left:10px;}
.siteSubtitle{padding-left:3em;}
.headerShadow .tiddlyLink:hover{text-decoration:underline;}
.top{float:right;margin-top:10px;display:none;}
#displayArea {clear:both;margin-left:18em;}
#messageArea {background:[[ColorPalette::TertiaryPale]];position:absolute;top:5px;left:35%;padding:1em 1%;margin:0 0 0 1%;width:35%;border:3px solid [[ColorPalette::TertiaryLight]];-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;background:[[ColorPalette::MsgLo]];}
#messageArea .messageToolbar {display:block;float:right;padding:0.1em;text-align:right;width:60px;}
#messageArea a, #messageArea .button {background:transparent;text-decoration:none;color:[[ColorPalette::TertiaryDark]];border:0;}
#messageArea a:hover{color:black;border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
#backstageToolbar {text-align:center;}
#mainMenu{width:15em;padding-top:2.5em;position:absolute;top:63px;left:0;}
#mainMenu .tiddlyLink, #mainMenu .button, .toolbar .button, #sidebarOptions .button, #searchResults .button, .buttontabs{line-height:1em;font-size:14px;display:block;text-align:center;color:[[ColorPalette::Background]] !important;font-weight:bold;background:[[ColorPalette::SecondaryMid]];padding:10px;margin:0 0 5px 0;[[StyleSheet::BigRound]]}
#mainMenu .tiddlyLink:hover, #mainMenu .button:hover, .toolbar .button:hover, #sidebarOptions .button:hover, #searchResults .button:hover, .buttontabs:hover{background:[[ColorPalette::SecondaryDark]];color:[[ColorPalette::Background]];}
.toolbar .button{display:inline-block;margin-bottom:0;}
#sidebar{width:19em;margin-top:2em;margin-right:1em;}
#sidebarTabs .tabContents {width:17em;}
#sidebarOptions{padding:0.3em 0.3em 0 0.3em;}
#sidebarTabs{padding:0 0.3em 0.3em 0.3em;}
#sidebarOptions .sliderPanel {padding-top:15px;background:[[ColorPalette::TertiaryPale]];border:1px solid [[ColorPalette::TertiaryLight]];font-size:110%;margin:0 0 5px 0;[[StyleSheet::BigRound]]}
#sidebar .txtOptionInput,#sidebar .pasOptionInput{display:block;width:12em;}
.button{cursor:pointer;}
a{color:[[ColorPalette::TertiaryDark]];font-weight:normal;}
a:hover{color:[[ColorPalette::SecondaryDark]];background:none;}
#search{position:absolute;top:2.2em;right:2em;background:transparent;z-index;100;width:265px;height:20px;}
#search input{float:right;clear:none;display:inline;position:absolute;right:0;top:0;display:inline;border:1px solid #ccc;padding:0px;width:180px;z-index:0;margin-left:5px;}
#search .button, .toggleButton .button {background:none;border:0;color:#eee;font-size:115%;font-weight:bold;padding:3px 2em;}
.viewer .button{padding:1px 3px;margin:0 1px;background:[[ColorPalette::SecondaryPale]];border-color:[[ColorPalette::SecondaryMid]];}
#searchResults{margin:2em 1em 0 1em;background:[[ColorPalette::TertiaryPale]];padding:1em;[[StyleSheet::BigRound]]}
#searchResults .button {float:right;}
.viewer .button {padding:0 1px;}
.tiddler{margin-bottom:2em;}
.viewer{margin-top:1em;}
.marked{background:[[ColorPalette::SecondaryPale]];padding:0 2px;}
.selected .tagged, .tagged, .selected .tagging, .tagging{background:none;border:none;list-style-type:circle;}
.tagging li{margin-left:15px;list-style-type:circle;}
.tagged .listTitle, .tagging .listTitle{list-style-type:none;margin-bottom:3px;color:[[ColorPalette::SecondaryDark]];}
.tagging ul, .tagging li, .tagging li a {display:block;width:100%;}
.tagging ul{padding-right:100px;}
.tagging li a{border:1px solid transparent;border-left-width:0;border-right-width:0;}
.tagging li a:hover{border-color:[[ColorPalette::SecondaryLight]];}
.subtag a{font-size:120%;color:[[ColorPalette::SecondaryDark]];}
.noTitle .listTitle{display:none;}
.strong{font-size:1.5em;}
.hastags{font-weight:bold !important;color:[[ColorPalette::SecondaryDark]] !important;}
/*}}}*/
Provides configuration for TagSearchPlugin...
!Tags
[[Priority]]
[[Action]]
[[Project]]
[[Contact]]
[[Many]]
!More
[[TAG:Archive]]
[[Journal]]
[[Reference]]
[[systemConfig]]
[[systemConfigDisable]]
[[excludeMissing]]
[[excludeSearch]]
[[excludeLists]]
[[TagSearchLegacy]]
<<tiddler Show with: {{
var f=true,v,s='',t,ti,ts=store.getTaggedTiddlers('TagSearchLegacy');
for(t=0;t<ts.length;t++){
ti=ts[t].title;
v=store.getTiddlerText(ti+'::Version');
s+=(f?'':'\n')+'* [['+v+'|'+ti+']]';
f=false;
}
ti="TagSearchPlugin";
s+='\n* [['+store.getTiddlerText(ti+'::Version')+'|'+ti+']]';
s;}}>>
/***
|''Name:''|TagSearchPlugin|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Author:''|[[Tobias Beer]]|
|''Version:''|1.2.0 (2010-10-10)|
|''Documentation:''|http://tagsearch.tiddlyspot.com|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''~TiddlyWiki:''|Version 2.5 or better|
/%***/
(function(e){config.macros.tagsearch={cfg:{defaultSource:"",defaultMore:"",defaultMode:1,keepModified:false,sidebarOffset:20,newAtSingle:30,newAt:18,excludeTagged:"",toolbar:"",label:"tags",options:"Options",more:"More...",tooltip:"Manage tiddler tags",notags:"no tags set...",aretags:"Current tags",addTag:"Add tag...",addTags:"Set tag...",txtEdit:"~ edit categories...",txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",txtNew:"~ add another tag",txtRemove:"remove tag %0",txtAdd:"set tag %0",txtFor:"To be tagged... ",txtCtrl:" (hold SHIFT to just add it or CTRL to replace in category)",promptNew:"Enter new tag:",modeAsk:"Do you want to remove existing tags from category '%0'?\nCancel simply adds tag '%1'."},handler:function(k,g,i,l,h,n){var m=this.cfg,j=story.findContainingTiddler(k),f=h.parseParams("tagman",null,true);e(createTiddlyButton(k,getParam(f,"label",m.label),getParam(f,"tooltip",m.tooltip),this.click,"button")).attr({id:this.newId("btntgs"),tid:(j?j.getAttribute("tiddler"):"")}).data({pa:i,p:f})},click:function(O){var k,G,S,R,K=[],w=true,W,V,U,M,A,Y,T,D,N,L,J=[],C,f,H,aa=O||window.event,X=e(this),F=X.attr("popup"),B=window.event?"keydown":"keypress",I=config.macros.tagsearch,ab=I.cfg,u=X.data("pa"),Q=X.data("p"),h=u.contains("toolbar"),v=getParam(Q,"source",ab.defaultSource),q=getParam(Q,"more",ab.defaultMore),Z=!u.contains("nosearch"),z=!u.contains("notags"),E=!u.contains("nomore"),n=getParam(Q,"goto",""),o=parseInt(getParam(Q,"mode")),g=getParam(Q,"tiddler",""),r=g?g:X.attr("tid"),ac=(getParam(Q,"exclude","")+" "+ab.excludeTagged).readBracketedList(),y=nu=v?ab.newAt:ab.newAtSingle,P=store.getTiddler(r);if(!r){return}o=isNaN(o)?ab.defaultMode:o;ac.map(function(i){K.pushUnique(i)});for(W=0;W<ac.length;W++){store.getTaggedTiddlers(ac[W]).map(function(i){K.pushUnique(i.title)})}if(v&&!store.getTiddlerText(v)){return false}if(F){D=e("#"+F)[0];e(D).empty()}if(!D){M=true;F=I.newId("tgspop");D=Popup.create(this);e(D).addClass("tgs").attr({id:F}).data({btn:X,tiddler:r,source:v,mode:o}).click(I.noBubble);X.attr("popup",F)}if(v){C=store.getTiddlerText(v).readBracketedList();for(L=0;L<C.length;L++){if(!K.contains(C[L])){H=store.getTaggedTiddlers(C[L]);J.push("TAG:"+C[L]);for(N=0;N<H.length;N++){if(!K.contains(H[N].title)){J.push(H[N].title)}}}}}else{J=store.getTags()}G=P?P.tags.sort():[];Y=function(j,i){return createTiddlyElement(createTiddlyElement(j,"li",null,null),"ol",null,i?i:null)};A=function(j,x,i,p){var m,l;m=createTiddlyElement(createTiddlyElement(j,"li"),"span",null,null);l=e(createTiddlyButton(m,x,p.format(["'"+i+"'"]),I.setTag,"button toggleButton",null));l.data({tiddler:r,tag:i,source:v,mode:o});insertSpacer(m);createTagButton(m,i)};S=Y(D,"tgside");if(config.macros.gotoTiddler&&Z){R=Y(S);if(g){U=createTiddlyElement(R,"li",null,"addto","");wikify("{{title{"+ab.txtFor+"}}}<<tag [["+r+"]]>>",U);R=Y(S)}createTiddlyElement(R,"li",null,"title",ab.addTag);wikify("<<gotoTiddler "+n+" >>",R);e("input",D).bind(B,I.noBubble).data("notify",config.macros.tagsearch.notify).focus()}R=Y(S);createTiddlyElement(R,"li",null,"title",ab.aretags);if(G.length==0){wikify("{{notags{"+ab.notags+"}}}",R)}else{for(L=0;L<G.length;L++){A(R,"[X]",G[L],ab.txtRemove)}}if(z){for(W=0;W<J.length;W++){nu++;f=v?J[W]:J[W][0];if(f.indexOf("TAG:")==0){f=f.substr(4);if(nu>y){nu=0;S=Y(D)}R=Y(S);nu++;createTiddlyLink(createTiddlyElement(R,"li",null,null),f,f,"title")}else{if(!G.contains(f)&&!K.contains(f)){if(!v&&nu>y||v&&nu>ab.newAtSingle){nu=0;S=Y(D);R=Y(S);if(w){createTiddlyElement(createTiddlyElement(R,"li",null,null),"li",null,"title",ab.addTags);w=false}}A(R,"["+String.fromCharCode(160,160,160)+"]",f,ab.txtAdd+(v?ab.txtCtrl:""))}}}}if(E){S=Y(D,"tgside");R=Y(S);createTiddlyElement(R,"li",null,"title",ab.options,null);createTiddlyButton(createTiddlyElement(R,"li"),ab.txtNew,null,I.setTag,"tsopt",null,null,{tiddler:r});if(v){createTiddlyButton(createTiddlyElement(R,"li"),ab.txtEdit,ab.txtEditTip,onClickTiddlerLink,"tsopt",null,null,{tiddlyLink:v.split("##")[0]})}w=true;if(q){T=store.getTiddlerText(q).readBracketedList();if(T.length>0){for(W=0;W<T.length;W++){f=T[W];if(f.indexOf("TAG:")==0){f=f.substr(4,f.length-4);R=Y(S);createTiddlyLink(createTiddlyElement(R,"li",null,null),f,f,"title");k=store.getTaggedTiddlers(f);for(V=0;V<k.length;V++){f=k[V].title;if(!G.contains(f)&&!K.contains(f)){A(R,"["+String.fromCharCode(160,160)+"]",f,ab.txtAdd)}}}else{if(w){R=Y(S);createTiddlyElement(R,"li",null,"title",ab.more);w=false}if(!G.contains(f)&&!K.contains(f)){A(R,"["+String.fromCharCode(160,160)+"]",f,ab.txtAdd)}}}}}}if(M){Popup.show(D,false);if(h){N=document.getElementById("sidebar");D.style.left="";D.style.right=(ab.sidebarOffset+(N?N.offsetWidth:0))+"px"}}return I.noBubble(aa)},setTag:function(w){var q,j,z,l=true,n,u,s,g,v=w||window.event,k=config.macros.tagsearch,y=k.cfg,f=e(this),o=f.closest(".tgs"),i=o.data("btn"),A=f.data("tag"),B=o.data("tiddler"),h=o.data("source"),r=parseInt(o.data("mode"));if(!A){z=prompt(y.promptNew,"");if(!z){return false}else{A=z}}tid=k.exists(B,A);if(tid){u=tid.tags;if(!u.contains(A)){if(h&&r<2&&!v.shiftKey){j=store.getTiddlerText(h).readBracketedList();findTagged:for(q=0;q<j.length;q++){g=j[q];s=store.getTaggedTiddlers(g).map(function(m){return m.title});if(s.contains(A)){s.splice(s.indexOf(A),1);if(!v.ctrlKey&&r==1&&u.containsAny(s)){l=confirm(y.modeAsk.format([g,A]))}if(l){for(n=0;n<s.length;n++){g=s[n];if(u.contains(g)){store.setTiddlerTag(B,false,g)}}}break findTagged}}}store.setTiddlerTag(B,true,A)}else{if(!z){store.setTiddlerTag(B,false,A)}}n=store.getTiddler(B);store.saveTiddler(B,B,n.text,y.keepModified?n.modifier:config.options.txtUserName,y.keepModified?n.modified:new Date(),n.tags,n.fields)}if(config.options.chkAutoSave){autoSaveChanges()}i.click();o.find("input").focus();return k.noBubble(v)},newId:function(f){return f+Math.random().toString().substr(3)},notify:function(f,h){var j=e(h).closest(".tgs"),g=e("form input",j)[0];t=config.macros.tagsearch.exists(j.data("tiddler"),f);if(t&&!t.tags.contains(f)){store.setTiddlerTag(t.title,t,f)}j.data("btn").click();g.select()},exists:function(i,g){if(!store.getTiddler(i)){var h=merge({},config.defaultCustomFields);store.saveTiddler(i,i,"",config.options.txtUserName,new Date(),g,h);return false}return store.getTiddler(i)},noBubble:function(g){var h=g||window.event,f=resolveTarget(h);if(h.keyCode==27){Popup.remove(0)}else{if(h.type!="click"&&f.nodeName.toUpperCase()=="INPUT"){return true}}if(hasClass(f,"tiddlyLink")){return true}Popup.remove(1);h.cancelBubble=true;try{event.keyCode=0}catch(h){}if(window.event){h.returnValue=false}if(h.preventDefault){h.preventDefault()}if(h.stopPropagation){h.stopPropagation()}return false}};config.commands.tagSearch={};var d=config.macros.toolbar;d.createCommandTAGS=d.createCommand;d.createCommand=function(f,h,g,i){if(h=="tagSearch"){wikify("<<tagsearch toolbar "+config.macros.tagsearch.cfg.toolbar+">>",f);e(f.lastChild).attr({commandName:"tagSearch",tiddler:g.title})}else{d.createCommandTAGS.apply(this,arguments)}};var b=config.macros.gotoTiddler;if(b){b.processItem=function(i,g,h,f){if(!i.length){return}h.style.display=f?"block":"none";if(i=="*"){story.search(g.value);return false}if(!f){g.value=i}var j=e(g).data("notify");if(j){j.call(this,i,g)}else{story.displayTiddler(null,i)}return false};b.IEtableFixup="%0"}var c=store.getTiddlerText("ColorPalette::TertiaryMid"),a=store.getTiddlerText("ColorPalette::TertiaryDark");config.shadowTiddlers.StyleSheetTagSearch="/*{{{*/\n.tgs {padding:7px !important;-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n.tgs li a, .tgs .quickopentag .tiddlyLink {display:inline;padding:2px;clear:none;}\n.tgs li a.toggleButton {display:inline;margin-left:5px;}\n.tgs .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+c+";padding:0;}\n.tgs form{display:block;float:left;clear:both;padding-left:5px !important;}\n.tgs .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n.tgs .notags, .tsopt{display:block;clear:both;margin:5px;}\n.tgs .highlight{background:"+a+";}\n.tgs ol{margin:0;padding:0 0 5px 0;}\n.tgs li{display:block;float:left;padding-bottom:10px !important;}\n.tgs li span{line-height:1em;}\n.tgs li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n.tgs li ol li:hover{border:1px solid "+c+";}\n.tgs li ol li ol li{padding:0 !important;}\n.tgs li ol li ol li:hover{border:1px solid transparent;}\n.tgside li ol li {min-width:150px;}.tgs .quickopentag {display:inline;}\n.tgs .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n.tgs .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n/*}}}*/";store.addNotification("StyleSheetTagSearch",refreshStyles)})(jQuery);
//%/
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.0 (2010-09-03)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set.|
|''~TiddlyWiki:''|Version 2.5 or better|
Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]]. For more info see [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]. For configuration options for [[GotoPlugin]] (limiting results, etc.) ...[[see documentation|Welcome]].
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
archive:'', //archive tag
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
txtRemove: 'remove tag',
txtEdit:"edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var arv,c,click,e,ex=[],goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",'');
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
arv=getParam(p,"archive",c.archive);
tid=rtid=getParam(p,"tiddler");
if(!tid){
if(tiddler)tid=tiddler.title;
else {
tid=story.findContainingTiddler(place);
tid=tid?tid.getAttribute('tiddler'):'';
}
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,d1,d2,i,curr,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
[['tiddler',tid],['tag',tag],['source',src],['mode',mode],['open',open]].map(function(a){t.setAttribute(a[0],a[1]);});
insertSpacer(s);
if(window.createTagButton_orig_mptw)createTagButton_orig_mptw(s,tag);
else createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[x]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){nu=0;d1=nuLi(pop);d2=nuLi(d1);}
nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag);
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink);
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
//archive
ti=arv;
if(ti){
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(i=0;i<ar.length;i++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);
for(i=0;i<m.length;i++){var ti=m[i];
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebar');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,tid?tid.fields:null);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch a {color:"+TD+";}\n"+
".tagsearch form{display:block !important;}\n"+
".tagsearch .added{display:block;padding:5px;clear:both;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{padding:3px;clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch li a{display:inline;float:left;}\n"+
".tagsearch .tiddlyLink:hover{background:transparent;}\n"+
".tagsearch .quickopentag {width:80%;display:inline-block;float:left;}\n"+
".tagsearch .quickopentag .tiddlyLink {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {display:inline;border:0;padding:1px 3%;text-align:center;width:10%;font-size:11px;font-size:110%;}\n"+
".tagsearch a.button{padding:0;}\n"+
".tagsearch a.toggleButton {display:inline;padding:0 2px;margin-right:1px; font-size:110%;}\n"+
".tagsearch .title {font-weight:bold;font-size:150%;color:"+SD+";margin:0;padding:0;}\n"+
".tagsearch .addto .title, .tagsearch .addto .tiddlyLink{clear:both;display:block;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.1 (2010-09-04)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set.|
|''~TiddlyWiki:''|Version 2.5 or better|
Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]]. For more info see [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]. For configuration options for [[GotoPlugin]] (limiting results, etc.) ...[[see documentation|Welcome]].
!Version Information
1.0.1 tried to fix bugs in StyleSheetTagSearch
1.0.0 initial Release
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
archive:'', //archive tag
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var arv,c,click,e,ex=[],goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",'');
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
arv=getParam(p,"archive",c.archive);
tid=rtid=getParam(p,"tiddler");
if(!tid){
if(tiddler)tid=tiddler.title;
else {
tid=story.findContainingTiddler(place);
tid=tid?tid.getAttribute('tiddler'):'';
}
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,d1,d2,i,curr,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
wikify('<<tag [['+tag+']]>>',s);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){nu=0;d1=nuLi(pop);d2=nuLi(d1);}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
//archive
ti=arv;
if(ti){
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(i=0;i<ar.length;i++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);
for(i=0;i<m.length;i++){var ti=m[i];
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebar');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,tid?tid.fields:null);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;width:"+config.macros.tagsearch.cfg.colWidth+"}\n"+
".tagsearch form input, .tagsearch .tsoption {margin-left:5px;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.2 (2010-09-05)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set.|
|''~TiddlyWiki:''|Version 2.5 or better|
Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]]. For more info see [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]. For configuration options for [[GotoPlugin]] (limiting results, etc.) ...[[see documentation|Welcome]].
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
defaultMore:'', //the default for the more section
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c,click,e,ex=[],goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",c.defaultMore);
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
tid=rtid=getParam(p,"tiddler");
if(!tid){
if(tiddler)tid=tiddler.title;
else {
tid=story.findContainingTiddler(place);
tid=tid?tid.getAttribute('tiddler'):'';
}
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,curr,d1,d2,fst=true,i,j,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){nu=0;d1=nuLi(pop);d2=nuLi(d1);}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
var ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}else{
if(fst){d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebar');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,tid?tid.fields:null);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;padding-left:5px !important;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.3 (2010-09-07)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|See [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]|
|''~TiddlyWiki:''|Version 2.5 or better|
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
defaultMore:'', //the default for the more section
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
addTags:'Set tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c,click,e,ex=[],goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,tmp,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",c.defaultMore);
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
tid=rtid=getParam(p,"tiddler");
if(!tid){
do{tid=tmp;tmp=story.findContainingTiddler(place);}while(tmp&&tid!=tmp);
tid=tid?tid.getAttribute('tiddler'):'';
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,curr,d1,d2,fst=true,i,j,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nuLi(pop);d2=nuLi(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,"li",null,null),'li',null,'title',c.addTags);fst=false;}
}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
fst=true;
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
var ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}else{
if(fst){d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebarTabs');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,tid?tid.fields:null);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;padding-left:5px !important;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.4 (2010-09-07)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|See [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]|
|''~TiddlyWiki:''|Version 2.5 or better|
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
defaultMore:'', //the default for the more section
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
addTags:'Set tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c,click,e,ex=[],goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,tmp,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",c.defaultMore);
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
tid=rtid=getParam(p,"tiddler");
if(!tid){
do{tid=tmp;tmp=story.findContainingTiddler(place);}while(tmp&&tid!=tmp);
tid=tid?tid.getAttribute('tiddler'):'';
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,curr,d1,d2,fst=true,i,j,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nuLi(pop);d2=nuLi(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,"li",null,null),'li',null,'title',c.addTags);fst=false;}
}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
fst=true;
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
var ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}else{
if(fst){d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebarTabs');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,f,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
f=merge((tid?tid.fields:{}), config.defaultCustomFields);
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,f);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;padding-left:5px !important;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.5 (2010-09-08)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|See [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]|
|''~TiddlyWiki:''|Version 2.5 or better|
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
defaultMore:'', //the default for the more section
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
addTags:'Set tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c,click,e,ex=[],fst=true,goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,tmp=place,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",c.defaultMore);
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
tid=rtid=getParam(p,"tiddler");
if(!tid){
do{if(fst)fst=false;else tid=tmp;tmp=story.findContainingTiddler(tmp);}while(tmp&&tid!=tmp);
tid=tid?tid.getAttribute('tiddler'):'';
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,curr,d1,d2,fst=true,i,j,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nuLi(pop);d2=nuLi(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,"li",null,null),'li',null,'title',c.addTags);fst=false;}
}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
fst=true;
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
var ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}else{
if(fst){d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebarTabs');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,f,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
f=merge((tid?tid.fields:{}), config.defaultCustomFields);
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,f);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
story.saveTiddler(title);
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;padding-left:5px !important;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.0.6 (2010-09-17)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|See [[Welcome]] or [[online help|http://tagsearch.tiddlyspot.com]]|
|''~TiddlyWiki:''|Version 2.5 or better|
***/
//{{{
config.macros.tagsearch={
cfg:{
defaultMode:1, // 0 -> substitute (silent), 1 -> ask for substitution, >1 -> always add (silent)
defaultOpenNew:1, //0: never open new tiddler, 1:ask, >2: always open
defaultMore:'', //the default for the more section
keepModified:false, //when true does not update modified date or modifier when setting tags
sidebarOffset:20, //dist from sidebar
colWidth:'180px', //minwidth of sides
newAtSingle:30, //new block for all tags
newAt:18, //new block when grouped
excludeTagged:'', //default tags or exclusion
arrow:document.all?" ▼":" ▾", //only the fat works in IE
label:'Tags:', //localization starts here
options:'Options',
more:'More...',
tooltip:'Manage tiddler tags',
notags:'no tags set...',
aretags:'Current tags',
addTag:'Add tag...',
addTags:'Set tag...',
txtRemove: 'remove tag',
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtAdd:"set tag ",
txtFor:"To be tagged... ",
promptNew:"Enter new tag:",
modeAsk:"Do also you want to remove tag '%0' and other tags from category '%1'?\nCancel simply adds tag '%2'.",
askOpen:"Do you want to open the newly created tiddler '%0' now tagged '%1'?"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c,click,e,ex=[],fst=true,goto,lbl,list,open,mode,more,notags,p,source,rtid,src,tb,tid,tip,tmp=place,x;
x=config.macros.tagsearch;c=x.cfg;
p=paramString.parseParams('tagman',null,true);
tb=params.contains("toolbar");
notags=params.contains("notags");
lbl=getParam(p,"label",c.label)+c.arrow;
tip=getParam(p,"tooltip",c.tooltip);
exclude=(getParam(p,"exclude",'')+' '+c.excludeTagged).readBracketedList();
exclude.map(function(e){ex.pushUnique(e);});
for(e=0;e<exclude.length;e++){
store.getTaggedTiddlers(exclude[e]).map(function(t){ex.pushUnique(t.title)});
}
src=getParam(p,"source",'');
if(src&&!store.getTiddlerText(src))return false;
more=getParam(p,"more",c.defaultMore);
mode=parseInt(getParam(p,"mode",c.defaultMode));
mode=isNaN(mode)?c.defaultMode:mode;
open=parseInt(getParam(p,"open",c.defaultOpenNew));
open=isNaN(open)?c.defaultOpenNew:open;
goto=getParam(p,"goto",'');
tid=rtid=getParam(p,"tiddler");
if(!tid){
do{if(fst)fst=false;else tid=tmp;tmp=story.findContainingTiddler(tmp);}while(tmp&&tid!=tmp);
tid=tid?tid.getAttribute('tiddler'):'';
}
if(!tid)return;
click=function(e){
e=e||window.event;
var ar,curr,d1,d2,fst=true,i,j,l,nuBtns,nuLi,m,max=nu=src?c.newAt:c.newAtSingle,oTid=store.getTiddler(tid),pop,s,t,tags=[],tids,ti,tgt;
pop=Popup.create(this);
addClass(pop,'tagsearch');
if(src){//mod tb:different method for source tiddler
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tags.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tags.push(tgt[s].title);
}
}
}
}else tags=store.getTags();
curr=oTid?oTid.tags.sort():[];
nuLi=function(p){return createTiddlyElement(createTiddlyElement(p,"li",null,null),"ol",null,null);}
nuBtns=function(where,text,tag,pref){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,"li"),"span",null,null);
t=createTiddlyButton(s,text,pref+" '"+tag+"'",x.setTag,"button toggleButton", null);
t.setAttribute("tiddler",tid);
t.setAttribute("tag",tag);
t.setAttribute("source",src);
t.setAttribute("mode",mode);
t.setAttribute("open",open);
insertSpacer(s);
createTagButton(s,tag);
}
d1=nuLi(pop);d2=nuLi(d1);
if(config.macros.gotoTiddler){
if(rtid){
l=createTiddlyElement(d2,"li",null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nuLi(d1);
}
createTiddlyElement(d2,"li",null,"title",c.addTag);
wikify('<<gotoTiddler '+goto+' >>',d2);
}
d2=nuLi(d1);
createTiddlyElement(d2,"li",null,"title",c.aretags);
if(curr.length==0)wikify('{{added{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nuBtns(d2,"[X]",curr[t],c.txtRemove);
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
if(!notags){
for(i=0;i<tags.length;i++){
nu++;
ti=src?tags[i]:tags[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nuLi(pop);}d2=nuLi(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nuLi(pop);d2=nuLi(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,"li",null,null),'li',null,'title',c.addTags);fst=false;}
}
nuBtns(d2,"["+String.fromCharCode(160,160,160)+"]",ti,c.txtAdd);
}
}
//options
d1=nuLi(pop);d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.options);
var newBtn=createTiddlyButton(createTiddlyElement(d2,"li"),(c.txtNew),null,x.setTag,'tsoption');
newBtn.setAttribute("tiddler",tid);
if(src){
var edit=createTiddlyButton(createTiddlyElement(d2,"li"),c.txtEdit,c.txtEditTip,onClickTiddlerLink,'tsoption');
edit.setAttribute("tiddlyLink",src.split('##')[0]);
}
fst=true;
if(more){//more
m=store.getTiddlerText(more).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
var ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nuLi(d1);createTiddlyLink(createTiddlyElement(d2,"li",null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){var ti=ar[i].title;
if(!tiddler.tags.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}else{
if(fst){d2=nuLi(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))nuBtns(d2,"["+String.fromCharCode(160,160)+"]",ti,c.txtAdd);
}
}
}
if(c.colWidth)jQuery('li',d1).css('min-width',c.colWidth);
}
}
jQuery(pop).attr({tiddler:tid,source:src,mode:mode,open:open});
Popup.show(pop,false);
put=jQuery(".tagsearch form input");
put.attr('notify','config.macros.tagsearch.notify');
put.focus();
if(tb){
s=document.getElementById('sidebarTabs');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
return false;
}
createTiddlyButton(place,lbl,tip,click,"button","tagsearchDrop");
},
setTag:function(e){
var a,b,el,f,m,nu,o,r,s,set,src,t,tag,ti,tid,title,c=config.macros.tagsearch.cfg;
el=e&&!e.target?e:this;
title=el.getAttribute("tiddler");
tag=el.getAttribute("tag");
src=el.getAttribute("source");
m=el.getAttribute("mode");
o=el.getAttribute("open");
tid=store.getTiddler(title);
if(!tag){nu=prompt(c.promptNew,"");if(!nu)return false;else tag=nu;}
b=!tid;
if(!tid||!tid.tags){
f=merge((tid?tid.fields:{}), config.defaultCustomFields);
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,f);
if(!tid&&!document.getElementById(title)&&o>0)
if(o>1||o==1&&confirm(c.askOpen.format([title,tag])))
story.displayTiddler(null,title);
}else{
if(!tid.tags.contains(tag)){
if(src){
if(m<2){
var cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(t=0;t<cats.length;t++){
ti=cats[t];
var tgt=store.getTaggedTiddlers(ti);
for(s=0;s<tgt.length;s++){
if(tgt[s].title==tag){
for(r=0;r<tgt.length;r++){
if(tid.tags.contains(tgt[r].title)){
var ok;
if(m==1&&!ok){
if(!confirm(c.modeAsk.format([tgt[r].title,ti,tag])))break findTagged;
ok=true;
}
store.setTiddlerTag(title,false,tgt[r].title);
}
}
break findTagged;
}
}
}
}
}
store.setTiddlerTag(title,true,tag);
}
else if(!nu)store.setTiddlerTag(title,false,tag);
t=store.getTiddler(title);
store.saveTiddler(title,title,t.text,c.keepModified?t.modifier:config.options.txtUserName,c.keepModified?t.modified:new Date(),t.tags,t.fields);
if(config.options.chkAutoSave)autoSaveChanges();
}
if(!e.target){e.value='';e.focus();}
},
notify:function(tag){
var p = jQuery('.tagsearch');
var i = jQuery('.tagsearch form input')[0];
var t = store.getTiddler(p.attr('tiddler'));
if(t&&t.tags.contains(tag))return false;
wikify('{{added{ {{add{+}}} <<tag "'+tag+'">>}}}',i.parentNode);
p.attr('tag',tag);
this.setTag(p[0]);
i.select();
},
tiddler:'',
src:''
}
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=="*") { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=here.getAttribute('notify');
if(n)eval(n+'("'+title+'")'); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup="%0";
}
var TP=store.getTiddlerText('ColorPalette::TertiaryPale'),
TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark'),
SP=store.getTiddlerText('ColorPalette::SecondaryPale'),
SD=store.getTiddlerText('ColorPalette::SecondaryDark');
config.shadowTiddlers["StyleSheetTagSearch"]="/*{{{*/\n"+
".tagsearch {padding:7px !important;border:1px solid "+SD+";background: "+TP+";-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n"+
".tagsearch li a, .tagsearch .quickopentag .tiddlyLink {display:inline;padding:2px;color:"+TD+";clear:none;}\n"+
".tagsearch li a.toggleButton {display:inline;margin-left:5px;}\n"+
".tagsearch .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:"+SD+";padding:0;}\n"+
".tagsearch form{display:block;float:left;clear:both;padding-left:5px !important;}\n"+
".tagsearch .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n"+
".tagsearch .added{display:block;clear:both;padding:5px;}\n"+
".tagsearch .added span{display:block;float:left;}\n"+
".tagsearch .add{clear:left;padding:0 3px;}\n"+
".tagsearch ol{margin:0;padding:0 0 5px 0;}\n"+
".tagsearch li{display:block;float:left;padding-bottom:10px !important;}\n"+
".tagsearch li span{line-height:1em;}\n"+
".tagsearch li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n"+
".tagsearch li ol li:hover{border:1px solid "+TM+";}\n"+
".tagsearch li ol li ol li{padding:0 !important;}\n"+
".tagsearch li ol li ol li:hover{border:1px solid transparent;}\n"+
".tagsearch .tiddlyLink:hover{color:"+SD+";background:"+SP+";}\n"+
".tagsearch .quickopentag {display:inline;}\n"+
".tagsearch .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n"+
".tagsearch .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n"+
"/*}}}*/";
store.addNotification("StyleSheetTagSearch",refreshStyles);
//}}}
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.2.0 (2010-10-10)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|http://tagsearch.tiddlyspot.com|
|''~TiddlyWiki:''|Version 2.5.3 or better|
***/
//{{{
(function($){
config.macros.tagsearch={
cfg:{
defaultSource:'',
defaultMore:'',
defaultMode:1,
keepModified:false,
sidebarOffset:20,
newAtSingle:30,
newAt:18,
excludeTagged:'',
toolbar:'',
label:"tags",
options:"Options",
more:"More...",
tooltip:"Manage tiddler tags",
notags:"no tags set...",
aretags:"Current tags",
addTag:"Add tag...",
addTags:"Set tag...",
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtRemove: "remove tag %0",
txtAdd:"set tag %0",
txtFor:"To be tagged... ",
txtCtrl:" (hold SHIFT to just add it or CTRL to replace in category)",
promptNew:"Enter new tag:",
modeAsk:"Do you want to remove existing tags from category '%0'?\nCancel simply adds tag '%1'.",
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c=this.cfg,
tid=story.findContainingTiddler(place),
p=paramString.parseParams('tagman',null,true);
$(createTiddlyButton(
place,
getParam(p,'label',c.label),
getParam(p,'tooltip',c.tooltip),
this.click,
'button'
)).attr({
id:this.newId('btntgs'),
tid:(tid?tid.getAttribute('tiddler'):'')
}).data({
pa:params,
p:p
})
},
click:function(ev){
var ar,curr,d1,d2,ex=[],fst=true,i,j,l,npop,nbtns,nli,m,pop,s,t,tgs=[],tids,ti,tgt,
e=ev||window.event,
el=$(this),
id=el.attr('popup'),
trigger=window.event?'keydown':'keypress',
x=config.macros.tagsearch,
c=x.cfg,
pa=el.data('pa'),
p=el.data('p'),
tb=pa.contains('toolbar'),
src=getParam(p,'source',c.defaultSource),
mr=getParam(p,'more',c.defaultMore),
search=!pa.contains('nosearch'),
tags=!pa.contains('notags'),
more=!pa.contains('nomore'),
gt=getParam(p,'goto',''),
mode=parseInt(getParam(p,'mode')),
rtid=getParam(p,'tiddler',''),
tid=rtid?rtid:el.attr('tid'),
exp=(getParam(p,'exclude','')+' '+c.excludeTagged).readBracketedList(),
max=nu=src?c.newAt:c.newAtSingle,
otid=store.getTiddler(tid);
if(!tid)return;
mode=isNaN(mode)?c.defaultMode:mode;
exp.map(function(e){ex.pushUnique(e);});
for(i=0;i<exp.length;i++){
store.getTaggedTiddlers(exp[i]).map(function(t){ex.pushUnique(t.title)});
}
if(src&&!store.getTiddlerText(src))return false;
if(id){
pop=$('#'+id)[0];
$(pop).empty();
}
if(!pop){
npop=true;
id=x.newId('tgspop');
pop=Popup.create(this);
$(pop).addClass('tgs'
).attr({
'id':id
}).data({
btn:el,
tiddler:tid,
source:src,
mode:mode
}).click(x.noBubble);
el.attr('popup',id);
}
if(src){
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tgs.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tgs.push(tgt[s].title);
}
}
}
}else tgs=store.getTags();
curr=otid?otid.tags.sort():[];
nli=function(p,cls){return createTiddlyElement(createTiddlyElement(p,'li',null,null),'ol',null,cls?cls:null);}
nbtns=function(where,text,tag,tip){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,'li'),'span',null,null);
t=$(createTiddlyButton(s,text,tip.format(["'"+tag+"'"]),x.setTag,'button toggleButton', null));
t.data({
tiddler:tid,
tag:tag,
source:src,
mode:mode
});
insertSpacer(s);
createTagButton(s,tag);
}
d1=nli(pop,'tgside');
//SEARCH
if(config.macros.gotoTiddler&&search){
d2=nli(d1);
if(rtid){
l=createTiddlyElement(d2,'li',null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nli(d1);
}
createTiddlyElement(d2,'li',null,'title',c.addTag);
wikify('<<gotoTiddler '+gt+' >>',d2);
$('input',pop
).bind(trigger,x.noBubble
).data('notify',config.macros.tagsearch.notify
).focus();
}
//EXISTING
d2=nli(d1);
createTiddlyElement(d2,'li',null,'title',c.aretags);
if(curr.length==0)wikify('{{notags{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nbtns(d2,'[X]',curr[t],c.txtRemove);
//TAGS
if(tags){
for(i=0;i<tgs.length;i++){
nu++;
ti=src?tgs[i]:tgs[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nli(pop);}d2=nli(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,'li',null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nli(pop);d2=nli(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,'li',null,null),'li',null,'title',c.addTags);fst=false;}
}
nbtns(d2,'['+String.fromCharCode(160,160,160)+']',ti,c.txtAdd+(src?c.txtCtrl:''));
}
}
}
//MORE / OPTIONS
if(more){
d1=nli(pop,'tgside');
d2=nli(d1);createTiddlyElement(d2,'li',null,'title',c.options,null);
createTiddlyButton(
createTiddlyElement(d2,'li'),
c.txtNew,
null,
x.setTag,
'tsopt',
null,
null,
{'tiddler':tid}
);
if(src){
createTiddlyButton(
createTiddlyElement(d2,'li'),
c.txtEdit,
c.txtEditTip,
onClickTiddlerLink,
'tsopt',
null,
null,
{'tiddlyLink':src.split('##')[0]}
)
}
//MORE
fst=true;
if(mr){
m=store.getTiddlerText(mr).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nli(d1);createTiddlyLink(createTiddlyElement(d2,'li',null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){
ti=ar[j].title;
if(!curr.contains(ti)&&!ex.contains(ti))
nbtns(d2,'['+String.fromCharCode(160,160)+']',ti,c.txtAdd);
}
}else{
if(fst){d2=nli(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))
nbtns(d2,'['+String.fromCharCode(160,160)+']',ti,c.txtAdd);
}
}
}
}
}
if(npop){
Popup.show(pop,false);
if(tb){
s=document.getElementById('sidebar');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
}
return x.noBubble(e);
},
setTag:function(ev){
var ca,cats,nu,ok=true,t,tgs,tgt,ti,
e=ev||window.event,
x=config.macros.tagsearch,
c=x.cfg,
el=$(this),
p=el.closest('.tgs'),
btn=p.data('btn'),
tag=el.data('tag'),
title=p.data('tiddler'),
src=p.data('source'),
m=parseInt(p.data('mode'));
if(!tag){nu=prompt(c.promptNew,'');if(!nu)return false;else tag=nu;}
tid=x.exists(title,tag);
if(tid){
tgs=tid.tags;
if(!tgs.contains(tag)){
if(src&&m<2&&!e.shiftKey){
cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(ca=0;ca<cats.length;ca++){
ti=cats[ca];
tgt=store.getTaggedTiddlers(ti).map(function(t){return t.title});
if(tgt.contains(tag)){
tgt.splice(tgt.indexOf(tag),1);
if(!e.ctrlKey&&m==1&&tgs.containsAny(tgt))
ok=confirm(c.modeAsk.format([ti,tag]));
if(ok){
for(t=0;t<tgt.length;t++){
ti=tgt[t];
if(tgs.contains(ti))store.setTiddlerTag(title,false,ti);
}
}
break findTagged;
}
}
}
store.setTiddlerTag(title,true,tag);
}else if(!nu)store.setTiddlerTag(title,false,tag);
t=store.getTiddler(title);
store.saveTiddler(
title,
title,
t.text,
c.keepModified?t.modifier:config.options.txtUserName,
c.keepModified?t.modified:new Date(),
t.tags,
t.fields
);
}
if(config.options.chkAutoSave)autoSaveChanges();
btn.click();
p.find('input').focus();
return x.noBubble(e);
},
newId:function(p){
return p+Math.random().toString().substr(3);
},
notify:function(tag,el){
var p=$(el).closest('.tgs'),
i=$('form input',p)[0];
t=config.macros.tagsearch.exists(p.data('tiddler'),tag);
if(t&&!t.tags.contains(tag))store.setTiddlerTag(t.title,t,tag);
p.data('btn').click();
i.select();
},
exists:function(title,tag){
if(!store.getTiddler(title)){ //||!tid.tags
var f=merge({}, config.defaultCustomFields);
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,f);
return false;
}
return store.getTiddler(title);
},
noBubble:function(ev){
var e=ev||window.event,el=resolveTarget(e);
if(e.keyCode==27)Popup.remove(0);
else if(e.type!='click'&&el.nodeName.toUpperCase()=='INPUT')return true;
if(hasClass(el,'tiddlyLink'))return true;
Popup.remove(1);
e.cancelBubble=true;
try{event.keyCode=0;}catch(e){};
if (window.event) e.returnValue=false;
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation) e.stopPropagation();
return false;
}
}
//HIJACK TOOLBAR
config.commands.tagSearch={}
var cmt=config.macros.toolbar;
cmt.createCommandTAGS=cmt.createCommand;
cmt.createCommand=function(place,commandName,tiddler,className){
if(commandName=='tagSearch'){
wikify('<<tagsearch toolbar '+config.macros.tagsearch.cfg.toolbar+'>>',place);
$(place.lastChild).attr({
commandName:'tagSearch',
tiddler:tiddler.title
});
}else cmt.createCommandTAGS.apply(this,arguments);
}
//GOTOPLUGIN
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=='*') { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=$(here).data('notify');
if(n)n.call(this,title,here); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup='%0';
}
var TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark');
config.shadowTiddlers['StyleSheetTagSearch']='/*{{{*/\n'+
'.tgs {padding:7px !important;-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n'+
'.tgs li a, .tgs .quickopentag .tiddlyLink {display:inline;padding:2px;clear:none;}\n'+
'.tgs li a.toggleButton {display:inline;margin-left:5px;}\n'+
'.tgs .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:'+TM+';padding:0;}\n'+
'.tgs form{display:block;float:left;clear:both;padding-left:5px !important;}\n'+
'.tgs .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n'+
'.tgs .notags, .tsopt{display:block;clear:both;margin:5px;}\n'+
'.tgs .highlight{background:'+TD+';}\n'+
'.tgs ol{margin:0;padding:0 0 5px 0;}\n'+
'.tgs li{display:block;float:left;padding-bottom:10px !important;}\n'+
'.tgs li span{line-height:1em;}\n'+
'.tgs li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n'+
'.tgs li ol li:hover{border:1px solid '+TM+';}\n'+
'.tgs li ol li ol li{padding:0 !important;}\n'+
'.tgs li ol li ol li:hover{border:1px solid transparent;}\n'+
'.tgside li ol li {min-width:150px;}'+
'.tgs .quickopentag {display:inline;}\n'+
'.tgs .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n'+
'.tgs .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n'+
'/*}}}*/';
store.addNotification('StyleSheetTagSearch',refreshStyles);
})(jQuery);
//}}}
<<tiddler Tagging2##SHOW with: {{
var s='',ex='$2'.readBracketedList(),t,ti,tg='$1',tgd;
if(tg!='$'+'1'){
s='\n*{{listTitle{Subtags and tagging tiddlers...}\}\}';
tgd=store.getTaggedTiddlers(tg);
for(t=0;t<tgd.length;t++){
ti=tgd[t].title;
if(!ex.contains(ti)){
s+='\n*{{subtag{[['+ti+':|'+ti+']]}\}\}';
store.getTaggedTiddlers(ti).map(function(t){s+='\n** [['+t.title+']]';});
}
}
}
s;}}>>/%
!SHOW
$1
!END%/
...the singlefile wiki under this hood.
|linkTable|k
|width:400px; !by modified date |width:400px; !by date created |
|vertical-align:top;padding-left:20px;<<timeline "modified">>|vertical-align:top;padding-left:20px;<<timeline "created">>|
[[...they guy who wrote this stuff!|Tobias Beer]]
The guy who also created [[tbGTD|http://tbGTD.tiddlyspot.com]] and provided you with [[vertical tabs|http://verticaltabs.tiddlyspot.com]] and his version of a [[RatingMacro|http://lastfm.tiddlyspot.com/#RatingMacro]].
/***
|''Name:''|ToggleSideBarTB|
|''Description''|allows to toggle left and right sidebar|
|''Version:''|1.1|
|''Type''|macro|
|''Author:''|[[TobiasBeer]]|
|''Info:''|http://tbgtd.tiddlyspot.com/#ToggleSideBarTB|
|''Source:''|http://tbgtd.tiddlyspot.com/#ToggleSideBarTB|
|''License''|[[Creative Commons Attribution-Share Alike 3.0|http://creativecommons.org/licenses/by-sa/3.0/]]|
|''~CoreVersion''|2.xx|
!Code
***/
//{{{
config.macros.toggleSideBarTB={
settings:{
arr1:"►",arr2:"◄",
lblToggle:"toggle %0",
leftBarID:"mainMenu",leftBarLbl:"main menu",
leftBarHide:"margin-left:1em;",leftBarShow:"margin-left:18 em;",
rightBarID:"sidebar",rightBarLbl:"sidebar",
rightBarHide:"margin-right:1em;",rightBarShow:"margin-right:19.1em;"
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var l=params[0]&¶ms[0]=="left";
var h=params[1]&¶ms[1]=="hide";
var no=params[2]&¶ms[2]=="notip";
var s=this.settings;
var el=l?s.leftBarID:s.rightBarID;
var btnId="ToggleSideBar"+(l?"Left":"Right");
var arr=l?(h?s.arr1:s.arr2):(h?s.arr2:s.arr1);
var lbl=(no?'':s.lblToggle.format([(l?s.leftBarLbl:s.rightBarLbl)]));
var fct=function(){config.macros.toggleSideBarTB.toggle(btnId)};
document.getElementById(el).setAttribute("toggle","hide");
createTiddlyButton(place,arr,lbl,fct,"button HideSideBarButton",btnId);
if(h)config.macros.toggleSideBarTB.toggle(btnId);
},
toggle:function(btnId){
var btn=document.getElementById(btnId);
var l=btn.id=="ToggleSideBarLeft";
var s=config.macros.toggleSideBarTB.settings;
var bl=document.getElementById(s.leftBarID);
var br=document.getElementById(s.rightBarID);
var bar=(l?bl:br);
var hl=bl.getAttribute("toggle")=='show';if(l)hl=!hl;
var hr=br.getAttribute("toggle")=='show';if(!l)hr=!hr;
var h=(l?hl:hr);
setStylesheet("#contentWrapper #displayArea {"+
(hl?s.leftBarHide:s.leftBarShow)+
(hr?s.rightBarHide:s.rightBarShow)+
"}","ToggleSideBarStyles");
bar.style.display=h?"none":"block";
bar.setAttribute("toggle",(h?"show":"hide"));
arr1=l?s.arr2:s.arr1;arr2=l?s.arr1:s.arr2;
btn.innerHTML=h?arr2:arr1;
}
}
//}}}
|~ViewToolbar|tagSearch closeTiddler closeOthers +editTiddler > fields syncing permalink references jump <|
|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{
// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'tagsearch';
// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too
// disable autosave in d3
if (window.location.protocol != "file:")
config.options.chkGTDLazyAutoSave = false;
// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}
// create some shadow tiddler content
merge(config.shadowTiddlers,{
'TspotOptions':[
"tiddlyspot password:",
"<<option pasUploadPassword>>",
""
].join("\n"),
'TspotControls':[
"| tiddlyspot password:|<<option pasUploadPassword>>|",
"| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
"| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),
'WelcomeToTiddlyspot':[
"This document is a ~TiddlyWiki from tiddlyspot.com. A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //What now?// @@ Before you can save any changes, you need to enter your password in the form below. Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
"<<tiddler TspotControls>>",
"See also GettingStarted.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working online// @@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// @@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick. You can make changes and save them locally without being connected to the Internet. When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Help!// @@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]]. Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help. If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// @@ We hope you like using your tiddlyspot.com site. Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),
'TspotSidebar':[
"<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n")
});
//}}}
*has been part of [[tbGTD|http://tbGTD.tiddlyspot.com/#x-tagger]] for a while now
*now extended to TagSearchPlugin thanks to GotoPlugin
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
major: 4, minor: 1, revision: 3,
date: new Date("Feb 24, 2008"),
source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0'
};
//
// Environment
//
if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false; // true to activate both in Plugin and UploadService
//
// Upload Macro
//
config.macros.upload = {
// default values
defaultBackupDir: '', //no backup
defaultStoreScript: "store.php",
defaultToFilename: "index.html",
defaultUploadDir: ".",
authenticateUser: true // UploadService Authenticate User
};
config.macros.upload.label = {
promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
promptParamMacro: "Save and Upload this TiddlyWiki in %0",
saveLabel: "save to web",
saveToDisk: "save to disk",
uploadLabel: "upload"
};
config.macros.upload.messages = {
noStoreUrl: "No store URL in parmeters or options",
usernameOrPasswordMissing: "Username or password missing"
};
config.macros.upload.handler = function(place,macroName,params) {
if (readOnly)
return;
var label;
if (document.location.toString().substr(0,4) == "http")
label = this.label.saveLabel;
else
label = this.label.uploadLabel;
var prompt;
if (params[0]) {
prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0],
(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
} else {
prompt = this.label.promptOption;
}
createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};
config.macros.upload.action = function(params)
{
// for missing macro parameter set value from options
if (!params) params = {};
var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
var username = params[4] ? params[4] : config.options.txtUploadUserName;
var password = config.options.pasUploadPassword; // for security reason no password as macro parameter
// for still missing parameter set default value
if ((!storeUrl) && (document.location.toString().substr(0,4) == "http"))
storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
if (storeUrl.substr(0,4) != "http")
storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
if (!toFilename)
toFilename = bidix.basename(window.location.toString());
if (!toFilename)
toFilename = config.macros.upload.defaultToFilename;
if (!uploadDir)
uploadDir = config.macros.upload.defaultUploadDir;
if (!backupDir)
backupDir = config.macros.upload.defaultBackupDir;
// report error if still missing
if (!storeUrl) {
alert(config.macros.upload.messages.noStoreUrl);
clearMessage();
return false;
}
if (config.macros.upload.authenticateUser && (!username || !password)) {
alert(config.macros.upload.messages.usernameOrPasswordMissing);
clearMessage();
return false;
}
bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password);
return false;
};
config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir)
{
if (!storeUrl)
return null;
var dest = bidix.dirname(storeUrl);
if (uploadDir && uploadDir != '.')
dest = dest + '/' + uploadDir;
dest = dest + '/' + toFilename;
return dest;
};
//
// uploadOptions Macro
//
config.macros.uploadOptions = {
handler: function(place,macroName,params) {
var wizard = new Wizard();
wizard.createWizard(place,this.wizardTitle);
wizard.addStep(this.step1Title,this.step1Html);
var markList = wizard.getElement("markList");
var listWrapper = document.createElement("div");
markList.parentNode.insertBefore(listWrapper,markList);
wizard.setValue("listWrapper",listWrapper);
this.refreshOptions(listWrapper,false);
var uploadCaption;
if (document.location.toString().substr(0,4) == "http")
uploadCaption = config.macros.upload.label.saveLabel;
else
uploadCaption = config.macros.upload.label.uploadLabel;
wizard.setButtons([
{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption,
onClick: config.macros.upload.action},
{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
]);
},
options: [
"txtUploadUserName",
"pasUploadPassword",
"txtUploadStoreUrl",
"txtUploadDir",
"txtUploadFilename",
"txtUploadBackupDir",
"chkUploadLog",
"txtUploadLogMaxLine"
],
refreshOptions: function(listWrapper) {
var opts = [];
for(i=0; i<this.options.length; i++) {
var opt = {};
opts.push();
opt.option = "";
n = this.options[i];
opt.name = n;
opt.lowlight = !config.optionsDesc[n];
opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
opts.push(opt);
}
var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
for(n=0; n<opts.length; n++) {
var type = opts[n].name.substr(0,3);
var h = config.macros.option.types[type];
if (h && h.create) {
h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
}
}
},
onCancel: function(e)
{
backstage.switchTab(null);
return false;
},
wizardTitle: "Upload with options",
step1Title: "These options are saved in cookies in your browser",
step1Html: "<input type='hidden' name='markList'></input><br>",
cancelButton: "Cancel",
cancelButtonPrompt: "Cancel prompt",
listViewTemplate: {
columns: [
{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
{name: 'Option', field: 'option', title: "Option", type: 'String'},
{name: 'Name', field: 'name', title: "Name", type: 'String'}
],
rowClasses: [
{className: 'lowlight', field: 'lowlight'}
]}
};
//
// upload functions
//
if (!bidix.upload) bidix.upload = {};
if (!bidix.upload.messages) bidix.upload.messages = {
//from saving
invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
backupSaved: "Backup saved",
backupFailed: "Failed to upload backup file",
rssSaved: "RSS feed uploaded",
rssFailed: "Failed to upload RSS feed file",
emptySaved: "Empty template uploaded",
emptyFailed: "Failed to upload empty template file",
mainSaved: "Main TiddlyWiki file uploaded",
mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
//specific upload
loadOriginalHttpPostError: "Can't get original file",
aboutToSaveOnHttpPost: 'About to upload on %0 ...',
storePhpNotFound: "The store script '%0' was not found."
};
bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
var callback = function(status,uploadParams,original,url,xhr) {
if (!status) {
displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
return;
}
if (bidix.debugMode)
alert(original.substr(0,500)+"\n...");
// Locate the storeArea div's
var posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
bidix.upload.uploadRss(uploadParams,original,posDiv);
};
if(onlyIfDirty && !store.isDirty())
return;
clearMessage();
// save on localdisk ?
if (document.location.toString().substr(0,4) == "file") {
var path = document.location.toString();
var localPath = getLocalPath(path);
saveChanges();
}
// get original
var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
var originalPath = document.location.toString();
// If url is a directory : add index.html
if (originalPath.charAt(originalPath.length-1) == "/")
originalPath = originalPath + "index.html";
var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
var log = new bidix.UploadLog();
log.startUpload(storeUrl, dest, uploadDir, backupDir);
displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
if (bidix.debugMode)
alert("about to execute Http - GET on "+originalPath);
var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
bidix.upload.uploadRss = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
if(status) {
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
bidix.upload.uploadMain(params[0],params[1],params[2]);
} else {
displayMessage(bidix.upload.messages.rssFailed);
}
};
// do uploadRss
if(config.options.chkGenerateAnRssFeed) {
var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
var rssString = generateRss();
// no UnicodeToUTF8 conversion needed when location is "file" !!!
if (document.location.toString().substr(0,4) != "file")
rssString = convertUnicodeToUTF8(rssString);
bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
} else {
bidix.upload.uploadMain(uploadParams,original,posDiv);
}
};
bidix.upload.uploadMain = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
var log = new bidix.UploadLog();
if(status) {
// if backupDir specified
if ((params[3]) && (responseText.indexOf("backupfile:") > -1)) {
var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
}
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
store.setDirty(false);
log.endUpload("ok");
} else {
alert(bidix.upload.messages.mainFailed);
displayMessage(bidix.upload.messages.mainFailed);
log.endUpload("failed");
}
};
// do uploadMain
var revised = bidix.upload.updateOriginal(original,posDiv);
bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};
bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
var localCallback = function(status,params,responseText,url,xhr) {
url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
if (xhr.status == 404)
alert(bidix.upload.messages.storePhpNotFound.format([url]));
if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
alert(responseText);
if (responseText.indexOf("Debug mode") >= 0 )
responseText = responseText.substring(responseText.indexOf("\n\n")+2);
} else if (responseText.charAt(0) != '0')
alert(responseText);
if (responseText.charAt(0) != '0')
status = null;
callback(status,params,responseText,url,xhr);
};
// do httpUpload
var boundary = "---------------------------"+"AaB03x";
var uploadFormName = "UploadPlugin";
// compose headers data
var sheader = "";
sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
sheader += uploadFormName +"\"\r\n\r\n";
sheader += "backupDir="+uploadParams[3] +
";user=" + uploadParams[4] +
";password=" + uploadParams[5] +
";uploaddir=" + uploadParams[2];
if (bidix.debugMode)
sheader += ";debug=1";
sheader += ";;\r\n";
sheader += "\r\n" + "--" + boundary + "\r\n";
sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
sheader += "Content-Length: " + data.length + "\r\n\r\n";
// compose trailer data
var strailer = new String();
strailer = "\r\n--" + boundary + "--\r\n";
data = sheader + data + strailer;
if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
if (!posDiv)
posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
store.allTiddlersAsHtml() + "\n" +
original.substr(posDiv[1]);
var newSiteTitle = getPageTitle().htmlEncode();
revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
return revised;
};
//
// UploadLog
//
// config.options.chkUploadLog :
// false : no logging
// true : logging
// config.options.txtUploadLogMaxLine :
// -1 : no limit
// 0 : no Log lines but UploadLog is still in place
// n : the last n lines are only kept
// NaN : no limit (-1)
bidix.UploadLog = function() {
if (!config.options.chkUploadLog)
return; // this.tiddler = null
this.tiddler = store.getTiddler("UploadLog");
if (!this.tiddler) {
this.tiddler = new Tiddler();
this.tiddler.title = "UploadLog";
this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
this.tiddler.created = new Date();
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
}
return this;
};
bidix.UploadLog.prototype.addText = function(text) {
if (!this.tiddler)
return;
// retrieve maxLine when we need it
var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
if (isNaN(maxLine))
maxLine = -1;
// add text
if (maxLine != 0)
this.tiddler.text = this.tiddler.text + text;
// Trunck to maxLine
if (maxLine >= 0) {
var textArray = this.tiddler.text.split('\n');
if (textArray.length > maxLine + 1)
textArray.splice(1,textArray.length-1-maxLine);
this.tiddler.text = textArray.join('\n');
}
// update tiddler fields
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
// refresh and notifiy for immediate update
story.refreshTiddler(this.tiddler.title);
store.notify(this.tiddler.title, true);
};
bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir, backupDir) {
if (!this.tiddler)
return;
var now = new Date();
var text = "\n| ";
var filename = bidix.basename(document.location.toString());
if (!filename) filename = '/';
text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
text += config.options.txtUserName + " | ";
text += "[["+filename+"|"+location + "]] |";
text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
text += uploadDir + " | ";
text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
text += backupDir + " |";
this.addText(text);
};
bidix.UploadLog.prototype.endUpload = function(status) {
if (!this.tiddler)
return;
this.addText(" "+status+" |");
};
//
// Utilities
//
bidix.checkPlugin = function(plugin, major, minor, revision) {
var ext = version.extensions[plugin];
if (!
(ext &&
((ext.major > major) ||
((ext.major == major) && (ext.minor > minor)) ||
((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
// write error in PluginManager
if (pluginInfo)
pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
}
};
bidix.dirname = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(0, lastpos);
} else {
return filePath.substring(0, filePath.lastIndexOf("\\"));
}
};
bidix.basename = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("#")) != -1)
filePath = filePath.substring(0, lastpos);
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(lastpos + 1);
} else
return filePath.substring(filePath.lastIndexOf("\\")+1);
};
bidix.initOption = function(name,value) {
if (!config.options[name])
config.options[name] = value;
};
//
// Initializations
//
// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);
// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");
//optionsDesc
merge(config.optionsDesc,{
txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
txtUploadUserName: "Upload Username",
pasUploadPassword: "Upload Password",
chkUploadLog: "do Logging in UploadLog (default: true)",
txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});
// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');
// Backstage
merge(config.tasks,{
uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");
//}}}
<!--{{{-->
<div class='toolbar'>
<span macro='tiddler newHere'></span>
<span macro='toolbar [[ToolbarCommands::ViewToolbar]]'></span>
</div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div macro='showWhenTagged Tagging2'><div class='tagging' macro='tiddler Tagging2 with: {{tiddler.title}}'></div></div>
<div macro='else'><div macro='hideWhenTagged noTagging'><div class='tagging' macro='tagging'></div></div></div>
<div class='tagClear'></div>
<!--}}}-->
{{strong{TagSearchPlugin}}} is a TiddlyWiki plugin and all about the {{strong{<<tagsearch toolbar label:"tags " source:"TagSearchConfig##Tags" more:"TagSearchConfig##More">>}}}-button in the toolbar. It allows you to set tags of different categories and - when installed - to use the interface of {{strong{GotoPlugin}}} to add new tags. Preferably you should add [[TagSearch|TagSearchPlugin]] to your {{strong{ToolbarCommands}}} (or the corresponding section in your theme) while using a tiddler like {{strong{TagSearchConfig}}} for configuration.
!How to use
Type any text in the {{strong{add tag...}}} box, hit enter and the text is added as a tag ...or select a tiddler title from the searchlist. Clicking on a checkbox - ''[ ]'' - in front of a tag will add or remove the tag. Clicking on the tag itself will open the tag popup or - if you have QuickOpenTagPlugin installed - it will display the corresponding tiddler while the little arrow next to it will show the popup of tiddlers tagging to said tag. While primarily intended to simplify tagging you can therefore just as well use TagSearchPlugin to access your most important tags.
!Tips
*in case you do select a tiddler from [[GotoPlugins'|GotoPlugin]] select-list, the input field may loose focus
**to get back to it in order to enter another tag try {{{SHIFT+TAB}}} or {{{ESC}}}
*consider using prefixes for tags that pertain to important tag-categories, for example:
**__category:__ <<tag Action>>
**__tags:__ <<tag #next>>, <<tag #queued>>, <<tag #waiting>>, <<tag #future>>, <<tag #done>>
**once you enter the prefix ''#'' into the searchbox and then hit the down key... you get all tiddlers with that prefix!
*to close the popup hit {{{ESC}}} or click anywhere outside of it
*you can use the searchbox as a kind of reverse ''~NewHere''
**enter a new tag, then click on the tag to open the new tiddler
!Macro and options
When you put {{{<<tagsearch>>}}} into any tiddler without parameters you get... <<tagsearch>>. There are a number of parameters to manipulate the way [[TagSearch|TagSearchPlugin]] works or looks...
|Parameter|Use|h
|{{{toolbar}}}|will align <<tagsearch toolbar label:'the popup '>> left to the sidebar, as it would make sense for a toolbar button|
|{{{notags}}}|will hide the list of all tags if no {{{source}}} is defined ...so you end up with the currently assigned tags and <<tagsearch notags label:'no tags column(s)'>>|
|{{{nomore}}}|will hide the right column with options and more section ...<<tagsearch nomore label:'no right column'>> ...and the currently assigned tags|
|{{{nosearch}}}|will hide the searchbox <<tagsearch nosearch label:'no searchbox'>>|
|>|{{{notags}}}, {{{nomore}}} and {{{nosearch}}} may combined result in <<tagsearch nosearch notags nomore label:'only current'>>, <<tagsearch nomore nosearch label:'only tags'>>, <<tagsearch notags nomore label:'only search'>>, <<tagsearch nosearch notags label:'only more' more:'TagSearchConfig##More'>>|
|{{{label:"my tags:"}}}|gives a name to the button, e.g. <<tagsearch label:'my tags:'>>|
|{{{tooltip:"Sets my tags..."}}}|adds a tooltip to <<tagsearch label:'the button' tooltip:'like this'>>|
|{{{exclude:"thisTag [[that tag]]"}}}|a bracketedList of <<tagsearch label:'tags that will be excluded ' exclude:'excludeLists Many systemConfig' tooltip:"this one won't show the tags excludeLists, systemConfig and Many and tags tagging to them">> ...as well as all tags tagging to them!|
|{{{source:"Tiddler##Tags"}}}|a tiddler, section or slice with <<tagsearch source:"TagSearchConfig##Tags" label:"tag categories">> in the form of a bracketedList<br> ...see [[TagSearchConfig##Tags|TagSearchConfig]]|
|{{{more:"Tiddler##More"}}}|a tiddler, section or slice defining tags for <<tagsearch more:"TagSearchConfig##More" label:"the more section">> in the right column in the form of a bracketedList ...see [[TagSearchConfig##More|TagSearchConfig]]<br><br>''Note:'' You can define blocks of tags with subtags __at the beginning__ of the more section by adding the prefix {{{TAG:}}}. Here I have added {{{[[TAG:Archive]]}}} whereas the [[Archive]] is a way to to mark tiddlers for export and eventually for deletion in the current wiki.|
|{{{tiddler:"TiddlerName"}}}|sets tags for a tiddler called <<tagsearch tiddler:'TiddlerName' label:'TiddlerName' label:"Set tags for tiddler TiddlerName">> ...which will be created if it didn't exist.|
|{{{mode}}}|defines if tags in tag categories are meant to be exclusive so that you can only set one per category<br> 0 = substitute (silent) @@color:grey; ...or hold {{{CTRL}}} while clicking@@<br>1 = ask for substitution (DEFAULT)<br>>1 = always add (silent) @@color:grey; ...or hold {{{SHIFT}}} while clicking@@<br><<tagsearch mode:'0' label:'This one replaces silently.' source:"TagSearchConfig##Tags" more:"TagSearchConfig##More">>|
|{{{goto}}}|options used by the embedded GotoPlugin <<tagsearch label:'searchbox' tooltip:'This one actually allows to search ...however, SHIFT+ENTER would always perform a search.' goto:'search'>> |
For more {{strong{configuration options}}}, look at the {{{cfg}}} section in the [[sourcecode of TagSearchPlugin|TagSearchSource]] and then use your [[zzConfig]] to specify...
|Parameter|Use|h
|{{{toolbar}}}|Since you can add a button by the name of {{{tagSearch}}} to your ToolbarCommands, the parameter {{{toolbar}}} defines all macro options that apply for the toolbar button; define it in your [[zzConfig]] like so:<br>{{{config.macros.tagsearch.cfg.toolbar="source:'TagSearchConfig##Tags' more:'TagSearchConfig##More'";}}}<br><br>@@color:red;''Important:''@@ If you are using a dedicated theme or [[MPTW|http://mptw.tiddlyspot.com]], make sure to use the corresponding ToolbarCommands section in your theme tiddler!|
|{{{defaultSource}}}|see {{{source}}} above|
|{{{defaultMore}}}|see {{{more}}} above|
|{{{defaultMode}}}|see {{{mode}}} above|
|{{{keepModified}}}|when {{{true}}}, preserves modified date and modifier when setting tags|
|{{{newAt}}}|creates a new column after more than this many tags when using a {{{source}}}|
|{{{newAtSingle}}}|definetely creates a new column after this many tags even for {{{source}}}|
|{{{sidebarOffset}}}|distance from sidebar in pixel ...used in combination with the macro parameter {{{toolbar}}}|
The {{strong{StyleSheet}}} being used is defined at the bottom of [[the source code|TagSearchSource]]. Overwrite it by editing the shadow tiddler StyleSheetTagSearch or add styles to your StyleSheet tiddler.
!Sourcecode
The sourcecode was compressed using [[yui compressor|http://refresh-sf.com/yui]]. [[The readable, non-compressed code can be found here...|TagSearchSource]]
!Issues
If your tiddler contains a lot of text then setting tags can take a long time due to the time it takes to save the tiddler./%
!Things for the future
{{noTitle{<<tagging #future>>}}}%/
!Release Notes
*1.2.0
**made all interface elements optional
**made the popup sticky, so that you can now set or remove multiple tags at once
**renamed popup class to {{{tgs}}} to shorten the code a bit
**added options to use {{{SHIFT}}} or {{{CTRL}}} when setting category tags
**removed bug for categories in the {{{more}}} section
**removed option {{{open}}} for new tiddlers as you can now click on the link in the popup
*1.0.6
**added config option to keep modifier and modified unchanged when setting tags
*1.0.5
**corrected bug in finding the outmost tiddler
*1.0.4
**allows for proper saving of new tiddlers on tiddlyspace by saving default field values
*1.0.3
**allows to properly use tagsearch macro in transclusions
**added heading for middle column when no source is used
**for tiddlyspace operability, changed 'toolbar' option to align to #sidebarTabs instead of #sidebar
*1.0.2
**generalized handling for [[Archive]]
*1.0.1
**tried to fix bugs in StyleSheetTagSearch
*1.0.0
**initial Release
!Version History
<<tiddler TagSearchLegacy>>
<<tiddler {{readOnly?'':'newHere##SHOW';}}>>/%
!SHOW
<<newTiddler "New tiddler" tag:{{here=story.findContainingTiddler(place);here?here.getAttribute('tiddler'):'';}}>><<rB "new" "Add a new tiddler tagging to this one">>
!END%/
<<toggleSideBarTB left show>>
//{{{
//TAGSEARCH TOOLBAR OPTIONS
config.macros.tagsearch.cfg.toolbar="source:'TagSearchConfig##Tags' exclude:'' label:'tags ' tooltip:'Set tags' more:'TagSearchConfig##More' toolbar";
//OTHER STUFF
//shortcuts
var c=config,co=c.options,cc=c.commands,cm=c.macros,cmg=c.messages,cv=c.views;
co.chkAnimate=false;
co.chkAutoSave=(window.location.protocol=="file:");
co.chkHttpReadOnly=false;//visitors can edit
co.chkSaveBackups=true;//backups in this folder
co.chkInsertTabs=true;//tab as tab when editing
co.txtBackupFolder='_backup';//autosave when local
co.txtIncrementalSearchMin=2;
co.chkUploadLog=false;
readOnly=!co.chkAutoSave;
showBackstage=!readOnly;
cv.editor.tagChooser.text='tags...';
cv.editor.defaultText="";//no text for a new tiddler
cv.wikified.defaultText="";//no msg when no tiddler
cv.wikified.tag.labelTags="";
cv.wikified.tag.labelNoTags="";
cv.wikified.tag.openTag= "Open '%0'";
cv.wikified.tag.otherTags= "Others from '%0'";
merge(cm.toolbar,{moreLabel:'+',lessLabel:'-'});
merge(c.messages.backstage,{open:{text:''},close:{text:''}});
//see ViewTemplate
//language settings
c.glyphs.codes.star=["\u22C6","\u22C6"];
cc.syncing.text="sync";
cc.references.text="ref";
cc.permalink.text="url";
var show="Show an URL in the brower address bar that ";
cc.permalink.tooltip=show+"links to the currently displayed tiddler";
cm.permaview.prompt=show+"retrieves all the currently displayed tiddlers";
cm.permaview.label="permalink";
cm.list.missing.prompt="referenced without tiddler:\n";
cm.list.orphans.prompt="tiddlers without reference:\n";
cm.list.shadowed.prompt="default shadow tiddlers:\n";
cm.option.passwordCheckboxLabel="save on this computer";
cm.tagging.label="Tagging tiddlers...";
//rename buttons
config.macros.rB={};
config.macros.rB.handler = function(place,macroName,params,wikifier,paramString,tiddler){
if (place.lastChild.tagName!="BR"){
var nameId=params.shift().split("#");
var name=nameId[0];
var id=nameId[1];
var title=params[0];
elem=place.lastChild;
if (elem.tagName.toUpperCase()!="A") elem=elem.firstChild;
elem.firstChild.data = name;
if (id) elem.setAttribute('id',id);
if (title) elem.title = title;
}
}
// Create a button for a tag with a popup listing all the tiddlers that it tags
if(!config.quickOpenTag){
createTagButton_NEW=createTagButton;
createTagButton = function (place,tag,excludeTiddler,title,tooltip)
{
var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
addClass(btn,store.getTaggedTiddlers(tag).length>0?'hastags':'hasnotags');
btn.setAttribute("tag",tag);
if(excludeTiddler)
btn.setAttribute("tiddler",excludeTiddler);
return btn;
}
}
//}}}