Welcome to TiddlyWiki created by Jeremy Ruston; Copyright © 2004-2007 Jeremy Ruston, Copyright © 2007-2011 UnaMesa Association
/%
!info
|Name|AutoRefresh|
|Source|http://www.TiddlyTools.com/#AutoRefresh|
|Version|2.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|set/clear tiddler refresh flags to force/prevent re-rendering when changes occur|
Usage:
<<<
{{{
<<tiddler AutoRefresh>>
<<tiddler AutoRefresh with: mode id>>
}}}
*''mode'' (optional), one of:
**''off'' or ''disable'' - prevents refresh of rendered content (except when PageTemplate is changed!)
**''on'' or ''enable'' - re-render content whenever corresponding tiddler source is changed (default)
**''force'' - re-render content whenever //''ANY''// tiddler is changed
*''id'' (optional), is a unique DOM element identifier on which to operate (e.g., 'mainMenu'). If omitted, the current tiddler (if any) is implied.
<<<
!end
!show
<<tiddler {{
var here=story.findContainingTiddler(place);
var target=document.getElementById('$2')||here||place.parentNode;
if (target==here) { // in a tiddler, get viewer element
var elems=target.getElementsByTagName('*');
for (var i=0;i<elems.length;i++)
if (hasClass(elems[i],'viewer')) { target=elems[i]; break; }
}
if (target) {
var mode='$1'; if (mode=='$'+'1') mode='on';
if (['on','enable','force'].contains(mode.toLowerCase())) {
var title=target.getAttribute('tiddler');
if (!title&&here) title=here.getAttribute('tiddler');
if (title) target.setAttribute('tiddler',title);
target.setAttribute('refresh','content');
target.setAttribute('force',(mode=='force')?'true':'');
} else if (['off','disable'].contains(mode.toLowerCase())) {
target.setAttribute('refresh','');
target.setAttribute('force','');
}
}
'';}}>>
!end
%/<<tiddler {{var src='AutoRefresh'; src+(tiddler&&tiddler.title==src?'##info':'##show');}}
with: [[$1]] [[$2]]>>
Auntie [[Amrita]]'s husband
/***
|Name|InlineJavascriptPlugin|
|Source|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
|Documentation|http://www.TiddlyTools.com/#InlineJavascriptPluginInfo|
|Version|1.9.6|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|Insert Javascript executable code directly into your tiddler content.|
''Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
!!!!!Documentation
>see [[InlineJavascriptPluginInfo]]
!!!!!Revisions
<<<
2010.12.15 1.9.6 allow (but ignore) type="..." syntax
|please see [[InlineJavascriptPluginInfo]] for additional revision details|
2005.11.08 1.0.0 initial release
<<<
!!!!!Code
***/
//{{{
version.extensions.InlineJavascriptPlugin= {major: 1, minor: 9, revision: 6, date: new Date(2010,12,15)};
config.formatters.push( {
name: "inlineJavascript",
match: "\\<script",
lookahead: "\\<script(?: type=\\\"[^\\\"]*\\\")?(?: src=\\\"([^\\\"]*)\\\")?(?: label=\\\"([^\\\"]*)\\\")?(?: title=\\\"([^\\\"]*)\\\")?(?: key=\\\"([^\\\"]*)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",
handler: function(w) {
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = lookaheadRegExp.exec(w.source)
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var src=lookaheadMatch[1];
var label=lookaheadMatch[2];
var tip=lookaheadMatch[3];
var key=lookaheadMatch[4];
var show=lookaheadMatch[5];
var code=lookaheadMatch[6];
if (src) { // external script library
var script = document.createElement("script"); script.src = src;
document.body.appendChild(script); document.body.removeChild(script);
}
if (code) { // inline code
if (show) // display source in tiddler
wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
if (label) { // create 'onclick' command link
var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",wikifyPlainText(label));
var fixup=code.replace(/document.write\s*\(/gi,'place.bufferedHTML+=(');
link.code="function _out(place,tiddler){"+fixup+"\n};_out(this,this.tiddler);"
link.tiddler=w.tiddler;
link.onclick=function(){
this.bufferedHTML="";
try{ var r=eval(this.code);
if(this.bufferedHTML.length || (typeof(r)==="string")&&r.length)
var s=this.parentNode.insertBefore(document.createElement("span"),this.nextSibling);
if(this.bufferedHTML.length)
s.innerHTML=this.bufferedHTML;
if((typeof(r)==="string")&&r.length) {
wikify(r,s,null,this.tiddler);
return false;
} else return r!==undefined?r:false;
} catch(e){alert(e.description||e.toString());return false;}
};
link.setAttribute("title",tip||"");
var URIcode='javascript:void(eval(decodeURIComponent(%22(function(){try{';
URIcode+=encodeURIComponent(encodeURIComponent(code.replace(/\n/g,' ')));
URIcode+='}catch(e){alert(e.description||e.toString())}})()%22)))';
link.setAttribute("href",URIcode);
link.style.cursor="pointer";
if (key) link.accessKey=key.substr(0,1); // single character only
}
else { // run script immediately
var fixup=code.replace(/document.write\s*\(/gi,'place.innerHTML+=(');
var c="function _out(place,tiddler){"+fixup+"\n};_out(w.output,w.tiddler);";
try { var out=eval(c); }
catch(e) { out=e.description?e.description:e.toString(); }
if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
}
}
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
}
}
} )
//}}}
// // Backward-compatibility for TW2.1.x and earlier
//{{{
if (typeof(wikifyPlainText)=="undefined") window.wikifyPlainText=function(text,limit,tiddler) {
if(limit > 0) text = text.substr(0,limit);
var wikifier = new Wikifier(text,formatter,null,tiddler);
return wikifier.wikifyPlain();
}
//}}}
// // GLOBAL FUNCTION: $(...) -- 'shorthand' convenience syntax for document.getElementById()
//{{{
if (typeof($)=='undefined') { function $(id) { return document.getElementById(id.replace(/^#/,'')); } }
//}}}
/***
|Name|InlineJavascriptPluginInfo|
|Source|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
|Documentation|http://www.TiddlyTools.com/#InlineJavascriptPluginInfo|
|Version|1.9.6|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|documentation|
|Description|Documentation for InlineJavascriptPlugin|
''Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
!!!!!Usage
<<<
This plugin adds wiki syntax for surrounding tiddler content with {{{<script>}}} and {{{</script>}}} markers, so that it can be recognized as embedded javascript code. When a tiddler is rendered, the plugin automatically invokes any embedded scripts, which can be used to construct and return dynamically-generated output that is inserted into the tiddler content.
{{{
<script type="..." src="..." label="..." title="..." key="..." show>
/* javascript code goes here... */
</script>
}}}
All parameters are //optional//. When the ''show'' keyword is used, the plugin will also include the script source code in the output that it displays in the tiddler. This is helpful when creating examples for documentation purposes (such as used in this tiddler!)
__''Deferred execution from an 'onClick' link''__
<script label="click here" title="mouseover tooltip text" key="X" show>
/* javascript code goes here... */
alert('you clicked on the link!');
</script>
By including a {{{label="..."}}} parameter in the initial {{{<script>}}} marker, the plugin will create a link to an 'onclick' script that will only be executed when that specific link is clicked, rather than running the script each time the tiddler is rendered. You may also include a {{{title="..."}}} parameter to specify the 'tooltip' text that will appear whenever the mouse is moved over the onClick link text, and a {{{key="X"}}} parameter to specify an //access key// (which must be a //single// letter or numeric digit only).
__''Loading scripts from external source files''__
<script src="URL" show>
/* optional javascript code goes here... */
</script>You can also load javascript directly from an external source URL, by including a src="..." parameter in the initial {{{<script>}}} marker (e.g., {{{<script src="demo.js"></script>}}}). This is particularly useful when incorporating third-party javascript libraries for use in custom extensions and plugins. The 'foreign' javascript code remains isolated in a separate file that can be easily replaced whenever an updated library file becomes available.
In addition to loading the javascript from the external file, you can also use this feature to invoke javascript code contained within the {{{<script>...</script>}}} markers. This code is invoked //after// the external script file has been processed, and can make immediate use of the functions and/or global variables defined by the external script file.
>Note: To ensure that your javascript functions are always available when needed, you should load the libraries from a tiddler that is rendered as soon as your TiddlyWiki document is opened, such as MainMenu. For example: put your {{{<script src="..."></script>}}} syntax into a separate 'library' tiddler (e.g., LoadScripts), and then add {{{<<tiddler LoadScripts>>}}} to MainMenu so that the library is loaded before any other tiddlers that rely upon the functions it defines.
>
>Normally, loading external javascript in this way does not produce any direct output, and should not have any impact on the appearance of your MainMenu. However, if your LoadScripts tiddler contains notes or other visible content, you can suppress this output by using 'inline CSS' in the MainMenu, like this: {{{@@display:none;<<tiddler LoadScripts>>@@}}}
<<<
!!!!!Creating dynamic tiddler content and accessing the ~TiddlyWiki DOM
<<<
An important difference between TiddlyWiki inline scripting and conventional embedded javascript techniques for web pages is the method used to produce output that is dynamically inserted into the document: in a typical web document, you use the {{{document.write()}}} (or {{{document.writeln()}}}) function to output text sequences (often containing HTML tags) that are then rendered when the entire document is first loaded into the browser window.
However, in a ~TiddlyWiki document, tiddlers (and other DOM elements) are created, deleted, and rendered "on-the-fly", so writing directly to the global 'document' object does not produce the results you want (i.e., replacing the embedded script within the tiddler content), and instead will //completely replace the entire ~TiddlyWiki document in your browser window (which is clearly not a good thing!)//. In order to allow scripts to use {{{document.write()}}}, the plugin automatically converts and buffers all HTML output so it can be safely inserted into your tiddler content, immediately following the script.
''Note that {{{document.write()}}} can only be used to output "pure HTML" syntax. To produce //wiki-formatted// output, your script should instead return a text value containing the desired wiki-syntax content'', which will then be automatically rendered immediately following the script. If returning a text value is not sufficient for your needs, the plugin also provides an automatically-defined variable, 'place', that gives the script code ''direct access to the //containing DOM element//'' into which the tiddler output is being rendered. You can use this variable to ''perform direct DOM manipulations'' that can, for example:
* generate wiki-formatted output using {{{wikify("...content...",place)}}}
* vary the script's actions based upon the DOM element in which it is embedded
* access 'tiddler-relative' DOM information using {{{story.findContainingTiddler(place)}}}
Note:
''When using an 'onclick' script, the 'place' element actually refers to the onclick //link text// itself, instead of the containing DOM element.'' This permits you to directly reference or modify the link text to reflect any 'stateful' conditions that might set by the script. To refer to the containing DOM element from within an 'onclick' script, you can use "place.parentNode" instead.
<<<
!!!!!Instant "bookmarklets"
<<<
You can also use an 'onclick' link to define a "bookmarklet": a small piece of javascript that can be ''invoked directly from the browser without having to be defined within the current document.'' This allows you to create 'stand-alone' commands that can be applied to virtually ANY TiddlyWiki document... even remotely-hosted documents that have been written by others!! To create a bookmarklet, simply define an 'onclick' script and then grab the resulting link text and drag-and-drop it onto your browser's toolbar (or right-click and use the 'bookmark this link' command to add it to the browser's menu).
Notes:
*When writing scripts intended for use as bookmarklets, due to the ~URI-encoding required by the browser, ''you cannot not use ANY double-quotes (") within the bookmarklet script code.''
*All comments embedded in the bookmarklet script must ''use the fully-delimited {{{/* ... */}}} comment syntax,'' rather than the shorter {{{//}}} comment syntax.
*Most importantly, because bookmarklets are invoked directly from the browser interface and are not embedded within the TiddlyWiki document, there is NO containing 'place' DOM element surrounding the script. As a result, ''you cannot use a bookmarklet to generate dynamic output in your document,'' and using {{{document.write()}}} or returning wiki-syntax text or making reference to the 'place' DOM element will halt the script and report a "Reference Error" when that bookmarklet is invoked.
Please see [[InstantBookmarklets]] for many examples of 'onclick' scripts that can also be used as bookmarklets.
<<<
!!!!!Special reserved function name
<<<
The plugin 'wraps' all inline javascript code inside a function, {{{_out()}}}, so that any return value you provide can be correctly handled by the plugin and inserted into the tiddler. To avoid unpredictable results (and possibly fatal execution errors), this function should never be redefined or called from ''within'' your script code.
<<<
!!!!!$(...) 'shorthand' function
<<<
As described by Dustin Diaz [[here|http://www.dustindiaz.com/top-ten-javascript/]], the plugin defines a 'shorthand' function that allows you to write:
{{{
$(id)
}}}
in place of the normal standard javascript syntax:
{{{
document.getElementById(id)
}}}
This function is provided merely as a convenience for javascript coders that may be familiar with this abbreviation, in order to allow them to save a few bytes when writing their own inline script code.
<<<
!!!!!Examples
<<<
simple dynamic output:
><script show>
document.write("The current date/time is: "+(new Date())+"<br>");
return "link to current user: [["+config.options.txtUserName+"]]\n";
</script>
dynamic output using 'place' to get size information for current tiddler:
><script show>
if (!window.story) window.story=window;
var title=story.findContainingTiddler(place).getAttribute("tiddler");
var size=store.getTiddlerText(title).length;
return title+" is using "+size+" bytes";
</script>
dynamic output from an 'onclick' script, using {{{document.write()}}} and/or {{{return "..."}}}
><script label="click here" show>
document.write("<br>The current date/time is: "+(new Date())+"<br>");
return "link to current user: [["+config.options.txtUserName+"]]\n";
</script>
creating an 'onclick' button/link that accesses the link text AND the containing tiddler:
><script label="click here" title="clicking this link will show an 'alert' box" key="H" show>
if (!window.story) window.story=window;
var txt=place.firstChild.data;
var tid=story.findContainingTiddler(place).getAttribute('tiddler');
alert('Hello World!\nlinktext='+txt+'\ntiddler='+tid);
</script>
dynamically setting onclick link text based on stateful information:
>{{block{
{{{
<script label="click here">
/* toggle "txtSomething" value */
var on=(config.txtSomething=="ON");
place.innerHTML=on?"enable":"disable";
config.txtSomething=on?"OFF":"ON";
return "\nThe current value is: "+config.txtSomething;
</script><script>
/* initialize onclick link text based on current "txtSomething" value */
var on=(config.txtSomething=="ON");
place.lastChild.previousSibling.innerHTML=on?"disable":"enable";
</script>
}}}
<script label="click here">
/* toggle "txtSomething" value */
var on=(config.txtSomething=="ON");
place.innerHTML=on?"enable":"disable";
config.txtSomething=on?"OFF":"ON";
return "\nThe current value is: "+config.txtSomething;
</script><script>
/* initialize onclick link text based on current "txtSomething" value */
var on=(config.txtSomething=="ON");
place.lastChild.innerHTML=on?"enable":"disable";
</script>
}}}
loading a script from a source url:
>http://www.TiddlyTools.com/demo.js contains:
>>{{{function inlineJavascriptDemo() { alert('Hello from demo.js!!') } }}}
>>{{{displayMessage('InlineJavascriptPlugin: demo.js has been loaded');}}}
>note: When using this example on your local system, you will need to download the external script file from the above URL and install it into the same directory as your document.
>
><script src="demo.js" show>
return "inlineJavascriptDemo() function has been defined"
</script>
><script label="click to invoke inlineJavascriptDemo()" key="D" show>
inlineJavascriptDemo();
</script>
<<<
!!!!!Revisions
<<<
2010.12.15 1.9.6 allow (but ignore) type="..." syntax
2009.04.11 1.9.5 pass current tiddler object into wrapper code so it can be referenced from within 'onclick' scripts
2009.02.26 1.9.4 in $(), handle leading '#' on ID for compatibility with JQuery syntax
2008.06.11 1.9.3 added $(...) function as 'shorthand' for document.getElementById()
2008.03.03 1.9.2 corrected fallback declaration of wikifyPlainText() (fixes Safari "parse error")
2008.02.23 1.9.1 in onclick function, use string instead of array for 'bufferedHTML' (fixes IE errors)
2008.02.21 1.9.0 output from 'onclick' scripts (return value or document.write() calls) are now buffered and rendered into into a span following the script. Also, added default 'return false' handling if no return value provided (prevents HREF from being triggered -- return TRUE to allow HREF to be processed). Thanks to Xavier Verges for suggestion and preliminary code.
2008.02.14 1.8.1 added backward-compatibility for use of wikifyPlainText() in TW2.1.3 and earlier
2008.01.08 [*.*.*] plugin size reduction: documentation moved to ...Info tiddler
2007.12.28 1.8.0 added support for key="X" syntax to specify custom access key definitions
2007.12.15 1.7.0 autogenerate URI encoded HREF on links for onclick scripts. Drag links to browser toolbar to create bookmarklets. IMPORTANT NOTE: place is NOT defined when scripts are used as bookmarklets. In addition, double-quotes will cause syntax errors. Thanks to PaulReiber for debugging and brainstorming.
2007.11.26 1.6.2 when converting "document.write()" function calls in inline code, allow whitespace between "write" and "(" so that "document.write ( foobar )" is properly converted.
2007.11.16 1.6.1 when rendering "onclick scripts", pass label text through wikifyPlainText() to parse any embedded wiki-syntax to enable use of HTML entities or even TW macros to generate dynamic label text.
2007.02.19 1.6.0 added support for title="..." to specify mouseover tooltip when using an onclick (label="...") script
2006.10.16 1.5.2 add newline before closing '}' in 'function out_' wrapper. Fixes error caused when last line of script is a comment.
2006.06.01 1.5.1 when calling wikify() on script return value, pass hightlightRegExp and tiddler params so macros that rely on these values can render properly
2006.04.19 1.5.0 added 'show' parameter to force display of javascript source code in tiddler output
2006.01.05 1.4.0 added support 'onclick' scripts. When label="..." param is present, a button/link is created using the indicated label text, and the script is only executed when the button/link is clicked. 'place' value is set to match the clicked button/link element.
2005.12.13 1.3.1 when catching eval error in IE, e.description contains the error text, instead of e.toString(). Fixed error reporting so IE shows the correct response text. Based on a suggestion by UdoBorkowski
2005.11.09 1.3.0 for 'inline' scripts (i.e., not scripts loaded with src="..."), automatically replace calls to 'document.write()' with 'place.innerHTML+=' so script output is directed into tiddler content. Based on a suggestion by BradleyMeck
2005.11.08 1.2.0 handle loading of javascript from an external URL via src="..." syntax
2005.11.08 1.1.0 pass 'place' param into scripts to provide direct DOM access
2005.11.08 1.0.0 initial release
<<<
/***
|''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);
}
//}}}
<<newTiddler label:'Add New Event' template:'eventEditTemplate' title:'New Event' tag:'event' >>
<<closeAll>>
----
[[Timeline All]]
[[Timeline Selected]]
[[Show All By Tags]]
----
[[Tweak Tiddlers]]
[[MainMenu]]
<<tiddler ToggleRightSidebar>>
/%
!info
|Name|OpenTaggedTiddlers|
|Source|http://www.TiddlyTools.com/#OpenTaggedTiddlers|
|Version|2.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|create a link to open a set of tagged tiddlers with a single click|
Usage:
<<<
{{{
<<tiddler OpenTaggedTiddlers with: label tagToMatch sortBy reverse close limit>>
}}}
*''label''<br>is the text of the link
*''tagToMatch''<br>is a single tag value to be matched. Note: when MatchTagsPlugin is installed, you can also use a boolean tag expression, enclosed in "..."
*''sortBy'' (optional)<br>a tiddler fieldname, (default="title", use "modified" or "created" for tiddler dates)
*''reverse'' (optional)<br>display order for the tiddlers (i.e., descending vs. ascending)
*''close'' (optional)<br>closes all open tiddlers before opening the tagged tiddlers
*''limit'' (optional)<br>maximum number of tiddlers to be opened
Note: use "" as placeholders when omitting optional parameters
<<<
Example
<<<
{{{<<tiddler OpenTaggedTiddlers##show with: "click me..." sample title reverse "" 3>>}}}
<<tiddler OpenTaggedTiddlers##show with: "click me..." sample title reverse "" 3>>
<<<
!end
!show
<html><nowiki><a href='javascript:;' onclick="
var list=[];
var match='$2';
var sortBy='$3'; if ((sortBy=='$'+'3')||(sortBy=='')) sortBy='title';
var filter='[tag[%0]][sort[%1]]'.format([match,sortBy]);
var tids=store.filterTiddlers(filter);
if ('$4'=='reverse') tids=tids.reverse();
if ('$5'=='close') story.closeAllTiddlers();
var limit=('$6'!='$'+'6')?parseInt('$6'):tids.length;
for (var t=0;t<tids.length && t<limit;t++) list.push(tids[t].title);
if (confirm('Show %0 tiddlers tagged with \x27%1\x27?'.format([tids.length,match]))) {
var here=story.findContainingTiddler(place);
story.displayTiddlers(here,list);
if (here && list.length) { // scroll to top of newly displayed tiddlers
var cmd='window.scrollTo(0,'+(here.offsetTop+here.offsetHeight)+')';
var delay=config.options.chkAnimate?config.animDuration+100:0;
setTimeout(cmd,delay);
}
}
return false;
">$1</a></html>
!end
%/<<tiddler {{var src='OpenTaggedTiddlers'; src+(tiddler&&tiddler.title==src?'##info':'##show')}}
with: [[$1]] [[$2]] [[$3]] [[$4]] [[$5]] [[$6]]>>
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
major: 1, minor: 0, revision: 2,
date: new Date("Apr 19, 2007"),
source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
coreVersion: '2.2.0 (Beta 5)'
};
config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");
merge(config.macros.option.types, {
'pas': {
elementType: "input",
valueField: "value",
eventName: "onkeyup",
className: "pasOptionInput",
typeValue: config.macros.option.passwordInputType,
create: function(place,type,opt,className,desc) {
// password field
config.macros.option.genericCreate(place,'pas',opt,className,desc);
// checkbox linked with this password "save this password on this computer"
config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);
// text savePasswordCheckboxLabel
place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
},
onChange: config.macros.option.genericOnChange
}
});
merge(config.optionHandlers['chk'], {
get: function(name) {
// is there an option linked with this chk ?
var opt = name.substr(3);
if (config.options[opt])
saveOptionCookie(opt);
return config.options[name] ? "true" : "false";
}
});
merge(config.optionHandlers, {
'pas': {
get: function(name) {
if (config.options["chk"+name]) {
return encodeCookie(config.options[name].toString());
} else {
return "";
}
},
set: function(name,value) {config.options[name] = decodeCookie(value);}
}
});
// need to reload options to load passwordOptions
loadOptionsCookie();
/*
if (!config.options['pasPassword'])
config.options['pasPassword'] = '';
merge(config.optionsDesc,{
pasPassword: "Test password"
});
*/
//}}}
/***
|Name|SetUserNamePlugin|
|Source|http://www.TiddlyTools.com/#SetUserNamePlugin|
|Version|1.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|prompt for TiddlyWiki username|
!!!!!Usage
<<<
{{{
<<setUserName>>
<<setUserName force>>
}}}
If the default username ("YourName") is currently set, the macro automatically prompts for a new username. The optional 'force' keyword triggers a prompt even if a non-default username has already been set. When the plugin is installed, the default (shadow) EditTemplate definition is updated to invoke the macro (using
template syntax: {{{<span macro='setUserName'></span>}}}). As a result, whenever a user attempts to edit/create a tiddler AND have not yet entered a username, they will be automatically prompted to enter a new username. If you are using a customized EditTemplate, you will need to edit it yourself to add the above syntax.
{{{
<<showUserName>>
}}}
Displays the current username. Clicking the name prompts for a new username. Note: for backward-compatibility, the plugin also creates a shadow tiddler named [[ShowUserName]] so you can invoke the macro by using: {{{<<tiddler ShowUserName>>}}}
<<<
!!!!!Revisions
<<<
2012.07.11 1.1.0 added ShowUserName macro and shadow (replaces ShowUserName transclusion)
2006.12.01 1.0.0 initial release - converted from SetUserName inline script
<<<
!!!!!Code
***/
//{{{
version.extensions.SetUserNamePlugin= {major: 1, minor: 1, revision: 0, date: new Date(2012,7,11)};
config.macros.setUserName = {
msg: "Please set your username",
handler: function(place,macroName,params) {
// only prompt when needed or forced
var force=params[0]&¶ms[0].toLowerCase()=="force";
if (!force && (readOnly || config.options.txtUserName!="YourName")) return;
var opt="txtUserName";
var who=prompt(this.msg,config.options[opt]);
if (!who||!who.trim().length) return; // cancelled by user
config.options[opt]=who;
saveOptionCookie(opt);
config.macros.option.propagateOption(opt,"value",config.options[opt],"input");
}
}
config.macros.showUserName = {
msg: "click to set your username",
handler: function(place,macroName,params) {
createTiddlyButton(place,config.options.txtUserName,this.msg,this.action);
},
action: function(ev) {
var place=resolveTarget(ev);
config.macros.setUserName.handler(resolveTarget(ev),"showUserName",['force']);
place.innerHTML=config.options.txtUserName;
return false;
}
}
config.shadowTiddlers.ShowUserName="<<showUserName>>";
// add trigger to default shadow EditTemplate (custom templates: add this by hand)
config.shadowTiddlers.EditTemplate+="<span macro='setUserName'></span>";
//}}}
<<tiddler ShowAllByTags with:"systemConfig Documentation pluginInfo script template transclusion">>
/%
|Name|ShowAllByTags|
|Source|http://www.TiddlyTools.com/#ShowAllByTags|
|Version|1.1.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|script|
|Requires|InlineJavascriptPlugin|
|Description|for each tag, show a numbered list of all tiddlers with that tag|
Usage:
<<tiddler ShowAllByTags with: "tag tag tag">>
where
"tag tag tag" (optional)
quoted, space-separated, bracketed list of tags to **exclude** from the display
!Revisions
2008.08.04 [1.1.0] added optional parameter to exclude specified tags
!end Revisions
%/<script>
var ex=[];
if ("$1"!="$"+"1") ex="$1".readBracketedList();
var tags = store.getTags();
if(tags.length == 0) return "no tags in document";
var out="";
for(var t=0; t<tags.length; t++) {
if (ex.contains(tags[t][0])) continue;
out+="*[["+tags[t][0]+"]] ("+tags[t][1]+")"+"\n";
var tids=store.getTaggedTiddlers(tags[t][0]);
for (i=0; i<tids.length; i++) out+="##[["+tids[i].title+"]]\n";
}
return out;
</script>
Provides configuration for TagSearchPlugin...
!Tags
[[type]]
[[circle]]
[[person]]
!More
[[TAG:Archive]]
[[Journal]]
[[Reference]]
[[systemConfig]]
[[systemConfigDisable]]
[[excludeMissing]]
[[excludeSearch]]
[[excludeLists]]
[[TagSearchLegacy]]
/***
|''Name:''|TagSearchPlugin|
|''Version:''|1.2.0 (2010-10-10)|
|''Source:''|http://tagsearch.tiddlyspot.com/#TagSearchPlugin|
|''Author:''|[[Tobias Beer]]|
|''Description:''|Provides a drop down listing current tags and others to be set. Based on [[x-tagger|http://tbgtd.tiddlyspot.com/#x-tagger]] which in turn was once based on [[TaggerPlugin|http://tw.lewcid.org/#TaggerPlugin]].|
|''Documentation:''|http://tagsearch.tiddlyspot.com|
|''~TiddlyWiki:''|Version 2.5.3 or better|
***/
//{{{
(function($){
config.macros.tagsearch={
cfg:{
defaultSource:'',
defaultMore:'',
defaultMode:1,
keepModified:false,
sidebarOffset:20,
newAtSingle:30,
newAt:18,
excludeTagged:'',
toolbar:'',
label:"tags",
options:"Options",
more:"More...",
tooltip:"Manage tiddler tags",
notags:"no tags set...",
aretags:"Current tags",
addTag:"Add tag...",
addTags:"Set tag...",
txtEdit:"~ edit categories...",
txtEditTip:"edit tiddler with GTD tag categories used by x-tagger",
txtNew:"~ add another tag",
txtRemove: "remove tag %0",
txtAdd:"set tag %0",
txtFor:"To be tagged... ",
txtCtrl:" (hold SHIFT to just add it or CTRL to replace in category)",
promptNew:"Enter new tag:",
modeAsk:"Do you want to remove existing tags from category '%0'?\nCancel simply adds tag '%1'.",
},
handler:function(place,macroName,params,wikifier,paramString,tiddler){
var c=this.cfg,
tid=story.findContainingTiddler(place),
p=paramString.parseParams('tagman',null,true);
$(createTiddlyButton(
place,
getParam(p,'label',c.label),
getParam(p,'tooltip',c.tooltip),
this.click,
'button'
)).attr({
id:this.newId('btntgs'),
tid:(tid?tid.getAttribute('tiddler'):'')
}).data({
pa:params,
p:p
})
},
click:function(ev){
var ar,curr,d1,d2,ex=[],fst=true,i,j,l,npop,nbtns,nli,m,pop,s,t,tgs=[],tids,ti,tgt,
e=ev||window.event,
el=$(this),
id=el.attr('popup'),
trigger=window.event?'keydown':'keypress',
x=config.macros.tagsearch,
c=x.cfg,
pa=el.data('pa'),
p=el.data('p'),
tb=pa.contains('toolbar'),
src=getParam(p,'source',c.defaultSource),
mr=getParam(p,'more',c.defaultMore),
search=!pa.contains('nosearch'),
tags=!pa.contains('notags'),
more=!pa.contains('nomore'),
gt=getParam(p,'goto',''),
mode=parseInt(getParam(p,'mode')),
rtid=getParam(p,'tiddler',''),
tid=rtid?rtid:el.attr('tid'),
exp=(getParam(p,'exclude','')+' '+c.excludeTagged).readBracketedList(),
max=nu=src?c.newAt:c.newAtSingle,
otid=store.getTiddler(tid);
if(!tid)return;
mode=isNaN(mode)?c.defaultMode:mode;
exp.map(function(e){ex.pushUnique(e);});
for(i=0;i<exp.length;i++){
store.getTaggedTiddlers(exp[i]).map(function(t){ex.pushUnique(t.title)});
}
if(src&&!store.getTiddlerText(src))return false;
if(id){
pop=$('#'+id)[0];
$(pop).empty();
}
if(!pop){
npop=true;
id=x.newId('tgspop');
pop=Popup.create(this);
$(pop).addClass('tgs'
).attr({
'id':id
}).data({
btn:el,
tiddler:tid,
source:src,
mode:mode
}).click(x.noBubble);
el.attr('popup',id);
}
if(src){
tids=store.getTiddlerText(src).readBracketedList();
for(t=0;t<tids.length;t++){
if(!ex.contains(tids[t])){
tgt=store.getTaggedTiddlers(tids[t]);
tgs.push('TAG:'+tids[t]);
for(s=0;s<tgt.length;s++){
if(!ex.contains(tgt[s].title))tgs.push(tgt[s].title);
}
}
}
}else tgs=store.getTags();
curr=otid?otid.tags.sort():[];
nli=function(p,cls){return createTiddlyElement(createTiddlyElement(p,'li',null,null),'ol',null,cls?cls:null);}
nbtns=function(where,text,tag,tip){
var s,t;
s=createTiddlyElement(createTiddlyElement(where,'li'),'span',null,null);
t=$(createTiddlyButton(s,text,tip.format(["'"+tag+"'"]),x.setTag,'button toggleButton', null));
t.data({
tiddler:tid,
tag:tag,
source:src,
mode:mode
});
insertSpacer(s);
createTagButton(s,tag);
}
d1=nli(pop,'tgside');
//SEARCH
if(config.macros.gotoTiddler&&search){
d2=nli(d1);
if(rtid){
l=createTiddlyElement(d2,'li',null,'addto','');
wikify('{{title{'+c.txtFor+'}}}<<tag [['+tid+']]>>',l);
d2=nli(d1);
}
createTiddlyElement(d2,'li',null,'title',c.addTag);
wikify('<<gotoTiddler '+gt+' >>',d2);
$('input',pop
).bind(trigger,x.noBubble
).data('notify',config.macros.tagsearch.notify
).focus();
}
//EXISTING
d2=nli(d1);
createTiddlyElement(d2,'li',null,'title',c.aretags);
if(curr.length==0)wikify('{{notags{'+c.notags+'}}}',d2);
else for(t=0;t<curr.length;t++)nbtns(d2,'[X]',curr[t],c.txtRemove);
//TAGS
if(tags){
for(i=0;i<tgs.length;i++){
nu++;
ti=src?tgs[i]:tgs[i][0];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4);
if(nu>max){nu=0;d1=nli(pop);}d2=nli(d1);nu++;
createTiddlyLink(createTiddlyElement(d2,'li',null,null),ti,ti,'title');
}
else if(!curr.contains(ti)&&!ex.contains(ti)){
if(!src&&nu>max||src&&nu>c.newAtSingle){
nu=0;d1=nli(pop);d2=nli(d1);
if(fst){createTiddlyElement(createTiddlyElement(d2,'li',null,null),'li',null,'title',c.addTags);fst=false;}
}
nbtns(d2,'['+String.fromCharCode(160,160,160)+']',ti,c.txtAdd+(src?c.txtCtrl:''));
}
}
}
//MORE / OPTIONS
if(more){
d1=nli(pop,'tgside');
d2=nli(d1);createTiddlyElement(d2,'li',null,'title',c.options,null);
createTiddlyButton(
createTiddlyElement(d2,'li'),
c.txtNew,
null,
x.setTag,
'tsopt',
null,
null,
{'tiddler':tid}
);
if(src){
createTiddlyButton(
createTiddlyElement(d2,'li'),
c.txtEdit,
c.txtEditTip,
onClickTiddlerLink,
'tsopt',
null,
null,
{'tiddlyLink':src.split('##')[0]}
)
}
//MORE
fst=true;
if(mr){
m=store.getTiddlerText(mr).readBracketedList();
if(m.length>0){
for(i=0;i<m.length;i++){
ti=m[i];
if(ti.indexOf('TAG:')==0){
ti=ti.substr(4,ti.length-4);
d2=nli(d1);createTiddlyLink(createTiddlyElement(d2,'li',null,null),ti,ti,'title');
ar=store.getTaggedTiddlers(ti);
for(j=0;j<ar.length;j++){
ti=ar[j].title;
if(!curr.contains(ti)&&!ex.contains(ti))
nbtns(d2,'['+String.fromCharCode(160,160)+']',ti,c.txtAdd);
}
}else{
if(fst){d2=nli(d1);createTiddlyElement(d2,'li',null,'title',c.more);fst=false;}
if(!curr.contains(ti)&&!ex.contains(ti))
nbtns(d2,'['+String.fromCharCode(160,160)+']',ti,c.txtAdd);
}
}
}
}
}
if(npop){
Popup.show(pop,false);
if(tb){
s=document.getElementById('sidebar');
pop.style.left='';pop.style.right=(c.sidebarOffset+(s?s.offsetWidth:0))+'px';
}
}
return x.noBubble(e);
},
setTag:function(ev){
var ca,cats,nu,ok=true,t,tgs,tgt,ti,
e=ev||window.event,
x=config.macros.tagsearch,
c=x.cfg,
el=$(this),
p=el.closest('.tgs'),
btn=p.data('btn'),
tag=el.data('tag'),
title=p.data('tiddler'),
src=p.data('source'),
m=parseInt(p.data('mode'));
if(!tag){nu=prompt(c.promptNew,'');if(!nu)return false;else tag=nu;}
tid=x.exists(title,tag);
if(tid){
tgs=tid.tags;
if(!tgs.contains(tag)){
if(src&&m<2&&!e.shiftKey){
cats=store.getTiddlerText(src).readBracketedList();
findTagged: for(ca=0;ca<cats.length;ca++){
ti=cats[ca];
tgt=store.getTaggedTiddlers(ti).map(function(t){return t.title});
if(tgt.contains(tag)){
tgt.splice(tgt.indexOf(tag),1);
if(!e.ctrlKey&&m==1&&tgs.containsAny(tgt))
ok=confirm(c.modeAsk.format([ti,tag]));
if(ok){
for(t=0;t<tgt.length;t++){
ti=tgt[t];
if(tgs.contains(ti))store.setTiddlerTag(title,false,ti);
}
}
break findTagged;
}
}
}
store.setTiddlerTag(title,true,tag);
}else if(!nu)store.setTiddlerTag(title,false,tag);
t=store.getTiddler(title);
store.saveTiddler(
title,
title,
t.text,
c.keepModified?t.modifier:config.options.txtUserName,
c.keepModified?t.modified:new Date(),
t.tags,
t.fields
);
}
if(config.options.chkAutoSave)autoSaveChanges();
btn.click();
p.find('input').focus();
return x.noBubble(e);
},
newId:function(p){
return p+Math.random().toString().substr(3);
},
notify:function(tag,el){
var p=$(el).closest('.tgs'),
i=$('form input',p)[0];
t=config.macros.tagsearch.exists(p.data('tiddler'),tag);
if(t&&!t.tags.contains(tag))store.setTiddlerTag(t.title,t,tag);
p.data('btn').click();
i.select();
},
exists:function(title,tag){
if(!store.getTiddler(title)){ //||!tid.tags
var f=merge({}, config.defaultCustomFields);
store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag,f);
return false;
}
return store.getTiddler(title);
},
noBubble:function(ev){
var e=ev||window.event,el=resolveTarget(e);
if(e.keyCode==27)Popup.remove(0);
else if(e.type!='click'&&el.nodeName.toUpperCase()=='INPUT')return true;
if(hasClass(el,'tiddlyLink'))return true;
Popup.remove(1);
e.cancelBubble=true;
try{event.keyCode=0;}catch(e){};
if (window.event) e.returnValue=false;
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation) e.stopPropagation();
return false;
}
}
//HIJACK TOOLBAR
config.commands.tagSearch={}
var cmt=config.macros.toolbar;
cmt.createCommandTAGS=cmt.createCommand;
cmt.createCommand=function(place,commandName,tiddler,className){
if(commandName=='tagSearch'){
wikify('<<tagsearch toolbar '+config.macros.tagsearch.cfg.toolbar+'>>',place);
$(place.lastChild).attr({
commandName:'tagSearch',
tiddler:tiddler.title
});
}else cmt.createCommandTAGS.apply(this,arguments);
}
//GOTOPLUGIN
var gt=config.macros.gotoTiddler;
if(gt){
gt.processItem=function(title,here,list,showlist) {
if (!title.length) return;
list.style.display=showlist?'block':'none';
if (title=='*') { story.search(here.value); return false; } // do full-text search
if (!showlist) here.value=title;
var n=$(here).data('notify');
if(n)n.call(this,title,here); //notify of selection, otherwise...
else story.displayTiddler(null,title); // show selected tiddler (default behaviour)
return false;
}
gt.IEtableFixup='%0';
}
var TM=store.getTiddlerText('ColorPalette::TertiaryMid'),
TD=store.getTiddlerText('ColorPalette::TertiaryDark');
config.shadowTiddlers['StyleSheetTagSearch']='/*{{{*/\n'+
'.tgs {padding:7px !important;-moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;}\n'+
'.tgs li a, .tgs .quickopentag .tiddlyLink {display:inline;padding:2px;clear:none;}\n'+
'.tgs li a.toggleButton {display:inline;margin-left:5px;}\n'+
'.tgs .title {margin:3px 0 0 5px;font-weight:bold;font-size:150%;color:'+TM+';padding:0;}\n'+
'.tgs form{display:block;float:left;clear:both;padding-left:5px !important;}\n'+
'.tgs .addto .quickopentag{display:block;clear:both;padding:5px;font-size:120%;}\n'+
'.tgs .notags, .tsopt{display:block;clear:both;margin:5px;}\n'+
'.tgs .highlight{background:'+TD+';}\n'+
'.tgs ol{margin:0;padding:0 0 5px 0;}\n'+
'.tgs li{display:block;float:left;padding-bottom:10px !important;}\n'+
'.tgs li span{line-height:1em;}\n'+
'.tgs li ol li{clear:both;min-width:120px;display:inline;border:1px solid transparent;}\n'+
'.tgs li ol li:hover{border:1px solid '+TM+';}\n'+
'.tgs li ol li ol li{padding:0 !important;}\n'+
'.tgs li ol li ol li:hover{border:1px solid transparent;}\n'+
'.tgside li ol li {min-width:150px;}'+
'.tgs .quickopentag {display:inline;}\n'+
'.tgs .quickopentag .tiddlyLink:hover {text-decoration:underline;}\n'+
'.tgs .quickopentag .button {border:0;padding:2px;font-size:1.5em;}\n'+
'/*}}}*/';
store.addNotification('StyleSheetTagSearch',refreshStyles);
})(jQuery);
//}}}
/***
|Name|TaggedTemplateTweak|
|Source|http://www.TiddlyTools.com/#TaggedTemplateTweak|
|Documentation|http://www.TiddlyTools.com/#TaggedTemplateTweakInfo|
|Version|1.6.1|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|use alternative ViewTemplate/EditTemplate for specific tiddlers|
This plugin extends the core function, story.chooseTemplateForTiddler(), so that any given tiddler can be viewed and/or edited using alternatives to the standard tiddler templates.
!!!!!Documentation
>see [[TaggedTemplateTweakInfo]]
!!!!!Revisions
<<<
2009.09.02 [1.6.1] apply field-based template (if any) *before* tag-based template
| please see [[TaggedTemplateTweakInfo]] for previous revision details |
2007.06.11 [1.0.0] initial release
<<<
!!!!!Code
***/
//{{{
version.extensions.TaggedTemplateTweak= {major: 1, minor: 6, revision: 1, date: new Date(2009,9,2)};
if (!config.options.txtTemplateTweakFieldname)
config.options.txtTemplateTweakFieldname='template';
Story.prototype.taggedTemplate_chooseTemplateForTiddler = Story.prototype.chooseTemplateForTiddler
Story.prototype.chooseTemplateForTiddler = function(title,template)
{
// get core template and split into theme and template name
var coreTemplate=this.taggedTemplate_chooseTemplateForTiddler.apply(this,arguments);
var theme=""; var template=coreTemplate;
var parts=template.split(config.textPrimitives.sectionSeparator);
if (parts[1]) { theme=parts[0]; template=parts[1]; }
else theme=config.options.txtTheme||""; // if theme is not specified
theme+=config.textPrimitives.sectionSeparator;
// look for template using title as prefix
if (!store.getTaggedTiddlers(title).length) { // if tiddler is not a tag
if (store.getTiddlerText(theme+title+template))
{ return theme+title+template; } // theme##TitleTemplate
if (store.getTiddlerText(title+template))
{ return title+template; } // TitleTemplate
}
// look for templates using custom field value as prefix
var v=store.getValue(title,config.options.txtTemplateTweakFieldname);
if (store.getTiddlerText(theme+v+template))
{ return theme+v+template; } // theme##valueTemplate
if (store.getTiddlerText(v+template))
{ return v+template; } // valueTemplate
// look for template using tags as prefix
var tiddler=store.getTiddler(title);
if (!tiddler) return coreTemplate; // tiddler doesn't exist... use core result
for (i=0; i<tiddler.tags.length; i++) {
var t=tiddler.tags[i]+template; // add tag prefix to template
var c=t.substr(0,1).toUpperCase()+t.substr(1); // capitalized for WikiWord title
if (store.getTiddlerText(theme+t)) { return theme+t; } // theme##tagTemplate
if (store.getTiddlerText(theme+c)) { return theme+c; } // theme##TagTemplate
if (store.getTiddlerText(t)) { return t; } // tagTemplate
if (store.getTiddlerText(c)) { return c; } // TagTemplate
}
// no match... use core result
return coreTemplate;
}
//}}}
/***
|Name|TaggedTemplateTweakInfo|
|Source|http://www.TiddlyTools.com/#TaggedTemplateTweak|
|Documentation|http://www.TiddlyTools.com/#TaggedTemplateTweakInfo|
|Version|1.6.1|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|documentation|
|Description|Documentation for TaggedTemplateTweak|
This plugin extends the core function, story.chooseTemplateForTiddler(), so that any given tiddler can be viewed and/or edited using alternatives to the standard tiddler templates. To select alternative templates, a 'template prefix' is determined by using the tiddler's title or matching a tag value or using a value stored in a custom tiddler field.
!!!!!Usage
<<<
*The plugin first attempts to use the tiddler's //title// as a prefix added to the standard TiddlyWiki template titles, [[ViewTemplate]] and [[EditTemplate]] (i.e., ''TiddlerNameViewTemplate'' and ''TiddlerNameEditTemplate''). This allows you to associate a custom template with a specific tiddler, without needing to add any special tags or custom field values to that individual tiddler.
*You can also define a tiddler's template prefix by using a //custom tiddler field// named 'template'. If no corresponding template was found using the tiddler's title, then the tiddler's 'template' field value, if present, will be used as a prefix (e.g., if template='SomeThing', then [[SomeThingViewTemplate]] will be applied).
*If no template is found using the either the title or 'template' field, then each of the tiddler's tags is tried as a template prefix, until a corresponding template, if any, is found. For example, any tiddlers that are tagged with ''<<tag media>>'' could find alternative templates named [[mediaViewTemplate]] and [[mediaEditTemplate]].
*If you using a systemTheme, the plugin will also tries adding the currently selected theme name (specified by {{{config.options.txtTheme}}}) to the template name (e.g. ''[[SomeTheme##MediaViewTemplate]]'') so that the alternative template definitions can be contained as //sections// within a single systemTheme tiddler.
*Lastly, if no alternative template is found at all, the standard [[ViewTemplate]] or [[EditTemplate]] definition as determined by the TiddlyWiki core handler is used.
Notes:
*You can redefine the //name// of the custom field used to store the template prefix. For example, to use the name of a TiddlyWeb server-side 'bag' as a prefix (so that tiddlers from separate bags can have different appearances), add the following to a tiddler tagged with<<tag systemConfig>>:{{block{
{{{
config.options.txtTemplateTweakFieldname='server.bag'; // use TiddlyWeb bag name as prefix
}}}
}}}
*To permit use of templates that have proper WikiWord tiddler titles (e.g., [[MediaViewTemplate]] and [[MediaEditTemplate]]), the plugin also attempts to use a capitalized form of the tag value (e.g., ''Media'') as a prefix. //This capitalization is for comparison purposes only and will not alter the actual tag values that are stored in the tiddler.//
<<<
!!!!!Examples
<<<
|Sample tiddler| tag | view template | edit template |
|[[MediaSample - QuickTime]]| <<tag media>> | [[MediaViewTemplate]] | [[MediaEditTemplate]] |
|[[MediaSample - Windows]]| <<tag media>> | [[MediaViewTemplate]] | [[MediaEditTemplate]] |
|[[CDSample]]| <<tag CD>> | [[CDViewTemplate]] | [[CDEditTemplate]] |
|<<newTiddler label:"create new task..." title:SampleTask tag:task text:"Type some text and then press DONE to view the task controls">> | <<tag task>> | [[TaskViewTemplate]] | [[EditTemplate]] |
//(note: if these samples are not present in your document, please visit// http://www.TiddlyTools.com/ //to view these sample tiddlers on-line)//
<<<
!!!!!Revisions
<<<
2009.09.02 1.6.1 apply field-based template (if any) *before* tag-based template
2009.07.31 1.6.0 added support for using custom field value as prefix
2009.05.04 1.5.2 check for tiddler exist *after* title-as-prefix (allows shadow tiddlers to use custom templates)
2009.01.06 1.5.1 reversed logic so that title-as-prefix takes precedence over tag-matched prefix
2008.12.18 1.5.0 added handling for using tiddler //title// as prefix (e.g., {{{SomeTiddlerViewTemplate}}})
2008.08.29 1.4.1 corrected handling for tiddlers with no matching tagged template when non-default theme is in effect (e.g., use "MyTheme##ViewTemplate").
2008.05.15 1.4.0 support use of *shadow* tagged templates (e.g., [[DiscussionViewTemplate]] created by [[DiscussionPlugin]])
2008.05.10 1.3.0 corrected handling for determining core template when using theme with sections
2008.05.01 1.2.5 added support for tagged templates stored as sections in a theme
2008.04.01 1.2.0 added support for using systemTheme section-based template definitions (requested by Phil Hawksworth)
2008.01.22 [*.*.*] plugin size reduction - documentation moved to [[TaggedTemplateTweakInfo]]
2007.06.23 1.1.0 re-written to use automatic 'tag prefix' search instead of hard coded check for each tag. Allows new custom tags to be used without requiring code changes to this plugin.
2007.06.11 1.0.0 initial release
<<<
/***
|Name|TiddlerTweakerPlugin|
|Source|http://www.TiddlyTools.com/#TiddlerTweakerPlugin|
|Version|2.4.5|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|select multiple tiddlers and modify author, created, modified and/or tag values|
~TiddlerTweaker is a 'power tool' for TiddlyWiki authors. Select multiple tiddlers from a listbox and 'bulk modify' the creator, author, created, modified and/or tag values of those tiddlers using a compact set of form fields. The values you enter into the fields simultaneously overwrite the existing values in all tiddlers you have selected.
!!!!!Usage
<<<
{{{<<tiddlerTweaker>>}}}
{{smallform{<<tiddlerTweaker>>}}}
By default, any tags you enter into the TiddlerTweaker will //replace// the existing tags in all the tiddlers you have selected. However, you can also use TiddlerTweaker to quickly filter specified tags from the selected tiddlers, while leaving any other tags assigned to those tiddlers unchanged:
>Any tag preceded by a '+' (plus) or '-' (minus), will be added or removed from the existing tags //instead of replacing the entire tag definition// of each tiddler (e.g., enter '-excludeLists' to remove that tag from all selected tiddlers. When using this syntax, care should be taken to ensure that //every// tag is preceded by '+' or '-', to avoid inadvertently overwriting any other existing tags on the selected tiddlers. (note: the '+' or '-' prefix on each tag value is NOT part of the tag value, and is only used by TiddlerTweaker to control how that tag value is processed)
Important Notes:
* TiddlerTweaker is a 'power user' tool that can make changes to many tiddlers at once. ''You should always have a recent backup of your document (or 'save changes' just *before* tweaking the tiddlers), just in case you accidentally 'shoot yourself in the foot'.''
* The date and author information on any tiddlers you tweak will ONLY be updated if the corresponding checkboxes have been selected. As a general rule, after using TiddlerTweaker, always ''//remember to save your document//'' when you are done, even though the tiddler timeline tab may not show any recently modified tiddlers.
* Selecting and updating all tiddlers in a document can take a while. Your browser may warn about an 'unresponsive script'. Usually, if you allow it to continue, it should complete the processing... eventually. Nonetheless, be sure to save your work before you begin tweaking lots of tiddlers, just in case something does get stuck.
<<<
!!!!!Revisions
<<<
2011.01.21 2.4.5 auto-selection: use "-" for untagged tiddlers. Also, added 'opened', 'invert'
2009.09.15 2.4.4 added 'edit' button. moved html definition to separate section
2009.09.13 2.4.3 in settiddlers(), convert backslashed chars (\n\b\s\t) in replacement text
2009.06.26 2.4.2 only add brackets around tags containing spaces
2009.06.22 2.4.1 in setFields(), add brackets around all tags shown tweaker edit field
2009.03.30 2.4.0 added 'sort by modifier'
2009.01.22 2.3.0 added support for text pattern find/replace
2008.10.27 2.2.3 in setTiddlers(), fixed Safari bug by replacing static Array.concat(...) with new Array().concat(...)
2008.09.07 2.2.2 added removeCookie() function for compatibility with [[CookieManagerPlugin]]
2008.05.12 2.2.1 replace built-in backstage tweak task with tiddler tweaker control panel (moved from BackstageTweaks)
2008.01.13 2.2.0 added 'auto-selection' links: all, changed, tags, title, text
2007.12.26 2.1.0 added support for managing 'creator' custom field (see [[CoreTweaks]])
2007.11.01 2.0.3 added config.options.txtTweakerSortBy for cookie-based persistence of list display order preference setting.
2007.09.28 2.0.2 in settiddlers() and deltiddlers(), added suspend/resume notification handling (improves performance when operating on multiple tiddlers)
2007.08.03 2.0.1 added shadow definition for [[TiddlerTweaker]] tiddler for use as parameter references with {{{<<tiddler>>, <<slider>> or <<tabs>>}}} macros.
2007.08.03 2.0.0 converted from inline script
2006.01.01 1.0.0 initial release
<<<
!!!!!Code
***/
//{{{
version.extensions.TiddlerTweakerPlugin= {major: 2, minor: 4, revision: 5, date: new Date(2011,1,21)};
// shadow tiddler
config.shadowTiddlers.TiddlerTweaker='<<tiddlerTweaker>>';
// defaults
if (config.options.txtTweakerSortBy==undefined) config.options.txtTweakerSortBy='modified';
// backstage task
if (config.tasks) { // for TW2.2b3 or above
config.tasks.tweak.tooltip='review/modify tiddler internals: dates, authors, tags, etc.';
config.tasks.tweak.content='{{smallform small groupbox{<<tiddlerTweaker>>}}}';
}
// if removeCookie() function is not defined by TW core, define it here.
if (window.removeCookie===undefined) {
window.removeCookie=function(name) {
document.cookie = name+'=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;';
}
}
config.macros.tiddlerTweaker = {
handler: function(place,macroName,params,wikifier,paramString,tiddler) {
var span=createTiddlyElement(place,'span');
span.innerHTML=store.getTiddlerText('TiddlerTweakerPlugin##html');
this.init(span.getElementsByTagName('form')[0],config.options.txtTweakerSortBy);
},
init: function(f,sortby) { // set form controls
if (!f) return; // form might not be rendered yet...
while (f.list.options[0]) f.list.options[0]=null; // empty the list
var tids=store.getTiddlers(sortby);
if (sortby=='size') // descending order
tids.sort(function(a,b) {return a.text.length > b.text.length ? -1 : (a.text.length == b.text.length ? 0 : +1);});
var who='';
for (i=0; i<tids.length; i++) { var t=tids[i];
var label=t.title; var value=t.title;
switch (sortby) {
case 'modified':
case 'created':
var t=tids[tids.length-i-1]; // reverse order
var when=t[sortby].formatString('YY.0MM.0DD 0hh:0mm ');
label=when+t.title;
value=t.title;
break;
case 'size':
label='['+t.text.length+'] '+label;
break;
case 'modifier':
case 'creator':
if (who!=t[sortby]) {
who=t[sortby];
f.list.options[f.list.length]=new Option('by '+who+':','',false,false);
}
label='\xa0\xa0\xa0'+label; // indent
break;
}
f.list.options[f.list.length]=new Option(label,value,false,false);
}
f.title.value=f.who.value=f.creator.value=f.tags.value='';
f.cm.value=f.cd.value=f.cy.value=f.ch.value=f.cn.value='';
f.mm.value=f.md.value=f.my.value=f.mh.value=f.mn.value='';
f.stats.disabled=f.set.disabled=f.del.disabled=f.edit.disabled=f.display.disabled=true;
f.settitle.disabled=false;
config.options.txtTweakerSortBy=sortby;
f.sortby.value=sortby; // sync droplist
if (sortby!='modified') saveOptionCookie('txtTweakerSortBy');
else removeCookie('txtTweakerSortBy');
},
enablefields: function(here) { // enables/disables inputs based on #items selected
var f=here.form; var list=f.list;
var c=0; for (i=0;i<list.length;i++) if (list.options[i].selected) c++;
if (c>1) f.title.disabled=true;
if (c>1) f.settitle.checked=false;
f.set.disabled=(c==0);
f.del.disabled=(c==0);
f.edit.disabled=(c==0);
f.display.disabled=(c==0);
f.settitle.disabled=(c>1);
f.stats.disabled=(c==0);
var msg=(c==0)?'select tiddlers':(c+' tiddler'+(c!=1?'s':'')+' selected');
here.previousSibling.firstChild.firstChild.nextSibling.innerHTML=msg;
if (c) clearMessage(); else displayMessage('no tiddlers selected');
},
setfields: function(here) { // set fields from first selected tiddler
var f=here.form;
if (!here.value.length) {
f.title.value=f.who.value=f.creator.value=f.tags.value='';
f.cm.value=f.cd.value=f.cy.value=f.ch.value=f.cn.value='';
f.mm.value=f.md.value=f.my.value=f.mh.value=f.mn.value='';
return;
}
var tid=store.getTiddler(here.value); if (!tid) return;
f.title.value=tid.title;
f.who.value=tid.modifier;
f.creator.value=tid.fields['creator']||''; // custom field - might not exist
f.tags.value=tid.tags.map(function(t){return String.encodeTiddlyLink(t)}).join(' ');
var c=tid.created; var m=tid.modified;
f.cm.value=c.getMonth()+1;
f.cd.value=c.getDate();
f.cy.value=c.getFullYear();
f.ch.value=c.getHours();
f.cn.value=c.getMinutes();
f.mm.value=m.getMonth()+1;
f.md.value=m.getDate();
f.my.value=m.getFullYear();
f.mh.value=m.getHours();
f.mn.value=m.getMinutes();
},
selecttiddlers: function(here,callback) {
var f=here; while (f&&f.nodeName.toLowerCase()!='form')f=f.parentNode;
for (var t=f.list.options.length-1; t>=0; t--)
f.list.options[t].selected=callback(f.list.options[t]);
config.macros.tiddlerTweaker.enablefields(f.list);
return false;
},
settiddlers: function(here) {
var f=here.form; var list=f.list;
var tids=[];
for (i=0;i<list.length;i++) if (list.options[i].selected) tids.push(list.options[i].value);
if (!tids.length) { alert('please select at least one tiddler'); return; }
var cdate=new Date(f.cy.value,f.cm.value-1,f.cd.value,f.ch.value,f.cn.value);
var mdate=new Date(f.my.value,f.mm.value-1,f.md.value,f.mh.value,f.mn.value);
if (tids.length>1 && !confirm('Are you sure you want to update these tiddlers:\n\n'+tids.join(', '))) return;
store.suspendNotifications();
for (t=0;t<tids.length;t++) {
var tid=store.getTiddler(tids[t]); if (!tid) continue;
var title=!f.settitle.checked?tid.title:f.title.value;
var who=!f.setwho.checked?tid.modifier:f.who.value;
var text=tid.text;
if (f.replacetext.checked) {
var r=f.replacement.value.replace(/\\t/mg,'\t').unescapeLineBreaks();
text=text.replace(new RegExp(f.pattern.value,'mg'),r);
}
var tags=tid.tags;
if (f.settags.checked) {
var intags=f.tags.value.readBracketedList();
var addtags=[]; var deltags=[]; var reptags=[];
for (i=0;i<intags.length;i++) {
if (intags[i].substr(0,1)=='+')
addtags.push(intags[i].substr(1));
else if (intags[i].substr(0,1)=='-')
deltags.push(intags[i].substr(1));
else
reptags.push(intags[i]);
}
if (reptags.length)
tags=reptags;
if (addtags.length)
tags=new Array().concat(tags,addtags);
if (deltags.length)
for (i=0;i<deltags.length;i++)
{ var pos=tags.indexOf(deltags[i]); if (pos!=-1) tags.splice(pos,1); }
}
if (!f.setcdate.checked) cdate=tid.created;
if (!f.setmdate.checked) mdate=tid.modified;
store.saveTiddler(tid.title,title,text,who,mdate,tags,tid.fields);
if (f.setcreator.checked) store.setValue(tid.title,'creator',f.creator.value); // set creator
if (f.setcdate.checked) tid.assign(null,null,null,null,null,cdate); // set create date
}
store.resumeNotifications();
this.init(f,f.sortby.value);
},
displaytiddlers: function(here,edit) {
var f=here.form; var list=f.list;
var tids=[];
for (i=0; i<list.length;i++) if (list.options[i].selected) tids.push(list.options[i].value);
if (!tids.length) { alert('please select at least one tiddler'); return; }
story.displayTiddlers(story.findContainingTiddler(f),tids,edit?DEFAULT_EDIT_TEMPLATE:null);
},
deltiddlers: function(here) {
var f=here.form; var list=f.list;
var tids=[];
for (i=0;i<list.length;i++) if (list.options[i].selected) tids.push(list.options[i].value);
if (!tids.length) { alert('please select at least one tiddler'); return; }
if (!confirm('Are you sure you want to delete these tiddlers:\n\n'+tids.join(', '))) return;
store.suspendNotifications();
for (t=0;t<tids.length;t++) {
var tid=store.getTiddler(tids[t]); if (!tid) continue;
if (tid.tags.contains('systemConfig')) {
var msg=tid.title+' is tagged with systemConfig.'
+'\n\nRemoving this tiddler may cause unexpected results. Are you sure?';
if (!confirm(msg)) continue;
}
store.removeTiddler(tid.title);
story.closeTiddler(tid.title);
}
store.resumeNotifications();
this.init(f,f.sortby.value);
},
stats: function(here) {
var f=here.form; var list=f.list; var tids=[]; var out=''; var tot=0;
var target=f.nextSibling;
for (i=0;i<list.length;i++) if (list.options[i].selected) tids.push(list.options[i].value);
if (!tids.length) { alert('please select at least one tiddler'); return; }
for (t=0;t<tids.length;t++) {
var tid=store.getTiddler(tids[t]); if (!tid) continue;
out+='[['+tid.title+']] '+tid.text.length+'\n'; tot+=tid.text.length;
}
var avg=tot/tids.length;
out=tot+' bytes in '+tids.length+' selected tiddlers ('+avg+' bytes/tiddler)\n<<<\n'+out+'<<<\n';
removeChildren(target);
target.innerHTML="<hr><font size=-2><a href='javascript:;' style='float:right' "
+"onclick='this.parentNode.parentNode.style.display=\"none\"'>close</a></font>";
wikify(out,target);
target.style.display='block';
}
};
//}}}
/***
//{{{
!html
<style>
.tiddlerTweaker table,
.tiddlerTweaker table tr,
.tiddlerTweaker table td
{ padding:0;margin:0;border:0;white-space:nowrap; }
</style><form class='tiddlerTweaker'><!--
--><table style="width:100%"><tr valign="top"><!--
--><td style="text-align:center;width:99%;"><!--
--><font size=-2><div style="text-align:left;"><span style="float:right"><!--
--> <a href="javascript:;"
title="select all tiddlers"
onclick="return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
return opt.value.length;
});">all</a><!--
--> <a href="javascript:;"
title="select tiddlers currently displayed in the story column"
onclick="return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
return story.getTiddler(opt.value);
});">opened</a><!--
--> <a href="javascript:;"
title="select tiddlers that are new/changed since the last file save"
onclick="var lastmod=new Date(document.lastModified);
return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
var tid=store.getTiddler(opt.value);
return tid&&tid.modified>lastmod;
});
">changed</a><!--
--> <a href="javascript:;"
title="select tiddlers with at least one matching tag"
onclick="var t=prompt('Enter space-separated tags (match one or more). Use \x22-\x22 to match untagged tiddlers');
if (!t||!t.length) return false;
var tags=t.readBracketedList();
return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
var tid=store.getTiddler(opt.value);
return tid&&tags[0]=='-'?!tid.tags.length:tid.tags.containsAny(tags);
});
">tags</a><!--
--> <a href="javascript:;"
title="select tiddlers whose titles include matching text"
onclick="var t=prompt('Enter a title (or portion of a title) to match');
if (!t||!t.length) return false;
return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
return opt.value.indexOf(t)!=-1;
});
">titles</a><!--
--> <a href="javascript:;"
title="select tiddlers containing matching text"
onclick="var t=prompt('Enter tiddler text (content) to match');
if (!t||!t.length) return false;
return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
var tt=store.getTiddlerText(opt.value,'');
return tt.indexOf(t)!=-1;
});
">text</a><!--
--> <a href="javascript:;"
title="reverse selection of all list items"
onclick="return config.macros.tiddlerTweaker.selecttiddlers(this,function(opt){
return !opt.selected;
});">invert</a><!--
--></span><span>select tiddlers</span><!--
--></div><!--
--></font><select multiple name=list size="11" style="width:99.99%"
title="use click, shift-click and/or ctrl-click to select multiple tiddler titles"
onclick="config.macros.tiddlerTweaker.enablefields(this)"
onchange="config.macros.tiddlerTweaker.setfields(this)"><!--
--></select><br><!--
-->show<input type=text size=1 value="11"
onchange="this.form.list.size=this.value; this.form.list.multiple=(this.value>1);"><!--
-->by<!--
--><select name=sortby size=1
onchange="config.macros.tiddlerTweaker.init(this.form,this.value)"><!--
--><option value="title">title</option><!--
--><option value="size">size</option><!--
--><option value="modified">modified</option><!--
--><option value="created">created</option><!--
--><option value="modifier">modifier</option><!--
--></select><!--
--><input type="button" value="refresh"
onclick="config.macros.tiddlerTweaker.init(this.form,this.form.sortby.value)"<!--
--> <input type="button" name="stats" disabled value="totals..."
onclick="config.macros.tiddlerTweaker.stats(this)"><!--
--></td><td style="width:1%"><!--
--><div style="text-align:left"><font size=-2> modify values</font></div><!--
--><table style="width:100%;"><tr><!--
--><td style="padding:1px"><!--
--><input type=checkbox name=settitle unchecked
title="allow changes to tiddler title (rename tiddler)"
onclick="this.form.title.disabled=!this.checked">title<!--
--></td><td style="padding:1px"><!--
--><input type=text name=title size=35 style="width:98%" disabled><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=setcreator unchecked
title="allow changes to tiddler creator"
onclick="this.form.creator.disabled=!this.checked">created by<!--
--></td><td style="padding:1px;"><!--
--><input type=text name=creator size=35 style="width:98%" disabled><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=setwho unchecked
title="allow changes to tiddler author"
onclick="this.form.who.disabled=!this.checked">modified by<!--
--></td><td style="padding:1px"><!--
--><input type=text name=who size=35 style="width:98%" disabled><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=setcdate unchecked
title="allow changes to created date"
onclick="var f=this.form;
f.cm.disabled=f.cd.disabled=f.cy.disabled=f.ch.disabled=f.cn.disabled=!this.checked"><!--
-->created on<!--
--></td><td style="padding:1px"><!--
--><input type=text name=cm size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> / <input type=text name=cd size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> / <input type=text name=cy size=4 style="width:3em;padding:0;text-align:center" disabled><!--
--> at <input type=text name=ch size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> : <input type=text name=cn size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=setmdate unchecked
title="allow changes to modified date"
onclick="var f=this.form;
f.mm.disabled=f.md.disabled=f.my.disabled=f.mh.disabled=f.mn.disabled=!this.checked"><!--
-->modified on<!--
--></td><td style="padding:1px"><!--
--><input type=text name=mm size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> / <input type=text name=md size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> / <input type=text name=my size=4 style="width:3em;padding:0;text-align:center" disabled><!--
--> at <input type=text name=mh size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--> : <input type=text name=mn size=2 style="width:2em;padding:0;text-align:center" disabled><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=replacetext unchecked
title="find/replace matching text"
onclick="this.form.pattern.disabled=this.form.replacement.disabled=!this.checked">replace text<!--
--></td><td style="padding:1px"><!--
--><input type=text name=pattern size=15 value="" style="width:40%" disabled
title="enter TEXT PATTERN (regular expression)"> with<!--
--><input type=text name=replacement size=15 value="" style="width:40%" disabled
title="enter REPLACEMENT TEXT"><!--
--></td></tr><tr><td style="padding:1px"><!--
--><input type=checkbox name=settags checked
title="allow changes to tiddler tags"
onclick="this.form.tags.disabled=!this.checked">tags<!--
--></td><td style="padding:1px"><!--
--><input type=text name=tags size=35 value="" style="width:98%"
title="enter new tags or use '+tag' and '-tag' to add/remove tags from existing tags"><!--
--></td></tr></table><!--
--><div style="text-align:center"><!--
--><nobr><input type=button name=display disabled style="width:24%" value="display"
title="show selected tiddlers"
onclick="config.macros.tiddlerTweaker.displaytiddlers(this,false)"><!--
--> <input type=button name=edit disabled style="width:23%" value="edit"
title="edit selected tiddlers"
onclick="config.macros.tiddlerTweaker.displaytiddlers(this,true)"><!--
--> <input type=button name=del disabled style="width:24%" value="delete"
title="remove selected tiddlers"
onclick="config.macros.tiddlerTweaker.deltiddlers(this)"><!--
--> <input type=button name=set disabled style="width:24%" value="update"
title="update selected tiddlers"
onclick="config.macros.tiddlerTweaker.settiddlers(this)"></nobr><!--
--></div><!--
--></td></tr></table><!--
--></form><span style="display:none"><!--content replaced by tiddler "stats"--></span>
!end
//}}}
***/
/***
|''Name:''|TiddlersBarPlugin|
|''Description:''|A bar to switch between tiddlers through tabs (like browser tabs bar).|
|''Version:''|1.2.5|
|''Date:''|Jan 18,2008|
|''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='none' 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.
<<option txtPreviousTabKey>> previous tab access key.
<<option txtNextTabKey>> next tab access key.
!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.options.txtPreviousTabKey = config.options.txtPreviousTabKey ? config.options.txtPreviousTabKey : "";
config.options.txtNextTabKey = config.options.txtNextTabKey ? config.options.txtNextTabKey : "";
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,
previousKey : config.options.txtPreviousTabKey,
nextKey : config.options.txtNextTabKey,
tabsAnimationSource : null, //use document.getElementById("tiddlerDisplay") if you need animation on tab switching.
handler: function(place,macroName,params) {
var previous = null;
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);
if (previous && config.macros.tiddlersBar.previousKey) previous.setAttribute("accessKey",config.macros.tiddlersBar.nextKey);
previous = "active";
}
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);
if (previous=="active" && config.macros.tiddlersBar.nextKey) btn.setAttribute("accessKey",config.macros.tiddlersBar.previousKey);
previous=btn;
}
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(config.macros.tiddlersBar.tabsAnimationSource,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);
}
var coreRefreshPageTemplate = coreRefreshPageTemplate ? coreRefreshPageTemplate : refreshPageTemplate;
refreshPageTemplate = function(title) {
coreRefreshPageTemplate(title);
if (config.macros.tiddlersBar) config.macros.tiddlersBar.refresh(document.getElementById("tiddlersBar"));
}
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.refreshers.none = function(){return true;}
config.shadowTiddlers.PageTemplate=config.shadowTiddlers.PageTemplate.replace(/<div id='tiddlerDisplay'><\/div>/m,"<div id='tiddlersBar' refresh='none' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>\n<div id='tiddlerDisplay'></div>");
//}}}
!All Events
<<tiddler OpenTaggedTiddlers with: "Open All" event>>
<<timeline when filter:'[tag[event]]' >>
<html>
<form class="dynaform">
</form>
</html>
<script>
/*****************FUNCTIONS*********************************/
var addDateSort = function (arr) {
arr.sort(function (a, b) {
var valueA = new Date(a.fields.when);
var valueB = new Date(b.fields.when);
if (valueA < valueB) {
return -1;
} else if (valueA > valueB) {
return 1;
} else {
return 0;
}
});
};
function getMonthString(e){e=parseInt(e);if(isNaN(e)){return"NAN"}switch(e){case 1:e="January";return e;case 2:e="February";return e;case 3:e="March";return e;case 4:e="April";return e;case 5:e="May";return e;case 6:e="June";return e;case 7:e="July";return e;case 8:e="August";return e;case 9:e="September";return e;case 10:e="October";return e;case 11:e="November";return e;case 12:e="December";return e;default:e="unknown month";return e}}
function getFormattedDateString(dateString){
var arr= dateString.split(",");
arr[1]=getMonthString(arr[1]);
return arr.join(" ");
}
function getGroupDate(tiddler, _lastDate){
if (!_lastDate || _lastDate != getFormattedDateString(tiddler.fields.when)) {
_lastDate = getFormattedDateString(tiddler.fields.when);
return "* {{{"+(_lastDate?_lastDate:"no date")+"}}}\n";
}else{
return "";
}
}
function getAnyMatched( tids, tags){
var matched=[];
for(var i=0;i<tids.length;i++){
for(var j=0;j<tags.length;j++){
if(tids[i].isTagged(tags[j])){
matched.push(tids[i]);
break;
}
}
}
return matched;
}
function getAllMatched(tids, tags){
var matched=[];
for(var i=0;i<tids.length;i++){
var allMatch=true;
for(var j=0;j<tags.length;j++){
if(!tids[i].isTagged(tags[j])){ allMatch=false; }
}
if(allMatch){ matched.push(tids[i]); }
}
return matched;
}
/************Create THE FORM DYNAMICALLY****************************************************/
// get the form element
form=story.findContainingTiddler(place).getElementsByTagName("FORM")[0];
while (form.firstChild) {
form.removeChild(form.firstChild);
}
/***LABEL CIRCLES*******************/
var lbl=document.createElement("label");
lbl.innerHTML="Circles:"
form.appendChild(lbl);
/******CIRCLE CHECKBOXES****************************************/
var circleTids=store.getTaggedTiddlers("circle");
for (var i=0; i<circleTids.length; i++) { // for each tiddler
var chkbx= document.createElement("input");
chkbx.type="checkbox";
chkbx.name="circle";
chkbx.value=circleTids[i].title;
form.appendChild(chkbx);
var lbl=document.createElement("label");
lbl.innerHTML=circleTids[i].title;
form.appendChild(lbl);
}
var br=document.createElement('br');
form.appendChild(br);
/*********CHECK ALL CIRCLES BUTTON********************************************/
var checkAllButton1=document.createElement("button");
checkAllButton1.innerHTML="Toggle check all circles";
checkAllButton1.onclick=function(){
checkboxes = jQuery(".dynaform input[name='circle']");
if(this.checked){
this.checked=false;
jQuery(".dynaform input[name='circle']").prop("checked", false);
}else{
this.checked=true;
jQuery(".dynaform input[name='circle']").prop("checked", true);
}
return false;
}
checkAllButton1.checked=false;
form.appendChild(checkAllButton1);
var br=document.createElement('br');
form.appendChild(br);
/*******TYPE LABEL AND CHECKBOXES******************************************/
lbl=document.createElement("label");
lbl.innerHTML="Types:"
form.appendChild(lbl);
var typeTids=store.getTaggedTiddlers("type");
for (var i=0; i<typeTids.length; i++) { // for each tiddler
var chkbx= document.createElement("input");
chkbx.type="checkbox";
chkbx.name="type";
chkbx.value=typeTids[i].title;
form.appendChild(chkbx);
var lbl=document.createElement("label");
lbl.innerHTML=typeTids[i].title;
form.appendChild(lbl);
}
var br=document.createElement('br');
form.appendChild(br);
/*********CHECK ALL TYPES BUTTON********************************************/
var checkAllButton2=document.createElement("button");
checkAllButton2.innerHTML="Toggle check all types";
checkAllButton2.clicked=0;
checkAllButton2.onclick=function(){
if(this.checked){
this.checked=false;
jQuery(".dynaform input[name='type']").prop("checked", false);
}else{
this.checked=true;
jQuery(".dynaform input[name='type']").prop("checked", true);
}
return false;
}
checkAllButton2.checked = false;
form.appendChild(checkAllButton2);
var br=document.createElement('br');
form.appendChild(br);
/*******SELECTION MODE RADIO BUTTON****************************************************/
var radio1=document.createElement('input');
radio1.type="radio";
radio1.name="anyall";
radio1.value="any";
radio1.checked="true";
form.appendChild(radio1);
lbl=document.createElement("label");
lbl.innerHTML="Should match any of the selected types"
form.appendChild(lbl);
var radio2=document.createElement('input');
radio2.type="radio";
radio2.name="anyall"
radio2.value="all";
form.appendChild(radio2);
lbl=document.createElement("label");
lbl.innerHTML="Should match all of the selected types"
form.appendChild(lbl);
var br=document.createElement('br');
form.appendChild(br);
/**********SUBMIT BUTTON*************************************************/
var btn=document.createElement("input");
btn.type="button";
btn.value="Show";
/****************ATTACH ONCLICK FUNCTION TO FORM BUTTON******************************/
btn.onclick=function(){
var elem = form.elements;
var circleTags=[];
var typeTags=[];
var events=[];
var matchedEvents=[];
//check if at least one circle is selected
if(jQuery('.dynaform input[name="circle"]:checked').length<1){
alert("check at least one circle.");
return;
}
//check if at least one type is selected
if(jQuery('.dynaform input[name="type"]:checked').length<1){
alert("check at least one type.");
return;
}
//get the tags in two arrays
for(var i = 0; i < elem.length; i++)
{
if(elem[i].type=="checkbox" && elem[i].checked){
if(elem[i].name=="circle"){
circleTags.push(elem[i].value);
}else if(elem[i].name=="type"){
typeTags.push(elem[i].value);
}
}
}
//get the event tiddler objects which match any of the circle tags
for(var i=0;i<circleTags.length;i++){
tempArr=store.getTaggedTiddlers(circleTags[i]);
events=events.concat(tempArr);
}
//check radio buttons and call appropriate method
if(jQuery('.dynaform input[name="anyall"]:checked').val()=="any"){
matchedEvents=getAnyMatched(events, typeTags);
}else{
matchedEvents=getAllMatched(events, typeTags);
}
addDateSort(matchedEvents);
matchedEvents.sort();
matchedEvents.reverse();
var outStr="";
outStr=outStr+"!Timeline of events.\n!!!Tags:";
for(var i=0;i<typeTags.length;i++){
outStr=outStr + '<<tag "' + typeTags[i] + '" >>';
}
outStr=outStr+ " in Circles:"
for(var i=0;i<circleTags.length;i++){
outStr=outStr + '<<tag "' + circleTags[i] + '" >>';
}
outStr=outStr+"\n";
var lastDate="";
for(var i=0;i<matchedEvents.length;i++){
outStr=outStr + getGroupDate(matchedEvents[i], lastDate) + "**[[" + matchedEvents[i].title + "]]\n";
}
var siblings=jQuery(".dynaform").parent().siblings();
for(var i=0;i<siblings.length;i++){
jQuery(siblings[i]).remove();
}
wikify(outStr,place);
return false;
};
form.appendChild(btn);
</script>
/%
!info
|Name|ToggleRightSidebar|
|Source|http://www.TiddlyTools.com/#ToggleRightSidebar|
|Version|2.0.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|transclusion|
|Description|show/hide right sidebar (SideBarOptions)|
Usage
<<<
{{{
<<tiddler ToggleRightSidebar>>
<<tiddler ToggleRightSidebar with: label tooltip>>
}}}
Try it: <<tiddler ToggleRightSidebar##show
with: {{config.options.chkShowRightSidebar?'â–º':'â—„'}}>>
<<<
Configuration:
<<<
copy/paste the following settings into a tiddler tagged with <<tag systemConfig>> and then modify the values to suit your preferences:
{{{
config.options.chkShowRightSidebar=true;
config.options.txtToggleRightSideBarLabelShow="â—„";
config.options.txtToggleRightSideBarLabelHide="â–º";
}}}
<<<
!end
!show
<<tiddler {{
var co=config.options;
if (co.chkShowRightSidebar===undefined) co.chkShowRightSidebar=true;
var sb=document.getElementById('sidebar');
var da=document.getElementById('displayArea');
if (sb) {
sb.style.display=co.chkShowRightSidebar?'block':'none';
da.style.marginRight=co.chkShowRightSidebar?'':'1em';
}
'';}}>><html><nowiki><a href='javascript:;' title="$2"
onmouseover="
this.href='javascript:void(eval(decodeURIComponent(%22(function(){try{('
+encodeURIComponent(encodeURIComponent(this.onclick))
+')()}catch(e){alert(e.description?e.description:e.toString())}})()%22)))';"
onclick="
var co=config.options;
var opt='chkShowRightSidebar';
var show=co[opt]=!co[opt];
var sb=document.getElementById('sidebar');
var da=document.getElementById('displayArea');
if (sb) {
sb.style.display=show?'block':'none';
da.style.marginRight=show?'':'1em';
}
saveOptionCookie(opt);
var labelShow=co.txtToggleRightSideBarLabelShow||'◄';
var labelHide=co.txtToggleRightSideBarLabelHide||'►';
if (this.innerHTML==labelShow||this.innerHTML==labelHide)
this.innerHTML=show?labelHide:labelShow;
this.title=(show?'hide':'show')+' right sidebar';
var sm=document.getElementById('storyMenu');
if (sm) config.refreshers.content(sm);
return false;
">$1</a></html>
!end
%/<<tiddler {{
var src='ToggleRightSidebar';
src+(tiddler&&tiddler.title==src?'##info':'##show');
}} with: {{
var co=config.options;
var labelShow=co.txtToggleRightSideBarLabelShow||'◄';
var labelHide=co.txtToggleRightSideBarLabelHide||'►';
'$1'!='$'+'1'?'$1':(co.chkShowRightSidebar?labelHide:labelShow);
}} {{
var tip=(config.options.chkShowRightSidebar?'hide':'show')+' right sidebar';
'$2'!='$'+'2'?'$2':tip;
}}>>
|~ViewToolbar|tagSearch closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|
|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{
// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'eventsnotebook';
// 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,{
'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"),
'TspotOptions':[
"tiddlyspot password:",
"<<option pasUploadPassword>>",
""
].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"),
'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")
});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 18/03/2013 23:52:56 | Shavinder | [[/|http://eventsnotebook.tiddlyspot.com/]] | [[store.cgi|http://eventsnotebook.tiddlyspot.com/store.cgi]] | . | [[index.html | http://eventsnotebook.tiddlyspot.com/index.html]] | . | ok |
| 18/03/2013 23:58:15 | Shavinder | [[/|http://eventsnotebook.tiddlyspot.com/]] | [[store.cgi|http://eventsnotebook.tiddlyspot.com/store.cgi]] | . | [[index.html | http://eventsnotebook.tiddlyspot.com/index.html]] | . |
| 19/03/2013 00:01:59 | Shavinder | [[/|http://eventsnotebook.tiddlyspot.com/]] | [[store.cgi|http://eventsnotebook.tiddlyspot.com/store.cgi]] | . | [[index.html | http://eventsnotebook.tiddlyspot.com/index.html]] | . | ok |
| 19/03/2013 00:08:06 | Shavinder | [[/|http://eventsnotebook.tiddlyspot.com/]] | [[store.cgi|http://eventsnotebook.tiddlyspot.com/store.cgi]] | . | [[index.html | http://eventsnotebook.tiddlyspot.com/index.html]] | . | ok |
| 19/03/2013 00:10:29 | Shavinder | [[/|http://eventsnotebook.tiddlyspot.com/]] | [[store.cgi|http://eventsnotebook.tiddlyspot.com/store.cgi]] | . | [[index.html | http://eventsnotebook.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");
//}}}
/***
|Name|WikifyPlugin|
|Source|http://www.TiddlyTools.com/#WikifyPlugin|
|Documentation|http://www.TiddlyTools.com/#WikifyPluginInfo|
|Version|1.2.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|insert sections, slices, fields, literals, or computed values into a wiki-format output|
!!!!!Documentation
> see [[WikifyPluginInfo]]
!!!!!Revisions
<<<
2011.03.07 1.2.0 added handling in getFieldReference() for retrieving section values
|please see [[WikifyPluginInfo]] for additional revision details|
2007.06.22 1.0.0 initial release
<<<
!!!!!Code
***/
//{{{
version.extensions.WikifyPlugin= {major: 1, minor: 2, revision: 0, date: new Date(2011,3,7)};
config.macros.wikify={
handler: function(place,macroName,params,wikifier,paramString,tiddler) {
var fmt=params.shift();
var values=[];
var out="";
if (!fmt.match(/\%[0-9]/g) && params.length) // format has no markers, just join all params with spaces
out=fmt+" "+params.join(" ");
else { // format param has markers, get values and perform substitution
while (p=params.shift()) values.push(this.getFieldReference(place,p));
out=fmt.format(values);
}
if (macroName=="wikiCalc") out=eval(out).toString();
wikify(out.unescapeLineBreaks(),place,null,tiddler);
},
getFieldReference: function(place,p) {
if (typeof p != "string") return p; // literal non-string value... just return it...
var val=undefined;
var here=story.findContainingTiddler(place);
var current=here?here.getAttribute('tiddler'):'';
// SLICES: "::slicename" OR "here::slicename" OR "tiddlername::slicename"
var parts=p.split(config.textPrimitives.sliceSeparator);
var tid=parts[0]; var slice=parts[1];
if (slice) { // slice reference
if (!tid || !tid.length || tid=="here") tid=current;
var val=store.getTiddlerSlice(tid,slice);
}
// SECTIONS: "##sectionname" OR "here##sectionname" OR "tiddlername##sectionname"
if (!slice) {
var parts=p.split(config.textPrimitives.sectionSeparator);
var tid=parts[0]; var section=parts[1];
if (section) {
if (!tid || !tid.length || tid=="here") tid=current;
var val=store.getTiddlerText(tid+config.textPrimitives.sectionSeparator+section);
}
}
// FIELDS: "fieldname" OR "fieldname@tiddlername"
if (!slice && !section) {
var parts=p.split("@");
var field=parts[0]; var tid=parts[1];
if (!tid || !tid.length || tid=="here") tid=current;
var val=store.getValue(tid,field);
}
// not a slice, section or field, or value not found... return value unchanged
return val===undefined?p:val;
}
}
//}}}
//{{{
// define alternative macroName for triggering pre-rendering call to eval()
config.macros.wikiCalc=config.macros.wikify;
//}}}
/***
|Name|WikifyPlugin|
|Source|http://www.TiddlyTools.com/#WikifyPlugin|
|Documentation|http://www.TiddlyTools.com/#WikifyPluginInfo|
|Version|1.2.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|documentation|
|Description|documentation for WikifyPlugin|
The {{{<<wikify>>}}} macro retrieves values from tiddler slices, sections, or fields and then inserts those values into wiki-formatted output. The {{{<<wikiCalc>>}}} macro performs the same processing as {{{<<wikify>>}}} and, in addition, passes the assembled text content through javascript's {{{eval()}}} function before rendering the results. This allows you to, for example, construct and compute mathematical expressions that use input values extracted from tiddler fields or slices.
!!!!!Usage
<<<
{{{
<<wikify "format" value value value value ...>>
<<wikiCalc "format" value value value value ...>>
}}}
* ''format'' specifies the output format of the wiki-syntax content (or javascript expression, if using {{{<<wikiCalc>>}}}). Use //substitution markers// "%0" through "%9" to insert each value parameter into the formatted content, replacing its corresponding marker. If the ''format'' is blank (or does //not// contain any substitution markers), then all values are simply joined together (with spaces) for output. If {{{<<wikiCalc>>}}} is used, the formatted output is evaluated as a javascript expression before rendering.
* ''value'' parameters (space-separated), specified using any of:
** slices:<br>''::slicename'' or ''tiddlername::slicename'' or ''here::slicename''
** sections:<br>''##sectionname'' or ''tiddlername##sectionname'' or ''here##sectionname''
** fields:<br>''fieldname'' or ''fieldname@tiddlername'' or ''fieldname@here''
** evaluated javascript:<br>''"""{{...}}"""''
** literal text:<br>''"..."''
Note: if a slice/section/field reference omits the tiddlername (or uses the special keyword, ''here''), the current tiddler is implied.
<<<
!!!!!Examples
<<<
{{{
<<wikify [[This tiddler is: %0 using %1 bytes (last author: %2)]] title {{tiddler.text.length}} modifier>>
<<wikify [[The source URL for this plugin is: %0]] 'here::Source'>>
<<wikify [[The tiddler has been changed %0 times]] changecount@here>>
<<wikify [[The Primary Mid color is: @@background:%0;%0@@]] 'ColorPalette::PrimaryMid'>>
<<wikify [[This current user is: %0]] {{config.options.txtUserName}}>>
}}}
<<wikify [[This tiddler is: %0 using %1 bytes (last author: %2)]] title {{tiddler.text.length}} modifier>>
<<wikify [[The source URL for this plugin is: %0]] 'here::Source'>>
<<wikify [[The tiddler has been changed %0 times]] changecount@here>>
<<wikify [[The Primary Mid color is: @@background:%0;%0@@]] 'ColorPalette::PrimaryMid'>>
<<wikify [[This current user is: %0]] {{config.options.txtUserName}}>>
<<<
!!!!!Revisions
<<<
2011.03.07 1.2.0 added handling in getFieldReference() for retrieving section values and eliminated ~SiteSlices, ~SiteFields and 'checked' (fieldname) fallbacks.
2009.03.29 1.1.4 in handler(), pass 'tiddler' value to wikify() to fix macro errors in rendered content
2009.03.26 1.1.3 unescape output before wikify so that \n can be used in formatting string
2008.11.16 1.1.2 in getFieldReference(), if not a field/slice reference (or field/slice is not found), return string input unchanged instead of returning a blank string.
2008.03.08 1.1.1 size reduction: documentation moved to [[WikifyPluginInfo]]
2008.03.07 1.1.0 added {{{<<wikicalc>>}}} variant for evaluating assembled output as javascript before rendering the result
2007.11.11 1.0.1 in handler(), fixed problem where a trailing space was created when no substitution markers were present in the format param.
2007.06.22 1.0.0 initial release
<<<
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div macro='annotations'></div>
<table>
<tr><td>What:</td><td><span class='editor' macro='edit title'></span></td></tr>
<tr><td>When:</td><td><span class='editor' macro='edit when'><em>yyyy,mm,dd</em></td></tr>
<tr><td>Where:</td><td><span class='editor' macro='edit where'></span></td></tr>
<tr><td>Why:</td><td><span class='editor' macro='edit why 5'></span></td></tr>
<tr><td>Who:</td><td><span class='editor' macro='edit who'></span></td></tr>
<tr><td>How:</td><td><span class='editor' macro='edit how 5'></span></td></tr>
</table>
<div style="display:none" class='editor' macro='edit tags'></div>
<span macro='setUserName'></span>
<!--}}}-->
<!--{{{-->
<div class='toolbar' role='navigation' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<table>
<tr><td>What:</td><td><span class='viewer' macro='view title'></span></td></tr>
<tr><td>When:</td><td><span class='viewer' macro='view when'></span></td></tr>
<tr><td>Where:</td><td><span class='viewer' macro='view where'></span></td></tr>
<tr><td>Why:</td><td><span class='viewer' macro='view why'></span></td></tr>
<tr><td>Who:</td><td><span class='viewer' macro='view who wikified'></span></td></tr>
<tr><td>How:</td><td><span class='viewer' macro='view how'></span></td></tr>
</table>
<div class='tagClear'></div>
<!--}}}-->
//{{{
//TAGSEARCH TOOLBAR OPTIONS
config.macros.tagsearch.cfg.toolbar="source:'TagSearchConfig##Tags' exclude:'' label:'tags ' tooltip:'Set tags' more:'TagSearchConfig##More' toolbar";
//OTHER STUFF
//shortcuts
var c=config,co=c.options,cc=c.commands,cm=c.macros,cmg=c.messages,cv=c.views;
co.chkAnimate=false;
co.chkAutoSave=true;
co.chkHttpReadOnly=false;//visitors can edit
co.chkSaveBackups=true;//backups in this folder
co.chkInsertTabs=true;//tab as tab when editing
co.txtBackupFolder='backup';//autosave when local
co.txtIncrementalSearchMin=2;
co.chkUploadLog=false;
co.chkShowRightSidebar=false;
readOnly=!co.chkAutoSave;
showBackstage=!readOnly;
cv.editor.tagChooser.text='tags...';
cv.editor.defaultText="";//no text for a new tiddler
cv.wikified.defaultText="";//no msg when no tiddler
cv.wikified.tag.labelTags="";
cv.wikified.tag.labelNoTags="";
cv.wikified.tag.openTag= "Open '%0'";
cv.wikified.tag.otherTags= "Others from '%0'";
merge(cm.toolbar,{moreLabel:'+',lessLabel:'-'});
merge(c.messages.backstage,{open:{text:''},close:{text:''}});
//see ViewTemplate
//language settings
c.glyphs.codes.star=["\u22C6","\u22C6"];
cc.syncing.text="sync";
cc.references.text="ref";
cc.permalink.text="url";
var show="Show an URL in the brower address bar that ";
cc.permalink.tooltip=show+"links to the currently displayed tiddler";
cm.permaview.prompt=show+"retrieves all the currently displayed tiddlers";
cm.permaview.label="permalink";
cm.list.missing.prompt="referenced without tiddler:\n";
cm.list.orphans.prompt="tiddlers without reference:\n";
cm.list.shadowed.prompt="default shadow tiddlers:\n";
cm.option.passwordCheckboxLabel="save on this computer";
cm.tagging.label="Tagging tiddlers...";
//rename buttons
config.macros.rB={};
config.macros.rB.handler = function(place,macroName,params,wikifier,paramString,tiddler){
if (place.lastChild.tagName!="BR"){
var nameId=params.shift().split("#");
var name=nameId[0];
var id=nameId[1];
var title=params[0];
elem=place.lastChild;
if (elem.tagName.toUpperCase()!="A") elem=elem.firstChild;
elem.firstChild.data = name;
if (id) elem.setAttribute('id',id);
if (title) elem.title = title;
}
}
// Create a button for a tag with a popup listing all the tiddlers that it tags
if(!config.quickOpenTag){
createTagButton_NEW=createTagButton;
createTagButton = function (place,tag,excludeTiddler,title,tooltip)
{
var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
addClass(btn,store.getTaggedTiddlers(tag).length>0?'hastags':'hasnotags');
btn.setAttribute("tag",tag);
if(excludeTiddler)
btn.setAttribute("tiddler",excludeTiddler);
return btn;
}
}
//}}}