Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
<<myMacro niceList tags:"systemConfig,-Plugin,-Template">>
Index of all tiddlers
{{{<<tiddlerList tags:-Config group:"tiddler.title.substr(0,1)" groupTemplate:'!%group\n'>>}}}
<<tiddlerList tags:-Config group:"tiddler.title.substr(0,1)" groupTemplate:'!%group\n'>>
<<option chkAutoSave>> AutoSave
<<option chkGenerateAnRssFeed>> GenerateAnRssFeed
<<option chkSaveBackups>> SaveBackups
<<option chkOpenInNewWindow>> OpenLinksInNewWindow
<<option chkRegExpSearch>> ~RegExpSearch
<<option chkCaseSensitiveSearch>> ~CaseSensitiveSearch
<<option chkAnimate>> ~EnableAnimations
<<option chkToggleLinks>> Clicking on links to tiddlers that are already open causes them to close
<<option chkHttpReadOnly>> HideEditingFeatures when viewed over HTTP
^^(override with Shift key when clicking 'done' or by pressing Ctrl-Shift-Enter^^
<<option chkConfirmDelete>> ConfirmBeforeDeleting
|User name|<<option txtUserName>>|
|Tiddler Edit Size|<<option txtMaxEditRows>>|
|Backup folder|<<option txtBackupFolder>>|
!Custom
<<option chkSinglePageMode>> Single Page Mode
config.options.chkHttpReadOnly = true;
/***
|''Name:''|ArchivePlugin|
|''Version:''|2.4.0 (2 Jun 2008)|
|''Source''|http://jackparke.googlepages.com/jtw.html#ArchivePlugin ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23ArchivePlugin]])|
|''Author:''|[[Jack]]|
|''Type:''|Plugin|
!Description
The archive plugin allows you to store tiddler text outside of the tiddlywiki file.
Typically you would tag bulky tiddlers or those with infrequently needed content as "Archive" and these would
then be archived as separate html files in the sub folder called "archive".
!Usage
#Create a folder "archive" in the same folder as your tiddlywiki file.
#Install the Archive Plugin and reload your tiddlywiki
#Tag your bulky tiddlers with "Archive"
#Save your tiddlywiki file
!To Do
* Synchronize tiddler renames/deletions with file system
* Lazy loading of archived files via HTTP
!Code
***/
//{{{
version.extensions.ArchivePlugin = {major: 2, minor: 4, revision: 0, date: new Date("Jun 6, 2008")};
config.macros.ArchivePlugin = {};
config.macros.ArchivePlugin.init = function () {
this.archivePath = getWikiPath('archive');
}
// Hijacking the built-in functions
TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
{
try {
var extendedAttributes = "";
var usePre = config.options.chkUsePreForStorage;
store.forEachField(tiddler,
function(tiddler,fieldName,value) {
// don't store stuff from the temp namespace
if(typeof value != "string")
value = "";
if (!fieldName.match(/^temp\./))
extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
},true);
var created = tiddler.created.convertToYYYYMMDDHHMM();
var modified = tiddler.modified.convertToYYYYMMDDHHMM();
var vdate = version.date.convertToYYYYMMDDHHMM();
var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
attributes += (usePre && modified == created) ? "" : ' modified="' + modified +'"';
attributes += (usePre && created == vdate) ? "" :' created="' + created + '"';
var tags = tiddler.getTags();
if(!usePre || tags)
attributes += ' tags="' + tags.htmlEncode() + '"';
return ('<div %0="%1"%2%3>%4</'+'div>').format([
usePre ? "title" : "tiddler",
tiddler.title.htmlEncode(),
attributes,
extendedAttributes,
usePre ? "\n<pre>" + tiddler.saveMe() + "</pre>\n" : tiddler.escapeLineBreaks().htmlEncode()
]);
} catch (ex) {
throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
}
};
Tiddler.prototype.saveMe = function() {
if (this.tags.indexOf('Archive') != -1) {
// Save tiddler body to a file in the archive folder
if (this.text) saveFile(config.macros.ArchivePlugin.archivePath + this.title.filenameEncode() + '.html', this.text)
return '';
}
else
return this.text.htmlEncode();
}
// This hijack ensures plugins can also be archived
var archivePlugin_getPluginInfo = getPluginInfo;
getPluginInfo = function(tiddler) {
alert(tiddler.title)
tiddler.text = store.getValue(tiddler, 'text');
return archivePlugin_getPluginInfo(tiddler);
}
TiddlyWiki.prototype.getValue = function(tiddler, fieldName) {
var t = this.resolveTiddler(tiddler);
if (!t)
return undefined;
fieldName = fieldName.toLowerCase();
if (t.tags.indexOf('Archive')!=-1 && fieldName=='text' && t['text']=='') {
try {
var tmp = loadFile(config.macros.ArchivePlugin.archivePath + t.title.filenameEncode() + '.html');
tmp = (tmp.charCodeAt(0) == 239 ? manualConvertUTF8ToUnicode(tmp) : tmp);
} catch (e) {
return ''; //alert("{{{Error: Unable to load file '" + config.macros.ArchivePlugin.archivePath + t.title.filenameEncode() + '.html' + "'}}}");
}
return tmp;
} else {
var accessor = TiddlyWiki.standardFieldAccess[fieldName];
if (accessor) {
return accessor.get(t);
}
}
return t.fields ? t.fields[fieldName] : undefined;
}
String.prototype.filenameEncode = function() {
return(this.toLowerCase().replace(/[^a-z0-9_-]/g ,"_"));
}
function getWikiPath(folderName) {
var originalPath = document.location.toString();
if(originalPath.substr(0,5) != 'file:') {
alert(config.messages.notFileUrlError);
if(store.tiddlerExists(config.messages.saveInstructions))
story.displayTiddler(null,config.messages.saveInstructions);
return;
}
var localPath = getLocalPath(originalPath);
var backSlash = localPath.lastIndexOf('\\') == -1 ? '/' : '\\';
var dirPathPos = localPath.lastIndexOf(backSlash);
var subPath = localPath.substr(0,dirPathPos) + backSlash + (folderName ? folderName + backSlash : '');
return subPath;
}
// Deleting archive files
TiddlyWiki.prototype.archivePlugin_removeTiddler = TiddlyWiki.prototype.removeTiddler;
TiddlyWiki.prototype.removeTiddler = function(title) {
var tiddler = store.getTiddler(title);
var filePath = config.macros.ArchivePlugin.archivePath + title.filenameEncode() + '.html';
if (tiddler.tags.indexOf('Archive') != -1) ieDeleteFile(filePath);
this.archivePlugin_removeTiddler(title);
}
function ieDeleteFile(filePath) {
// IE Support only
if (!config.browser.isIE) return false;
try {
var fso = new ActiveXObject("Scripting.FileSystemObject");
} catch(ex) {return null;}
try {
var file = fso.GetFile(filePath);
file.Delete();
} catch(ex) {return null;}
return true;
}
//}}}
/***
|''Name:''|BreadCrumbsPlugin|
|''Version:''|2.2.1 (05-July-2007)|
|''Author:''|AlanHecht|
|''Adapted By:''|[[Jack]]|
|''Type:''|Plugin|
!Description
This plugin creates an area at the top of the tiddler area that displays "breadcrumbs" of where you've been. This is especially useful for ~TWs using SinglePageMode by Eric Schulman.
!Usage
Just install the plugin and tag with systemConfig. Optionally position the following div in your PageTemplate to control the positioning of the breadcrumbs menu:
{{{
<div id='breadCrumbs'></div>
}}}
!Revision History
* Original by AlanHecht
* 2.0 Made 2.0.x compatible by [[Jack]]
* Made 2.0.10 compatible (onstart paramifier)
* Bugfix -> return false in onClickTiddlerLink()
* 2.2 Made 2.2.x compatible
!Code
***/
// // Use the following line to set the number of breadcrumbs to display before rotating them off the list.
//{{{
version.extensions.breadCrumbs = {major: 2, minor: 2, revision: 1, date: new Date("Jul 5, 2007")};
var crumbsToShow = 7;
var breadCrumbs = [];
onClickTiddlerLink_orig_breadCrumbs = onClickTiddlerLink;
onClickTiddlerLink = function(e){
onClickTiddlerLink_orig_breadCrumbs(e);
breadcrumbsAdd(e);
return false;
}
restart_orig_breadCrumbs = restart;
function restart() {
invokeParamifier(params,"onstart");
var defaultParams = store.getTiddlerText("DefaultTiddlers").parseParams("open",null,false);
invokeParamifier(defaultParams,"onstart");
breadCrumbs = [];
breadcrumbsRefresh();
window.scrollTo(0,0);
return false;
}
function breadcrumbsAdd(e) {
var uniqueCrumb = true;
var crumbIndex = 0;
if (!e) var e = window.event;
var target = resolveTarget(e);
var thisCrumb="[["+resolveTarget(e).getAttribute("tiddlyLink")+"]]";
var lastInactiveCrumb = breadCrumbs.length -(breadCrumbs.length < crumbsToShow ? breadCrumbs.length : crumbsToShow);
for(t=lastInactiveCrumb; t<breadCrumbs.length; t++)
if(breadCrumbs[t] == thisCrumb) {
uniqueCrumb = false;
crumbIndex = t+1;
}
if(uniqueCrumb)
breadCrumbs.push(thisCrumb);
else
breadCrumbs = breadCrumbs.slice(0,crumbIndex);
breadcrumbsRefresh();
}
function breadcrumbsRefresh() {
if (!document.getElementById("breadCrumbs")) {
// Create breadCrumbs div
var ca = document.createElement("div");
ca.id = "breadCrumbs";
ca.style.visibility= "hidden";
var targetArea = document.getElementById("tiddlerDisplay")||document.getElementById("storyDisplay");
targetArea.parentNode.insertBefore(ca,targetArea);
}
var crumbArea = document.getElementById("breadCrumbs");
crumbArea.style.visibility = "visible";
removeChildren(crumbArea);
createTiddlyButton(crumbArea,"Home",null,restart);
crumbArea.appendChild(document.createTextNode(" > "));
var crumbLine = "";
var crumbCount = breadCrumbs.length;
var firstCrumb = crumbCount -(crumbCount < crumbsToShow ? crumbCount : crumbsToShow);
for(t=firstCrumb; t<crumbCount; t++) {
if(t != firstCrumb)
crumbLine += " > ";
crumbLine += breadCrumbs[t];
}
wikify(crumbLine,crumbArea)
}
//}}}
/***
|''Name:''|CloseUnsavedOnCancel|
|''Version:''|2.0.8 (16-Apr-2006)|
|''Author:''|SimonBaird|
|''Adapted By:''|[[Jack]]|
|''Type:''|Plugin|
!Description
When you click new tiddler then click cancel I think the new tiddler should close automatically. This plugin implements that behaviour.
!Revision History
* 1.0.1 (11-Oct-2005) by SimonBaird
* 2.0.8 Made 2.0.x compatible by Jack on 16-Apr-2006
!Code
***/
//{{{
config.commands.cancelTiddler.handler = function(event,src,title) {
if(story.hasChanges(title) && !readOnly)
if(!confirm(this.warning.format([title])))
return false;
story.setDirty(title,false);
if (!store.tiddlerExists(title) || store.fetchTiddler(title).modifier==config.views.wikified.defaultModifier) {
story.closeTiddler(title,false);
store.removeTiddler(title)
} else {
story.displayTiddler(null,title);
}
return false;
}
//}}}
Background: #fff
Foreground: #000
PrimaryPale: #EEE
PrimaryLight: #777
PrimaryMid: #111
PrimaryDark: #000
SecondaryPale: #EEF
SecondaryLight: #CCF
SecondaryMid: #69C
SecondaryDark: #36C
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #333
Error: #f88
<<tabs tabsClass
Layout "Layout Templates" SystemLayout
System "System Tiddlers" SystemTiddlers
Style "StyleSheets" StyleSheets
"Side Bar" "Side Bar Elements" SystemSideBars
Options "Personal Preferences" SystemOptions
Plugins "Installed Plugins" SystemPlugins
Shadows "Hidden System Pages" ShadowPages
>>
<<configOptions
chkAutoSave=true
txtUserName=Jack
chkSaveBackups=false
chkHttpReadOnly=false
chkSinglePageMode=true
>>
See the ConfigOptionsMacro
/***
|''Name:''|ConfigOptionsMacro|
|''Version:''|0.1 (31 May 2007)|
|''Source''|http://jackparke.googlepages.com/jtw.html#ConfigOptionsMacro ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23ConfigOptionsMacro]])|
|''Author:''|[[Jack]]|
!Description
This plugin allows you to store TiddlyWiki options in a tiddler. This means the options are part of the store and are not shared among TiddlyWiki files. The options are also more robust and persist when cookies are loaded.
!Usage
*After installation, enter the options you want persisted into the [[ConfigOptions]] tiddler
*In view mode of this tiddler you can see and modify the options
*Changes are effective and written immediately to the ConfigOptions tiddler as you modify them
*The options are loaded from ConfigOptions on startup of TiddlyWiki overriding any cookie settings
!Revision History
* Original by [[Jack]] 31 May 2007
!Code
***/
//{{{
version.extensions.configOptions = {major: 0, minor: 0, revision: 1, date: new Date('May 31, 2007')};
config.shadowTiddlers.ConfigOptions = '<<configOptions\nchkAutoSave=false\ntxtUserName=Your Name\n>>'
config.macros.configOptions = {};
config.macros.configOptions.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
var resultText = this.parseOptions(paramString);
if (resultText) {
resultText = '|!Option|!Value|\n' + resultText;
wikify(resultText, place)
//createTiddlyButton(place,'Update','Saves your current options to the ConfigOptions tiddler.',this.update);
applyHtmlMacros(place,tiddler)
}
}
config.macros.configOptions.init = function() {
var txtConfigOptions = store.getValue('ConfigOptions', 'text') || config.shadowTiddlers.ConfigOptions;
txtConfigOptions = txtConfigOptions.substr(txtConfigOptions.indexOf('\n')).substr(0, txtConfigOptions.length-2);
this.parseOptions(txtConfigOptions);
}
config.macros.configOptions.parseOptions = function (paramString) {
var resultText = ''
var options = paramString.split(/\n/);
for(var i=0; i < options.length; i++) {
var opt = options[i].split('=');
if(opt.length > 1) {
if (opt[1] != 'true' && opt[1] != 'false' && !opt[1].match(/^\d+$/))
opt[1] = '\'' + opt[1].replace(/'/, '\\\'') + '\'';
resultText += '|' + opt[0].replace(/^[a-z]{2,3}/,'') + '|<<option ' + opt[0] + '>>|\n'
try {
eval('config.options.' + opt[0] + ' = ' + opt[1] + ';');
//alert('config.options.' + opt[0] + ' = ' + opt[1] + ';')
} catch (e) {
debugger
}
}
}
return resultText;
}
config.macros.option.propagateOption = function(opt,valueField,value,elementType)
{
config.options[opt] = value;
// saveOptionCookie(opt);
//if (opt=='txtUserName') debugger;
if ((new RegExp('\n' + opt + '=','g')).test(store.getValue('ConfigOptions','text'))) {
config.macros.configOptions.updateOption(opt, decodeCookie(config.optionHandlers[opt.substr(0,3)].get(opt)))
}
var nodes = document.getElementsByTagName(elementType);
for(var t=0; t<nodes.length; t++) {
var optNode = nodes[t].getAttribute("option");
if(opt == optNode)
nodes[t][valueField] = value;
}
}
config.macros.configOptions.updateOption = function(name, value) {
var txtConfigOptions = store.getValue('ConfigOptions', 'text');
var t1 = txtConfigOptions.indexOf('\n' + name + '=');
var t2 = txtConfigOptions.indexOf('\n', t1+1);
txtConfigOptions = txtConfigOptions.substr(0,t1) + '\n' + name + '=' + value + txtConfigOptions.substr(t2)
store.setValue('ConfigOptions', 'text', txtConfigOptions)
}
//}}}
<<tabs tabsClass
Config "Config Tiddlers" ConfigTiddlers
Plugins "Installed Plugins" SystemPlugins
>>
<<tiddlerList tags:"Config">>
/***
|''Name:''|Definition Macro|
|''Version:''|0.1|
|''Source''|http://jackparke.googlepages.com/jtw.html#DefinitionMacro ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23DefinitionMacro]])|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Allow definitions of glossary terms to be easily visible via mouseover
!Usage
{{{<<def MyTermTiddler>>}}}
Do you know what <<def EDM>> is?
!Revision History
* Original by [[Jack]] 24 May 2006
!Code
***/
//{{{
version.extensions.def = {major: 0, minor: 1, revision: 0, date: new Date("May 24, 2006")};
config.macros.def = {};
config.macros.def.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
var text = store.getTiddlerText(params[0]);
var wrapper = createTiddlyButton(place,params[0],text?"":"No definition available.",onClickTiddlerLink,"definition")
var e = createTiddlyElement(wrapper,"span",null,null,text)
wrapper.setAttribute("tiddlyLink", params[0])
}
config.macros.def.editMe = function(e) {
var title = this.getAttribute("tiddlyLink");
clearMessage();
story.displayTiddler(null,title,DEFAULT_VIEW_TEMPLATE);
story.focusTiddler(title,"text");
}
setStylesheet("a.definition {position:relative; z-index:24;} a.definition:hover {z-index:25;} a.definition span{display:none;} a.definition:hover span{display:block; position:absolute; top:2em; left:2em; width:15em; border:1px solid #ffd; background-color:#ffd; color:#000; text-align: center}");
//}}}
/***
|''Name:''|DeliciousTaggingPlugin|
|''Version:''|0.1|
|''Source''|http://jackparke.googlepages.com/jtw.html#DeliciousTaggingPlugin ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%DeliciousTaggingPlugin]])|
|''Author:''|[[Jack]]|
!Description
Allows easy 'del.icio.us'-like tagging in the EditTemplate by showing all tags as a list of link-buttons.
!Usage
Replace your the editorFooter div in your [[EditTemplate]] with the following:
{{{
<div class='editorFooter' macro='deliciousTagging'></div>
}}}
!Code
***/
//{{{
version.extensions.deliciousTagging = {major: 0, minor: 1, revision: 0, date: new Date("June 11, 2007")};
config.macros.deliciousTagging= {};
config.macros.deliciousTagging.onTagClick = function(e)
{
if(!e) var e = window.event;
var tag = this.getAttribute("tag");
var title = this.getAttribute("tiddler");
if(!readOnly)
story.setTiddlerTag(title,tag,0);
return false;
};
config.macros.deliciousTagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
if(tiddler instanceof Tiddler) {
var title = tiddler.title;
if(!e) var e = window.event;
var tags = store.getTags();
var lingo = config.views.editor.tagChooser;
for(var t=0; t<tags.length; t++) {
var theTag = createTiddlyButton(place,tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.deliciousTagging.onTagClick);
theTag.setAttribute("tag",tags[t][0]);
theTag.setAttribute("tiddler",tiddler.title);
place.appendChild(document.createTextNode(" "));
}
}
};
//}}}
/***
|''Name:''|DoBackupMacro|
|''Version:''|2.0 (9-Apr-2006)|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Creates a button which allows you to backup your TiddlyWiki on demand.
!Usage
Add the following command to your SideBarOptions tiddler:
{{{<<doBackup>>}}}
!Revision History
* Original by [[Jack]] 9-Apr-2006
!To Do
* List non-explicit links (e.g. from tagging macro)
!Code
***/
//{{{
version.extensions.doBackup= {major: 2, minor: 0, revision: 0, date: new Date("Apr 9, 2006")};
config.macros.doBackup={label: "backup", prompt: "Backup this TiddlyWiki"}
config.macros.doBackup.handler = function(place)
{
if(!readOnly)
createTiddlyButton(place,this.label,this.prompt,function ()
{doBackup(); return false;},null,null,this.accessKey);
}
doBackup = function() {
var optSaveBackups = config.options.chkSaveBackups
config.options.chkSaveBackups = true
saveChanges()
config.options.chkSaveBackups = optSaveBackups
}
//}}}
* In Single Page Mode we should not jump to 0,0 when opening a tiddler ([[Hack]]ed)
* In Single Page Mode, when a user presses Alt while clicking a tiddler, it should not close all tiddlers.
* Search should display all results in Single Page Mode ([[Hack]]ed)
* Add favorites tab instead of "More". Easy tagging using a checkbox.
* TiddlerListMacro should allow filter:"tiddler.title.length<12 && tiddler.tags.containsAny("Plugin")"
* TiddlerListMacro should allow custom templates for header, footer, item and group
/***
| Name:|''dropTags''|
| Created by:|SaqImtiaz|
| Location:|http://lewcid.googlepages.com/lewcid.html|
| Version:|0.4 (06-Apr-2006)|
| Requires:|~TW2.07|
!About
*provides a drop down list of tags in the current tiddler, a replacement for the core tags macro.
!Demonstration
*DropTagsTest
''I recommend using either tagAdder or monkeyTagger, with dropTags and dropTagging in the toolbar:''
Examples:
#: tagAdder & dropTags: TagToolbarTest1
#: monkeyTagger & dropTags: TagToolbarTest2
!Usage
{{{<<dropTags>>}}} for <<dropTags>>
or {{{<<dropTags 'custom label'>>}}} for <<dropTags 'custom label'>>
!Installation:
*Copy this tiddler to your TW with the systemConfig tag
* copy the following to your ViewTemplate:
#either {{{<div class='tagged' macro='dropTags'></div>}}} to add to next to the tags macro in the viewer area, or
#{{{<div class='toolbar' >
<span style="padding-right:8.75em;" macro='dropTags "current tags: "+config.macros.dropTags.dropdownchar}}'></span>
<span macro='toolbar -closeTiddler closeOthers +editTiddler permalink references jump'></span>
</div>}}}
!To Do
*tweak popup css to optimize placement and colors.
*''optimize code to use core functions and reduce code size!''
!Code
***/
//{{{
//do we need this?
window.removeEvent(document,"click",Popup.onDocumentClick);
//hijack some core Popup functions
window.PopuponDocumentClick_droptag=window.Popup.onDocumentClick;
window.Popup.onDocumentClick = function(e)
{
if (!e) var e = window.event;
var target = resolveTarget(e);
if(e.eventPhase == undefined)
Popup.removeFrom(0);
else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase ==Event.AT_TARGET)
Popup.removeFrom(0);
return true;
}
window.Popupremove_droptag = window.Popup.remove;
window.Popup.remove = function()
{
if ((Popup.stack.length > 1)&&(document.getElementById("droptag")))
{Popup.removeFrom(1);}
else if(Popup.stack.length > 1)
{Popup.removeFrom(0);};
}
//add eventlistener
window.addEvent(document,"click",Popup.onDocumentClick);
//start dropTags macro
config.macros.dropTags={};
//config.macros.dropTags.dropdownchar = (document.all?"?":"?"); // the fat one is the only one that works in IE
config.macros.dropTags.dropdownchar = "?"; // uncomment previous line and comment this for smaller version in FF
config.macros.dropTags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
var arrow=': '+ config.macros.dropTags.dropdownchar;
var droptaglabel= (params[0] && params[0] !='.')? params[0]: 'tags'+arrow;
var droptagtooltip="current tags for this tiddler";
var droptag = function(e)
{ if (!e) var e = window.event;
var popup = Popup.create(this);
var lingo = config.views.wikified.tag;
if (tiddler.tags.length==0)
createTiddlyElement(popup,"li",null,"listTitle",lingo.labelNoTags);
else
for(var t=0; t<tiddler.tags.length; t++)
{createTagButton(createTiddlyElement(popup,"li","droptag",null,null),tiddler.tags[t],tiddler.title);}
Popup.show(popup,false);
e.cancelBubble = true;
if (e.stopPropagation)
e.stopPropagation();
return(false);
};
var createdropperButton = function(place){
var sp = createTiddlyElement(place,"span",null,"tagdropbutton");
var theDropDownBtn = createTiddlyButton(sp,droptaglabel,droptagtooltip,droptag);
};
createdropperButton(place);
//createTiddlyButton(place,droptaglabel,droptaglabel,droptag);
};
setStylesheet(
".toolbar .tagdropbutton { margin-right:0em; border:0px solid #eee; padding:0px; padding-right:0px; padding-left:0px; }\n"+
".tagdropbutton a.button { padding:2px; padding-left:2px; padding-right:2px;}\n"+
// ".tagdropbutton {font-size:150%;}\n"+
".popup .highlight{background: #fe8; color:#000;}\n"+
"",
"DropTagsStyles");
//}}}
Electronic Distance Measurement
<div class='toolbar' macro='toolbar +saveTiddler saveClose -cancelTiddler deleteTiddler'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div>
<div class='editorFooter' macro='deliciousTagging'></div>
/***
|Name|ExternalTiddlersPlugin|
|Source|http://www.TiddlyTools.com/#ExternalTiddlersPlugin|
|Documentation|http://www.TiddlyTools.com/#ExternalTiddlersPluginInfo|
|Version|1.3.0|
|Author|Eric Shulman - ELS Design Studios|
|License|http://www.TiddlyTools.com/#LegalStatements <br>and [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|plugin|
|Requires|TemporaryTiddlersPlugin (optional, recommended)|
|Overrides|config.macros.tiddler.handler|
|Description|retrieve and wikify content from external files or remote URLs|
This plugin extends the {{{<<tiddler>>}}} macro syntax so you can retrieve and wikify content directly from external files or remote URLs. You can also define alternative "fallback" sources to provide basic "import on demand" handling by automatically creating/importing tiddler content from external sources when the specified ~TiddlerName does not already exist in your document.
!!!!!Documentation
>see [[ExternalTiddlersPluginInfo]]
!!!!!Configuration
<<<
<<option chkExternalTiddlersImport>> automatically create/import tiddlers when using external fallback references
{{{usage: <<option chkExternalTiddlersImport>>}}}
<<option chkExternalTiddlersQuiet>> don't display messages when adding tiddlers ("quiet mode")
{{{usage: <<option chkExternalTiddlersQuiet>>}}}
<<option chkExternalTiddlersTemporary>> tag retrieved tiddlers as 'temporary'(requires [[TemporaryTiddlersPlugin]])
{{{usage: <<option chkExternalTiddlersTemporary>>}}}
tag retrieved tiddlers with: <<option txtExternalTiddlersTags>>
{{{usage: <<option txtExternalTiddlersTags>>}}}
__password-protected server settings //(optional, if needed)//:__
>username: <<option txtRemoteUsername>> password: <<option txtRemotePassword>>
>{{{usage: <<option txtRemoteUsername>> <<option txtRemotePassword>>}}}
>''note: these settings are also used by [[LoadTiddlersPlugin]] and [[ImportTiddlersPlugin]]''
<<<
!!!!!Code
***/
//{{{
version.extensions.ExternalTiddlers= {major: 1, minor: 3, revision: 0, date: new Date(2008,1,3)};
// optional automatic import/create for missing tiddlers
if (config.options.chkExternalTiddlersImport==undefined) config.options.chkExternalTiddlersImport=true;
if (config.options.chkExternalTiddlersTemporary==undefined) config.options.chkExternalTiddlersTemporary=true;
if (config.options.chkExternalTiddlersQuiet==undefined) config.options.chkExternalTiddlersQuiet=false;
if (config.options.txtExternalTiddlersTags==undefined) config.options.txtExternalTiddlersTags="external";
if (config.options.txtRemoteUsername==undefined) config.options.txtRemoteUsername="";
if (config.options.txtRemotePassword==undefined) config.options.txtRemotePassword="";
config.macros.tiddler.externalTiddlers_handler = config.macros.tiddler.handler;
config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
params = paramString.parseParams("name",null,true,false,true);
var names = params[0]["name"];
var list = names[0];
var items = list.split("|");
var className = names[1] ? names[1] : null;
var args = params[0]["with"];
// UTILITY FUNCTIONS
function extract(text,tids) { // get tiddler source content from plain text or TW doc
if (!text || !tids || !tids.length) return text; // no text or no tiddler list... return text as-is
var remoteStore=new TiddlyWiki();
if (!remoteStore.importTiddlyWiki(text)) return text; // not a TW document... return text as-is
var out=[]; for (var t=0;t<tids.length;t++)
{ var txt=remoteStore.getTiddlerText(tids[t]); if (txt) out.push(txt); }
return out.join("\n");
}
function substitute(text,args) { // replace "substitution markers" ($1-$9) with macro param values (if any)
if (!text || !args || !args.length) return text;
var n=args.length; if (n>9) n=9;
for(var i=0; i<n; i++) { var re=new RegExp("\\$" + (i + 1),"mg"); text=text.replace(re,args[i]); }
return text;
}
function addTiddler(src,text,tids) { // extract tiddler(s) from text and create local copy
if (!config.options.chkExternalTiddlersImport) return; // not enabled... do nothing
if (!text || !tids || !tids.length) return; // no text or no tiddler list... do nothing
var remoteStore=new TiddlyWiki();
if (!remoteStore.importTiddlyWiki(text)) // not a TW document... create a single tiddler from text
makeTiddler(src,text,tids[0]);
else // TW document with "permaview-like" suffix... copy tiddler(s) from remote store
for (var t=0;t<tids.length;t++)
insertTiddler(src,remoteStore.getTiddler(tids[t]));
return;
}
function makeTiddler(src,text,title) { // create a new tiddler object from text
var who=config.options.txtUserName; var when=new Date();
var msg="/%\n\nThis tiddler was automatically created using ExternalTiddlersPlugin\n";
msg+="by %0 on %1\nsource: %2\n\n%/";
var tags=config.options.txtExternalTiddlersTags.readBracketedList();
if (config.options.chkExternalTiddlersTemporary) tags.pushUnique(config.options.txtTemporaryTag);
store.saveTiddler(null,title,msg.format([who,when,src])+text,who,when,tags,{});
if (!config.options.chkExternalTiddlersQuiet) displayMessage("Created new tiddler '"+title+"' from text file "+src);
}
function insertTiddler(src,t) { // import a single tiddler object into the current document store
if (!t) return;
var who=config.options.txtUserName; var when=new Date();
var msg="/%\n\nThis tiddler was automatically imported using ExternalTiddlersPlugin\n";
msg+="by %0 on %1\nsource: %2\n\n%/";
var newtags=Array.concat(t.tags,config.options.txtExternalTiddlersTags.readBracketedList());
if (config.options.chkExternalTiddlersTemporary) newtags.push(config.options.txtTemporaryTag);
store.saveTiddler(null,t.title,msg.format([who,when,src])+t.text,t.modifier,t.modified,newtags,t.fields);
if (!config.options.chkExternalTiddlersQuiet) displayMessage("Imported tiddler '"+t.title+"' from "+src);
}
function getGUID() // create a Globally Unique ID (for async reference to DOM elements)
{ return new Date().getTime()+Math.random().toString(); }
// loop through "|"-separated list of alternative tiddler/file/URL references until successful
var fallback="";
for (var i=0; i<items.length; i++) { var src=items[i];
// if tiddler (or shadow) exists, replace reference list with current source name and apply core handler
if (store.getTiddlerText(src)) {
arguments[2][0]=src; // params[] array
var p=arguments[4].split(list); arguments[4]=p[0]+src+p[1]; // paramString
this.externalTiddlers_handler.apply(this,arguments);
break; // stop processing alternatives
}
// tiddler doesn't exist, and not an external file/URL reference... skip it
if (!config.formatterHelpers.isExternalLink(src)) {
if (!fallback.length) fallback=src; // title to use when importing external tiddler
continue;
}
// separate 'permaview' list of tiddlers (if any) from file/URL (i.e., '#name name name..." suffix)
var p=src.split("#"); src=p[0]; var tids=p[1]?p[1].readBracketedList(false):[];
// if reference is to a remotely hosted document or the current document is remotely hosted...
if (src.substr(0,4)=="http" || document.location.protocol.substr(0,4)=="http") {
if (src.substr(0,4)!="http") // fixup URL for relative remote references
{ var h=document.location.href; src=h.substr(0,h.lastIndexOf("/")+1)+src; }
var wrapper = createTiddlyElement(place,"span",getGUID(),className); // create placeholder for async rendering
var callback=function(success,params,text,src,xhr) { // ASYNC CALLBACK
if (!success) { displayMessage(xhr.status); return; } // couldn't read remote file... report the error
if (params.fallback.length)
addTiddler(params.url,text,params.tids.length?params.tids:[params.fallback]); // import tiddler
var wrapper=document.getElementById(params.id); if (!wrapper) return;
wikify(substitute(extract(text,params.tids),params.args),wrapper); // ASYNC RENDER
};
var callbackparams={ url:src, id:wrapper.id, args:args, tids:tids, fallback:fallback } // ASYNC PARAMS
var name=config.options.txtRemoteUsername; // optional value
var pass=config.options.txtRemotePassword; // optional value
var x=doHttp("GET",src,null,null,name,pass,callback,callbackparams,null)
if (typeof(x)=="string") // couldn't start XMLHttpRequest... report error
{ displayMessage("error: cannot access "+src); displayMessage(x); }
break; // can't tell if async read will succeed.... stop processing alternatives anyway.
}
else { // read file from local filesystem
var text=loadFile(getLocalPath(src));
if (!text) { // couldn't load file... fixup path for relative reference and retry...
var h=document.location.href;
var text=loadFile(getLocalPath(decodeURIComponent(h.substr(0,h.lastIndexOf("/")+1)))+src);
}
if (text) { // test it again... if file was loaded OK, render it in a class wrapper
if (fallback.length) // create new tiddler using primary source name (if any)
addTiddler(src,text,tids.length?tids:[fallback]);
var wrapper=createTiddlyElement(place,"span",null,className);
wikify(substitute(extract(text,tids),args),wrapper); // render
break; // stop processing alternatives
}
}
}
};
//}}}
<<tiddlerList tags:"Favorite">>
/***
|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.
!!!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
//}}}
!!!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=2;
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 value="search..." autocomplete="off" accesskey="G" style="%instyle%"\
title="ENTER=search | SHIFT+ENTER=open | DOWN=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','');
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;
}
}
//}}}
// // My favorite hacks
// // This makes the tagging macro present a simple list without title
//{{{
config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
var theList = createTiddlyElement(place,"ul");
var title = "";
if(tiddler instanceof Tiddler)
title = tiddler.title;
if(params[0])
title = params[0];
var tagged = store.getTaggedTiddlers(title);
for(var t=0; t<tagged.length; t++)
createTiddlyLink(createTiddlyElement(theList,"li"),tagged[t].title,true);
}
//}}}
// // Make the list of tags horizontal
//{{{
config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
if(params[0] && store.tiddlerExists(params[0]))
tiddler = store.getTiddler(params[0]);
for(var t=0; t<tiddler.tags.length;t++)
createTagButton(createTiddlyElement(place,"span"),tiddler.tags[t],tiddler.title);
}
//}}}
// // Workarounds for SinglePageModePlugin
//{{{
onClickTagOpenAll = function(e) {
var oldChkSinglePageMode = config.options.chkSinglePageMode;
config.options.chkSinglePageMode = false;
if (!e) var e = window.event;
var tag = this.getAttribute("tag");
var tagged = store.getTaggedTiddlers(tag);
for(var t=tagged.length-1; t>=0; t--)
story.displayTiddler(this,tagged[t].title,null,false,e.shiftKey || e.altKey);
config.options.chkSinglePageMode = oldChkSinglePageMode;
return(false);
}
// // Prevent scrolldown when viewing tiddlers
Story.prototype.displayTiddlerOld = Story.prototype.displayTiddler;
Story.prototype.displayTiddler = function(srcElement,title,template,animate,slowly) {
this.displayTiddlerOld(srcElement,title,template,animate,slowly);
if (config.options.chkSinglePageMode) window.scrollTo(0,0);
}
// // Enable search for SinglePageMode
Story.prototype.searchOld = Story.prototype.search;
Story.prototype.search = function(text,useCaseSensitive,useRegExp) {
var oldChkSinglePageMode = config.options.chkSinglePageMode
config.options.chkSinglePageMode = false;
this.searchOld(text,useCaseSensitive,useRegExp);
config.options.chkSinglePageMode = oldChkSinglePageMode;
return(false);
}
//}}}
// // Fix for broken file import
//{{{
FileAdaptor.prototype.openHost = function(host,context,userParams,callback)
{
this.host = host;
if(!context)
context = {};
context.adaptor = this;
context.callback = callback;
context.userParams = userParams;
var str = loadFile(host.replace(/file:\/\//,''),FileAdaptor.openHostCallback,context);
if (str)
FileAdaptor.openHostCallback(true,context,str,host,null)
else
return "Error loading file " + host;
return true;
};
//}}}
// // Configurable Search Exclusion Tags
//{{{
TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
{
if (lookupField=='tags' && lookupValue=='excludeSearch') lookupValue=config.options.txtExcludeSearch;
var arrLookupValue = lookupValue.readBracketedList();
var results = [];
this.forEachTiddler(function(title,tiddler) {
var f = !lookupMatch;
for(var lookup=0; lookup<tiddler[lookupField].length; lookup++) {
if(arrLookupValue.contains(tiddler[lookupField][lookup]))
f = lookupMatch;
}
if(f)
results.push(tiddler);
});
if(!sortField)
sortField = "title";
results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
return results;
};
TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag)
{
var candidates = this.reverseLookup("tags",excludeTag,false);
var results = [];
for(var t=0; t<candidates.length; t++) {
if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
results.push(candidates[t]);
}
if(!sortField)
sortField = "title";
results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
if (results.length == 0 && excludeTag == 'excludeSearch')
return this.search(searchRegExp,sortField,"");
else
return results;
};
//}}}
//{{{
config.commands.refreshTiddler = {
handler : function(event,src,title) {
story.refreshTiddler(title,event.getAttribute("template"),true);
return false;
},
text: "refresh",
tooltip: "Refresh this tiddler"
}
;
chkConfirmDelete=false;
//}}}
''Hello all...'' here is a [[link to google|http://www.google.com]] and a [[pretty internal link|Plugins]] and link to [[Plugins]].
<<tiddlerList tags:"-Config,-systemConfig,-Template" group:'tiddler.title.substr(0,1)' groupTemplate:"<<section %group\n" groupFooterTemplate:"$))\n">>
That's me!
jackparke at! gmail dotcom
[[http://jackparke.googlepages.com/]]
/***
|''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);
}
//}}}
<<tiddlerList tags:Menu,-Template format:stack>>
[[Config]]
<<tiddler MyMacros>>
Powered By:
[[TiddlyWiki|http://www.tiddlywiki.com]]
<<myMacro niceList tags:"Plugin,-Template">>
''Note:''
This list is created using the TiddlerListMacro as:
{{{<<myMacro niceList>>}}}
The named macro "niceList" is a MyMacroMacro defined in the MyMacros.
Index of all tiddlers by month
{{{<<tiddlerList group:"tiddler.created.formatString('DD MMM YYYY')" sort:"created">>}}}
<<tiddlerList group:"tiddler.created.formatString('DD MMM YYYY')" sort:"created">>
/***
|''Name:''|MultiTagEditorPlugin|
|''Version:''|0.2.0 (Dec 29, 2006)|
|''Source:''|http://ido-xp.tiddlyspot.com/#MultiTagEditorPlugin|
|''Author:''|Ido Magal (idoXatXidomagalXdotXcom)|
|''Licence:''|[[BSD open source license]]|
|''CoreVersion:''|2.1.0|
|''Browser:''|??|
!Description
This plugin enables the addition and deletion of tags from sets of tiddlers.
!Installation instructions
*Create a new tiddler in your wiki and copy the contents of this tiddler into it. Name it the same and tag it with "systemConfig".
*Save and reload your wiki.
*Use it here [[MultiTagEditor]].
!Revision history
* v0.2.0 (Dec 29, 2006)
** Added Selection column that allows excluding tiddlers.
* v0.1.0 (Dec 27, 2006)
** First draft.
!To Do
* Clean up text strings.
* Figure out how to store selection so it isn't reset after every action.
* Prettify layout.
!Code
***/
//{{{
merge(config.shadowTiddlers,
{
MultiTagEditor:[
"<<MTE>>",
""
].join("\n")
});
config.macros.MTE =
{
AddToListLabel : "Add to List",
AddToListPrompt : "Add Tiddlers to the List",
listViewTemplate :
{
columns: [
{name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
{name: 'Title', field: 'title', tiddlerLink: 'title', title: "Title", type: 'TiddlerLink'},
{name: 'Snippet', field: 'text', title: "Snippet", type: 'String'},
{name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
],
rowClasses: [
],
actions: [
//{caption: "More actions...", name: ''},
//{caption: "Remove selected tiddlers from list", name: 'delete'}
]
},
tiddlers : [],
HomeSection : [],
ListViewSection : [],
AddToListSection : [],
handler : function( place, macroName, params, wikifier, paramString, tiddler )
{
this.HomeSection = place;
var newsection = createTiddlyElement( null, "div", null, "MTE_AddTag" );
createTiddlyText(newsection, "Tiddler Tags to edit: ");
var input = createTiddlyElement( null, "input", null, "txtOptionInput" );
input.type = "text";
input.size = 50;
newsection.appendChild( input );
newsection.inputBox = input;
createTiddlyButton( newsection, this.AddToListLabel, this.AddToListPrompt, this.onAddToList, null, null, null );
createTiddlyButton( newsection, "Clear List", this.addtoListPrompt, this.onClear, null, null, null );
createTiddlyElement( newsection, "br" );
createTiddlyElement( newsection, "br" );
this.AddToListSection = newsection;
this.HomeSection.appendChild( newsection );
newsection = createTiddlyElement( null, "div", null, "MTE_addtag" );
createTiddlyButton( newsection, "Add Tag", "Add tag to all listed tiddlers", this.onAddTag, null, null, null );
var input = createTiddlyElement( null, "input", null, "txtOptionInput" );
input.type = "text";
input.size = 50;
newsection.appendChild( input );
newsection.inputBox = input;
createTiddlyElement( newsection, "br" );
this.AddTagSection = newsection;
this.HomeSection.appendChild( newsection );
newsection = createTiddlyElement( null, "div", null, "MTE_removetag" );
createTiddlyButton( newsection, "Remove Tag", "Remove tag from all listed tiddlers", this.onRemoveTag, null, null, null );
var input = createTiddlyElement( null, "input", null, "txtOptionInput" );
input.type = "text";
input.size = 50;
newsection.appendChild( input );
newsection.inputBox = input;
createTiddlyElement( newsection, "br" );
this.RemoveTagSection = newsection;
this.HomeSection.appendChild( newsection );
this.ListViewSection = createTiddlyElement( null, "div", null, "MTE_listview" );
this.HomeSection.appendChild( this.ListViewSection );
ListView.create( this.ListViewSection, this.tiddlers, this.listViewTemplate, null );
},
ResetListView : function()
{
ListView.forEachSelector( config.macros.MTE.ListViewSection, function( e, rowName )
{
if( e.checked )
{
var title = e.getAttribute( "rowName" );
var tiddler = config.macros.MTE.tiddlers.findByField( "title", title );
tiddler.Selected = 1;
}
});
config.macros.MTE.HomeSection.removeChild( config.macros.MTE.ListViewSection );
config.macros.MTE.ListViewSection = createTiddlyElement( null, "div", null, "MTE_listview" );
config.macros.MTE.HomeSection.appendChild( config.macros.MTE.ListViewSection );
ListView.create( config.macros.MTE.ListViewSection, config.macros.MTE.tiddlers, config.macros.MTE.listViewTemplate, config.macros.MTE.onSelectCommand);
},
onAddToList : function()
{
store.forEachTiddler( function ( title, tiddler )
{
var tags = config.macros.MTE.AddToListSection.inputBox.value.readBracketedList();
if (( tiddler.tags.containsAll( tags )) && ( config.macros.MTE.tiddlers.findByField( "title", title ) == null ))
{
var t = store.getTiddlerSlices( title, ["Name", "Description", "Version", "CoreVersion", "Date", "Source", "Author", "License", "Browsers"] );
t.title = title;
t.tiddler = tiddler;
t.text = tiddler.text.substr(0,50);
t.tags = tiddler.tags;
config.macros.MTE.tiddlers.push(t);
}
});
config.macros.MTE.ResetListView();
},
onClear : function()
{
config.macros.MTE.tiddlers = [];
config.macros.MTE.ResetListView();
},
onAddTag : function( e )
{
var selectedRows = [];
ListView.forEachSelector(config.macros.MTE.ListViewSection, function( e, rowName )
{
if( e.checked )
selectedRows.push( e.getAttribute( "rowName" ));
});
var tag = config.macros.MTE.AddTagSection.inputBox.value;
for(t=0; t < config.macros.MTE.tiddlers.length; t++)
{
if ( selectedRows.indexOf( config.macros.MTE.tiddlers[t].title ) != -1 )
store.setTiddlerTag( config.macros.MTE.tiddlers[t].title, true, tag);
}
config.macros.MTE.ResetListView();
},
onRemoveTag : function( e )
{
var selectedRows = [];
ListView.forEachSelector(config.macros.MTE.ListViewSection, function( e, rowName )
{
if( e.checked )
selectedRows.push( e.getAttribute( "rowName" ));
});
var tag = config.macros.MTE.RemoveTagSection.inputBox.value;
for(t=0; t < config.macros.MTE.tiddlers.length; t++)
{
if ( selectedRows.indexOf( config.macros.MTE.tiddlers[t].title ) != -1 )
store.setTiddlerTag( config.macros.MTE.tiddlers[t].title, false, tag);
}
config.macros.MTE.ResetListView();
}
};
//}}}
<<tiddlerList title:Test>>
/***
|''Name:''|~MyMacroMacro|
|''Version:''|0.1.1|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Allows you to define named shortcuts to your own macros with parameters and simplifies calling them. The {{{<<defineMyMacro>>}}} statements should go in your MainMenu or some other tiddler which displayed at startup.
!Usage
{{{<<defineMyMacro shortName realMacroName realMacroParameters...>>}}}
{{{<<myMacro shortName>>}}}
!Example
{{{<<defineMyMacro csvPlugins tiddlerList tags:"Plugin,-Template" format:csv>>}}}
{{{<<myMacro csvPlugins>>}}}
<<defineMyMacro csvPlugins tiddlerList tags:"Plugin,-Template" format:csv>><<myMacro csvPlugins>>
{{{<<myMacro csvPlugins order:"-title">>}}}
<<myMacro csvPlugins order:"-title">>
!Code
***/
//{{{
version.extensions.myMacro = {major: 0, minor: 1, revision: 1, date: new Date("Apr 22, 2006")};
config.macros.defineMyMacro={macroList:{}}
config.macros.defineMyMacro.handler=function(place,macroName,params,wikifier,paramString,tiddler) {
this.macroList[params[0]] = paramString.substr(params[0].length+1)
}
config.macros.myMacro={}
config.macros.myMacro.handler=function(place,macroName,params,wikifier,paramString,tiddler) {
wikify("<<" + config.macros.defineMyMacro.macroList[params[0]] + paramString.substr(params[0].length) + ">>", place)
applyHtmlMacros(place,tiddler)
}
//}}}
<<defineMyMacro niceList tiddlerList header:"|>|!Plugin|\n|bgcolor(#ddf):''Title''|bgcolor(#ddf):''Version''|" itemTemplate:"|%link|%custom|\n" format:"table" group:"tiddler.modified.formatString('DDD, DD MMM YYYY')" groupTemplate:"|>|bgcolor(#eef):%group |\n" order:"-modified" customParameter:"tiddler.text.match(/\|[^|]*Version[^|]*\|(.*)\|/)[1]">>
<<defineMyMacro docDate tiddlerList header:{{(new Date(document.lastModified)).formatString('DDD, DD MMM YYYY')}} top:0>>
<<tiddlerList top:"13" order:"-modified">>
/***
| ''Name'' |NewFromTemplateMacro|
| ''Version'' |0.3|
| ''Source'' |[[Rich Carrillo|http://www.kultofbubb.net/tiddlywiki/]]|
| ''Author'' |[[RichCarrillo|RichCarrillo@gmail.com]]|
| ''Type'' |Macro|
| ''Required'' |TiddlyWiki 2.0+|
| ''License'' ||
!Revision History
|20060113|0.1|First release|
|20060116|0.2|Added the ability to pass the templateTag as an optional first parameter.|
|20060116|0.3|Bunch of little code tweaks trying to figure out why it was breaking in IE. Fixed it.|
!Description
Using this macro will create a pop-up that lists anything tagged with TiddlerTemplates. Choosing an item off this list will create a new Tiddler. This new Tiddler will have the same contents as the template. The title will be NEW<template title> and it's tags will be the same as the template, but with the TiddlerTemplates tag stripped off.
!Installation
Import (or copy the contents of) this Tiddler into your Wiki.
Tag it with systemConfg, Save and Refresh.
!Syntax
|{{{<<newFromTemplate>>}}}| If the macro is started without any parameters, the templateTag of "TiddlerTemplates" will be used|
|{{{<<newFromTemplate [yourTemplateTag]>>}}}| Optionally, you can provide a tag name. Any tiddlers with that tag will appear on the pop-up menu as templates|
I've included some example templates. Copy over all Tiddlers tagged with TiddlerTemplates to get you started.
!Example
<<newFromTemplate PluginTemplate>>
!Credits
Most of this code is adaptions of TiddlyWiki core functions. I took a close look at PopupMacro and WikiBar's Templater Add-on for help.
!Roadmap - ToDo list
*Let users pass the button label, tooltip and template tag as parameters.
*Create a standalone button (no popup) that is keyed directly to a template tiddler
*Make copying over of Tags and Title optional (like in WikiBar templates)
*More error catching and reporting
*Use named parameters
*Combine with NewHere in some way. Maybe make this into a toolbar command so it's more like NewHereFromTemplate. I'd like to be able to be in a Project tiddler and have a "New Task Here" or "New Reminder Here" type of commands available.
!Code
***/
//{{{
// default settings
config.macros.newFromTemplate =
{
label: "New",
tooltip: "Create a tiddler from a Template",
templateTag: "TiddlerTemplates"
}
config.macros.newFromTemplate.handler = function(place,macroName,params) {
var onClickTemplateButton = function(event) {
if (!event) var event = window.event;
var tag = this.getAttribute("tag");
// error out if no tiddlers are tagged as temlates
var templateList = store.getTaggedTiddlers(tag);
if(!templateList) {
displayMessage('No templates found! Add the tag '+tag+' to a tiddler you would like to use as a template');
return;
}
var popup = Popup.create(templateButton);
// pull the titles out of the tiddlers retured by getTaggedTiddlers
var templateTitles = [];
var li,r;
for(r=0;r<templateList.length;r++)
if(templateList[r].title != templateTitles){
templateTitles.push(templateList[r].title);}
// for each one of the titles create a new TiddlyButton inthe popup
for(r=0; r<templateTitles.length; r++) {
var itemTitle = templateTitles[r].match(/(.+)Template$/)?templateTitles[r].match(/(.+)Template$/)[1]:templateTitles[r];
var templateListItem = createTiddlyButton(createTiddlyElement(popup,"li"),itemTitle,null,onClickTemplateTitle);
templateListItem.setAttribute("templateTitle",templateTitles[r]);
templateListItem.setAttribute("templateTag",tag);
}
Popup.show(popup,true);
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
return false;
}
var onClickTemplateTitle = function(event) {
var title = this.getAttribute("templateTitle");
var templateTag = this.getAttribute("templateTag");
// get the template and extract its info
var template = store.getTiddler(title);
var newTitle = 'New'+template.title;
var newTags = template.getTags();
var newText = template.text;
// create new tiddler
story.displayTiddler(null,newTitle,DEFAULT_EDIT_TEMPLATE);
// grab the new Tiddlers text edit box
var tiddlerTextArea = getTiddlerEditField(newTitle,"text");
var tiddlerTagArea = getTiddlerEditField(newTitle,"tags");
// Stuff template info into newly created tiddler
tiddlerTextArea.value=newText;
tiddlerTagArea.value=newTags;
story.setTiddlerTag(newTitle,templateTag,-1);
story.focusTiddler(newTitle,"text");
return false;
}
var getTiddlerEditField = function(title,field) {
var tiddler = document.getElementById(story.idPrefix + title);
if(tiddler != null) {
var children = tiddler.getElementsByTagName("*")
var e = null;
for (var t=0; t<children.length; t++) {
var c = children[t];
if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
if(!e) e = c;
if(c.getAttribute("edit") == field) e = c;
}
}
if(e) return e;
}
}
var templateTag;
if (params[0])
templateTag=params[0];
else
templateTag=this.templateTag;
var templateButton = createTiddlyButton(place,this.label,this.tooltip,onClickTemplateButton);
templateButton.setAttribute("tag",templateTag);
}
//}}}
<<tiddlerList tags:"Plugin" header:"|!People|!Created|" itemTemplate:"|%link|%custom|\n" format:"table">>
----
<<tiddlerList tags:{{tiddler.title}}>>
----
!News as sliders
{{{<<tiddlerList tags:"News,-Template" itemTemplate:"%link<<section ... %abstract$))\n" order:"-created">>}}}
<<tiddlerList tags:"News,-Template" itemTemplate:"%link<<section ... %abstract$))\n" order:"-created">>
!News in custom format
{{{<<tiddlerList tags:"News,-Template" itemTemplate:"%link (%created)\n%abstract\n\n" order:"-created">>}}}
<<tiddlerList tags:"News,-Template" filter:"tiddler.title!=currentTiddler.title" itemTemplate:"%link (%created)\n%abstract\n\n" order:"-created">>
!Easy editing of included tiddlers
{{{<<tiddlerList tags:"News,-Template" itemTemplate:"<<tiddler %title$))\n\n" order:"-created">>}}}
<<tiddlerList tags:"News,-Template" itemTemplate:"!!!%link\n<<tiddler '%title'$))\n\n" order:"-created">>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?
<<option chkSinglePageMode>> Single Page Mode
<<option chkAutoSave>> AutoSave
See AdvancedOptions and ConfigOptions
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></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='tiddlersBar' refresh='content' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>
<div id='tiddlerDisplay'></div>
</div>
/***
|''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"
});
*/
//}}}
* ExportAllMacro which exports selected/visible tiddlers and, optionally removes them (with linkback) for compacting TW
* TiddlerListMacro should allow new standard formats (popup, dropdown)
* VersionPlugin to save version information for this session
* Grouping in TiddlerListMacro does not break out of ul list
* TW should only write changed tiddlers to file for performance boost
/***
|''Name:''|xxx|
|''Version:''|xxx|
|''Source''|http://jackparke.googlepages.com/jtw.html#XXX ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23XXX]])|
|''Author:''|[[Jack]]|
|''Type:''|xxx|
!Description
xxxxxxxxxxxxxxxxxx
!Usage
{{{<<xxx>>}}}
!Revision History
* Original by [[Jack]] xxxx
!To Do
* xxxx
!Code
***/
//{{{
version.extensions.xxx = {major: 2, minor: 0, revision: 0, date: new Date("Mar 2, 2006")};
config.macros.xxx = {};
config.macros.xxx.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
//xxx
}
//}}}
<<slider chkImportant Plugins##IMPORTANT "IMPORTANT INFORMATION!!!" "Please read!">>/%
!IMPORTANT
This is __NOT__ the official version of [[jtw|http://sites.google.com/site/jackparke]] which can still be found for download [[here|http://sites.google.com/site/jackparke]]. However, as the official version is not accessible as a TiddlyWiki I have decided to upload it to tiddlyspot. If there's anything wrong with that please contact me at http://tobibeer.tiddlyspace.com.
Also, some elements of this wiki might not work as I have imported everything into a version <<version>> whereas the original runs on version __2.4.0__ and was last modified on ''2 July 2008''. For example, these plugins had to be disabled to not show warning messages when run on tiddlyspot:
*PublishMacro
*ArchivePlugin
*DoBackupMacro
!END%/<<tabs txtPluginsTa
'My Plugins' "Plugins I've created" Mine
'3rd Party' "Plugins by others" '3rd Party'
>>
/***
|''Name:''|PluralAliasPlugin|
|''Version:''|2.1 (29-May-2007)|
|''Author:''|[[Jack]]|
|''Type:''|Plugin|
!Description
This plugin ensures links to tiddlers in plural or singular form without the need to create duplicate tiddlers or resort to pretty linking. Example: "I love [[SiameseCat]] and even had a beautiful [[SiameseCat]] once."
!Usage
Just install the plugin and tag with systemConfig.
!Revision History
* Original by [[Jack]] on 2-Mar-2006
* Support createTiddler() function for aliased permalinks
* Support for reverseLookups (referrers functionality, thanks to Mike Fuellbrandt)
!Code
***/
//{{{
version.extensions.pluralAlias = {major: 2, minor: 1,
revision: 0, date: new Date("May 29, 2007")};
pluralAlias_createTiddlyLink = createTiddlyLink;
createTiddlyLink = function(place,title,includeText,theClass,isStatic) {
title = pluralAlias_getTitle(title);
return pluralAlias_createTiddlyLink(place,title,includeText,theClass,isStatic);
}
Story.prototype.pluralAlias_createTiddler= Story.prototype.createTiddler;
Story.prototype.createTiddler = function(place,before,title,template) {
title = pluralAlias_getTitle(title);
return this.pluralAlias_createTiddler(place,before,title,template);
}
function pluralAlias_getTitle(title) {
if (!store.tiddlerExists(title)) {
var aliasTitle = title.match(/s$/)?title.substr(0, title.length-1):title+"s";
if (store.tiddlerExists(aliasTitle)) title = aliasTitle;
}
return title;
}
TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
{
var results = [];
this.forEachTiddler(function(title,tiddler) {
var f = !lookupMatch;
for(var lookup=0; lookup<tiddler[lookupField].length; lookup++)
if(tiddler[lookupField][lookup] == lookupValue || pluralAlias_getTitle(tiddler[lookupField][lookup]) == lookupValue)
f = lookupMatch;
if(f)
results.push(tiddler);
});
if(!sortField)
sortField = "title";
results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
return results;
}
//}}}
/***
|''Name:''|Publish Macro|
|''Version:''|2.4.1 (2 July 2008)|
|''Source''|http://jackparke.googlepages.com/jtw.html#PublishMacro ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23PublishMacro]])|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
<<doPublish>> tiddlers tagged with these tags <<option txtPublishTags>> (comma seperated) as HTML pages to the subfolder 'publish' (you must create this). Use the [[PublishTemplateHead]] and [[PublishTemplateBody]] templates to style your pages and the [[PublishIndexTemplate]] to define an index page. For publishing individual tiddlers the [[PublishTemplateBodySingle]] template is used.
!Usage
To publish all tagged tiddlers:
{{{<<doPublish>>}}} <<doPublish>>
To publish a single tiddler, use the {{{<<publishTiddler>>}}} macro or add the "publishTiddler" command to your ViewTemplate
!Template placeholders
|!Placeholder|!Meaning|
|%0|Your SiteTitle "<<tiddler SiteTitle>>"|
|%1|The current tiddler title|
|%2|The rendered tiddler HTML|
|%3|CSV list of tags|
|%4|Tiddler modifier|
|%5|Tiddler modified date|
|%6|Tiddler creation date|
|%7|Tiddler wiki text|
!Revision History
* Original by [[Jack]] 24 May 2006
* Updated 2 Jan 2007
* Refactored 4 Jan 2007
* Small improvements
* Publish single tiddlers
* Template placeholder %7 for tiddler's wiki text
!Code
***/
//{{{
version.extensions.doPublish = {
major: 2,
minor: 4,
revision: 1,
date: new Date("July 2, 2008")
};
config.macros.doPublish = {
label: "publish",
prompt: "Publish Tiddlers as HTML files"
};
if (config.options.txtPublishTags == undefined) config.options.txtPublishTags = "Publish";
config.shadowTiddlers.PublishTemplateHead = '<title>%0 - %1</title>\n<link rel="stylesheet" type="text/css" href="style.css"/>\n<meta name="keywords" content="%3"/>'
config.shadowTiddlers.PublishTemplateBody = '<div class=\'viewer\' id=\'contentWrapper\'><small><a href=\"./publish/index.html\">Home</a> > %1</small><h1>%0</h1>\n<h2>%1</h2>\n%2\n<hr>Tags: %3\n<hr>%4, %5 (created %6)\n</div>\n'
config.shadowTiddlers.PublishTemplateBodySingle = '<h1>%0</h1>\n<h2>%1</h2>\n%2\n<hr>Tags: %3\n<hr>%4, %5 (created %6)\n</div>\n'
config.shadowTiddlers.PublishIndexTemplate = '<div class=\'viewer\' id=\'contentWrapper\'><small><a href="./publish/index.html">Home</a> > %1</small><h1>%0</h1><h2>%1</h2>\n<ul>%2\n</ul>\n<small>Published: %6</small>\n</div>\n';
config.macros.doPublish.handler = function(place)
{
if (!readOnly)
createTiddlyButton(place, this.label, this.prompt,
function() {
doPublish();
return false;
},
null, null, this.accessKey);
}
config.macros.publishTiddler = {
label : 'publish',
prompt : 'Publish this tiddler as an HTML file.',
handler : function(place,macroName,params,wikifier,paramString,tiddler)
{
var btn = createTiddlyButton(place, this.label, this.prompt,
function(e) {
if(!e) var e = window.event;
publishTiddler(this.getAttribute('tiddler'))
return false;
},
null, null, this.accessKey);
btn.setAttribute('tiddler', tiddler.title);
}}
config.commands.publishTiddler = {handler : function(event,src,title) {publishTiddler(title);},text: "publish", tooltip: "Publish this tiddler as HTML"};
function publishTiddler(title) {
//debugger
var PublishFolder = getWikiPath('publish');
var place = document.getElementById(story.container)
var HTMLTemplateHead = store.getTiddlerText("PublishTemplateHead");
var HTMLTemplateBody = store.getTiddlerText("PublishTemplateBodySingle") || store.getTiddlerText("PublishTemplateBody");
HTMLTemplateBody = renderTemplate(HTMLTemplateBody)
HTMLTemplateBody = wiki2Web(HTMLTemplateBody);
var tiddler = store.getTiddler(title);
var tiddlerText = store.getValue(tiddler, 'text');
var tiddlerHTML = wikifyStatic(tiddlerText);
var HTML = '<html>\n\<head>\n' + HTMLTemplateHead + '\n</head>\n<body>\n' + HTMLTemplateBody + '\n</body>\n</html>';
HTML = HTML.format([
wikifyPlain("SiteTitle").htmlEncode(),
tiddler.title.htmlEncode(),
wiki2Web(tiddlerHTML),
tiddler.tags.join(", "),
tiddler.modifier,
tiddler.modified.toLocaleString(),
tiddler.created.toLocaleString(),
tiddlerText
]);
saveFile(PublishFolder + tiddler.title.filenameEncode() + ".html", HTML);
//story.closeTiddler(tiddler.title);
var indexWin = window.open((PublishFolder + title.filenameEncode() + ".html").replace(/\\/g, "/"), null);
indexWin.focus();
}
function doPublish() {
var savedTiddlers = [];
var tiddlers = store.getTiddlers("title");
var place = document.getElementById(story.container)
var HTMLTemplateHead = store.getTiddlerText("PublishTemplateHead");
var HTMLTemplateBody = store.getTiddlerText("PublishTemplateBody");
HTMLTemplateBody = renderTemplate(HTMLTemplateBody)
HTMLTemplateBody = wiki2Web(HTMLTemplateBody);
var PublishTags = config.options.txtPublishTags || "publish";
PublishTags = PublishTags.split(",")
var PublishFolder = getWikiPath('publish');
if (!PublishFolder) return;
var indexFile = "";
var indexFileTemplate = store.getTiddlerText("PublishIndexTemplate");
// This does not allow <<myMacro>> but wants <div macro="myMacro">
indexFileTemplate = renderTemplate(indexFileTemplate)
// This option allows WIKI-syntax but is limited in it's HTML capabilities
//indexFileTemplate = wikifyStatic(indexFileTemplate)
for (var t = 0; t < tiddlers.length; t++) {
var tiddler = tiddlers[t];
if (tiddler.tags.containsAny(PublishTags)) {
var tiddlerText = store.getValue(tiddler, 'text');
var tiddlerHTML = wikifyStatic(tiddlerText);
var HTML = '<html>\n\<head>\n' + HTMLTemplateHead + '\n</head>\n<body>\n' + HTMLTemplateBody + '\n</body>\n</html>';
HTML = HTML.format([
wikifyPlain("SiteTitle").htmlEncode(),
tiddler.title.htmlEncode(),
wiki2Web(tiddlerHTML),
tiddler.tags.join(", "),
tiddler.modifier,
tiddler.modified.toLocaleString(),
tiddler.created.toLocaleString(),
tiddlerText
]);
//saveFile(PublishFolder + tiddler.created.formatString("YYYY0MM0DD") + ".html", HTML);
saveFile(PublishFolder + tiddler.title.filenameEncode() + ".html", HTML);
indexFile += "<li><a href=\"" + tiddler.title.filenameEncode() + ".html" + "\" class=\"tiddlyLink tiddlyLinkExisting\">" + tiddler.title + "</a></li>\n";
story.closeTiddler(tiddler.title);
}
}
indexFileTemplate = '<html>\n\<head>\n' + HTMLTemplateHead + '\n</head>\n<body>\n' + indexFileTemplate + '\n</body>\n</html>';
indexFileTemplate = indexFileTemplate.format([wikifyPlain("SiteTitle").htmlEncode(), wikifyPlain("SiteSubtitle").htmlEncode(), "%2", "", "", "", (new Date()).toLocaleString()])
indexFile = indexFileTemplate.replace("%2", indexFile)
indexFile = wiki2Web(indexFile);
saveFile(PublishFolder + "index.html", indexFile)
saveFile(PublishFolder + "style.css", store.getTiddlerText("StyleSheet") + store.getTiddlerText("StyleSheetLayout") + store.getTiddlerText("StyleSheetColors"))
var indexWin = window.open("file://" + PublishFolder.replace(/\\/g, "/") + "index.html", null);
indexWin.focus();
}
function renderTemplate(html) {
var result = document.createElement("div");
result.innerHTML = html;
applyHtmlMacros(result, null);
var temp = result.innerHTML;
//result.parentNode.removeChild(result);
return temp;
}
// Convert wikified text to html
function wiki2Web(wikiHTML) {
//var regexpLinks = new RegExp("<a tiddlylink=.*?</a>", "img");
var regexpLinks = /<a[^>]+tiddlylink\s*=\s*["']?\s*?([^ "'>]*)\s*["']?[^>]*>[^<]+<\/a>/img;
var result = wikiHTML.match(regexpLinks);
if (result) {
for (i = 0; i < result.length; i++) {
var className = result[i].match(/ class="(.*?)"/i) ? result[i].match(/ class="(.*?)"/i)[1] : "";
var tiddlerName = result[i].match(/ tiddlylink="(.*?)"/i)[1];
var url = tiddlerName.htmlDecode().filenameEncode() + ".html";
var tiddlerLabel = result[i].match(/">(.*?)<\/a>/i)[1];
if (!className.match(/tiddlyLinkNonExisting/i))
wikiHTML = wikiHTML.myReplace(result[i], "<a class=\"" + className + "\" href=\"" + url + "\">" + tiddlerLabel + "</a>");
else
wikiHTML = wikiHTML.myReplace(result[i], "<a class=\"" + className + "\" title=\"Page does not exist\" href=\"#\">" + tiddlerName + "</a>");
}
wikiHTML = wikiHTML.replace(/ href="http:\/\//gi, " target=\"_blank\" href=\"http://");
}
return wikiHTML
}
function getWikiPath(folderName) {
var originalPath = document.location.toString();
if (originalPath.substr(0, 5) != 'file:') {
alert(arguments['caller']);
alert(config.messages.notFileUrlError);
if (store.tiddlerExists(config.messages.saveInstructions))
story.displayTiddler(null, config.messages.saveInstructions);
return;
}
var localPath = getLocalPath(originalPath);
var backSlash = localPath.lastIndexOf('\\') == -1 ? '/': '\\';
var dirPathPos = localPath.lastIndexOf(backSlash);
var subPath = localPath.substr(0, dirPathPos) + backSlash + (folderName ? folderName + backSlash: '');
return subPath;
}
// Replace without regex
String.prototype.myReplace = function(sea, rep) {
var t1 = this.indexOf(sea);
var t2 = parseInt(this.indexOf(sea)) + parseInt(sea.length);
var t3 = this.length;
return this.substring(0, t1) + rep + this.substring(t2, t3)
}
// Convert illegal characters to underscores
String.prototype.filenameEncode = function()
{
return (this.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
}
//}}}
<div class='viewer' id='contentWrapper'><small><a href="./publish/index.html">Home</a> > %1</small><h1>%0</h1>
<h2>%1</h2>
%2
<pre>%7</pre>
<hr>Tags: %3
<hr>%4, %5 (created %6)
</div>
<h1>%0</h1>
<h2>%1</h2>
%2
<hr>Tags: %3
<hr>
<h3>Tiddler WIKI Text</h3>
<pre>
%7
</pre>
<hr>%4, %5 (created %6)
</div>
/***
|''Name:''|ReferrersMacro|
|''Version:''|2.0 (2-Mar-2006)|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Display a list of tiddlers linking to this plugin.
!Usage
{{{<<referrers>>}}}
!Revision History
* Original by [[Jack]] 2-Mar-2006
!To Do
* List non-explicit links (e.g. from tagging macro)
!Code
***/
//{{{
version.extensions.referrers = {major: 2, minor: 0, revision: 0, date: new Date("Mar 2, 2006")};
config.macros.referrers = {};
config.macros.referrers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
var tiddlers = store.getReferringTiddlers(tiddler.title);
var theList = createTiddlyElement(place,"ul");
for(var t=0; t<tiddlers.length; t++)
if (!params[0] || tiddlers[t].tags.contains(params[0]))
createTiddlyLink(createTiddlyElement(theList,"li"),tiddlers[t].title,true);
}
//}}}
Connection1: DRIVER={SQL Server};SERVER=(local);DATABASE=Northwind;
pubs: DRIVER={SQL Server};SERVER=(local);DATABASE=pubs;
{{{<<SQLQuery sql:"SELECT TOP 10 ProductID, ProductName FROM Products">>}}}
<<SQLQuery sql:"SELECT TOP 10 ProductID, ProductName FROM Products">>
{{{<<SQLQuery sql:"SELECT TOP 10 au_id, au_lname, au_fname FROM Authors" connection:pubs>>}}}
<<SQLQuery sql:"SELECT TOP 10 au_id, au_lname, au_fname FROM Authors" connection:pubs>>
/***
|''Name:''|SQLQueryPlugin|
|''Version:''|0.1|
|''Source''|http://jackparke.googlepages.com/jtw.html#SQLQueryPlugin ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23SQLQueryPlugin]])|
|''Author:''|[[Jack]]|
!Description
Query a SQL database (defined in [[SQLConfig]]) and display results in a tiddler. See [[SQLExamples]].
See http://www.connectionstrings.com for connection strings examples.
!Usage
{{{<<SQLQuery sql:"SELECT * FROM Products">>}}}
!Advanced Usage
{{{<<SQLQuery sql:"SELECT * FROM Products" connection:pubs rowstart:"*" colsep:"," rowend:{{\n}} headerstart:!>>}}}
!Configuration
Define all database connection strings (ADO) in the [[SQLConfig]] tiddler.
Example:
{{{
Northwind: DRIVER={SQL Server};SERVER=(local);DATABASE=Northwind;
pubs: DRIVER={SQL Server};SERVER=(local);DATABASE=pubs;
CompanyContacts: DRIVER={SQL Server};SERVER=MyCompanyServer;DATABASE=Contacts;UID=sa;pwd=admin;
}}}
!Code
***/
//{{{
version.extensions.SQLQuery= {major: 0, minor: 1, revision: 0, date: new Date("Aug 23, 2007")};
config.macros.SQLQuery= {};
//config.shadowTiddlers.SQLConfig = 'Connection1: DRIVER={SQL Server};SERVER=(local);DATABASE=Northwind;';
config.macros.SQLQuery.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
var parameters = paramString.parseParams('name',null,true);
var pSQL = parameters[0]['sql']?parameters[0]['sql'][0]:-1;
if (!pSQL) return false;
var Connection = parameters[0]['connection']?parameters[0]['connection'][0]:'Connection1';
var SQLConnection = store.getTiddlerText('SQLConfig::' + Connection)
if (!SQLConnection) return wikify('Please configure this connection \'' + Connection + '\' in [[SQLConfig]]!', place, null, tiddler);
var RowStart = parameters[0]['rowstart']?parameters[0]['rowstart'][0]:'|';
var ColSep = parameters[0]['colsep']?parameters[0]['colsep'][0]:'|';
var RowEnd = parameters[0]['rowend']?parameters[0]['rowend'][0]:'|\n';
var HeaderStart = parameters[0]['headerstart']?parameters[0]['headerstart'][0]:'!~';
try {
var strResult = sql_DBQuery(SQLConnection, pSQL, RowStart, ColSep, RowEnd, HeaderStart, 'No results')
wikify(strResult,place, null, tiddler)
} catch (err) {
wikify('Error ' + err.message,place, null, tiddler)
}
}
function sql_DBQuery(ConnStr, SQL, RowStart, ColSep, RowEnd, HeaderStart, NoData) {
var Conn = new ActiveXObject('ADODB.Connection');
Conn.open(ConnStr);
var RS = Conn.execute(SQL);
var strOut='';
if (!RS.eof) {
strOut += RowStart;
for (var i=0; i < RS.Fields.Count; i++) {
strOut += HeaderStart + RS.Fields(i).name.toString() + (i<RS.Fields.Count-1?ColSep:'');
}
strOut += RowEnd;
while (!RS.eof) {
strOut += RowStart;
for (var i=0; i < RS.Fields.Count; i++) {
strOut += RS.Fields(i).Value.toString() + (i<RS.Fields.Count-1?ColSep:'');
}
strOut += RowEnd;
RS.MoveNext
}
} else {
strOut = NoData;
}
return strOut;
RS.close()
Conn.close()
}
//}}}
/***
|''Name:''|saveClose |
|''Version:''|Revision: 1.1.1, 2006-04-10|
|''Source:''|http://knighjm.googlepages.com/knightnet-default-tw.html|
|''Author:''|[[Julian Knight]]|
|''Type:''|Toolbar Macro Extension|
|''Requires:''|TiddlyWiki 2.0.0 or higher|
!Description
Extends the TiddlyWiki commands for the toolbar macro by adding a button to save and then close the tiddler immediately.
It simply duplicates and mashes the code from the two pre-defined commands SaveTiddler and closeTiddler.
!History
|!2006-04-10 - 1.1.1|Minor improvements to versioning, no code changes, improve description and history|
|!2006-04-07 - 1.1|Amended "source" and move master copy to my Google web space|
|!2006-03-30 - 1.0|First release|
!Useage
Add to your EditTemplate, e.g.:
{{{
<!-- ********* -->
<div class='toolbar' macro='toolbar +saveTiddler saveClose -cancelTiddler deleteTiddler closeTiddler'></div>
}}}
It does a save followed by a close.
!Code
***/
//{{{
version.extensions.saveClose = {
major: 1, minor: 1, revision: 1, date: new Date("Apr 10, 2006"), type: 'macro',
source: 'http://knighjm.googlepages.com/knightnet-default-tw.html#saveClose'
};
config.commands.saveClose = {
text: "save/close", tooltip: "Save then close this tiddler"
}
config.commands.saveClose.handler = function(event,src,title) {
var newTitle = story.saveTiddler(title,event.shiftKey);
story.closeTiddler(title,true,event.shiftKey || event.altKey);
// story.displayTiddler(null,newTitle);
return false;
}
//}}}
/***
This plugin is released under the "Do whatever you like at your own risk" license.
***/
<<tiddlerList tags:Plugin group:"tiddler.title.substr(0,1)" groupTemplate:"!%group\n" itemTemplate:"%link" separator:" - " groupFooterTemplate:"\n">>
<<tiddler [[ColorPalette::Foreground]]>>
<<write {{'[[todays meeting:' + (new Date()).formatString('YYYY/MM/DD') + ']]'}}>>
<<tiddlerList tags:Menu itemTemplate:{{'%link\n<<tiddlerList tags:Menu-%title$))'}}>>
/***
|''Name:''|~SectionMacro|
|''Version:''|0.9.4 (20-Apr-2007)|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Allows you to create collapsable sections just like the slider macro but without needing to create new tiddlers for these sections.
!Usage
{{{<<section Title Tiddler Text goes here...
and can be multi-
line and include {${${monospace text}$}$}.
>>}}}
<<section Title Tiddler Text goes here...
and can be multi-
line and include {${${monospace text}$}$}.
>>
!Revision History
* Original by [[Jack]] 0.9
* Nested sliders and cookie persistence 0.9.1
* Removed crappy cookie persistance 0.9.2
* Bug-fix with quoted 2st parameter (thanks M. Macolio) 0.9.3
* Bug-fix with monospace text (thanks M. Macolio) 0.9.4
!Code
***/
//{{{
version.extensions.section = {major: 0, minor: 9, revision: 4, date: new Date("Apr 20, 2007")};
config.macros.section = {count:0,display:'none'};
config.macros.section.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
this.slider(place,"chkSection" + this.count++,paramString.substr(params[0].length+(paramString.substr(params[0].length+1,1).match(/['"]/)?2:1)).replace(/\$\>/g, '>').replace(/}\$}\$}/, '}}}').replace(/{\${\${/, '{{{'),params[0], "tooltip");
}
config.macros.section.slider = function(place,cookie,text,title,tooltips) {
var btn = createTiddlyButton(place,title,tooltips,config.macros.slider.onClickSlider,"tiddlyLink tiddlyLinkExisting");
var panel = createTiddlyElement(place,"div",null,"timelineSliderPanel",null);
panel.setAttribute("cookie",cookie);
panel.style.display = config.options[cookie] ? "block" : "none";
panel.style.display=this.display;
if(text) wikify(text,panel);
};
//}}}
<<showParams a:"Plugin,-Template" aa:"ok" b:'Yes' c:"Yes'sir">>
ShowParamsMacro
/***
|''Name:''|ShowParamsMacro|
|''Version:''|0.1|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Simply lists the parameters it is given. Used for testing named params.
!Usage
{{{<<showParams parameter1:"value1" parameter2:value2 anon>>}}}
<<showParams parameter1:"value1" parameter2:value2 anon>>
!Code
***/
//{{{
config.macros.showParams = {}
config.macros.showParams.handler=function(place,macroName,params,wikifier,paramString,tiddler) {
var p = paramString.parseParams(null,null,true);
var temp='|!Parameter|!Value|\n';
for (var i=1; i<p.length; i++) {
temp += '|' + p[i].name + '|' + (p[0][p[i].name]?p[0][p[i].name][0]:'') + '|\n'
}
wikify(temp, place)
}
//}}}
A type of cat, famous in Disney movies for being evil!
<<gotoTiddler search>><<closeAll>><<permaview>><<newTiddler>>/%<<doBackup>><<doPublish>>%/<<saveChanges>>
<<tabs txtMainTab
Tags 'All tags' TabTags
New 'Recently modified tiddlers' New
Fav 'Favorite Tiddlers' Favorite
Cfg 'Config Tiddlers' ConfigTab
Opt "Options" OptionsPanel
i 'Index' Index
>>
/***
|''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"
//}}}
/***
|Version:|2.1.1|
***/
//{{{
version.extensions.SinglePageMode= {major: 2, minor: 1, revision: 1, date: new Date(2006,2,4)};
if (config.options.chkSinglePageMode==undefined)
config.options.chkSinglePageMode=false;
config.shadowTiddlers.AdvancedOptions
+= "\n<<option chkSinglePageMode>> Display one tiddler at a time";
config.SPMTimer = 0;
config.lastURL = window.location.hash;
function checkLastURL()
{
if (!config.options.chkSinglePageMode)
{ window.clearInterval(config.SPMTimer); config.SPMTimer=0; return; }
if (config.lastURL == window.location.hash)
return;
var tiddlerName = convertUTF8ToUnicode(decodeURI(window.location.hash.substr(1)));
tiddlerName=tiddlerName.replace(/\[\[/,"").replace(/\]\]/,""); // strip any [[ ]] bracketing
if (tiddlerName.length) story.displayTiddler(null,tiddlerName,1,null,null);
}
Story.prototype.coreDisplayTiddler=Story.prototype.displayTiddler;
Story.prototype.displayTiddler = function(srcElement,title,template,animate,slowly)
{
if (config.options.chkSinglePageMode) {
window.location.hash = encodeURIComponent(String.encodeTiddlyLink(title));
config.lastURL = window.location.hash;
document.title = wikifyPlain("SiteTitle") + " - " + title;
story.closeAllTiddlers();
if (!config.SPMTimer) config.SPMTimer=window.setInterval(function() {checkLastURL();},1000);
}
this.coreDisplayTiddler(srcElement,title,template,animate,slowly)
}
Story.prototype.coreDisplayTiddlers=Story.prototype.displayTiddlers;
Story.prototype.displayTiddlers = function(srcElement,titles,template,unused1,unused2,animate,slowly)
{
// suspend single-page mode when displaying multiple tiddlers
var save=config.options.chkSinglePageMode;
config.options.chkSinglePageMode=false;
this.coreDisplayTiddlers(srcElement,titles,template,unused1,unused2,animate,slowly);
config.options.chkSinglePageMode=save;
}
//}}}
Plugins, Macros and Hacks
[<img[http://jackparke.googlepages.com/notebook.gif]]Jack's ~TiddlyWiki
/***
''My Styles'' /%------------------------------------------------%/
***/
/*{{{*/
#breadCrumbs {display:none;}
.view {
border-top:1px dashed #ddd;
border-bottom:1px dashed #ddd;
}
span.listParent {
padding:4px;
}
li.listGroup {
list-style-type: none;
margin-left: -2em;
font-weight:bold;
}
.viewer th, thead td {
background-color: #00a;
}
th a {
color:#fff;
}
.viewer li {
list-style-type: square;
list-style-color: #800;
}
/*}}}*/
/***
!Tabs /%==================================================%/
***/
/*{{{*/
.tab {
margin: 0em 0em 0em 0.25em;
padding: 2px;
}
.tabContents ul, .tabContents ol {
margin: 0;
padding: 0;
}
.txtMainTab .tabContents li {
list-style: none;
}
.tabContents li.listLink {
margin-left: .75em;
}
/*}}}*/
/***
!Tabs /%==================================================%/
***/
/*{{{*/
.tab {
margin: 0em 0em 0em 0.25em;
padding: 2px;
}
.tabContents ul, .tabContents ol {
margin: 0;
padding: 0;
}
.txtMainTab .tabContents li {
list-style: none;
}
.tabContents li.listLink {
margin-left: .75em;
}
/*}}}*/
/***
!Message Area /%==================================================%/
***/
/*{{{*/
#messageArea a {color:888;}
/*}}}*/
* StyleSheet
* StyleSheetColors
* StyleSheetLayout
* StyleSheetPrint
* ColorPalette
|>|>|!PageTemplate|
|>|>|[[SiteTitle]] - [[SiteSubtitle]]|
|[[MainMenu]]|[[DefaultTiddlers]]<br><br>[[ViewTemplate]]<br><br>[[EditTemplate]]|[[SideBarOptions]]|
|~|~|[[OptionsPanel]]<br>AdvancedOptions|
|~|~|SideBarTabs|
|>|>|[[SiteUrl]]|
* AdvancedOptions
* OptionsPanel
<<section Mine <<tiddlerList tags:"-Template,Plugin" $>$> >>
<<section 3rdParty <<tiddlerList tags:"systemConfig,-Template,-Plugin"$>$> >>
<<section All <<tiddlerList tags:"systemConfig,-Template"$>$> >>
* SideBarOptions
* SideBarTabs
* TabAll
* TabMore
* TabMoreMissing
* TabMoreOrphans
* TabTags
* TabTimeline
* DefaultTiddlers
* MainMenu
* SiteSubtitle
* SiteTitle
* SiteUrl
Here is a reference for the markup "language" used. See also [[Internal Macros]] (especially for the <<br>> macro that throws a new line).
!Basic Formatting
|!Format|!Markup|!Example|
|Bold|{{{''Bold''}}} (2 single quotes)|''Bold''|
|Highlight|{{{@@Highlight@@}}}|@@Highlight@@|
|CSS Extended Highlights|{{{@@some css;Highlight@@}}}<<br>>For backwards compatibility, the following highlight syntax is also accepted:{{{@@bgcolor(#ff0000):color(#ffffff):red coloured@@}}}|@@background-color:#ff0000;color:#ffffff;red coloured@@|
|Custom CSS Class|{{{ {{wrappingClass{Text that is now accentuated}}} }}}<<br>>By default, the text is placed in a <span>. To use a <div> instead, insert a line break before the text (after the single {)|Add .wrappingClass to StyleSheet|
|Italic|{{{//Italic//}}}|//Italic//|
|Monospaced text|{{{{{{ ... }}}}}}|{{{Monospaced text}}}|
|Monospaced block multiline|Put {{{{{{}}} and {{{}}}}}} on their own lines|<html><pre>{{{<br/>Monospaced<br/>Multi-line<br/>Block<br/>}}}</pre></html>|
|Strikethough|{{{==Strikethrough==}}}|==Strikethrough==|
|Subscript|{{{~~Subscript~~}}}|Text~~Subscript~~|
|Superscript|{{{^^Superscript^^}}}|Text^^Superscript^^|
|Underlined|{{{__Underline__}}}(2 underscores)|__Underscored__|
|Any HTML|{{{<html>any valid xhtml</html>}}}||
!"Document" Structure
|!Format|!Markup|!Example|
|Headings|{{{!Heading 1}}}<<br>>{{{!!Heading 2}}}|<html><h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><h4>Heading 4</h4><h5>Heading 5</h5></html>|
|Any HTML|{{{<html>any valid xhtml</html>}}}||
|Block quotes|{{{>Blockquote}}}<<br>>Can be nested using multiple >|<html><blockquote>Blockquote<blockquote>Nested Blockquote</blockquote></blockquote></html>|
|Blockquotes - Multiline|<html><tt><<<</tt><br/>multi-line<br/>blockquote<br/><tt><<<</tt></html> |<html><blockquote>multi-line<br/>blockquote</blockquote></html>|
|Horizontal Rule|{{{----}}} (4 dashes on a line of their own)|<html><hr></html>|
|Images|{{{[img[favicon.ico]]}}}<<br>>Note that image files are always external to the TW file|[img[http://www.tiddlywiki.com/favicon.ico]]|
|Inline Comments|{{{/% .... %/}}}<<br>>Text between the markers will not be shown in view mode|Not shown: /% Not Shown %/|
|Links|Any WikiWord (creates a link to a tiddler whether it exists or not)|PageTemplate|
|~|{{{[[Manual Link]]}}} (Especially for tiddlers with spaces in their titles)|[[Table of Contents]]|
|~|{{{[[Pretty Link|Some Crafty Link]]}}}<<br>>Note: Makes an external link if the target does not yet exist|[[Pretty Link|MainMenu]]|
|~|Automatic external link {{{http://www.knightnet.org.uk}}}|http://www.knightnet.org.uk|
|~|Pretty external link<<br>>{{{[[My Home Page|http://www.knightnet.org.uk]]}}}|[[My Home Page|http://www.knightnet.org.uk]]|
|~|OS Folder link<<br>>Windows Share: {{{file://///server/share}}}<<br>>Windows Local: {{{file:///c:/folder/file}}}<<br>>Un*x Local File: {{{file://folder/file}}}<<br>>Relative File: {{{folder/file}}}||
|List - Bulleted|{{{* List entry}}}|<html><ul><li>Bullet List</li></ul></html>|
|List - Numbered|{{{# List entry}}}|<html><ol><li>Numbered List</li></ol></html>|
|List - Nested|Both list types can be nested by using multiple * or #<<br>>Note that * and # must be the first character of the line as with all block format markup||
|Tables| {{{|}}} |Column Separator |
|~| {{{!}}} |Header (Row or Column) |
|~| {{{>}}} |Column Span |
|~| {{{~}}} |Row Span |
|~| {{{|Left |}}} |Left Align |
|~| {{{| Right|}}} |Right Align|
|~| {{{| Center |}}} |Center Align |
|~| {{{|Caption|c}}} |Table Caption (Can be at top or bottom)|
|Table Sample|{{{|}}} !header {{{|}}} !header {{{|}}}<html><br/></html>{{{|>|}}}colspan=2 {{{|}}}<html><br/></html>{{{|}}} rowspan {{{|}}}left align {{{|}}}<html><br/></html>{{{|}}}~{{{|}}} center {{{|}}}<html><br/></html>{{{|}}}bgcolor(green):green{{{|}}} right{{{|}}}<html><br/></html>{{{|}}}table caption{{{|}}}c<html><br/></html> |<html><table width="80%" border=1><tbody><tr><th align="center">header</th><th align="center">header</th></tr><tr><td colspan="2" align="center">colspan="2"</td></tr><tr><td rowspan="2" align="center">rowspan</td><td align="left">left align</td></tr><tr><td align="center">centered</td></tr><tr><td bgcolor="green">green</td><td align="right">right</td></tr><caption valign="bottom">table caption</caption></tbody></table></html>|
!Notes
You can use the custom CSS formatter in combination with headers and lists to allow new lines within the entry. e.g.:
{{{
#{{block{
Bullet 1
Some text in the same bullet (Note that "block" can be anything, it is the formatters CSS class name)
}}}
# Bullet 2
}}}
#{{block{
Bullet 1
Some text in the same bullet
}}}
# Bullet 2
(Julian Knight, 2006-04-20)
*store.getValue does not load shadowTiddler text if tiddler is missing
|Document Date|<<myMacro docDate>>|
/***
|Name|TabEditPlugin|
|Created by|SaqImtiaz|
|Location|http://lewcid.googlepages.com/lewcid.html#TabEditPlugin|
|Version|0.32|
|Requires|~TW2.x|
!Description
Makes editing of tabs easier.
!Usage
*Double click a tab to edit the source tiddler
*Double click outside the tabset to edit the containing tiddler.
!Demo
TestTabs
!History
*28-04-06, v0.32 - fixed previous bug fix!
*27-04-06, v0.31 - fixed conflicts with tabs created using PartTiddler.
*26-04-06, v0.30 - first public release
***/
//{{{
//tab on double click event handler
Story.prototype.onTabDblClick = function(e){
if (!e) var e = window.event;
var theTarget = resolveTarget(e);
var title= this.getAttribute("source");
if ((version.extensions.PartTiddlerPlugin)&&(title.indexOf("/")!=-1))
{if (!oldFetchTiddler.call(this, [title]))
{return false;}}
story.displayTiddler(theTarget,title,2,false,null)
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}
config.macros.tabs.switchTab = function(tabset,tab)
{
var cookie = tabset.getAttribute("cookie");
var theTab = null
var nodes = tabset.childNodes;
for(var t=0; t<nodes.length; t++)
if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab)
{
theTab = nodes[t];
theTab.className = "tab tabSelected";
}
else
nodes[t].className = "tab tabUnselected"
if(theTab)
{
if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
tabset.parentNode.removeChild(tabset.nextSibling);
var tabContent = createTiddlyElement(null,"div",null,"tabContents",null);
tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
var contentTitle = theTab.getAttribute("content");
//set source attribute equal to title of tiddler displayed in tab
tabContent.setAttribute("source",contentTitle);
//add dbl click event
tabContent.ondblclick = story.onTabDblClick;
wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
if(cookie)
{
config.options[cookie] = tab;
saveOptionCookie(cookie);
}
}
}
//}}}
<<allTags excludeLists>>
MultiTagEditor, TiddlersAndTags
/***
| Name:|''tagAdder''|
| Created by:|SaqImtiaz|
| Location:|http://lewcid.googlepages.com/lewcid.html|
| Version:|0.61 (07 Apr-2006)|
| Requires:|~TW2.07|
!About
*provides a drop down list for toggling tags
*you can specify which tags to list, and have multiple drop downs with different tag lists.
!Demonstration
[[tagAdderTest]]
''I recommend using either tagAdder or monkeyTagger, with dropTags and dropTagging in the toolbar:''
Examples:
#: tagAdder & dropTags: TagToolbarTest1
#: monkeyTagger & dropTags: TagToolbarTest2
!Installation:
*Copy this tiddler to your TW with the systemConfig tag
* copy the following to your ViewTemplate:
#either {{{
<div class='tagged' macro='tagAdder'></div>
}}} to add to next to the tags macro in the viewer area, or
#{{{<div class='toolbar' >
<span style="padding-right:1.75em;" macro='tagAdder'></span>
<span macro='toolbar -closeTiddler closeOthers +editTiddler permalink references jump'></span></div>}}} to add to the toolbar.
(adjust padding to taste)
!Usage:
*by default {{{<<tagAdder>>}}} will display drop down list of all tags, with tags present on the tiddler grouped together.
*to sort alphabetically (ignoring the [x]), use {{{<<tagAdder 'nogroup'>>}}}
*to specify what tags to list, use {{{<<tagAdder 'group/nogroup' 'tiddler'>>}}} where tiddler is a tiddler that is tagged with the tags you want to list. (use one of either group or no group, not both!)
Eg: TagDataBase is my tiddler that is tagged with the tags I want to list, so I will use {{{<<tagAdder 'group' 'TagDataBase'>>}}}
for a list like this: <<tagAdder 'group' 'TagDataBase'>>
*you can specify a custom label by giving the macro an additional parameter.
Eg: {{{<<tagAdder 'group' 'TagDataBase' 'custom label'>>}}} gives <<tagAdder 'group' 'TagDataBase' 'custom label'>>
!Tips:
*On the tiddler you want to use as your TagsDataBase, add {{{<<tagAdder>>}}} for a drop down list of all tags, so you can easily toggle tags on it!
*You can have as many TagDataBases as you like.
!Notes:
*use css to style to taste
*tags to be removed are preceded by [x]
!To Do:
*Combine with features of normal tags drop down list.(drop tag macro)
*TagsDB manager
*''add exclude tag feature''
!History
*07 Apr-2006, version 0.61
**fixed IE bug with not returning false
!CODE
***/
//{{{
config.macros.tagAdder= {};
//config.macros.tagAdder.dropdownchar = (document.all?"?":"?"); // the fat one is the only one that works in IE
config.macros.tagAdder.dropdownchar = "?"; // uncomment previous line and comment this for smaller version in FF
config.macros.tagAdder.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
var arrow=': '+ config.macros.tagAdder.dropdownchar;
var tAsort = (params[0] && params[0] !='.') ? params[0]: 'group';
if (params[1]){var tAsource=params[1]};
if ((tAsource)&&(!store.getTiddler(tAsource)))
return false;
var tAlabel= (params[2] && params[2] !='.')? params[2]: 'toggle tags'+arrow;
var tAtooltip= (params[2] && params[2] !='.')? params[2]: 'toggle tags on this tiddler';
if(tiddler instanceof Tiddler)
{
var title = tiddler.title;
var lingo = config.views.editor.tagChooser;
var ontagclick = function(e) {
if (!e) var e = window.event;
var tag = this.getAttribute("tag");
var t=store.getTiddler(title);
if (!t || !t.tags) return;
if (t.tags.indexOf(tag)==null)
{t.tags.push(tag)}
else
{t.tags.splice(t.tags.indexOf(tag),1)};
story.saveTiddler(title);
story.refreshTiddler(title,null,true);
return false;
};
var onclick = function(e) {
if (!e) var e = window.event;
var popup = Popup.create(this);
var t=store.getTiddler(title);
if (!t) return false;
var tagsarray = store.getTags();
var tagsvalue=new Array();
for (var i=0; i<tagsarray.length; i++){
var thetagonly= (tagsarray[i][0]);
tagsvalue.push(thetagonly);}
if (tAsource)
{var sourcetiddler=store.getTiddler(tAsource);
var tagsvalue=sourcetiddler.tags;
}
var tagslabel=new Array();
var tagssorted=new Array();
for (var i=0;i<tagsvalue.length;i++){
var temptag=(tagsvalue[i]);
if (t.tags.indexOf(temptag)==null)
{var temptagx = '[ ] '+temptag;
tagslabel.push(temptagx);
tagssorted.push(temptag);
}
else
{var temptagx ='[x] '+temptag;
if (tAsort=='group'){
tagslabel.unshift(temptagx);
tagssorted.unshift(temptag);}
else if (tAsort=='nogroup'){
tagslabel.push(temptagx);
tagssorted.push(temptag);} }
;}
if(tagsvalue.length == 0)
createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
for (var t=0; t<tagsvalue.length; t++)
{
var theTag = createTiddlyButton(createTiddlyElement(popup,"li"),tagslabel[t],"toggle '"+([tagssorted[t]])+"'",ontagclick);
theTag.setAttribute("tag",tagssorted[t]);
}
Popup.show(popup,false);
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return(false);
};
//createTiddlyButton(place,tAlabel,tAtooltip,onclick);
var createdropperButton = function(place){
var sp = createTiddlyElement(place,"span",null,"tagadderbutton");
var theDropDownBtn = createTiddlyButton(sp,tAlabel,tAtooltip,onclick);
};
createdropperButton(place);
}
};
setStylesheet(
".toolbar .tagadderbutton { margin-right:0em; border:0px solid #eee; padding:0px; padding-right:0px; padding-left:0px; }\n"+
".tagadderbutton a.button { padding:2px; padding-left:2px; padding-right:2px;}\n"+
// ".tagadderbutton {font-size:150%;}\n"+
"",
"TagAdderStyles");
//}}}
Delete me whilst watching the [[My test]] tiddler.
[<<write {{window.currentTiddler.title}}>>]
/***
|''Name:''|TiddlerListMacro|
|''Version:''|2.3 (8-Jan-2008)|
|''Source''|http://jackparke.googlepages.com/jtw.html#TiddlerListMacro ([[del.icio.us|http://del.icio.us/post?url=http://jackparke.googlepages.com/jtw.html%23TiddlerListMacro]])|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
|''Documentation:''|http://jackparke.googlepages.com/jtw.html#TiddlerListMacroDoc|
!Usage
{{{<<tiddlerList parameter1:"value1" parameter2:"value2" ...>>}}}
See TiddlerListMacroDocumentation and TiddlerListMacroExamples
!Code
***/
//{{{
version.extensions.tiddlerList = {major: 2, minor: 3, revision: 0, date: new Date("Jan 08, 2008")};
// template = [header, item, separator, group, footer]
config.macros.tiddlerList={
formats : {list:true, nlist:true, span:true, stack:true, csv:true, table:true},
templates : {
list : [ "%0\n", "* %0\n", "", "%group\n", "%0\n"],
nlist : [ "%0", "# %0\n", "", "%group\n", "%0\n"],
span : [ "%0", "%0", " ", "%group", "%0"],
stack : [ "%0", "%0", "\n", "%group", "%0"],
csv : [ "%0", "%0", ", ", "%0", "%0\n"],
table : ["|!%0|\n", "|%0|\n", "", "|%group|\n", "|%0|\n"]
},
dateFormat : "DD MMM YYYY"
}
if (typeof gCurrentTiddler == 'undefined')
var gCurrentTiddler;
config.macros.tiddlerList.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
// Some globals
var count=0, groupCount=0, theGroup="", lastGroup="", firstInGroup = false;
var currentTiddler = tiddler;
gCurrentTiddler = tiddler;
var listWikiText="";
var formats = this.formats;
// SQL-Like parameters
var parameters = paramString.parseParams("name",null,true);
var pTags = parameters[0]["tags"]?parameters[0]["tags"][0].split(','):[];
var pOrder = parameters[0]["order"]?parameters[0]["order"][0]:"title";
var pTop = parameters[0]["top"]?parameters[0]["top"][0]:-1;
var pText = parameters[0]["text"]?parameters[0]["text"][0]:"";
var pTitle = parameters[0]["title"]?parameters[0]["title"][0]:"";
var pSearch = parameters[0]["search"]?parameters[0]["search"][0]:"";
var pFilter = parameters[0]["filter"]?parameters[0]["filter"][0]:"";
var pHeader = parameters[0]["header"]?paramFormat(parameters[0]["header"][0]):"";
var pFooter = parameters[0]["footer"]?paramFormat(parameters[0]["footer"][0]):"";
var pGroup = parameters[0]["group"]?parameters[0]["group"][0]:"";
var pDateFormat = parameters[0]["dateFormat"]?parameters[0]["dateFormat"][0]:this.dateFormat;
var pCustomParameter = parameters[0]["customParameter"]?parameters[0]["customParameter"][0]:"";
var pFormat = parameters[0]["format"]?parameters[0]["format"][0]:"list";
pFormat = formats[pFormat]?pFormat:"list"
// Separator
var pSeparator = parameters[0]["separator"]?paramFormat(parameters[0]["separator"][0]):(parameters[0]["seperator"]?paramFormat(parameters[0]["seperator"][0]):this.templates[pFormat][2])
// Template for group
var pGroupTemplate = this.templates[pFormat][3];
if (parameters[0]["groupTemplate"])
pGroupTemplate = paramFormat(parameters[0]["groupTemplate"][0])
pGroupTemplate = pGroupTemplate.replace(/\$\)\)/g, ">>")
// Template for group footer
var pGroupFooterTemplate = "";
if (parameters[0]["groupFooterTemplate"])
pGroupFooterTemplate = paramFormat(parameters[0]["groupFooterTemplate"][0]);
pGroupFooterTemplate = pGroupFooterTemplate.replace(/\$\)\)/g, ">>");
// Template for item
var pItemTemplate = this.templates[pFormat][1];
if (parameters[0]["itemTemplate"])
pItemTemplate = paramFormat(parameters[0]["itemTemplate"][0])
pItemTemplate = pItemTemplate.replace(/\$\)\)/g, ">>").replace(/%link/g, "%0").replace(/%item/g, "%1").replace(/%abstract/g, "%2").replace(/%text/g, "%3").replace(/%created/g, "%4").replace(/%modified/g, "%5").replace(/%modifier/g, "%6").replace(/%group/g, "%7").replace(/%title/g, "%8").replace(/%tags/g, "%9").replace(/%nolink/g, "%10").replace(/%custom/g, "%11")
// Template for footer
var pFooterTemplate = this.templates[pFormat][4].replace(/%count/g, "%1")
// Get all tiddlers
var tiddlers = store.reverseLookup("tags","",false);
// Sorting
if(!pOrder)
pOrder = "title";
if (pOrder.match(/^\-/i)) {
pOrder = pOrder.substr(1)
var sortDesc = true;
}
// Sorting on a standard field
if (pOrder.match(/(title)|(text)|(modifier)|(modified)|(created)|(tags)/))
if (sortDesc)
tiddlers.sort(function (a,b) {if(a[pOrder] == b[pOrder]) return(0); else return (a[pOrder] > b[pOrder]) ? -1 : +1; });
else
tiddlers.sort(function (a,b) {if(a[pOrder] == b[pOrder]) return(0); else return (a[pOrder] < b[pOrder]) ? -1 : +1; });
else
if (sortDesc)
tiddlers.sort(function (a,b) {if(a.fields[pOrder] == b.fields[pOrder]) return(0); else return (a.fields[pOrder] > b.fields[pOrder]) ? -1 : +1; });
else
tiddlers.sort(function (a,b) {if(a.fields[pOrder] == b.fields[pOrder]) return(0); else return (a.fields[pOrder] < b.fields[pOrder]) ? -1 : +1; });
// Header
if (pHeader)
listWikiText += formatItem(this.templates[pFormat][0], [pHeader], pFormat)
for(var t=0; t<tiddlers.length; t++) {
tiddler = tiddlers[t];
if (pText!="" && tiddler.text=="") tiddler.text=store.getValue(tiddler, 'text')
if (pTop==-1 || count<pTop) {
if (pText=="" || tiddler.text.match(pText)) {
if (pTitle=="" || tiddler.title.match(pTitle)) {
if (pSearch=="" || (tiddler.title.match(pSearch) || tiddler.text.match(pSearch))) {
if (pFilter=="" || eval(pFilter)) {
if (pTags.length==0 || compareArrays(tiddler.tags, pTags, "all")) {
count++;
if (tiddler.text=="") tiddler.text=store.getValue(tiddler, 'text')
// Grouping
if (pGroup) {
theGroup = eval(pGroup);
if(theGroup != lastGroup) {
groupCount++;firstInGroup = true;
if (pGroupFooterTemplate && groupCount>1)
listWikiText += pGroupFooterTemplate.replace("%group", theGroup)
listWikiText += pGroupTemplate.replace("%group", theGroup)
lastGroup = theGroup;
} else
firstInGroup = false;
}
// Separators
if (count>1 && !firstInGroup) listWikiText += pSeparator;
//Plaintext title
var noLink = tiddler.title.match(config.textPrimitives.wikiLink)?"~" + tiddler.title:tiddler.title;
// Custom parameter
if (pCustomParameter)
var custom="";
try {
custom = eval(pCustomParameter)
} catch (e) {}
// List individual tiddler
var strItem = formatItem(pItemTemplate,["[[" + tiddler.title + "]]",count,tiddler.text.substr(0,300),tiddler.text,tiddler.created.formatString(pDateFormat),tiddler.modified.formatString(pDateFormat),tiddler.modifier,theGroup,tiddler.title,(tiddler.tags.length>0?"[["+tiddler.tags.join("]], [[")+"]]":""),noLink,custom], pFormat)
for (var fld in tiddler.fields) strItem = strItem.replace('%field.' + fld, tiddler.fields[fld]);
listWikiText += strItem
}
}
}
}
}
}
}
// Last group footer
if (pGroup && pGroupFooterTemplate && count>0)
listWikiText += pGroupFooterTemplate.replace("%group", theGroup)
// Footer
if (pFooter) {
pFooter = pFooter.replace("%count", count)
listWikiText += formatItem(pFooterTemplate, [pFooter], pFormat)
}
// Render result
if (!parameters[0]["debug"])
wikify(listWikiText,place, null, currentTiddler)
else
place.innerHTML = "<textarea style=\"width:100%;\" rows=30>" + listWikiText + "</textarea>"
// Local functions
function paramFormat(param) {
// Allow "\n" in non evalled parameters
return param.replace(/\\n/g, "\n");
}
function formatItem(template, values, format) {
// Fill template with values (depending on list format)
if (format.match(/table/) && values[0].match(/\|/))
return ("%0\n").format(values)
else
return template.format(values)
}
function compareArrays(array, values, logic) {
// Compare items in array with AND("all") or OR("any") logic
var matches=0;
for(var v=0; v<values.length; v++)
if(values[v].replace(/^\s+|\s+$/g,"").match(/^\-/) && !array.contains(values[v].replace(/^\s+|\s+$/g,"").substr(1)))
matches++;
else if (array.contains(values[v]))
matches++;
return ((logic=="all" && matches==values.length) || (logic!="all" && matches>0))
}
}
String.prototype.prettyTrim = function(len,prefix,postfix) {
var result = this.trim().replace(/\r\n/g,' ').replace(/\n/g,' ');
if (!prefix) prefix = '';
if (!postfix) postfix = '';
if (result.length > len - 3)
return prefix + result.substr(0,len) + '...' + postfix;
else if (result.length > 0)
return prefix + result + postfix;
else
return result;
}
//}}}
!Description
The TiddlerListMacro lists tiddlers with ~SQL-Like features:
* List tiddlers containing a word in the title or text (case-sensitive)
* List tiddlers tagged with given tags or exclude certain tags
* Ascending and descending sorting of single fields
* Limit number of tiddlers displayed
* Specify different HTML formats for the lists
* Grouping of items in a list
* Customizable wiki templates
* Numbering and totals
!Revision History
* Original by [[Jack]] 17-Apr-2006
* Added formatting (v2.0.1 18-Apr-2006)
* Added grouping (v2.0.2 18-Apr-2006)
* Added flexible filtering (v2.0.3 19-Apr-2006)
* Added custom item templates (v2.0.4 20-Apr-2006)
* Added custom templates (v2.0.5 21-Apr-2006)
* Allow evalled parameters (v2.0.7 23-Apr-2006)
* Allow groupFooterTemplate (v2.0.9 30-Apr-2006)
* Added the customParameter (v2.0.10 2-May-2006)
!To Do
* Case-insensitive searching
* Sorting on multiple fields
!Usage
{{{<<tiddlerList parameter1:"value1" parameter2:"value2" ...>>}}}
!Examples ([[TiddlerListMacroExamples]])
List all tiddlers tagged with "Plugin"
{{{<<tiddlerList tags:Plugin>>}}}
List newest 3 plugins which are not templates:
{{{<<tiddlerList tags:"Plugin,-Template" top:3 order:"-created">>}}}
List all tiddlers containing "Jack" in their title or text (last modified first):
{{{<<tiddlerList search:"Jack" order:"-modified">>}}}
List all tiddlers starting with "T" in a table:
{{{<<tiddlerList title:"^T" format:"table" header:"Tiddlers beginning with T" footer:"%count items listed">>}}}
Group tiddlers by first letter
{{{<<tiddlerList top:"15" group:"tiddler.title.substr(0,1)" groupTemplate:"''%group''">>}}}
Show a list of all tiddlers with creation date (overrides default item template)
{{{<<tiddlerList itemTemplate:"* %link (%created)\n">>}}}
Show all tiddlers that have the host's tiddler title in their tag list
{{{<<tiddlerList filter:"tiddler.tags.contains(currentTiddler.title)">>}}}
!Parameters
|!Parameter|!Type|!Meaning|!Example|
|top|Integer|Number of tiddlers to display|"10"|
|tags|String|List tiddlers with matching tags (AND Logic). Leading - to exclude.|"~ToDo,Urgent,-Done"|
|title|~RegEx|List tiddlers with matching title|"^[Pp]"|
|text|~RegEx|List tiddlers with matching text|"Searchtext"|
|search|~RegEx|List tiddlers with matching title OR text|"Problem"|
|filter*|~JavaScript|List tiddlers according to boolean expression)|"tiddler.title.length<4 && tiddler.tags.contains('Idea')"|
|format|String (fixed list)|HTML formatting of list. list (ul, default), nlist (ol), span, stack (div), csv, table.|"list"|
|order|String|Sort order of tiddlers. - is descending, + ascending|"-created"|
|group*|~JavaScript|Grouping field|tiddler.title.substr(0,1)|
|customParameter*|~JavaScript|Custom parameter to be evalled for use in the itemTemplate|tiddler.text.match(/Version: (.*)/)[1]|
|header|String|Top caption|"Tiddlers beginning with T"|
|footer|String|Bottom caption|"End of list"|
|itemTemplate|~WikiTemplate|~WikiText with %placeholders|"%link\n%abstract\n%modified"|
|groupTemplate|~WikiTemplate|~WikiText with %placeholders for the start of each group|"!!%group"|
|groupFooterTemplate|~WikiTemplate|~WikiText with %placeholders for the end of each group|"----\n"|
|dateFormat|String|Date formatting string when displaying dates|~YYYY-MM-DD|
|separator|String|Define a string or character to be inserted between items listed|" "|
|debug|Boolean|Set to 1 or true for debug mode where only wikitext will be output|debug:1|
{{{*}}} Parameter will be evalled (do not pass with {{{{{ }} }}} unless you want it evalled twice!)
!Template Placeholders
Placeholder values for itemTemplate parameter
|!Placeholder|!Field|
|%item|List item number|
|%link|Link to Tiddler {{{[[MyTiddler]]}}}|
|%title|Tiddler Name {{{MyTiddler}}}|
|%nolink|Unlinked Tiddler Title {{{~MyTiddler}}}|
|%abstract|First 300 chars of tiddler text|
|%text|All tiddler text|
|%tags|Tags separated by space|
|%created|Creation date|
|%modified|Modified date|
|%modifier|Last modifier|
|%group|Name of group field|
|%custom|The result of your evalled customParameter|
|%count|Number of items listed (footer only)|
!Variables
{{{{{currentTiddler}} }}}refers to the current (host) tiddler in function scope (i.e. within the filter or group parameters)
{{{{{gCurrentTiddler}} }}}refers to the current (host) tiddler in global scope (i.e. within{{{ {{}} }}}evalled parameters. Example:
{{{<<tiddlerList tags:{{gCurrentTiddler.title}}>>}}}
!Style
No styles are pre-assigned to the lists. Use {{{@@}}} notation to define custom styles in the header, footer, groupTemplate and itemTemplate parameters.
Examples using the TiddlerListMacro:
!List Formatting
List all tiddlers tagged with "Plugin"
{{{<<tiddlerList tags:Plugin>>}}}
<<tiddlerList tags:Plugin>>
List top 1 plugins which are not templates:
{{{<<tiddlerList tags:"Plugin,-Template" top:1>>}}}
<<tiddlerList tags:"Plugin,-Template" top:1>>
List all tiddlers containing "Plugin" in their title and text (newest first):
{{{<<tiddlerList title:"Plugin" text:"Plugin" order:"-created">>}}}
<<tiddlerList title:"Plugin" text:"Plugin" order:"-created">>
List all tiddlers containing "Jack" in their title or text (oldest first):
{{{<<tiddlerList search:"Jack" order:"created">>}}}
<<tiddlerList search:"Jack" order:"created">>
List all tiddlers starting with "T":
{{{<<tiddlerList title:"^T">>}}}
<<tiddlerList title:"^T">>
List all tiddlers tagged with the current tiddler's title:
{{{<<tiddlerList tags:{{window.currentTiddler.title}}>>}}}
<<tiddlerList tags:{{window.currentTiddler.title}}>>
!Other Formats
Simple unnumbered list of tiddlers
{{{<<tiddlerList top:"3" format:"list">>}}}
<<tiddlerList top:"3" format:"list">>
Numbered list of tiddlers
{{{<<tiddlerList top:"3" format:"nlist">>}}}
<<tiddlerList top:"3" format:"nlist">>
Table with header and footer
{{{<<tiddlerList top:"3" format:"table" header:"Plugins" footer:"Tiddlers: %count">>}}}
<<tiddlerList top:"3" format:"table" header:"Plugins" footer:"Tiddlers: %count">>
Simple horizontal list:
{{{<<tiddlerList top:"3" format:"span">>}}}
<<tiddlerList top:"3" format:"span">>
Comma Separated list
{{{<<tiddlerList top:"3" format:"csv" header:"Plugins: [ " footer:" ]">>}}}
<<tiddlerList top:"3" format:"csv" header:"Plugins: [ " footer:" ]">>
Custom Separated list
{{{<<tiddlerList top:"10" separator:" - " format:"span">>}}}
<<tiddlerList top:"10" separator:" - " format:"span">>
!Grouping
Group tiddlers by first letter
{{{<<tiddlerList top:"7" group:"tiddler.title.substr(0,1)">>}}}
<<tiddlerList top:"7" group:"tiddler.title.substr(0,1)">>
!Custom Item Templates
List tiddlers in a custom format (title, date, abstract)
{{{<<tiddlerList tags:"News,-Template" itemTemplate:"* %link (%created)<<br>>%abstract\n" order:"-created">>}}}
<<tiddlerList tags:"News,-Template" filter:"tiddler.title!=currentTiddler.title" itemTemplate:"%link (%created)\n%abstract" order:"-created">>
!!!Beware of infinite recursion!!
!Advanced
Tiddlers created today
{{{<<tiddlerList format:table filter:"tiddler.created.formatString('YYYYMMDD')==(new Date()).formatString('YYYYMMDD')" header:{{'Tiddlers created on ' + (new Date()).formatString('DDD, DD MMM YYYY')}}>>}}}
<<tiddlerList format:table filter:"tiddler.created.formatString('YYYYMMDD')==(new Date()).formatString('YYYYMMDD')" header:{{'Tiddlers created on ' + (new Date()).formatString('DDD, DD MMM YYYY')}}>>
Fancy table with grouping on modified date
{{{<<tiddlerList top:"10" header:"|>|!Tiddlers|\n|bgcolor(#ddf):''Title''|bgcolor(#ddf):''Created''|" itemTemplate:"|%0|%4|\n" format:"table" group:"tiddler.created.formatString('DD MMM YYYY')" groupTemplate:"|>|bgcolor(#eef): ''Updated: %group'' |\n" dateFormat:"DDD, DD MM YYYY">>}}}
<<tiddlerList top:"10" header:"|>|!Tiddlers|\n|bgcolor(#ddf):''Title''|bgcolor(#ddf):''Created''|" itemTemplate:"|%0|%4|\n" format:"table" group:"tiddler.created.formatString('DD MMM YYYY')" groupTemplate:"|>|bgcolor(#eef): ''Updated: %group'' |\n" dateFormat:"DDD, DD MM YYYY">>
/***
|Name|TiddlerWithEditPlugin|
|Created by|SaqImtiaz|
|Location|http://lewcid.googlepages.com/lewcid.html#TiddlerWithEditPlugin|
|Version|0.1|
|Requires|~TW2.x|
!Description:
Adds 'doubleclick to edit source' capabilites to the core {{{<<tiddler>>}}} macro.
!History
*28-04-06: version 0.1: working.
!Code
***/
//{{{
config.macros.tiddler.onTiddlerMacroDblClick = function(e){
if (!e) var e = window.event;
var theTarget = resolveTarget(e);
var title= this.getAttribute("source");
if ((version.extensions.PartTiddlerPlugin)&&(title.indexOf("/")!=-1))
{if (!oldFetchTiddler.call(this, [title]))
{title=title.slice(0,title.lastIndexOf("/"))}}
story.displayTiddler(theTarget,title,2,false,null)
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}
config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
params = paramString.parseParams("name",null,true,false,true);
var names = params[0]["name"];
var tiddlerName = names[0];
var className = names[1] ? names[1] : null;
var args = params[0]["with"];
var wrapper = createTiddlyElement(place,"span",null,className);
wrapper.ondblclick = this.onTiddlerMacroDblClick;
if(!args) {
wrapper.setAttribute("refresh","content");
wrapper.setAttribute("tiddler",tiddlerName);
}
var text = store.getTiddlerText(tiddlerName);
if(text) {
var stack = config.macros.tiddler.tiddlerStack;
if(stack.indexOf(tiddlerName) !== -1)
return;
stack.push(tiddlerName);
try {
var n = args ? Math.min(args.length,9) : 0;
for(var i=0; i<n; i++) {
var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
text = text.replace(placeholderRE,args[i]);
}
config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
} finally {
stack.pop();
}
}
};
config.macros.tiddler.tiddlerStack = [];
//}}}
<<tiddlerList top:10 format:table itemTemplate:"|%link|<<tags %title$))|\n" header:"|!Tiddler|!Tags|">>
/***
|''Name:''|TiddlersBarPlugin|
|''Description:''|A bar to switch between tiddlers through tabs (like browser tabs bar).|
|''Version:''|1.2.1|
|''Date:''|Dec 21,2007|
|''Source:''|http://visualtw.ouvaton.org/VisualTW.html|
|''Author:''|Pascal Collin|
|''License:''|[[BSD open source license|License]]|
|''~CoreVersion:''|2.1.0|
|''Browser:''|Firefox 2.0; InternetExplorer 6.0, others|
!Demos
On [[homepage|http://visualtw.ouvaton.org/VisualTW.html]], open several tiddlers to use the tabs bar.
!Installation
#import this tiddler from [[homepage|http://visualtw.ouvaton.org/VisualTW.html]] (tagged as systemConfig)
#save and reload
#''if you're using a custom [[PageTemplate]]'', add {{{<div id='tiddlersBar' refresh='content' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>}}} before {{{<div id='tiddlerDisplay'></div>}}}
#optionally, adjust StyleSheetTiddlersBar
!Tips
*Doubleclick on the tiddlers bar (where there is no tab) create a new tiddler.
*Tabs include a button to close {{{x}}} or save {{{!}}} their tiddler.
*By default, click on the current tab close all others tiddlers.
!Configuration options
<<option chkDisableTabsBar>> Disable the tabs bar (to print, by example).
<<option chkHideTabsBarWhenSingleTab >> Automatically hide the tabs bar when only one tiddler is displayed.
<<option txtSelectedTiddlerTabButton>> ''selected'' tab command button.
!Code
***/
//{{{
config.options.chkDisableTabsBar = config.options.chkDisableTabsBar ? config.options.chkDisableTabsBar : false;
config.options.chkHideTabsBarWhenSingleTab = config.options.chkHideTabsBarWhenSingleTab ? config.options.chkHideTabsBarWhenSingleTab : false;
config.options.txtSelectedTiddlerTabButton = config.options.txtSelectedTiddlerTabButton ? config.options.txtSelectedTiddlerTabButton : "closeOthers";
config.macros.tiddlersBar = {
tooltip : "see ",
tooltipClose : "click here to close this tab",
tooltipSave : "click here to save this tab",
promptRename : "Enter tiddler new name",
currentTiddler : "",
previousState : false,
handler: function(place,macroName,params) {
if (config.macros.tiddlersBar.isShown())
story.forEachTiddler(function(title,e){
if (title==config.macros.tiddlersBar.currentTiddler){
var d = createTiddlyElement(null,"span",null,"tab tabSelected");
config.macros.tiddlersBar.createActiveTabButton(d,title);
}
else {
var d = createTiddlyElement(place,"span",null,"tab tabUnselected");
var btn = createTiddlyButton(d,title,config.macros.tiddlersBar.tooltip + title,config.macros.tiddlersBar.onSelectTab);
btn.setAttribute("tiddler", title);
}
var isDirty =story.isDirty(title);
var c = createTiddlyButton(d,isDirty ?"!":"x",isDirty?config.macros.tiddlersBar.tooltipSave:config.macros.tiddlersBar.tooltipClose, isDirty ? config.macros.tiddlersBar.onTabSave : config.macros.tiddlersBar.onTabClose,"tabButton");
c.setAttribute("tiddler", title);
if (place.childNodes) {
place.insertBefore(document.createTextNode(" "),place.firstChild); // to allow break line here when many tiddlers are open
place.insertBefore(d,place.firstChild);
}
else place.appendChild(d);
})
},
refresh: function(place,params){
removeChildren(place);
config.macros.tiddlersBar.handler(place,"tiddlersBar",params);
if (config.macros.tiddlersBar.previousState!=config.macros.tiddlersBar.isShown()) {
story.refreshAllTiddlers();
if (config.macros.tiddlersBar.previousState) story.forEachTiddler(function(t,e){e.style.display="";});
config.macros.tiddlersBar.previousState = !config.macros.tiddlersBar.previousState;
}
},
isShown : function(){
if (config.options.chkDisableTabsBar) return false;
if (!config.options.chkHideTabsBarWhenSingleTab) return true;
var cpt=0;
story.forEachTiddler(function(){cpt++});
return (cpt>1);
},
selectNextTab : function(){ //used when the current tab is closed (to select another tab)
var previous="";
story.forEachTiddler(function(title){
if (!config.macros.tiddlersBar.currentTiddler) {
story.displayTiddler(null,title);
return;
}
if (title==config.macros.tiddlersBar.currentTiddler) {
if (previous) {
story.displayTiddler(null,previous);
return;
}
else config.macros.tiddlersBar.currentTiddler=""; // so next tab will be selected
}
else previous=title;
});
},
onSelectTab : function(e){
var t = this.getAttribute("tiddler");
if (t) story.displayTiddler(null,t);
return false;
},
onTabClose : function(e){
var t = this.getAttribute("tiddler");
if (t) {
if(story.hasChanges(t) && !readOnly) {
if(!confirm(config.commands.cancelTiddler.warning.format([t])))
return false;
}
story.closeTiddler(t);
}
return false;
},
onTabSave : function(e) {
var t = this.getAttribute("tiddler");
if (!e) e=window.event;
if (t) config.commands.saveTiddler.handler(e,null,t);
return false;
},
onSelectedTabButtonClick : function(event,src,title) {
var t = this.getAttribute("tiddler");
if (!event) event=window.event;
if (t && config.options.txtSelectedTiddlerTabButton && config.commands[config.options.txtSelectedTiddlerTabButton])
config.commands[config.options.txtSelectedTiddlerTabButton].handler(event, src, t);
return false;
},
onTiddlersBarAction: function(event) {
var source = event.target ? event.target.id : event.srcElement.id; // FF uses target and IE uses srcElement;
if (source=="tiddlersBar") story.displayTiddler(null,'New Tiddler',DEFAULT_EDIT_TEMPLATE,false,null,null);
},
createActiveTabButton : function(place,title) {
if (config.options.txtSelectedTiddlerTabButton && config.commands[config.options.txtSelectedTiddlerTabButton]) {
var btn = createTiddlyButton(place, title, config.commands[config.options.txtSelectedTiddlerTabButton].tooltip ,config.macros.tiddlersBar.onSelectedTabButtonClick);
btn.setAttribute("tiddler", title);
}
else
createTiddlyText(place,title);
}
}
story.coreCloseTiddler = story.coreCloseTiddler? story.coreCloseTiddler : story.closeTiddler;
story.coreDisplayTiddler = story.coreDisplayTiddler ? story.coreDisplayTiddler : story.displayTiddler;
story.closeTiddler = function(title,animate,unused) {
if (title==config.macros.tiddlersBar.currentTiddler)
config.macros.tiddlersBar.selectNextTab();
story.coreCloseTiddler(title,false,unused); //disable animation to get it closed before calling tiddlersBar.refresh
var e=document.getElementById("tiddlersBar");
if (e) config.macros.tiddlersBar.refresh(e,null);
}
story.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle){
story.coreDisplayTiddler(srcElement,tiddler,template,animate,unused,customFields,toggle);
var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;
if (config.macros.tiddlersBar.isShown()) {
story.forEachTiddler(function(t,e){
if (t!=title) e.style.display="none";
else e.style.display="";
})
config.macros.tiddlersBar.currentTiddler=title;
}
var e=document.getElementById("tiddlersBar");
if (e) config.macros.tiddlersBar.refresh(e,null);
}
ensureVisible=function (e) {return 0} //disable bottom scrolling (not useful now)
config.shadowTiddlers.StyleSheetTiddlersBar = "/*{{{*/\n";
config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar .button {border:0}\n";
config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar .tab {white-space:nowrap}\n";
config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar {padding : 1em 0.5em 2px 0.5em}\n";
config.shadowTiddlers.StyleSheetTiddlersBar += ".tabUnselected .tabButton, .tabSelected .tabButton {padding : 0 2px 0 2px; margin: 0 0 0 4px;}\n";
config.shadowTiddlers.StyleSheetTiddlersBar += ".tiddler, .tabContents {border:1px [[ColorPalette::TertiaryPale]] solid;}\n";
config.shadowTiddlers.StyleSheetTiddlersBar +="/*}}}*/";
store.addNotification("StyleSheetTiddlersBar", refreshStyles);
config.shadowTiddlers.PageTemplate=config.shadowTiddlers.PageTemplate.replace(/<div id='tiddlerDisplay'><\/div>/m,"<div id='tiddlersBar' refresh='content' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>\n<div id='tiddlerDisplay'></div>")
//}}}
TiddlySnip for IE is a version of the very cool [[TiddlySnip|http://www.tiddlysnip.com]] by ''lewcid'' which adds a right-click function to Internet Explorer for easily saving text snippets from web pages to your TiddlyWiki.
!!Installation
#Unzip the [[installation archive|http://jackparke.googlepages.com/snip.zip]] to a folder on your PC
#Update the snip.reg file with this folder path
#Double click snip.reg and restart IE to add the new feature to your context menu (right-click menu)
#Update the snip.xml file with your preferences
**Jack -> Enter your name
**tags -> Default tags for your snippets
**file -> Path to your TiddlyWiki file where snips will be saved
!!Usage
#Just browse to any web page
#Select some text
#Right-click and choose TiddlyWiki (or press ''k'')
The selected text is saved to your TiddlyWiki file as a new tiddler.
!Pending
<<tiddler Pending>>
!Done
<<tiddler Done>>
Today's Tiddlers
{{{<<tiddlerList filter:"tiddler.created.formatString('YYYYMMDD')==(new Date()).formatString('YYYYMMDD')">>}}}
<<tiddlerList filter:"tiddler.created.formatString('YYYYMMDD')==(new Date()).formatString('YYYYMMDD')">>
/***
Examples:
|Code|Description|Example|h
|{{{<<toggleTag>>}}}|Toggles the default tag (checked) in this tiddler|<<toggleTag>>|
|{{{<<toggleTag TagName>>}}}|Toggles the TagName tag in this tiddler|<<toggleTag TagName>>|
|{{{<<toggleTag TagName TiddlerName>>}}}|Toggles the TagName tag in the TiddlerName tiddler|<<toggleTag TagName TiddlerName>>|
|{{{<<toggleTag TagName TiddlerName nolabel>>Click me}}}|Same but hide the label|<<toggleTag TagName TiddlerName nolabel>>Click me|
(Note if TiddlerName doesn't exist it will be silently created)
!Known issues
* Doesn't smoothly handle the case where you toggle a tag in a tiddler that is current open for editing. Should it stick the tag in the edit box?
!Code
***/
//{{{
// This function contributed by Eric Shulman
function toggleTag(title,tag) {
var t=store.getTiddler(title); if (!t || !t.tags) return;
if (t.tags.indexOf(tag)==null) t.tags.push(tag)
else t.tags.splice(t.tags.indexOf(tag),1)
}
// This function contributed by Eric Shulman
function isTagged(title,tag) {
var t=store.getTiddler(title); if (!t) return false;
return (t.tags.indexOf(tag)!=null);
}
config.macros.toggleTag = {};
config.views.wikified.toggleTag = {fulllabel: "[[%0]] [[%1]]", shortlabel: "[[%0]]", nolabel: "" };
config.macros.toggleTag.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
if(tiddler instanceof Tiddler) {
var tag = (params[0] && params[0] != '.') ? params[0] : "checked";
var title = (params[1] && params[1] != '.') ? params[1] : tiddler.title;
var hidelabel = (params[2] && params[2] != '.') ? true : false;
var alsoRefreshStyles = (params[3] && params[3] != '.') ? true : false;
var onclick = function(e) {
if (!e) var e = window.event;
if (!store.getTiddler(title))
store.saveTiddler(title,title,"",config.options.txtUserName,new Date(),null);
toggleTag(title,tag);
store.setDirty(true); // so TW knows it has to save now
story.forEachTiddler(function(title,element) {
if (element.getAttribute("dirty") != "true")
story.refreshTiddler(title,false,true);
});
if (alsoRefreshStyles)
store.notifyAll();
return false;
};
var lingo = config.views.wikified.toggleTag;
// this part also contributed by Eric Shulman
var c = document.createElement("input");
c.setAttribute("type","checkbox");
c.onclick=onclick;
place.appendChild(c);
c.checked=isTagged(title,tag);
if (!hidelabel) {
var label = (title!=tiddler.title)?lingo.fulllabel:lingo.shortlabel;
wikify(label.format([tag,title]),place);
}
}
}
//}}}
/***
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 = 'jackparke';
// 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")
});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 05/10/2010 22:42:34 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jackparke.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jackparke.tiddlyspot.com/index.html]] | . | ok |
| 05/10/2010 22:44:16 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jackparke.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jackparke.tiddlyspot.com/index.html]] | . | ok |
| 12/10/2010 20:32:08 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jackparke.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jackparke.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:15:43 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:15:58 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:16:27 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:16:46 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:17:00 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:17:52 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jtw.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jtw.tiddlyspot.com/index.html]] | . | failed |
| 03/03/2011 12:20:18 | Jack | [[jackparke.html|file:///C:/xTiddle/tiddlyspot/jackparke/jackparke.html]] | [[store.cgi|http://jackparke.tiddlyspot.com/store.cgi]] | . | [[index.html | http://jackparke.tiddlyspot.com/index.html]] | . |
/***
|''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' macro='toolbar -closeTiddler closeOthers +editTiddler publishTiddler permalink references jump'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date [[DD MMM YYYY]]'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date [[DD MMM YYYY]]'></span>)</div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagged' macro='tags'></div>
<div class='tagClear'></div>
<!--}}}-->
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://jtw.tiddlyspot.com/controlpanel]] (your control panel username is //jtw//).
<<tiddler tiddlyspotControls>>
@@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 Guides|http://tiddlywikiguides.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.
/***
|''Name:''|~WriteMacro|
|''Version:''|0.1|
|''Author:''|[[Jack]]|
|''Type:''|Macro|
!Description
Makes use of evalled parameters to write values to the current tiddler or execute code.
!Usage
{{{<<write {{javascript expression}}>>}}}
!Examples (WriteMacroExamples)
Write today's date:
{{{<<write {{'Today is ' + (new Date()).formatString('DDD')}}>>}}}
<<write {{'Today is ' + (new Date()).formatString('DDD')}}>>
!Code
***/
//{{{
version.extensions.write = {major: 0, minor: 1, revision: 0, date: new Date("Apr 23, 2006")};
config.macros.write = {handler:function(place,macroName,params,wikifier,paramString,tiddler) {
var parameters = paramString.parseParams("code",null,true);
var code = parameters[0]['code'][0];
wikify(code,place,null,tiddler);
}}
config.macros.write.wikify = wikify;
wikify = function(source,output,highlightRegExp,tiddler) {
window.currentTiddler = tiddler;
config.macros.write.wikify(source,output,highlightRegExp,tiddler);
}
//}}}
{{{<<write {{'Welcome ' + config.options.txtUserName}}>>}}}
<<write {{'Welcome ' + config.options.txtUserName}}>>
{{{<<write {{'This is the ' + tiddler.title + ' tiddler'}}>>}}}
<<write {{'This is the ' + tiddler.title + ' tiddler'}}>>
{{{<<write {{'Today is ' + (new Date()).formatString('DDD')}}>>}}}
<<write {{'Today is ' + (new Date()).formatString('DDD')}}>>
{{{<<write {{'There are ' + store.reverseLookup("tags"," ",false).length + ' tiddlers in this file.'}}>>}}}
<<write {{'There are ' + store.reverseLookup("tags"," ",false).length + ' tiddlers in this file.'}}>>
{{{<<write {{'This file was updated on ' + (new Date(document.lastModified)).formatString('DD MMM YYYY')}}>>}}}
<<write {{'This file was updated on ' + (new Date(document.lastModified)).formatString('DD MMM YYYY')}}>>
<<tiddlerList tags:{{gCurrentTiddler.title}}>>
| tiddlyspot password:|<<option pasUploadPassword>>|
| site management:|<<upload http://jtw.tiddlyspot.com/store.cgi index.html . . jtw>>//(requires tiddlyspot password)//<<br>>[[control panel|http://jtw.tiddlyspot.com/controlpanel]], [[download (go offline)|http://jtw.tiddlyspot.com/download]]|
| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[announcements|http://announce.tiddlyspot.com/]], [[blog|http://tiddlyspot.com/blog/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|
readOnly=false
config.options.txtUserName="Jack";