Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Arcobacter butzleri","strain":"RM4018","location":true,"pathogenicity":"primary","Genome":"2341251","GC":"27","gram":"negative","option2":false,"option1":false,"option3":false,"option4":false,"option5":false,"option6":true}</data>
It is often found in foods, especially meat and it is pathogenic to humans.
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Actinomyces odontolyticus","strain":"ATCC17982","Genome":"2393758","Topology=text/":"","GC":"65","gram":"positive","pathogenicity":"opportunist","location":true,"option6":false,"option1":true,"option5":false}</data>
They are commonly found in the oral cavity but also are present in the distal gut in small amounts and are opportunistically pathogenic. When pathogenic they cause abscesses in the mouth and even sometimes in the lung, and have also been found in dental caries and in genital tract infections.
<html><img width="600" height="135" src="http://www.rtpi.org.uk/download/1715/Liverpool-LVP_UNI_LOGO_Pantone.jpg"/></html>
<html><img width="150" height="185" src="http://www.liv.ac.uk/international/images/south-korea-case-stu.JPG"/></html>
Hi, my name is Hong and I am a Final Year student at the University of Liverpool and this is my Honours School Project.
The title of the project is:
Development of wiki-based web-based information resources for microbial genomes with particular reference to recently sequenced genomes of gut commensals and probiotics.
This was designed to be an online information resource to aid anyone who was interested in research in the field and also for educational purposes, as a microbiology encyclopaedia to some extent. It was gruelling compiling all the data, especially since the gut microbiome is not clearly defined yet, with estimates being to only about 50% being detected, but I've found all the information that I can find and here it's presented. Hopefully you will find it useful, and feel free to contact me at <html><b>h.c.lee@student.liverpool.ac.uk</b></html> with any queries or if you would like to add or edit material.
At the moment, the virulence factor tiddlywiki has not been worked on yet, but information will be on it soon hopefully.
Hong
NCBI Genbank:
http://www.ncbi.nlm.nih.gov/
MicrobeWiki:
http://microbewiki.kenyon.edu/index.php/MicrobeWiki
Washington University of Medicine. Human Gut Microbiome Initiative:
http://genome.wustl.edu/hgm/HGM_frontpage.cgi
Royal Town Planning Institute:
http://www.rtpi.org.uk/
Indianapolis Marion County Public Library
http://www.imcpl.org/
Wikipedia
http://wikipedia.org/
abego Software
http://www.abego-software.de/
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Bdellovibrio bacteriovorus","strain":"HD100","Genome":"3782950","gram":"negative","location":true,"pathogenicity":"commensal","GC":"50","option2":false,"option3":false,"option4":false,"option5":true}</data>
This bacteria is purely commensal, not known to cause any disease. It is however pathogenic to other gram-negative bacteria by attaching to them and growing on them. This could be potentially useful in a probiotic form in the future and as a natural remedy for illnesses caused by bacterial infections in the gut. They are also known to be able to survive in most places.
<<formTiddler [[FormTemplateSpecies]]>>
<data>{"species":"Bifidobacterium adolescentis","strain":"ATCC 15703","Genome":"2089645","GC":"59","Topology=text/":"circular","gram":"positive","pathogenicity":"commensal","location":true,"option2":true,"option3":true,"option4":true}</data>
[img[http://upload.wikimedia.org/wikipedia/commons/3/35/Bifidobacterium_adolescentis_Gram.jpg]]
Ref: Img from Wikipedia, Author: Y tambe
B. adolescentis has shown efficacy in treating irritable bowel syndrome in many trials and has a lot of potential for future usage as a probiotic to treat IBS.
<<formTiddler [[FormTemplateSpecies]]>><data>{"location":true,"species":"Bacteroides capillosus","strain":"ATCC 29799","gram":"negative","pathogenicity":"unclassified","Genome":"n/a","GC":"n/a","option6":true}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Bacteroides distasonis","strain":"ATCC 8503","location":true,"gram":"negative","pathogenicity":"commensal","Genome":"4811379","GC":"45","option3":true,"option2":true,"option4":true}</data>
beta-lactamase producers; they are resistant to penicillin.
<<formTiddler [[FormTemplateSpecies]]>>
<data>{"species":"Bacteroides fragilis","strain":"YCH 46","Genome":"5277274","GC":"43","Topology=text/":"circular","gram":"negative","pathogenicity":"opportunist","location":true,"option2":true,"option3":true,"option4":true}</data>
It is very resistant to penicillin and can cause infections leading to diarrhoea.
[img[http://microbewiki.kenyon.edu/images/4/49/DennisKunkelMicroscopy%2CInc.jpg]]
Image copyright Dennis Kunkel Microscopy, Inc. of Bacteroides sp.
Image from microbewiki.kenyon.edu
<<formTiddler [[FormTemplateSpecies]]>>
<data>{"species":"Bifidobacterium longum","strain":"NCC2705","Genome":"2256640","GC":"60","Topology=text/":"circular","pathogenicity":"commensal","location":true,"gram":"positive","option2":true,"option3":true,"option4":true}</data>
Completely non-pathogenic and may potentially be a useful probiotic in controlling obesity, along with other bifidobacterium species.
[img[http://microbewiki.kenyon.edu/images/4/46/Bifidobacterium_longum.png]]
Bifidobacterium longum.Courtesy of Mark Schell, University of Georgia, Athens, GA
Img found on http://microbewiki.kenyon.edu/
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Bacteroides ovatus","strain":"ATCC 8483T","gram":"negative","location":true}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Bacteroides thetaiotaomicron","location":true,"gram":"negative","pathogenicity":"opportunist","strain":"VPI-5482","Genome":"6260361","GC":"42","option2":true,"option3":true,"option4":true}</data>
B. thetaiotaomicron helps to degrade plant polysaccharides, thus aiding digestion, but it can also be pathogenic when the conditions are suitable.
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Bacteroides uniformis","strain":"ATCC 8492","location":true,"gram":"negative","pathogenicity":"opportunist","Genome":"n/a","GC":"n/a"}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"strain":"ATCC 8482","location":true,"species":"Bacteroides","gram":"negative","pathogenicity":"commensal","Genome":"5163189","GC":"42"}</data>
/***
|''Name:''|BreadCrumbsPlugin|
|''Version:''|2.2.1 (05-July-2007)|
|''Author:''|AlanHecht|
|''Adapted By:''|[[Jack]]|
|''Type:''|Plugin|
!Description
This plugin creates an area at the top of the tiddler area that displays "breadcrumbs" of where you've been. This is especially useful for ~TWs using SinglePageMode by Eric Schulman.
!Usage
Just install the plugin and tag with systemConfig. Optionally position the following div in your PageTemplate to control the positioning of the breadcrumbs menu:
{{{
<div id='breadCrumbs'></div>
}}}
!Revision History
* Original by AlanHecht
* 2.0 Made 2.0.x compatible by [[Jack]]
* Made 2.0.10 compatible (onstart paramifier)
* Bugfix -> return false in onClickTiddlerLink()
* 2.2 Made 2.2.x compatible
!Code
***/
// // Use the following line to set the number of breadcrumbs to display before rotating them off the list.
//{{{
version.extensions.breadCrumbs = {major: 2, minor: 2, revision: 1, date: new Date("Jul 5, 2007")};
var crumbsToShow = 7;
var breadCrumbs = [];
onClickTiddlerLink_orig_breadCrumbs = onClickTiddlerLink;
onClickTiddlerLink = function(e){
onClickTiddlerLink_orig_breadCrumbs(e);
breadcrumbsAdd(e);
return false;
}
restart_orig_breadCrumbs = restart;
function restart() {
invokeParamifier(params,"onstart");
var defaultParams = store.getTiddlerText("DefaultTiddlers").parseParams("open",null,false);
invokeParamifier(defaultParams,"onstart");
breadCrumbs = [];
breadcrumbsRefresh();
window.scrollTo(0,0);
return false;
}
function breadcrumbsAdd(e) {
var uniqueCrumb = true;
var crumbIndex = 0;
if (!e) var e = window.event;
var target = resolveTarget(e);
var thisCrumb="[["+resolveTarget(e).getAttribute("tiddlyLink")+"]]";
var lastInactiveCrumb = breadCrumbs.length -(breadCrumbs.length < crumbsToShow ? breadCrumbs.length : crumbsToShow);
for(t=lastInactiveCrumb; t<breadCrumbs.length; t++)
if(breadCrumbs[t] == thisCrumb) {
uniqueCrumb = false;
crumbIndex = t+1;
}
if(uniqueCrumb)
breadCrumbs.push(thisCrumb);
else
breadCrumbs = breadCrumbs.slice(0,crumbIndex);
breadcrumbsRefresh();
}
function breadcrumbsRefresh() {
if (!document.getElementById("breadCrumbs")) {
// Create breadCrumbs div
var ca = document.createElement("div");
ca.id = "breadCrumbs";
ca.style.visibility= "hidden";
var targetArea = document.getElementById("tiddlerDisplay")||document.getElementById("storyDisplay");
targetArea.parentNode.insertBefore(ca,targetArea);
}
var crumbArea = document.getElementById("breadCrumbs");
crumbArea.style.visibility = "visible";
removeChildren(crumbArea);
createTiddlyButton(crumbArea,"Home",null,restart);
crumbArea.appendChild(document.createTextNode(" > "));
var crumbLine = "";
var crumbCount = breadCrumbs.length;
var firstCrumb = crumbCount -(crumbCount < crumbsToShow ? crumbCount : crumbsToShow);
for(t=firstCrumb; t<crumbCount; t++) {
if(t != firstCrumb)
crumbLine += " > ";
crumbLine += breadCrumbs[t];
}
wikify(crumbLine,crumbArea)
}
//}}}
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Clostridium acetobutylicum","strain":"ATCC 824","Genome":"3940880","Topology=text/":"circular","GC":"30","pathogenicity":"transient","gram":"positive","location":true}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Collinsella aerofaciens","strain":"ATCC 25986","Genome":"2439869","GC":"60","location":true,"gram":"positive","pathogenicity":"commensal"}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Coprococcus eutactus","strain":"ATCC 27759","location":true,"pathogenicity":"unclassified"}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Clostridium leptum","strain":"ATCC29065","location":true,"pathogenicity":"commensal","gram":"unclassified","Genome":"n/a","GC":"n/a"}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Clostridium perfringens","strain":"ATCC 13124","Genome":"3256683","GC":"28","Topology=text/":"circular","pathogenicity":"opportunist","gram":"positive","location":true}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Clostridium tetani","strain":"E88","Genome":"2799251","Topology=text/":"circular","GC":"28","gram":"positive","pathogenicity":"unclassified"}</data>
//============================================================================
//============================================================================
// DataTiddlerPlugin
//============================================================================
//============================================================================
// Ensure that the DataTiddler Plugin is only installed once.
//
if (!version.extensions.DataTiddlerPlugin) {
version.extensions.DataTiddlerPlugin = {
major: 1, minor: 0, revision: 6,
date: new Date(2006, 7, 26),
type: 'plugin',
source: "http://tiddlywiki.abego-software.de/#DataTiddlerPlugin"
};
// For backward compatibility with v1.2.x
//
if (!window.story) window.story=window;
if (!TiddlyWiki.prototype.getTiddler) {
TiddlyWiki.prototype.getTiddler = function(title) {
var t = this.tiddlers[title];
return (t !== undefined && t instanceof Tiddler) ? t : null;
};
}
//============================================================================
// DataTiddler Class
//============================================================================
// ---------------------------------------------------------------------------
// Configurations and constants
// ---------------------------------------------------------------------------
function DataTiddler() {
}
DataTiddler = {
// Function to stringify a JavaScript value, producing the text for the data section content.
// (Must match the implementation of DataTiddler.parse.)
//
stringify : null,
// Function to parse the text for the data section content, producing a JavaScript value.
// (Must match the implementation of DataTiddler.stringify.)
//
parse : null
};
// Ensure access for IE
window.DataTiddler = DataTiddler;
// ---------------------------------------------------------------------------
// Data Accessor and Mutator
// ---------------------------------------------------------------------------
// Returns the value of the given data field of the tiddler.
// When no such field is defined or its value is undefined
// the defaultValue is returned.
//
// @param tiddler either a tiddler name or a tiddler
//
DataTiddler.getData = function(tiddler, field, defaultValue) {
var t = (typeof tiddler == "string") ? store.getTiddler(tiddler) : tiddler;
if (!(t instanceof Tiddler)) {
throw "Tiddler expected. Got "+tiddler;
}
return DataTiddler.getTiddlerDataValue(t, field, defaultValue);
};
// Sets the value of the given data field of the tiddler to
// the value. When the value is equal to the defaultValue
// no value is set (and the field is removed)
//
// Changing data of a tiddler will not trigger notifications.
//
// @param tiddler either a tiddler name or a tiddler
//
DataTiddler.setData = function(tiddler, field, value, defaultValue) {
var t = (typeof tiddler == "string") ? store.getTiddler(tiddler) : tiddler;
if (!(t instanceof Tiddler)) {
throw "Tiddler expected. Got "+tiddler+ "("+t+")";
}
DataTiddler.setTiddlerDataValue(t, field, value, defaultValue);
};
// Returns the data object of the tiddler, with a property for every field.
//
// The properties of the returned data object may only be read and
// not be modified. To modify the data use DataTiddler.setData(...)
// or the corresponding Tiddler method.
//
// If no data section is defined a new (empty) object is returned.
//
// @param tiddler either a tiddler name or a Tiddler
//
DataTiddler.getDataObject = function(tiddler) {
var t = (typeof tiddler == "string") ? store.getTiddler(tiddler) : tiddler;
if (!(t instanceof Tiddler)) {
throw "Tiddler expected. Got "+tiddler;
}
return DataTiddler.getTiddlerDataObject(t);
};
// Returns the text of the content of the data section of the tiddler.
//
// When no data section is defined for the tiddler null is returned
//
// @param tiddler either a tiddler name or a Tiddler
// @return [may be null]
//
DataTiddler.getDataText = function(tiddler) {
var t = (typeof tiddler == "string") ? store.getTiddler(tiddler) : tiddler;
if (!(t instanceof Tiddler)) {
throw "Tiddler expected. Got "+tiddler;
}
return DataTiddler.readDataSectionText(t);
};
// ---------------------------------------------------------------------------
// Internal helper methods (must not be used by code from outside this plugin)
// ---------------------------------------------------------------------------
// Internal.
//
// The original JSONError is not very user friendly,
// especially it does not define a toString() method
// Therefore we extend it here.
//
DataTiddler.extendJSONError = function(ex) {
if (ex.name == 'JSONError') {
ex.toString = function() {
return ex.name + ": "+ex.message+" ("+ex.text+")";
};
}
return ex;
};
// Internal.
//
// @param t a Tiddler
//
DataTiddler.getTiddlerDataObject = function(t) {
if (t.dataObject === undefined) {
var data = DataTiddler.readData(t);
t.dataObject = (data) ? data : {};
}
return t.dataObject;
};
// Internal.
//
// @param tiddler a Tiddler
//
DataTiddler.getTiddlerDataValue = function(tiddler, field, defaultValue) {
var value = DataTiddler.getTiddlerDataObject(tiddler)[field];
return (value === undefined) ? defaultValue : value;
};
// Internal.
//
// @param tiddler a Tiddler
//
DataTiddler.setTiddlerDataValue = function(tiddler, field, value, defaultValue) {
var data = DataTiddler.getTiddlerDataObject(tiddler);
var oldValue = data[field];
if (value == defaultValue) {
if (oldValue !== undefined) {
delete data[field];
DataTiddler.save(tiddler);
}
return;
}
data[field] = value;
DataTiddler.save(tiddler);
};
// Internal.
//
// Reads the data section from the tiddler's content and returns its text
// (as a String).
//
// Returns null when no data is defined.
//
// @param tiddler a Tiddler
// @return [may be null]
//
DataTiddler.readDataSectionText = function(tiddler) {
var matches = DataTiddler.getDataTiddlerMatches(tiddler);
if (matches === null || !matches[2]) {
return null;
}
return matches[2];
};
// Internal.
//
// Reads the data section from the tiddler's content and returns it
// (as an internalized object).
//
// Returns null when no data is defined.
//
// @param tiddler a Tiddler
// @return [may be null]
//
DataTiddler.readData = function(tiddler) {
var text = DataTiddler.readDataSectionText(tiddler);
try {
return text ? DataTiddler.parse(text) : null;
} catch(ex) {
throw DataTiddler.extendJSONError(ex);
}
};
// Internal.
//
// Returns the serialized text of the data of the given tiddler, as it
// should be stored in the data section.
//
// @param tiddler a Tiddler
//
DataTiddler.getDataTextOfTiddler = function(tiddler) {
var data = DataTiddler.getTiddlerDataObject(tiddler);
return DataTiddler.stringify(data);
};
// Internal.
//
DataTiddler.indexOfNonEscapedText = function(s, subString, startIndex) {
var index = s.indexOf(subString, startIndex);
while ((index > 0) && (s[index-1] == '~')) {
index = s.indexOf(subString, index+1);
}
return index;
};
// Internal.
//
DataTiddler.getDataSectionInfo = function(text) {
// Special care must be taken to handle "<data>" and "</data>" texts inside
// a data section.
// Also take care not to use an escaped <data> (i.e. "~<data>") as the start
// of a data section. (Same for </data>)
// NOTE: we are explicitly searching for a data section that contains a JSON
// string, i.e. framed with braces. This way we are little bit more robust in
// case the tiddler contains unescaped texts "<data>" or "</data>". This must
// be changed when using a different stringifier.
var startTagText = "<data>{";
var endTagText = "}</data>";
var startPos = 0;
// Find the first not escaped "<data>".
var startDataTagIndex = DataTiddler.indexOfNonEscapedText(text, startTagText, 0);
if (startDataTagIndex < 0) {
return null;
}
// Find the *last* not escaped "</data>".
var endDataTagIndex = text.indexOf(endTagText, startDataTagIndex);
if (endDataTagIndex < 0) {
return null;
}
var nextEndDataTagIndex;
while ((nextEndDataTagIndex = text.indexOf(endTagText, endDataTagIndex+1)) >= 0) {
endDataTagIndex = nextEndDataTagIndex;
}
return {
prefixEnd: startDataTagIndex,
dataStart: startDataTagIndex+(startTagText.length)-1,
dataEnd: endDataTagIndex,
suffixStart: endDataTagIndex+(endTagText.length)
};
};
// Internal.
//
// Returns the "matches" of a content of a DataTiddler on the
// "data" regular expression. Return null when no data is defined
// in the tiddler content.
//
// Group 1: text before data section (prefix)
// Group 2: content of data section
// Group 3: text behind data section (suffix)
//
// @param tiddler a Tiddler
// @return [may be null] null when the tiddler contains no data section, otherwise see above.
//
DataTiddler.getDataTiddlerMatches = function(tiddler) {
var text = tiddler.text;
var info = DataTiddler.getDataSectionInfo(text);
if (!info) {
return null;
}
var prefix = text.substr(0,info.prefixEnd);
var data = text.substr(info.dataStart, info.dataEnd-info.dataStart+1);
var suffix = text.substr(info.suffixStart);
return [text, prefix, data, suffix];
};
// Internal.
//
// Saves the data in a <data> block of the given tiddler (as a minor change).
//
// The "chkAutoSave" and "chkForceMinorUpdate" options are respected.
// I.e. the TiddlyWiki *file* is only saved when AutoSave is on.
//
// Notifications are not send.
//
// This method should only be called when the data really has changed.
//
// @param tiddler
// the tiddler to be saved.
//
DataTiddler.save = function(tiddler) {
var matches = DataTiddler.getDataTiddlerMatches(tiddler);
var prefix;
var suffix;
if (matches === null) {
prefix = tiddler.text;
suffix = "";
} else {
prefix = matches[1];
suffix = matches[3];
}
var dataText = DataTiddler.getDataTextOfTiddler(tiddler);
var newText =
(dataText !== null)
? prefix + "<data>" + dataText + "</data>" + suffix
: prefix + suffix;
if (newText != tiddler.text) {
// make the change in the tiddlers text
// ... see DataTiddler.MyTiddlerChangedFunction
tiddler.isDataTiddlerChange = true;
// ... do the action change
tiddler.set(
tiddler.title,
newText,
config.options.txtUserName,
config.options.chkForceMinorUpdate? undefined : new Date(),
tiddler.tags);
// ... see DataTiddler.MyTiddlerChangedFunction
delete tiddler.isDataTiddlerChange;
// Mark the store as dirty.
store.dirty = true;
// AutoSave if option is selected
if(config.options.chkAutoSave) {
saveChanges();
}
}
};
// Internal.
//
DataTiddler.MyTiddlerChangedFunction = function() {
// Remove the data object from the tiddler when the tiddler is changed
// by code other than DataTiddler code.
//
// This is necessary since the data object is just a "cached version"
// of the data defined in the data section of the tiddler and the
// "external" change may have changed the content of the data section.
// Thus we are not sure if the data object reflects the data section
// contents.
//
// By deleting the data object we ensure that the data object is
// reconstructed the next time it is needed, with the data defined by
// the data section in the tiddler's text.
// To indicate that a change is a "DataTiddler change" a temporary
// property "isDataTiddlerChange" is added to the tiddler.
if (this.dataObject && !this.isDataTiddlerChange) {
delete this.dataObject;
}
// call the original code.
DataTiddler.originalTiddlerChangedFunction.apply(this, arguments);
};
//============================================================================
// Formatters
//============================================================================
// This formatter ensures that "~<data>" is rendered as "<data>". This is used to
// escape the "<data>" of a data section, just in case someone really wants to use
// "<data>" as a text in a tiddler and not start a data section.
//
// Same for </data>.
//
config.formatters.push( {
name: "data-escape",
match: "~<\\/?data>",
handler: function(w) {
w.outputText(w.output,w.matchStart + 1,w.nextMatch);
}
} );
// This formatter ensures that <data>...</data> sections are not rendered.
//
config.formatters.push( {
name: "data",
match: "<data>",
handler: function(w) {
var info = DataTiddler.getDataSectionInfo(w.source);
if (info && info.prefixEnd == w.matchStart) {
w.nextMatch = info.suffixStart;
} else {
w.outputText(w.output,w.matchStart,w.nextMatch);
}
}
} );
//============================================================================
// Tiddler Class Extension
//============================================================================
// "Hijack" the changed method ---------------------------------------------------
DataTiddler.originalTiddlerChangedFunction = Tiddler.prototype.changed;
Tiddler.prototype.changed = DataTiddler.MyTiddlerChangedFunction;
// Define accessor methods -------------------------------------------------------
// Returns the value of the given data field of the tiddler. When no such field
// is defined or its value is undefined the defaultValue is returned.
//
// When field is undefined (or null) the data object is returned. (See
// DataTiddler.getDataObject.)
//
// @param field [may be null, undefined]
// @param defaultValue [may be null, undefined]
// @return [may be null, undefined]
//
Tiddler.prototype.data = function(field, defaultValue) {
return (field)
? DataTiddler.getTiddlerDataValue(this, field, defaultValue)
: DataTiddler.getTiddlerDataObject(this);
};
// Sets the value of the given data field of the tiddler to the value. When the
// value is equal to the defaultValue no value is set (and the field is removed).
//
// @param value [may be null, undefined]
// @param defaultValue [may be null, undefined]
//
Tiddler.prototype.setData = function(field, value, defaultValue) {
DataTiddler.setTiddlerDataValue(this, field, value, defaultValue);
};
//============================================================================
// showData Macro
//============================================================================
config.macros.showData = {
// Standard Properties
label: "showData",
prompt: "Display the values stored in the data section of the tiddler"
};
config.macros.showData.handler = function(place,macroName,params) {
// --- Parsing ------------------------------------------
var i = 0; // index running over the params
// Parse the optional "JSON"
var showInJSONFormat = false;
if ((i < params.length) && params[i] == "JSON") {
i++;
showInJSONFormat = true;
}
var tiddlerName = story.findContainingTiddler(place).id.substr(7);
if (i < params.length) {
tiddlerName = params[i];
i++;
}
// --- Processing ------------------------------------------
try {
if (showInJSONFormat) {
this.renderDataInJSONFormat(place, tiddlerName);
} else {
this.renderDataAsTable(place, tiddlerName);
}
} catch (e) {
this.createErrorElement(place, e);
}
};
config.macros.showData.renderDataInJSONFormat = function(place,tiddlerName) {
var text = DataTiddler.getDataText(tiddlerName);
if (text) {
createTiddlyElement(place,"pre",null,null,text);
}
};
config.macros.showData.renderDataAsTable = function(place,tiddlerName) {
var text = "|!Name|!Value|\n";
var data = DataTiddler.getDataObject(tiddlerName);
if (data) {
for (var i in data) {
var value = data[i];
text += "|"+i+"|"+DataTiddler.stringify(value)+"|\n";
}
}
wikify(text, place);
};
// Internal.
//
// Creates an element that holds an error message
//
config.macros.showData.createErrorElement = function(place, exception) {
var message = (exception.description) ? exception.description : exception.toString();
return createTiddlyElement(place,"span",null,"showDataError","<<showData ...>>: "+message);
};
// ---------------------------------------------------------------------------
// Stylesheet Extensions (may be overridden by local StyleSheet)
// ---------------------------------------------------------------------------
//
setStylesheet(
".showDataError{color: #ffffff;background-color: #880000;}",
"showData");
} // of "install only once"
// Used Globals (for JSLint) ==============
// ... TiddlyWiki Core
/*global createTiddlyElement, saveChanges, store, story, wikify */
// ... DataTiddler
/*global DataTiddler */
// ... JSON
/*global JSON */
/***
!JSON Code, used to serialize the data
***/
/*
Copyright (c) 2005 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
The global object JSON contains two methods.
JSON.stringify(value) takes a JavaScript value and produces a JSON text.
The value must not be cyclical.
JSON.parse(text) takes a JSON text and produces a JavaScript value. It will
throw a 'JSONError' exception if there is an error.
*/
var JSON = {
copyright: '(c)2005 JSON.org',
license: 'http://www.crockford.com/JSON/license.html',
/*
Stringify a JavaScript value, producing a JSON text.
*/
stringify: function (v) {
var a = [];
/*
Emit a string.
*/
function e(s) {
a[a.length] = s;
}
/*
Convert a value.
*/
function g(x) {
var c, i, l, v;
switch (typeof x) {
case 'object':
if (x) {
if (x instanceof Array) {
e('[');
l = a.length;
for (i = 0; i < x.length; i += 1) {
v = x[i];
if (typeof v != 'undefined' &&
typeof v != 'function') {
if (l < a.length) {
e(',');
}
g(v);
}
}
e(']');
return;
} else if (typeof x.toString != 'undefined') {
e('{');
l = a.length;
for (i in x) {
v = x[i];
if (x.hasOwnProperty(i) &&
typeof v != 'undefined' &&
typeof v != 'function') {
if (l < a.length) {
e(',');
}
g(i);
e(':');
g(v);
}
}
return e('}');
}
}
e('null');
return;
case 'number':
e(isFinite(x) ? +x : 'null');
return;
case 'string':
l = x.length;
e('"');
for (i = 0; i < l; i += 1) {
c = x.charAt(i);
if (c >= ' ') {
if (c == '\\' || c == '"') {
e('\\');
}
e(c);
} else {
switch (c) {
case '\b':
e('\\b');
break;
case '\f':
e('\\f');
break;
case '\n':
e('\\n');
break;
case '\r':
e('\\r');
break;
case '\t':
e('\\t');
break;
default:
c = c.charCodeAt();
e('\\u00' + Math.floor(c / 16).toString(16) +
(c % 16).toString(16));
}
}
}
e('"');
return;
case 'boolean':
e(String(x));
return;
default:
e('null');
return;
}
}
g(v);
return a.join('');
},
/*
Parse a JSON text, producing a JavaScript value.
*/
parse: function (text) {
var p = /^\s*(([,:{}\[\]])|"(\\.|[^\x00-\x1f"\\])*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)\s*/,
token,
operator;
function error(m, t) {
throw {
name: 'JSONError',
message: m,
text: t || operator || token
};
}
function next(b) {
if (b && b != operator) {
error("Expected '" + b + "'");
}
if (text) {
var t = p.exec(text);
if (t) {
if (t[2]) {
token = null;
operator = t[2];
} else {
operator = null;
try {
token = eval(t[1]);
} catch (e) {
error("Bad token", t[1]);
}
}
text = text.substring(t[0].length);
} else {
error("Unrecognized token", text);
}
} else {
token = operator = undefined;
}
}
function val() {
var k, o;
switch (operator) {
case '{':
next('{');
o = {};
if (operator != '}') {
for (;;) {
if (operator || typeof token != 'string') {
error("Missing key");
}
k = token;
next();
next(':');
o[k] = val();
if (operator != ',') {
break;
}
next(',');
}
}
next('}');
return o;
case '[':
next('[');
o = [];
if (operator != ']') {
for (;;) {
o.push(val());
if (operator != ',') {
break;
}
next(',');
}
}
next(']');
return o;
default:
if (operator !== null) {
error("Missing value");
}
k = token;
next();
return k;
}
}
next();
return val();
}
};
/***
!Setup the data serialization
***/
DataTiddler.format = "JSON";
DataTiddler.stringify = JSON.stringify;
DataTiddler.parse = JSON.parse;
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Escherichia coli","location":true,"gram":"negative","pathogenicity":"opportunist"}</data>
//============================================================================
//============================================================================
// ForEachTiddlerPlugin
//============================================================================
//============================================================================
// Only install once
if (!version.extensions.ForEachTiddlerPlugin) {
if (!window.abego) window.abego = {};
version.extensions.ForEachTiddlerPlugin = {
major: 1, minor: 0, revision: 8,
date: new Date(2007,3,12),
source: "http://tiddlywiki.abego-software.de/#ForEachTiddlerPlugin",
licence: "[[BSD open source license (abego Software)|http://www.abego-software.de/legal/apl-v10.html]]",
copyright: "Copyright (c) abego Software GmbH, 2005-2007 (www.abego-software.de)"
};
// For backward compatibility with TW 1.2.x
//
if (!TiddlyWiki.prototype.forEachTiddler) {
TiddlyWiki.prototype.forEachTiddler = function(callback) {
for(var t in this.tiddlers) {
callback.call(this,t,this.tiddlers[t]);
}
};
}
//============================================================================
// forEachTiddler Macro
//============================================================================
version.extensions.forEachTiddler = {
major: 1, minor: 0, revision: 8, date: new Date(2007,3,12), provider: "http://tiddlywiki.abego-software.de"};
// ---------------------------------------------------------------------------
// Configurations and constants
// ---------------------------------------------------------------------------
config.macros.forEachTiddler = {
// Standard Properties
label: "forEachTiddler",
prompt: "Perform actions on a (sorted) selection of tiddlers",
// actions
actions: {
addToList: {},
write: {}
}
};
// ---------------------------------------------------------------------------
// The forEachTiddler Macro Handler
// ---------------------------------------------------------------------------
config.macros.forEachTiddler.getContainingTiddler = function(e) {
while(e && !hasClass(e,"tiddler"))
e = e.parentNode;
var title = e ? e.getAttribute("tiddler") : null;
return title ? store.getTiddler(title) : null;
};
config.macros.forEachTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
// config.macros.forEachTiddler.traceMacroCall(place,macroName,params,wikifier,paramString,tiddler);
if (!tiddler) tiddler = config.macros.forEachTiddler.getContainingTiddler(place);
// --- Parsing ------------------------------------------
var i = 0; // index running over the params
// Parse the "in" clause
var tiddlyWikiPath = undefined;
if ((i < params.length) && params[i] == "in") {
i++;
if (i >= params.length) {
this.handleError(place, "TiddlyWiki path expected behind 'in'.");
return;
}
tiddlyWikiPath = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the where clause
var whereClause ="true";
if ((i < params.length) && params[i] == "where") {
i++;
whereClause = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the sort stuff
var sortClause = null;
var sortAscending = true;
if ((i < params.length) && params[i] == "sortBy") {
i++;
if (i >= params.length) {
this.handleError(place, "sortClause missing behind 'sortBy'.");
return;
}
sortClause = this.paramEncode(params[i]);
i++;
if ((i < params.length) && (params[i] == "ascending" || params[i] == "descending")) {
sortAscending = params[i] == "ascending";
i++;
}
}
// Parse the script
var scriptText = null;
if ((i < params.length) && params[i] == "script") {
i++;
scriptText = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the action.
// When we are already at the end use the default action
var actionName = "addToList";
if (i < params.length) {
if (!config.macros.forEachTiddler.actions[params[i]]) {
this.handleError(place, "Unknown action '"+params[i]+"'.");
return;
} else {
actionName = params[i];
i++;
}
}
// Get the action parameter
// (the parsing is done inside the individual action implementation.)
var actionParameter = params.slice(i);
// --- Processing ------------------------------------------
try {
this.performMacro({
place: place,
inTiddler: tiddler,
whereClause: whereClause,
sortClause: sortClause,
sortAscending: sortAscending,
actionName: actionName,
actionParameter: actionParameter,
scriptText: scriptText,
tiddlyWikiPath: tiddlyWikiPath});
} catch (e) {
this.handleError(place, e);
}
};
// Returns an object with properties "tiddlers" and "context".
// tiddlers holds the (sorted) tiddlers selected by the parameter,
// context the context of the execution of the macro.
//
// The action is not yet performed.
//
// @parameter see performMacro
//
config.macros.forEachTiddler.getTiddlersAndContext = function(parameter) {
var context = config.macros.forEachTiddler.createContext(parameter.place, parameter.whereClause, parameter.sortClause, parameter.sortAscending, parameter.actionName, parameter.actionParameter, parameter.scriptText, parameter.tiddlyWikiPath, parameter.inTiddler);
var tiddlyWiki = parameter.tiddlyWikiPath ? this.loadTiddlyWiki(parameter.tiddlyWikiPath) : store;
context["tiddlyWiki"] = tiddlyWiki;
// Get the tiddlers, as defined by the whereClause
var tiddlers = this.findTiddlers(parameter.whereClause, context, tiddlyWiki);
context["tiddlers"] = tiddlers;
// Sort the tiddlers, when sorting is required.
if (parameter.sortClause) {
this.sortTiddlers(tiddlers, parameter.sortClause, parameter.sortAscending, context);
}
return {tiddlers: tiddlers, context: context};
};
// Returns the (sorted) tiddlers selected by the parameter.
//
// The action is not yet performed.
//
// @parameter see performMacro
//
config.macros.forEachTiddler.getTiddlers = function(parameter) {
return this.getTiddlersAndContext(parameter).tiddlers;
};
// Performs the macros with the given parameter.
//
// @param parameter holds the parameter of the macro as separate properties.
// The following properties are supported:
//
// place
// whereClause
// sortClause
// sortAscending
// actionName
// actionParameter
// scriptText
// tiddlyWikiPath
//
// All properties are optional.
// For most actions the place property must be defined.
//
config.macros.forEachTiddler.performMacro = function(parameter) {
var tiddlersAndContext = this.getTiddlersAndContext(parameter);
// Perform the action
var actionName = parameter.actionName ? parameter.actionName : "addToList";
var action = config.macros.forEachTiddler.actions[actionName];
if (!action) {
this.handleError(parameter.place, "Unknown action '"+actionName+"'.");
return;
}
var actionHandler = action.handler;
actionHandler(parameter.place, tiddlersAndContext.tiddlers, parameter.actionParameter, tiddlersAndContext.context);
};
// ---------------------------------------------------------------------------
// The actions
// ---------------------------------------------------------------------------
// Internal.
//
// --- The addToList Action -----------------------------------------------
//
config.macros.forEachTiddler.actions.addToList.handler = function(place, tiddlers, parameter, context) {
// Parse the parameter
var p = 0;
// Check for extra parameters
if (parameter.length > p) {
config.macros.forEachTiddler.createExtraParameterErrorElement(place, "addToList", parameter, p);
return;
}
// Perform the action.
var list = document.createElement("ul");
place.appendChild(list);
for (var i = 0; i < tiddlers.length; i++) {
var tiddler = tiddlers[i];
var listItem = document.createElement("li");
list.appendChild(listItem);
createTiddlyLink(listItem, tiddler.title, true);
}
};
abego.parseNamedParameter = function(name, parameter, i) {
var beginExpression = null;
if ((i < parameter.length) && parameter[i] == name) {
i++;
if (i >= parameter.length) {
throw "Missing text behind '%0'".format([name]);
}
return config.macros.forEachTiddler.paramEncode(parameter[i]);
}
return null;
}
// Internal.
//
// --- The write Action ---------------------------------------------------
//
config.macros.forEachTiddler.actions.write.handler = function(place, tiddlers, parameter, context) {
// Parse the parameter
var p = 0;
if (p >= parameter.length) {
this.handleError(place, "Missing expression behind 'write'.");
return;
}
var textExpression = config.macros.forEachTiddler.paramEncode(parameter[p]);
p++;
// Parse the "begin" option
var beginExpression = abego.parseNamedParameter("begin", parameter, p);
if (beginExpression !== null)
p += 2;
var endExpression = abego.parseNamedParameter("end", parameter, p);
if (endExpression !== null)
p += 2;
var noneExpression = abego.parseNamedParameter("none", parameter, p);
if (noneExpression !== null)
p += 2;
// Parse the "toFile" option
var filename = null;
var lineSeparator = undefined;
if ((p < parameter.length) && parameter[p] == "toFile") {
p++;
if (p >= parameter.length) {
this.handleError(place, "Filename expected behind 'toFile' of 'write' action.");
return;
}
filename = config.macros.forEachTiddler.getLocalPath(config.macros.forEachTiddler.paramEncode(parameter[p]));
p++;
if ((p < parameter.length) && parameter[p] == "withLineSeparator") {
p++;
if (p >= parameter.length) {
this.handleError(place, "Line separator text expected behind 'withLineSeparator' of 'write' action.");
return;
}
lineSeparator = config.macros.forEachTiddler.paramEncode(parameter[p]);
p++;
}
}
// Check for extra parameters
if (parameter.length > p) {
config.macros.forEachTiddler.createExtraParameterErrorElement(place, "write", parameter, p);
return;
}
// Perform the action.
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(textExpression, context);
var count = tiddlers.length;
var text = "";
if (count > 0 && beginExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(beginExpression, context)(undefined, context, count, undefined);
for (var i = 0; i < count; i++) {
var tiddler = tiddlers[i];
text += func(tiddler, context, count, i);
}
if (count > 0 && endExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(endExpression, context)(undefined, context, count, undefined);
if (count == 0 && noneExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(noneExpression, context)(undefined, context, count, undefined);
if (filename) {
if (lineSeparator !== undefined) {
lineSeparator = lineSeparator.replace(/\\n/mg, "\n").replace(/\\r/mg, "\r");
text = text.replace(/\n/mg,lineSeparator);
}
saveFile(filename, convertUnicodeToUTF8(text));
} else {
var wrapper = createTiddlyElement(place, "span");
wikify(text, wrapper, null/* highlightRegExp */, context.inTiddler);
}
};
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
// Internal.
//
config.macros.forEachTiddler.createContext = function(placeParam, whereClauseParam, sortClauseParam, sortAscendingParam, actionNameParam, actionParameterParam, scriptText, tiddlyWikiPathParam, inTiddlerParam) {
return {
place : placeParam,
whereClause : whereClauseParam,
sortClause : sortClauseParam,
sortAscending : sortAscendingParam,
script : scriptText,
actionName : actionNameParam,
actionParameter : actionParameterParam,
tiddlyWikiPath : tiddlyWikiPathParam,
inTiddler : inTiddlerParam, // the tiddler containing the <<forEachTiddler ...>> macro call.
viewerTiddler : config.macros.forEachTiddler.getContainingTiddler(placeParam) // the tiddler showing the forEachTiddler result
};
};
// Internal.
//
// Returns a TiddlyWiki with the tiddlers loaded from the TiddlyWiki of
// the given path.
//
config.macros.forEachTiddler.loadTiddlyWiki = function(path, idPrefix) {
if (!idPrefix) {
idPrefix = "store";
}
var lenPrefix = idPrefix.length;
// Read the content of the given file
var content = loadFile(this.getLocalPath(path));
if(content === null) {
throw "TiddlyWiki '"+path+"' not found.";
}
var tiddlyWiki = new TiddlyWiki();
// Starting with TW 2.2 there is a helper function to import the tiddlers
if (tiddlyWiki.importTiddlyWiki) {
if (!tiddlyWiki.importTiddlyWiki(content))
throw "File '"+path+"' is not a TiddlyWiki.";
tiddlyWiki.dirty = false;
return tiddlyWiki;
}
// The legacy code, for TW < 2.2
// Locate the storeArea div's
var posOpeningDiv = content.indexOf(startSaveArea);
var posClosingDiv = content.lastIndexOf(endSaveArea);
if((posOpeningDiv == -1) || (posClosingDiv == -1)) {
throw "File '"+path+"' is not a TiddlyWiki.";
}
var storageText = content.substr(posOpeningDiv + startSaveArea.length, posClosingDiv);
// Create a "div" element that contains the storage text
var myStorageDiv = document.createElement("div");
myStorageDiv.innerHTML = storageText;
myStorageDiv.normalize();
// Create all tiddlers in a new TiddlyWiki
// (following code is modified copy of TiddlyWiki.prototype.loadFromDiv)
var store = myStorageDiv.childNodes;
for(var t = 0; t < store.length; t++) {
var e = store[t];
var title = null;
if(e.getAttribute)
title = e.getAttribute("tiddler");
if(!title && e.id && e.id.substr(0,lenPrefix) == idPrefix)
title = e.id.substr(lenPrefix);
if(title && title !== "") {
var tiddler = tiddlyWiki.createTiddler(title);
tiddler.loadFromDiv(e,title);
}
}
tiddlyWiki.dirty = false;
return tiddlyWiki;
};
// Internal.
//
// Returns a function that has a function body returning the given javaScriptExpression.
// The function has the parameters:
//
// (tiddler, context, count, index)
//
config.macros.forEachTiddler.getEvalTiddlerFunction = function (javaScriptExpression, context) {
var script = context["script"];
var functionText = "var theFunction = function(tiddler, context, count, index) { return "+javaScriptExpression+"}";
var fullText = (script ? script+";" : "")+functionText+";theFunction;";
return eval(fullText);
};
// Internal.
//
config.macros.forEachTiddler.findTiddlers = function(whereClause, context, tiddlyWiki) {
var result = [];
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(whereClause, context);
tiddlyWiki.forEachTiddler(function(title,tiddler) {
if (func(tiddler, context, undefined, undefined)) {
result.push(tiddler);
}
});
return result;
};
// Internal.
//
config.macros.forEachTiddler.createExtraParameterErrorElement = function(place, actionName, parameter, firstUnusedIndex) {
var message = "Extra parameter behind '"+actionName+"':";
for (var i = firstUnusedIndex; i < parameter.length; i++) {
message += " "+parameter[i];
}
this.handleError(place, message);
};
// Internal.
//
config.macros.forEachTiddler.sortAscending = function(tiddlerA, tiddlerB) {
var result =
(tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue)
? 0
: (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)
? -1
: +1;
return result;
};
// Internal.
//
config.macros.forEachTiddler.sortDescending = function(tiddlerA, tiddlerB) {
var result =
(tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue)
? 0
: (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)
? +1
: -1;
return result;
};
// Internal.
//
config.macros.forEachTiddler.sortTiddlers = function(tiddlers, sortClause, ascending, context) {
// To avoid evaluating the sortClause whenever two items are compared
// we pre-calculate the sortValue for every item in the array and store it in a
// temporary property ("forEachTiddlerSortValue") of the tiddlers.
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(sortClause, context);
var count = tiddlers.length;
var i;
for (i = 0; i < count; i++) {
var tiddler = tiddlers[i];
tiddler.forEachTiddlerSortValue = func(tiddler,context, undefined, undefined);
}
// Do the sorting
tiddlers.sort(ascending ? this.sortAscending : this.sortDescending);
// Delete the temporary property that holds the sortValue.
for (i = 0; i < tiddlers.length; i++) {
delete tiddlers[i].forEachTiddlerSortValue;
}
};
// Internal.
//
config.macros.forEachTiddler.trace = function(message) {
displayMessage(message);
};
// Internal.
//
config.macros.forEachTiddler.traceMacroCall = function(place,macroName,params) {
var message ="<<"+macroName;
for (var i = 0; i < params.length; i++) {
message += " "+params[i];
}
message += ">>";
displayMessage(message);
};
// Internal.
//
// Creates an element that holds an error message
//
config.macros.forEachTiddler.createErrorElement = function(place, exception) {
var message = (exception.description) ? exception.description : exception.toString();
return createTiddlyElement(place,"span",null,"forEachTiddlerError","<<forEachTiddler ...>>: "+message);
};
// Internal.
//
// @param place [may be null]
//
config.macros.forEachTiddler.handleError = function(place, exception) {
if (place) {
this.createErrorElement(place, exception);
} else {
throw exception;
}
};
// Internal.
//
// Encodes the given string.
//
// Replaces
// "$))" to ">>"
// "$)" to ">"
//
config.macros.forEachTiddler.paramEncode = function(s) {
var reGTGT = new RegExp("\\$\\)\\)","mg");
var reGT = new RegExp("\\$\\)","mg");
return s.replace(reGTGT, ">>").replace(reGT, ">");
};
// Internal.
//
// Returns the given original path (that is a file path, starting with "file:")
// as a path to a local file, in the systems native file format.
//
// Location information in the originalPath (i.e. the "#" and stuff following)
// is stripped.
//
config.macros.forEachTiddler.getLocalPath = function(originalPath) {
// Remove any location part of the URL
var hashPos = originalPath.indexOf("#");
if(hashPos != -1)
originalPath = originalPath.substr(0,hashPos);
// Convert to a native file format assuming
// "file:///x:/path/path/path..." - pc local file --> "x:\path\path\path..."
// "file://///server/share/path/path/path..." - FireFox pc network file --> "\\server\share\path\path\path..."
// "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."
// "file://server/share/path/path/path..." - pc network file --> "\\server\share\path\path\path..."
var localPath;
if(originalPath.charAt(9) == ":") // pc local file
localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
else if(originalPath.indexOf("file://///") === 0) // FireFox pc network file
localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
else if(originalPath.indexOf("file:///") === 0) // mac/unix local file
localPath = unescape(originalPath.substr(7));
else if(originalPath.indexOf("file:/") === 0) // mac/unix local file
localPath = unescape(originalPath.substr(5));
else // pc network file
localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
return localPath;
};
// ---------------------------------------------------------------------------
// Stylesheet Extensions (may be overridden by local StyleSheet)
// ---------------------------------------------------------------------------
//
setStylesheet(
".forEachTiddlerError{color: #ffffff;background-color: #880000;}",
"forEachTiddler");
//============================================================================
// End of forEachTiddler Macro
//============================================================================
//============================================================================
// String.startsWith Function
//============================================================================
//
// Returns true if the string starts with the given prefix, false otherwise.
//
version.extensions["String.startsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.startsWith = function(prefix) {
var n = prefix.length;
return (this.length >= n) && (this.slice(0, n) == prefix);
};
//============================================================================
// String.endsWith Function
//============================================================================
//
// Returns true if the string ends with the given suffix, false otherwise.
//
version.extensions["String.endsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.endsWith = function(suffix) {
var n = suffix.length;
return (this.length >= n) && (this.right(n) == suffix);
};
//============================================================================
// String.contains Function
//============================================================================
//
// Returns true when the string contains the given substring, false otherwise.
//
version.extensions["String.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.contains = function(substring) {
return this.indexOf(substring) >= 0;
};
//============================================================================
// Array.indexOf Function
//============================================================================
//
// Returns the index of the first occurance of the given item in the array or
// -1 when no such item exists.
//
// @param item [may be null]
//
version.extensions["Array.indexOf"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.indexOf = function(item) {
for (var i = 0; i < this.length; i++) {
if (this[i] == item) {
return i;
}
}
return -1;
};
//============================================================================
// Array.contains Function
//============================================================================
//
// Returns true when the array contains the given item, otherwise false.
//
// @param item [may be null]
//
version.extensions["Array.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.contains = function(item) {
return (this.indexOf(item) >= 0);
};
//============================================================================
// Array.containsAny Function
//============================================================================
//
// Returns true when the array contains at least one of the elements
// of the item. Otherwise (or when items contains no elements) false is returned.
//
version.extensions["Array.containsAny"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.containsAny = function(items) {
for(var i = 0; i < items.length; i++) {
if (this.contains(items[i])) {
return true;
}
}
return false;
};
//============================================================================
// Array.containsAll Function
//============================================================================
//
// Returns true when the array contains all the items, otherwise false.
//
// When items is null false is returned (even if the array contains a null).
//
// @param items [may be null]
//
version.extensions["Array.containsAll"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.containsAll = function(items) {
for(var i = 0; i < items.length; i++) {
if (!this.contains(items[i])) {
return false;
}
}
return true;
};
} // of "install only once"
// Used Globals (for JSLint) ==============
// ... DOM
/*global document */
// ... TiddlyWiki Core
/*global convertUnicodeToUTF8, createTiddlyElement, createTiddlyLink,
displayMessage, endSaveArea, hasClass, loadFile, saveFile,
startSaveArea, store, wikify */
<html>
<b>Species:</b><br/>
<input name=species type=text /><br/>
<b>Strain:</b><br/>
<input name=strain type=text /><br/>
<b>Location:</b><br/>
<input type="checkbox" name="option1" value="oral cavity"> Oral cavity<br>
<input type="checkbox" name="option2" value="small intestine"> Small intestine<br>
<input type="checkbox" name="option3" value="large intestine"> Large intestine<br>
<input type="checkbox" name="option4" value="colon"> Colon<br>
<input type="checkbox" name="option5" value="everywhere"> Everywhere<br>
<input type="checkbox" name="option6" value="unclassified"> Unclassified<br>
</br>
<b>Gram:</b><br/>
<input name=gram type=radio value="negative" />Negative<input name=gram type=radio value="positive" />Positive<input name=gram type=radio value="unclassified" />Unclassified
<br/><b>Pathogenicity:</b><br/>
<input name=pathogenicity type=radio value="primary" />Primary pathogen
<input name=pathogenicity type=radio value="opportunist" />Opportunist
<input name=pathogenicity type=radio value="commensal" />Commensal
<input name=pathogenicity type=radio value="transient" />Transient
<input name=pathogenicity type=radio value="unclassified" />Unclassified<br/>
<b>Genome Length (kb):</b><br/>
<input name=Genome length=text/><br/>
<b>GC Content (%):</b><br/>
<input name=GC Content=text/><br/>
</html>
//============================================================================
//============================================================================
// FormTiddlerPlugin
//============================================================================
//============================================================================
if (!window.abego) window.abego = {};
abego.getOptionsValue = function(element,i) {
var v = element.options[i].value;
if (!v && element.options[i].text)
v = element.options[i].text;
return v;
};
version.extensions.FormTiddlerPlugin = {
major: 1, minor: 0, revision: 5,
date: new Date(2006, 2, 24),
type: 'plugin',
source: "http://tiddlywiki.abego-software.de/#FormTiddlerPlugin"
};
// For backward compatibility with v1.2.x
//
if (!window.story) window.story=window;
if (!TiddlyWiki.prototype.getTiddler) TiddlyWiki.prototype.getTiddler = function(title) { return t = this.tiddlers[title]; return (t != undefined && t instanceof Tiddler) ? t : null; }
//============================================================================
// formTiddler Macro
//============================================================================
// -------------------------------------------------------------------------------
// Configurations and constants
// -------------------------------------------------------------------------------
config.macros.formTiddler = {
// Standard Properties
label: "formTiddler",
version: {major: 1, minor: 0, revision: 4, date: new Date(2006, 2, 7)},
prompt: "Edit tiddler data using forms",
// Define the "setters" that set the values of INPUT elements of a given type
// (must match the corresponding "getter")
setter: {
button: function(e, value) {/*contains no data */ },
checkbox: function(e, value) {e.checked = value;},
file: function(e, value) {try {e.value = value;} catch(e) {/* ignore, possibly security error*/}},
hidden: function(e, value) {e.value = value;},
password: function(e, value) {e.value = value;},
radio: function(e, value) {e.checked = (e.value == value);},
reset: function(e, value) {/*contains no data */ },
"select-one": function(e, value) {config.macros.formTiddler.setSelectOneValue(e,value);},
"select-multiple": function(e, value) {config.macros.formTiddler.setSelectMultipleValue(e,value);},
submit: function(e, value) {/*contains no data */},
text: function(e, value) {e.value = value;},
textarea: function(e, value) {e.value = value;}
},
// Define the "getters" that return the value of INPUT elements of a given type
// Return undefined to not store any data.
getter: {
button: function(e, value) {return undefined;},
checkbox: function(e, value) {return e.checked;},
file: function(e, value) {return e.value;},
hidden: function(e, value) {return e.value;},
password: function(e, value) {return e.value;},
radio: function(e, value) {return e.checked ? e.value : undefined;},
reset: function(e, value) {return undefined;},
"select-one": function(e, value) {return config.macros.formTiddler.getSelectOneValue(e);},
"select-multiple": function(e, value) {return config.macros.formTiddler.getSelectMultipleValue(e);},
submit: function(e, value) {return undefined;},
text: function(e, value) {return e.value;},
textarea: function(e, value) {return e.value;}
}
};
// -------------------------------------------------------------------------------
// The formTiddler Macro Handler
// -------------------------------------------------------------------------------
config.macros.formTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
if (!config.macros.formTiddler.checkForExtensions(place, macroName)) {
return;
}
// --- Parsing ------------------------------------------
var i = 0; // index running over the params
// get the name of the form template tiddler
var formTemplateName = undefined;
if (i < params.length) {
formTemplateName = params[i];
i++;
}
if (!formTemplateName) {
config.macros.formTiddler.createErrorElement(place, "No form template specified in <<" + macroName + ">>.");
return;
}
// --- Processing ------------------------------------------
// Get the form template text.
// (This contains the INPUT elements for the form.)
var formTemplateTiddler = store.getTiddler(formTemplateName);
if (!formTemplateTiddler) {
config.macros.formTiddler.createErrorElement(place, "Form template '" + formTemplateName + "' not found.");
return;
}
var templateText = formTemplateTiddler.text;
if(!templateText) {
// Shortcut: when template text is empty we do nothing.
return;
}
// Get the name of the tiddler containing this "formTiddler" macro
// (i.e. the tiddler, that will be edited and that contains the data)
var tiddlerName = config.macros.formTiddler.getContainingTiddlerName(place);
// Append a "form" element.
var formName = "form"+formTemplateName+"__"+tiddlerName;
var e = document.createElement("form");
e.setAttribute("name", formName);
place.appendChild(e);
// "Embed" the elements defined by the templateText (i.e. the INPUT elements)
// into the "form" element we just created
wikify(templateText, e);
// Initialize the INPUT elements.
config.macros.formTiddler.initValuesAndHandlersInFormElements(formName, DataTiddler.getDataObject(tiddlerName));
}
// -------------------------------------------------------------------------------
// Form Data Access
// -------------------------------------------------------------------------------
// Internal.
//
// Initialize the INPUT elements of the form with the values of their "matching"
// data fields in the tiddler. Also setup the onChange handler to ensure that
// changes in the INPUT elements are stored in the tiddler's data.
//
config.macros.formTiddler.initValuesAndHandlersInFormElements = function(formName, data) {
// config.macros.formTiddler.trace("initValuesAndHandlersInFormElements(formName="+formName+", data="+data+")");
// find the form
var form = config.macros.formTiddler.findForm(formName);
if (!form) {
return;
}
try {
var elems = form.elements;
for (var i = 0; i < elems.length; i++) {
var c = elems[i];
var setter = config.macros.formTiddler.setter[c.type];
if (setter) {
var value = data[c.name];
if (value != null) {
setter(c, value);
}
c.onchange = onFormTiddlerChange;
} else {
config.macros.formTiddler.displayFormTiddlerError("No setter defined for INPUT element of type '"+c.type+"'. (Element '"+c.name+"' in form '"+formName+"')");
}
}
} catch(e) {
config.macros.formTiddler.displayFormTiddlerError("Error when updating elements with new formData. "+e);
}
}
// Internal.
//
// @return [may be null]
//
config.macros.formTiddler.findForm = function(formName) {
// We must manually iterate through the document's forms, since
// IE does not support the "document[formName]" approach
var forms = window.document.forms;
for (var i = 0; i < forms.length; i++) {
var form = forms[i];
if (form.name == formName) {
return form;
}
}
return null;
}
// Internal.
//
config.macros.formTiddler.setSelectOneValue = function(element,value) {
var n = element.options.length;
for (var i = 0; i < n; i++) {
element.options[i].selected = abego.getOptionsValue(element,i) == value;
}
}
// Internal.
//
config.macros.formTiddler.setSelectMultipleValue = function(element,value) {
var values = {};
for (var i = 0; i < value.length; i++) {
values[value[i]] = true;
}
var n = element.length;
for (var i = 0; i < n; i++) {
element.options[i].selected = !(!values[abego.getOptionsValue(element,i)]);
}
}
// Internal.
//
config.macros.formTiddler.getSelectOneValue = function(element) {
var i = element.selectedIndex;
return (i >= 0) ? abego.getOptionsValue(element,i) : null;
}
// Internal.
//
config.macros.formTiddler.getSelectMultipleValue = function(element) {
var values = [];
var n = element.length;
for (var i = 0; i < n; i++) {
if (element.options[i].selected) {
values.push(abego.getOptionsValue(element,i));
}
}
return values;
}
// -------------------------------------------------------------------------------
// Helpers
// -------------------------------------------------------------------------------
// Internal.
//
config.macros.formTiddler.checkForExtensions = function(place,macroName) {
if (!version.extensions.DataTiddlerPlugin) {
config.macros.formTiddler.createErrorElement(place, "<<" + macroName + ">> requires the DataTiddlerPlugin. (You can get it from http://tiddlywiki.abego-software.de/#DataTiddlerPlugin)");
return false;
}
return true;
}
// Internal.
//
// Displays a trace message in the "TiddlyWiki" message pane.
// (used for debugging)
//
config.macros.formTiddler.trace = function(s) {
displayMessage("Trace: "+s);
}
// Internal.
//
// Display some error message in the "TiddlyWiki" message pane.
//
config.macros.formTiddler.displayFormTiddlerError = function(s) {
alert("FormTiddlerPlugin Error: "+s);
}
// Internal.
//
// Creates an element that holds an error message
//
config.macros.formTiddler.createErrorElement = function(place, message) {
return createTiddlyElement(place,"span",null,"formTiddlerError",message);
}
// Internal.
//
// Returns the name of the tiddler containing the given element.
//
config.macros.formTiddler.getContainingTiddlerName = function(element) {
return story.findContainingTiddler(element).id.substr(7);
}
// -------------------------------------------------------------------------------
// Event Handlers
// -------------------------------------------------------------------------------
// This function must be called by the INPUT elements whenever their
// data changes. Typically this is done through an "onChange" handler.
//
function onFormTiddlerChange (e) {
// config.macros.formTiddler.trace("onFormTiddlerChange "+e);
if (!e) var e = window.event;
var target = resolveTarget(e);
var tiddlerName = config.macros.formTiddler.getContainingTiddlerName(target);
var getter = config.macros.formTiddler.getter[target.type];
if (getter) {
var value = getter(target);
DataTiddler.setData(tiddlerName, target.name, value);
} else {
config.macros.formTiddler.displayFormTiddlerError("No getter defined for INPUT element of type '"+target.type+"'. (Element '"+target.name+"' used in tiddler '"+tiddlerName+"')");
}
}
// ensure that the function can be used in HTML event handler
window.onFormTiddlerChange = onFormTiddlerChange;
// -------------------------------------------------------------------------------
// Stylesheet Extensions (may be overridden by local StyleSheet)
// -------------------------------------------------------------------------------
setStylesheet(
".formTiddlerError{color: #ffffff;background-color: #880000;}",
"formTiddler");
//============================================================================
// checkForDataTiddlerPlugin Macro
//============================================================================
config.macros.checkForDataTiddlerPlugin = {
// Standard Properties
label: "checkForDataTiddlerPlugin",
version: {major: 1, minor: 0, revision: 0, date: new Date(2005, 12, 14)},
prompt: "Check if the DataTiddlerPlugin exists"
}
config.macros.checkForDataTiddlerPlugin.handler = function(place,macroName,params) {
config.macros.formTiddler.checkForExtensions(place, config.macros.formTiddler.label);
}
//============================================================================
// newTiddlerWithForm Macro
//============================================================================
config.macros.newTiddlerWithForm = {
// Standard Properties
label: "newTiddlerWithForm",
version: {major: 1, minor: 0, revision: 1, date: new Date(2006, 1, 6)},
prompt: "Creates a new Tiddler with a <<formTiddler ...>> macro"
}
config.macros.newTiddlerWithForm.handler = function(place,macroName,params) {
// --- Parsing ------------------------------------------
var i = 0; // index running over the params
// get the name of the form template tiddler
var formTemplateName = undefined;
if (i < params.length) {
formTemplateName = params[i];
i++;
}
if (!formTemplateName) {
config.macros.formTiddler.createErrorElement(place, "No form template specified in <<" + macroName + ">>.");
return;
}
// get the button label
var buttonLabel = undefined;
if (i < params.length) {
buttonLabel = params[i];
i++;
}
if (!buttonLabel) {
config.macros.formTiddler.createErrorElement(place, "No button label specified in <<" + macroName + ">>.");
return;
}
// get the (optional) tiddlerName script and "askUser"
var tiddlerNameScript = undefined;
var askUser = false;
if (i < params.length) {
tiddlerNameScript = params[i];
i++;
if (i < params.length && params[i] == "askUser") {
askUser = true;
i++;
}
}
// --- Processing ------------------------------------------
if(!readOnly) {
var onClick = function() {
var tiddlerName;
if (tiddlerNameScript) {
try {
tiddlerName = eval(tiddlerNameScript);
} catch (ex) {
}
}
if (!tiddlerName || askUser) {
tiddlerName = prompt("Please specify a tiddler name.", askUser ? tiddlerName : "");
}
while (tiddlerName && store.getTiddler(tiddlerName)) {
tiddlerName = prompt("A tiddler named '"+tiddlerName+"' already exists.\n\n"+"Please specify a tiddler name.", tiddlerName);
}
// tiddlerName is either null (user canceled) or a name that is not yet in the store.
if (tiddlerName) {
var body = "<<formTiddler [["+formTemplateName+"]]>>";
var tags = [];
store.saveTiddler(tiddlerName,tiddlerName,body,config.options.txtUserName,new Date(),tags);
story.displayTiddler(null,tiddlerName,1);
}
}
createTiddlyButton(place,buttonLabel,buttonLabel,onClick);
}
}
Define genome properties using Genome Properties Homepage on JCVI CMR
http://cmr.tigr.org/tigr-scripts/CMR/shared/GenomePropertiesHomePage.cgi
It is thought to be the case that the microorganisms that live inside and on human beings outnumber human cells by 1 to 10. The microbiota that live within us provide us with many benefits that humans were not able to develop naturally. Many of these organisms are commensals and do not trigger an immune response but help ward off pathogenic bacteria, assist the digestive system and more. It is thought that the microbiota are closely linked to human health and there has been a lot of interest in looking into the link more closely and in December 2007, the National Institute of Health announced the Human Microbiome Project.
Using metagenomic DNA sequencing and also the traditional method of sequencing isolated strains the Human Microbiome Project hopes to answer various questions that have yet to be answered and in the long-term, prove to be beneficial to overall human health in the future. It's main goals currently, according to the National Institute of Health are:
Determining whether individuals share a core human microbiome
Understanding whether changes in the human microbiome can be correlated with changes in human health
Developing the new technological and bioinformatic tools needed to support these goals
Addressing the ethical, legal and social implications raised by human microbiome research.
Links:
http://nihroadmap.nih.gov/hmp/
http://www.nih.gov/news/pr/dec2007/od-19.htm
/***
|''Name:''|IntelliTaggerPlugin|
|''Version:''|1.0.2 (2007-07-25)|
|''Type:''|plugin|
|''Source:''|http://tiddlywiki.abego-software.de/#IntelliTaggerPlugin|
|''Author:''|Udo Borkowski (ub [at] abego-software [dot] de)|
|''Documentation:''|[[IntelliTaggerPlugin Documentation]]|
|''~SourceCode:''|[[IntelliTaggerPlugin SourceCode]]|
|''Licence:''|[[BSD open source license (abego Software)]]|
|''~CoreVersion:''|2.0.8|
|''Browser:''|Firefox 1.5.0.2 or better|
***/
/***
!Version History
* 1.0.2 (2007-07-25):
** Feature: "Return" key may be used to accept first tag suggestion (beside "Alt-1")
** Bugfix: Keyboard shortcuts (Alt+3 etc.) shifted
* 1.0.1 (2007-05-18): Improvement: Speedup when using TiddlyWikis with many tags
* 1.0.0 (2006-04-26): Initial release
***/
/***
!Source Code
***/
//{{{
// Ensure the Plugin is only installed once.
//
if (!version.extensions.IntelliTaggerPlugin) {
// Ensure the global abego namespace is set up.
if (!window.abego) window.abego = {};
if (!abego.internal) abego.internal = {};
// Opens an alert with the given string and throws an exception
// with the same string after the alert is closed.
//
abego.alertAndThrow = function(s) {
alert(s);
throw s;
};
if (version.major < 2) {
abego.alertAndThrow("Use TiddlyWiki 2.0.8 or better to run the IntelliTagger Plugin.");
}
version.extensions.IntelliTaggerPlugin = {
major: 1, minor: 0, revision: 2,
date: new Date(2007, 6, 25),
type: 'plugin',
source: "http://tiddlywiki.abego-software.de/#IntelliTaggerPlugin",
documentation: "[[IntelliTaggerPlugin Documentation]]",
sourcecode: "[[IntelliTaggerPlugin SourceCode]]",
author: "Udo Borkowski (ub [at] abego-software [dot] de)",
licence: "[[BSD open source license (abego Software)]]",
tiddlywiki: "Version 2.0.8 or better",
browser: "Firefox 1.5.0.2 or better"
};
//}}}
//#startOf: MainCode
//{{{
// ========================================================================
// Utilities ==============================================================
// ========================================================================
// ========================================================================
// Popup
//
// A Popup is an HTML element floating on top of the main HTML page.
//
// The HTML element (typically a "div" element) is added as a direct child
// of the document.body.
//
// A Popup element should respect the following style conventions:
//
// position = "absolute"; // required.
// left = aDimension; // required. E.g. "10px"
// // When not defined the Popup is not displayed.
// top = aDimension; // required. E.g. "10px"
// // When not defined the Popup is not displayed.
// background = aColor; // optional. E.g. "white"
// // When not defined the Popup is transparent.
// border = aBorderSpec; // optional. E.g. "1px solid DarkGray"
// width = aDimension; // optional. E.g. "200px"
// // When not defined the width is calculated
// // automatically.
// height = aDimension; // optional. E.g. "200px"
// // When not defined the height is calculated
// // automatically.
// ========================================================================
abego.createEllipsis = function(place) {
var e = createTiddlyElement(place,"span");
e.innerHTML = "…";
};
// Returns true iff the given element is "opened as a popup",
// i.e. a direct child of the document.body.
//
// @param element [may be null/undefined]
// an HTML element
//
abego.isPopupOpen = function(element) {
return element && element.parentNode == document.body;
};
// Opens the given element as a popup.
//
// @param element
// an HTML element
//
abego.openAsPopup = function(element) {
if (element.parentNode != document.body)
document.body.appendChild(element);
};
// Closes the given popup.
// Does nothing when the element is not a popup or not open.
//
// @param element [may be null/undefined]
// an HTML element
//
abego.closePopup = function(element) {
if (abego.isPopupOpen(element))
document.body.removeChild(element);
};
// Returns the rectangle of the (browser) window
//
// @return {left,top,height,width}
//
abego.getWindowRect = function() {
return {
left: findScrollX(),
top: findScrollY(),
height: findWindowHeight(),
width: findWindowWidth()
};
};
// Moves the given element to the given position (in pixel).
//
abego.moveElement = function(element, left, top) {
element.style.left = left + "px";
element.style.top = top + "px";
};
// Centers the given element on the window.
//
// The element must have absolute position
//
abego.centerOnWindow = function(element) {
if (element.style.position != "absolute")
throw "abego.centerOnWindow: element must have absolute position";
var winRect = abego.getWindowRect();
abego.moveElement(
element,
winRect.left + (winRect.width - element.offsetWidth) / 2,
winRect.top + (winRect.height - element.offsetHeight) / 2);
};
// Returns true if e is either self or a descendant (child, grandchild,...) of self.
//
// @param self DOM:Element
// @param e DOM:Element [may be null]
//
abego.isDescendantOrSelf = function(self, e) {
while (e) {
if (self == e) return true;
e = e.parentNode;
}
return false;
};
// Returns a set containing the items of the array.
//
// It is an object that has a property for every item of the array.
// The name of the property is the "toString" representation of
// the item. The value of the property is "true".
//
// Duplicate items are removed.
//
abego.toSet = function(array) {
var result = {};
for (var i = 0; i < array.length; i++)
result[array[i]] = true;
return result;
};
// Returns an array with all strings from strings that match the filterRE.
//
// @param maxCount [optional] if defined at most maxCount strings are returned.
abego.filterStrings = function(strings, filterRE, maxCount) {
var result =[];
for (var i = 0; i < strings.length && (maxCount === undefined || result.length < maxCount); i++) {
var s = strings[i];
if (s.match(filterRE))
result.push(s);
}
return result;
};
// @param a [may be null/undefined] Object[]
// @param b [may be null/undefined] Object[]
abego.arraysAreEqual = function(a,b) {
if (!a)
return !b;
if (!b)
return false;
var n = a.length;
if (n != b.length)
return false;
for (var i = 0; i < n; i++)
if (a[i] != b[i])
return false;
return true;
};
// Adjusts the element's position to appear below the anchorElement,
// and ensures the element fits into the window.
//
abego.moveBelowAndClip = function(element, anchorElement) {
if (!anchorElement)
return;
// Position the result below the anchor and resize it if necessary.
var anchorLeft = findPosX(anchorElement);
var anchorTop = findPosY(anchorElement);
var anchorHeight = anchorElement.offsetHeight;
var elementLeft = anchorLeft;
var elementTop = anchorTop + anchorHeight;
// Make sure the result is not wider than the window
var winWidth = findWindowWidth();
if (winWidth < element.offsetWidth) {
element.style.width = (winWidth - 100)+"px";
}
// Ensure that the left and right of the result are not
// clipped by the window. Move it to the left or right, if necessary.
var elementWidth = element.offsetWidth;
if(elementLeft + elementWidth > winWidth)
elementLeft = winWidth - elementWidth-30;
if (elementLeft < 0)
elementLeft = 0;
// Do the actual moving
element.style.left = elementLeft + "px";
element.style.top = elementTop + "px";
element.style.display = "block";
};
abego.compareStrings = function(a, b) {
return (a == b) ? 0 : (a < b) ? -1 : 1;
};
// Sorts the given array alphabetically, ignoring the case.
//
abego.sortIgnoreCase = function(arr) {
var result =[];
// To avoid toLowerCase to be called twice for every comparison
// we convert the strings once and sort the lowercase.
// After sorting we replace them with the cased ones.
//
// Benchmarks have shown that this is significantly faster
// than the ad hoc solution, even for small arrays
// (like 5 Strings (10 chars each))
var n = arr.length;
for (var i = 0; i < n; i++) {
var s = arr[i];
result.push([s.toString().toLowerCase(),s]);
}
result.sort(function(a,b) {
return (a[0] == b[0]) ? 0 : (a[0] < b[0]) ? -1 : 1;
});
for (i = 0; i < n; i++)
arr[i] = result[i][1];
};
// Returns the specified field (input or textarea element), otherwise the first edit field it finds
// or null if it found no edit field at all
//
abego.getTiddlerField = function(story,title,field) {
var tiddler = document.getElementById(story.idPrefix + title);
var e = null;
if (tiddler != null) {
var children = tiddler.getElementsByTagName("*");
for (var t=0; t<children.length; t++) {
var c = children[t];
if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
if(!e)
e = c;
if(c.getAttribute("edit") == field)
e = c;
// break; // adding this break would not be 100% compatible to <= TW 2.0.9. when a
}
}
}
return e;
};
abego.setRange = function(element, start, end) {
// adapted from TaskMacroPlugin by LukeBlanshard.
// http://labwiki.sourceforge.net/#CopyrightAndLicense.
if (element.setSelectionRange) { // Mozilla
element.setSelectionRange(start, end);
// Damn mozilla doesn't scroll to visible. Approximate.
var max = 0.0 + element.scrollHeight;
var len = element.textLength;
var top = max*start/len, bot = max*end/len;
element.scrollTop = Math.min(top, (bot+top-element.clientHeight)/2);
} else if (element.createTextRange != undefined) { // IE
var range = element.createTextRange();
range.collapse();
range.moveEnd("character", end);
range.moveStart("character", start);
range.select();
} else // Other? Too bad, just select the whole thing.
element.select();
};
// TiddlerSet: an object with one property per tiddler in the set.
// The name of the property corresponds to the tiddler name,
// the value is "not false" (e.g. true or a non-zero number).
//
// TagMap<X>: an object that maps a tag to an object of type X (access through properties)
//
abego.internal.TagManager = function() {
var tagReferences = null; // TagMap<{count: natural, tiddlers: TiddlerSet}>
var ensureTagsAreLoaded = function() {
if (tagReferences)
return;
tagReferences = {};
store.forEachTiddler(function(title,tiddler) {
for(var i=0; i<tiddler.tags.length; i++) {
var tag = tiddler.tags[i];
var refedBy = tagReferences[tag];
if (!refedBy) {
refedBy = tagReferences[tag] = {count:0, tiddlers: {}};
}
refedBy.tiddlers[tiddler.title] = true;
refedBy.count += 1;
}
});
};
// When any tags are changed reset the TagManager.
//
var oldTiddlyWikiSaveTiddler = TiddlyWiki.prototype.saveTiddler;
TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags) {
var tiddler = this.fetchTiddler(title);
var oldTags = tiddler ? tiddler.tags : [];
var newTags = (typeof tags == "string") ? tags.readBracketedList() : tags;
oldTiddlyWikiSaveTiddler.apply(this, arguments);
if (!abego.arraysAreEqual(oldTags, newTags))
abego.internal.getTagManager().reset();
};
// When a tiddler is removed that had tags reset the TagManager.
//
var oldTiddlyWikiRemoveTiddler = TiddlyWiki.prototype.removeTiddler;
TiddlyWiki.prototype.removeTiddler = function(title) {
var tiddler = this.fetchTiddler(title);
var resetTagManager = tiddler && tiddler.tags.length > 0;
oldTiddlyWikiRemoveTiddler.apply(this, arguments);
if (resetTagManager)
abego.internal.getTagManager().reset();
};
// Resets the TagManager, thus ensures that cached tagging
// information is discarded and the most recent tag state is used.
//
this.reset = function () {
tagReferences = null;
};
// Returns a TiddlerSet with all tiddlers that have the given tag,
// or null when the tag is not used in any tiddler.
//
// @return [may be null]
//
this.getTiddlersWithTag = function(tag) {
ensureTagsAreLoaded();
var tagInfo = tagReferences[tag];
return tagInfo ? tagInfo.tiddlers : null;
};
// Returns an array with the names of all tags defined
// plus the (optional) extraTags.
//
// The tags are sorted alphabetically (caseinsensitive).
//
// @params [optional] an array of tags to be added to the list
//
//
this.getAllTags = function(extraTags) {
ensureTagsAreLoaded();
var result =[];
for (var i in tagReferences)
result.push(i);
for (i = 0; extraTags && i < extraTags.length; i++)
result.pushUnique(extraTags[i], true);
abego.sortIgnoreCase(result);
return result;
};
// An array with two items per tag
// result[i][0] : the tag name
// result[i][1] : TiddlerSet, with tiddlers that are tagged with that tag
//
this.getTagInfos = function() {
ensureTagsAreLoaded();
var result = [];
for (var tiddler in tagReferences) {
result.push([tiddler, tagReferences[tiddler]]);
}
return result;
};
var compareTiddlerCountAndTagName = function(a,b) {
var a1 = a[1];
var b1 = b[1];
var d = b[1].count - a[1].count;
return d != 0 ? d : abego.compareStrings(a[0].toLowerCase(), b[0].toLowerCase());
};
this.getSortedTagInfos = function() {
ensureTagsAreLoaded();
var result = this.getTagInfos();
result.sort(compareTiddlerCountAndTagName);
return result;
};
// @return an array of the tags that "partner" the activeTags,
// sorted by the number of conjoint occurances.
//
this.getPartnerRankedTags = function(activeTags) {
var partnerTagCounts = {};
for (var i = 0; i < activeTags.length; i++) {
var tiddlersWithTag = this.getTiddlersWithTag(activeTags[i]);
for (var name in tiddlersWithTag) {
var tiddler = store.getTiddler(name);
// It may happen that a tiddler is "gone" in the meantime
if (!(tiddler instanceof Tiddler))
continue;
for(var j=0; j<tiddler.tags.length; j++) {
var tag = tiddler.tags[j];
var c = partnerTagCounts[tag];
partnerTagCounts[tag] = c ? c+1 : 1;
}
}
}
var currentTagSet = abego.toSet(activeTags);
var result = [];
for (var n in partnerTagCounts) {
if (!currentTagSet[n])
result.push(n);
}
// Sort the tags by their partner tag count, then alphabetically
result.sort(function (a,b) {
var d = partnerTagCounts[b] - partnerTagCounts[a];
return d != 0 ? d : abego.compareStrings(a.toLowerCase(), b.toLowerCase());
});
return result;
};
}; // of abego.internal.TagManager
abego.internal.getTagManager = function() {
if (!abego.internal.gTagManager) abego.internal.gTagManager = new abego.internal.TagManager();
return abego.internal.gTagManager;
};
// ========================================================================
// IntelliTagger ==========================================================
// ========================================================================
(function(){
var PADDING = 2;
var BORDERWIDTH = 1;
var MAX_FAVORITE_TAGS = 30;
var fSuggestionPopup; // DOM:Element
var fAnchorElement; // DOM:Element
var fOnTagSelected; // function(e) {...}
var fSuggestedTags; // [Tag]
var fActiveTagSet; // TagSet
var fFavoriteTags; // array of Tags, [optional]
if (!abego.IntelliTagger) abego.IntelliTagger = {};
var getAnchorElement = function() {
return fAnchorElement;
};
var isCurrentTag = function(tag) {
return fActiveTagSet[tag];
};
var removeLastWord = function(s) {
var i = s.lastIndexOf(" ");
return (i >= 0) ? s.substr(0,i) : "";
};
var lastWordIsFilter = function(inputField) {
var s = inputField.value;
var len = s.length;
return (len > 0 && s[len-1] != ' ');
};
var ensureFieldEndsWithSpace = function(field) {
var s = field.value;
var len = s.length;
if (len > 0 && s[len-1] != ' ') {
field.value += ' ';
}
};
var updateTag = function(tag, inputField, tiddler) {
if (lastWordIsFilter(inputField))
inputField.value = removeLastWord(inputField.value);
story.setTiddlerTag (tiddler.title,tag,0);
ensureFieldEndsWithSpace(inputField);
abego.IntelliTagger.assistTagging(inputField, tiddler);
};
// returns the n-th suggestion, first counting the favorites, then the normal suggestions
//
// @param n zero-based.
// @return [may be null]
var getNthSuggestion = function(n) {
if (fFavoriteTags && fFavoriteTags.length > n)
return fFavoriteTags[n];
return (fSuggestedTags && fSuggestedTags.length > n)
? fSuggestedTags[n]
: null;
};
var useNthSuggestion = function(n, inputField, tiddler) {
var suggestion = getNthSuggestion(n);
if (suggestion)
updateTag(suggestion, inputField, tiddler);
};
var getFilter = function(inputField) {
var pos = inputField.value.lastIndexOf(" ");
var filter = (pos >= 0) ? inputField.value.substr(++pos,inputField.value.length) : inputField.value;
return new RegExp(filter.escapeRegExp(),"i");
};
var countExpectedTags = function(tags, expectedTagsAsProperties) {
var result = 0;
for (var i = 0; i<tags.length;i++)
if (expectedTagsAsProperties[tags[i]])
result++;
return result;
};
// Returns the number tags that have the same count of tiddlers
// as the index-th tagInfo.
//
// The index-th tag is included in the returned number.
//
// @param sortedTagInfo Array of TagInfos, sorted by count of tiddlers.
//
var getNumberOfTagsWithSameCount = function(sortedTagInfos, index, filterRE) {
var result = 1;
var c = sortedTagInfos[index];
for (var i = index+1; i < sortedTagInfos.length; i++)
if (sortedTagInfos[i][1].count == c) {
if (sortedTagInfos[i][0].match(filterRE))
result++;
} else
break;
return result;
};
var getInitialTagSuggestions = function(filterRE, maxCount) {
var tagInfos = abego.internal.getTagManager().getSortedTagInfos();
var result =[];
var lastCount = 0;
for (var i = 0; i < tagInfos.length; i++) {
var c = tagInfos[i][1].count;
// Stop adding tags to the result if not all tags with that count of tiddlers would fit into the result.
if (c != lastCount) {
if (maxCount && (result.length + getNumberOfTagsWithSameCount(tagInfos, i, filterRE) > maxCount))
break;
lastCount = c;
}
// Don't add tags that are only used in one tiddler.
if (c == 1)
break;
var s = tagInfos[i][0];
if (s.match(filterRE))
result.push(s);
}
return result;
};
var getAllFilteredTags = function(filterRE, extraTags) {
return abego.filterStrings(
abego.internal.getTagManager().getAllTags(extraTags),
filterRE);
};
// Refreshes the tagSuggestions window
//
var refreshPopup = function() {
if (!fSuggestionPopup)
return;
// Load the template for the YourSearchResult
var html = store.getTiddlerText("IntelliTaggerMainTemplate");
if (!html)
html = "<b>Tiddler IntelliTaggerMainTemplate not found</b>";
fSuggestionPopup.innerHTML = html;
// Expand the template macros etc.
applyHtmlMacros(fSuggestionPopup,null);
refreshElements(fSuggestionPopup,null);
};
var onTagClicked = function(e) {
if (!e) var e = window.event;
var tag = this.getAttribute("tag");
if (fOnTagSelected)
fOnTagSelected.call(this,tag, e);
return false;
};
var addSeparator = function(place) {
createTiddlyElement(place,"span",null,"tagSeparator", " | ");
};
var appendTags = function(place, tags, suggestionIndex, excludeTags, maxCount) {
if (!tags)
return;
var excludeTagSet = excludeTags ? abego.toSet(excludeTags) : {};
var n = tags.length;
var c = 0;
for (var i = 0; i < n; i++) {
var tag = tags[i];
if (excludeTagSet[tag])
continue;
if (c > 0)
addSeparator(place);
if (maxCount && c >= maxCount) {
abego.createEllipsis(place);
break;
}
c++;
var shortcutText = "";
var placeForButton = place;
if (suggestionIndex < 10) {
// create a wrapping span that ensures the number and the text are not linebreaked.
placeForButton = createTiddlyElement(place,"span",null,"numberedSuggestion");
suggestionIndex++;
var key = suggestionIndex < 10 ? ""+(suggestionIndex) : "0";
createTiddlyElement(placeForButton,"span",null,"suggestionNumber", key+") ");
var fastKeyText = suggestionIndex == 1 ? "Return or " : "";
shortcutText = " (Shortcut: %1Alt-%0)".format([key, fastKeyText]);
}
var shiftClickToolTip = config.views.wikified.tag.tooltip.format([tag]);
var normalClickToolTip = (isCurrentTag(tag) ? "Remove tag '%0'%1" : "Add tag '%0'%1").format([tag,shortcutText]);
var tooltip = "%0; Shift-Click: %1".format([normalClickToolTip, shiftClickToolTip]);
var btn = createTiddlyButton(
placeForButton,
tag,
tooltip,
onTagClicked,
isCurrentTag(tag) ? "currentTag" : null);
btn.setAttribute("tag",tag);
}
};
var scrollVisible = function() {
// Scroll the window to make the fSuggestionPopup page (and the anchorElement) visible.
if (fSuggestionPopup) window.scrollTo(0,ensureVisible(fSuggestionPopup));
if (getAnchorElement()) window.scrollTo(0,ensureVisible(getAnchorElement()));
};
// Close the suggestions window when the user clicks on the document
// (and not into the getAnchorElement or in the suggestions window)
//
var onDocumentClick = function(e) {
if (!e) var e = window.event;
if (!fSuggestionPopup)
return;
var target = resolveTarget(e);
if (target == getAnchorElement()) return;
if (abego.isDescendantOrSelf(fSuggestionPopup, target)) return;
abego.IntelliTagger.close();
};
addEvent(document,"click",onDocumentClick);
// We added a space to the tags edit field. To avoid that the
// tiddler is marked as "changed" just because of that we trim
// the field value
//
var oldGatherSaveFields = Story.prototype.gatherSaveFields;
Story.prototype.gatherSaveFields = function(e,fields) {
oldGatherSaveFields.apply(this, arguments);
var tags = fields.tags;
if (tags)
fields.tags = tags.trim();
};
var focusTagsField = function(title) {
story.focusTiddler(title,"tags");
var tags = abego.getTiddlerField(story, title, "tags");
if (tags) {
var len = tags.value.length;
abego.setRange(tags, len, len);
window.scrollTo(0,ensureVisible(tags));
}
};
// Attach the assistTagging to the "tags" edit field.
//
var oldEditHandler = config.macros.edit.handler;
config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
oldEditHandler.apply(this, arguments);
var field = params[0];
if((tiddler instanceof Tiddler) && field == "tags") {
// Just added the "edit tags" field.
// Attach it to the "Tag Suggestions" feature.
var inputField = place.lastChild;
inputField.onfocus = function(e) {
abego.IntelliTagger.assistTagging(inputField, tiddler);
setTimeout(
function() {
focusTagsField(tiddler.title);
}, 100);
};
inputField.onkeyup = function(e) {
if (!e) var e = window.event;
if (e.altKey && !e.ctrlKey && !e.metaKey && (e.keyCode >= 48 && e.keyCode <= 57)) {
useNthSuggestion(e.keyCode == 48 ? 9 : e.keyCode-49, inputField, tiddler);
} else if (e.ctrlKey && e.keyCode == 32) {
useNthSuggestion(0, inputField, tiddler);
} if (!e.ctrlKey && (e.keyCode == 13 || e.keyCode == 10)) {
useNthSuggestion(0, inputField, tiddler);
}
setTimeout(
function() {
abego.IntelliTagger.assistTagging(inputField, tiddler);
}, 100);
return false;
};
// ensure that the tags text ends with a space
// (otherwise the last word is used as a filter when the field gets the focus)
ensureFieldEndsWithSpace(inputField);
}
};
var onEditTags = function(e) {
if (!e) var e = window.event;
var target = resolveTarget(e);
var title = target.getAttribute("tiddler");
if (title) {
story.displayTiddler(target,title,"IntelliTaggerEditTagsTemplate", false);
focusTagsField(title);
}
return false;
};
// Add an "[edit]" button to the "tags" field that is displayed with the tiddler in the ViewTemplate.
// Pressing the button allows editing the tags only, with the text still being displayed in wikified form.
//
var oldTagsHandler = config.macros.tags.handler;
config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
oldTagsHandler.apply(this, arguments);
abego.IntelliTagger.createEditTagsButton(tiddler, createTiddlyElement(place.lastChild,"li"));
};
// close the Suggestion Window when the tiddler is no longer edited
// (i.e. the tag edit inputfield is gone.)
//
// (Note: we must poll this condition since onblur on the input field
// cannot be used since every click into the suggestion window results
// in a lost focus/blur)
//
var closeIfAnchorElementIsHidden = function() {
if (fSuggestionPopup && fAnchorElement && !abego.isDescendantOrSelf(document, fAnchorElement))
abego.IntelliTagger.close();
};
setInterval(closeIfAnchorElementIsHidden, 100);
//----------------------------------------------------------------------------
// The public API
//----------------------------------------------------------------------------
// @param suggestedTags
// array of strings representing the tags to be suggested.
//
// @param activeTags
// array of strings representing the tags currently "active".
//
// @param favoriteTags [optional]
// a subset of the suggested tags that are "favorites".
// I.e. They should be presented first etc.
//
// @param anchorElement [optional]
// when defined the suggestions are displayed "close" to the anchorElement.
// The page is scrolled to make the anchorElement visible.
// When the anchorElement is not defined the suggestions are displayed in the
// center of the window.
//
// @param onTagSelected [optional]
// function(tag, e) to be called when a tag is selected.
//
abego.IntelliTagger.displayTagSuggestions = function(suggestedTags, activeTags, favoriteTags, anchorElement, onTagSelected) {
fSuggestedTags = suggestedTags;
fActiveTagSet = abego.toSet(activeTags);
fFavoriteTags = favoriteTags;
fAnchorElement = anchorElement;
fOnTagSelected = onTagSelected;
if (!fSuggestionPopup) {
fSuggestionPopup = createTiddlyElement(document.body,"div",null,"intelliTaggerSuggestions");
fSuggestionPopup.style.position = "absolute";
}
refreshPopup();
abego.openAsPopup(fSuggestionPopup);
if (getAnchorElement()) {
var w = getAnchorElement().offsetWidth;
if (fSuggestionPopup.offsetWidth < w) {
fSuggestionPopup.style.width = (w-2*(PADDING+BORDERWIDTH)) + "px";
}
abego.moveBelowAndClip(fSuggestionPopup, getAnchorElement());
} else {
abego.centerOnWindow(fSuggestionPopup);
}
scrollVisible();
};
// Shows the Tag Suggestion Popup for the given tiddler, below the specified inputField.
//
abego.IntelliTagger.assistTagging = function(inputField, tiddler) {
var filterRE = getFilter(inputField);
var s = inputField.value;
if (lastWordIsFilter(inputField))
s = removeLastWord(s);
var activeTags = s.readBracketedList();
var favoriteTags = activeTags.length > 0
? abego.filterStrings(abego.internal.getTagManager().getPartnerRankedTags(activeTags), filterRE, MAX_FAVORITE_TAGS)
: getInitialTagSuggestions(filterRE, MAX_FAVORITE_TAGS);
abego.IntelliTagger.displayTagSuggestions(
getAllFilteredTags(filterRE,activeTags),
activeTags,
favoriteTags,
inputField,
function(tag, e) {
if (e.shiftKey) {
onClickTag.call(this,e);
} else
updateTag(tag, inputField, tiddler);
});
};
// Closes the Tag Suggestions Popup
//
abego.IntelliTagger.close = function() {
abego.closePopup(fSuggestionPopup);
fSuggestionPopup = null;
return false;
};
// Creates an TiddlyButton at the given place to edit the tags of the given tiddler.
//
abego.IntelliTagger.createEditTagsButton = function(tiddler, place, text, tooltip, className, id, accessKey) {
if (!text) text = "[edit]";
if (!tooltip) tooltip = "Edit the tags";
if (!className) className = "editTags";
var editButton = createTiddlyButton(place,text,tooltip, onEditTags, className, id, accessKey);
editButton.setAttribute("tiddler", (tiddler instanceof Tiddler) ? tiddler.title : String(tiddler));
return editButton;
};
abego.IntelliTagger.getSuggestionTagsMaxCount = function() {
return 100;
};
//----------------------------------------------------------------------------
// Macros
//----------------------------------------------------------------------------
// ====Macro intelliTagger ================================================
config.macros.intelliTagger = {
// Standard Properties
label: "intelliTagger",
handler : function(place,macroName,params,wikifier,paramString,tiddler) {
var namesAndValues = paramString.parseParams("list",null, true);
var actions = namesAndValues[0]["action"];
for (var i = 0; actions && i < actions.length; i++) {
var actionName = actions[i];
var action = config.macros.intelliTagger.subhandlers[actionName];
if (!action)
abego.alertAndThrow("Unsupported action '%0'".format([actionName]));
action(place,macroName,params,wikifier,paramString,tiddler);
}
},
subhandlers: {
showTags : function(place,macroName,params,wikifier,paramString,tiddler) {
appendTags(place, fSuggestedTags, fFavoriteTags ? fFavoriteTags.length : 0, fFavoriteTags,abego.IntelliTagger.getSuggestionTagsMaxCount());
},
showFavorites : function(place,macroName,params,wikifier,paramString,tiddler) {
appendTags(place, fFavoriteTags, 0);
},
closeButton : function(place,macroName,params,wikifier,paramString,tiddler) {
var button = createTiddlyButton(place, "close", "Close the suggestions", abego.IntelliTagger.close);
},
version : function(place) {
var t = "IntelliTagger %0.%1.%2".format(
[version.extensions.IntelliTaggerPlugin.major,
version.extensions.IntelliTaggerPlugin.minor,
version.extensions.IntelliTaggerPlugin.revision]);
var e = createTiddlyElement(place, "a");
e.setAttribute("href", "http://tiddlywiki.abego-software.de/#IntelliTaggerPlugin");
e.innerHTML = '<font color="black" face="Arial, Helvetica, sans-serif">'+t+'<font>';
},
copyright : function(place) {
var e = createTiddlyElement(place, "a");
e.setAttribute("href", "http://tiddlywiki.abego-software.de");
e.innerHTML = '<font color="black" face="Arial, Helvetica, sans-serif">© 2006-2007 <b><font color="red">abego</font></b> Software<font>';
}
}
};
})();
//}}}
//#endOf: MainCode
//{{{
config.shadowTiddlers["IntelliTaggerStyleSheet"] =
"/***\n"+
"!~IntelliTagger Stylesheet\n"+
"***/\n"+
"/*{{{*/\n"+
".intelliTaggerSuggestions {\n"+
"\tposition: absolute;\n"+
"\twidth: 600px;\n"+
"\n"+
"\tpadding: 2px;\n"+
"\tlist-style: none;\n"+
"\tmargin: 0;\n"+
"\n"+
"\tbackground: #eeeeee;\n"+
"\tborder: 1px solid DarkGray;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .currentTag {\n"+
"\tfont-weight: bold;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .suggestionNumber {\n"+
"\tcolor: #808080;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .numberedSuggestion{\n"+
"\twhite-space: nowrap;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .intelliTaggerFooter {\n"+
"\tmargin-top: 4px;\n"+
"\tborder-top-width: thin;\n"+
"\tborder-top-style: solid;\n"+
"\tborder-top-color: #999999;\n"+
"}\n"+
".intelliTaggerSuggestions .favorites {\n"+
"\tborder-bottom-width: thin;\n"+
"\tborder-bottom-style: solid;\n"+
"\tborder-bottom-color: #999999;\n"+
"\tpadding-bottom: 2px;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .normalTags {\n"+
"\tpadding-top: 2px;\n"+
"}\n"+
"\n"+
".intelliTaggerSuggestions .intelliTaggerFooter .button {\n"+
"\tfont-size: 10px;\n"+
"\n"+
"\tpadding-left: 0.3em;\n"+
"\tpadding-right: 0.3em;\n"+
"}\n"+
"\n"+
"/*}}}*/\n";
config.shadowTiddlers["IntelliTaggerMainTemplate"] =
"<!--\n"+
"{{{\n"+
"-->\n"+
"<div class=\"favorites\" macro=\"intelliTagger action: showFavorites\"></div>\n"+
"<div class=\"normalTags\" macro=\"intelliTagger action: showTags\"></div>\n"+
"<!-- The Footer (with the Navigation) ============================================ -->\n"+
"<table class=\"intelliTaggerFooter\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tbody>\n"+
" <tr>\n"+
"\t<td align=\"left\">\n"+
"\t\t<span macro=\"intelliTagger action: closeButton\"></span>\n"+
"\t</td>\n"+
"\t<td align=\"right\">\n"+
"\t\t<span macro=\"intelliTagger action: version\"></span>, <span macro=\"intelliTagger action: copyright \"></span>\n"+
"\t</td>\n"+
" </tr>\n"+
"</tbody></table>\n"+
"<!--\n"+
"}}}\n"+
"-->\n";
config.shadowTiddlers["IntelliTaggerEditTagsTemplate"] =
"<!--\n"+
"{{{\n"+
"-->\n"+
"<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler'></div>\n"+
"<div class='title' macro='view title'></div>\n"+
"<div class='tagged' macro='tags'></div>\n"+
"<div class='viewer' macro='view text wikified'></div>\n"+
"<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler'></div>\n"+
"<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>\n"+
"<!--\n"+
"}}}\n"+
"-->\n";
config.shadowTiddlers["BSD open source license (abego Software)"] = "See [[Licence|http://tiddlywiki.abego-software.de/#%5B%5BBSD%20open%20source%20license%5D%5D]].";
config.shadowTiddlers["IntelliTaggerPlugin Documentation"] = "[[Documentation on abego Software website|http://tiddlywiki.abego-software.de/doc/IntelliTagger.pdf]].";
config.shadowTiddlers["IntelliTaggerPlugin SourceCode"] = "[[Plugin source code on abego Software website|http://tiddlywiki.abego-software.de/archive/IntelliTaggerPlugin/Plugin-IntelliTagger-src.1.0.2.js]]\n";
//}}}
//{{{
(function() {
var oldRestart = restart;
restart = function() {
setStylesheet(store.getTiddlerText('IntelliTaggerStyleSheet'),'IntelliTaggerStyleSheet');
oldRestart.apply(this,arguments);
}
})();
//}}}
//{{{
} // of single install
//}}}
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Lactobacillus lactis","strain":"Ssp. IL1403","location":true,"gram":"positive","pathogenicity":"commensal","Genome":"2365589","GC":"35"}</data>
Human Oral Microbiome Database (HOMD)
http://www.homd.org/
Human Gut Microbiome Initiative
http://genome.wustl.edu/hgm/HGM_frontpage.cgi
<<forEachTiddler
where
'tiddler.tags.contains("Actinobacteria")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Bacteria")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Bacteroidetes")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Commensal")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Firmicutes")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("PrimaryPathogen")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Probiotic")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("Proteobacteria")'
>>
<<forEachTiddler
where
'tiddler.tags.contains("systemConfig")'
>>
/***
|''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);
}
//}}}
[[WelcomeToTiddlyspot]]
GettingStarted
[[About]]
[[Human Microbiome Project]]
[[The Host]]
[[Microbial Genomes]]
[[Virulence Factors]]
[[Acknowledgements]]
[[References & Bibliography]]
[[Links and other interesting bits of information]]
[[List all Bacteria]]
[[List all Bacteroidetes]]
[[List all Firmicutes]]
[[List all Proteobacteria]]
[[List all Actinobacteria]]
[[List all Primary Pathogens]]
[[List all Probiotics]]
[[List all Commensals]]
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Ochrobactrum anthropi","location":true,"strain":"n/a","pathogenicity":"opportunist","gram":"negative"}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"pathogenicity":"opportunist","species":"Ochrobactrum intermedium","location":true,"strain":"n/a","gram":"negative"}</data>
<<formTiddler [[FormTemplateSpecies]]>>
<data>{"species":"Porphyromonas gingivalis","strain":"W83","Genome":"2343476","GC":"48","Topology=text/":"circular","gram":"negative","pathogenicity":"opportunist","location":true}</data>
<<formTiddler [[FormTemplateSpecies]]>><data>{"species":"Ruminococcus gnavus","strain":"ATCC 29149","location":true,"Genome":"n/a","GC":"n/a","gram":"unclassified","pathogenicity":"unclassified"}</data>
Microbiol Mol Biol Rev. 1998 Dec ;62 (4):1244-63 9841671 (P,S,E,B)
Life below the gum line: pathogenic mechanisms of Porphyromonas gingivalis
R J Lamont, H F Jenkinson
The microbial models of molecular biology from genes to genomes
Rowland Davis
Molecular microbial ecology
Taylor & Francis
Microbial functional genomics
Jizhong Zhou et.al. - university ebrary
Microbial genetics edited by Morad A Abou - Sabe
Morad A Abou-sabe
Microbial genetics
Stanley Maloy
Colonization of mucosal surfaces
James Nataro et. al.
Gut ecology
Ailsa L. Hart et. al.
A systematic review of literature to determine if the use of probiotics are effective in the treatment of irritable bowel syndrome.
Karin Ingrid Lee
Probiotics: the scientific basis
Roy Fuller
Intestinal microbiology
Bohumil Drasar
Bioinformatics: sequence and genome analysis
David Mount
The normal intestinal microbiota
Marchesi & Shanahan
Molecular analysis of the bacterial microbiota in the human stomach
Bik et. al.
Diversity of the human intestinal microbial flora
Bil et. al.
Metagenomic analysis of the human distal gut microbiome
Gill et. al.
Layers of mutualism with commensal bacteria protect us from intestinal inflammation
Mueller & Macpherson
Efficacy of an encapsulated probiotic Bifidobacterium infantis 35624
Whorwell et. al.
Microbial Inhabitants of Humans
Wilson M.
version.extensions.SinglePageMode= {major: 2, minor: 6, revision: 0, date: new Date(2008,3,1)};
if (config.options.chkSinglePageMode==undefined) config.options.chkSinglePageMode=false;
if (config.options.chkSinglePagePermalink==undefined) config.options.chkSinglePagePermalink=true;
if (config.options.chkTopOfPageMode==undefined) config.options.chkTopOfPageMode=false;
if (config.options.chkBottomOfPageMode==undefined) config.options.chkBottomOfPageMode=false;
if (config.options.chkSinglePageAutoScroll==undefined) config.options.chkSinglePageAutoScroll=true;
if (config.optionsDesc) {
config.optionsDesc.chkSinglePageMode="Display one tiddler at a time";
config.optionsDesc.chkSinglePagePermalink="Automatically permalink current tiddler";
config.optionsDesc.chkSinglePageAutoScroll="Automatically scroll tiddler into view (if needed)";
config.optionsDesc.chkTopOfPageMode="Always open tiddlers at the top of the page";
config.optionsDesc.chkBottomOfPageMode="Always open tiddlers at the bottom of the page";
} else {
config.shadowTiddlers.AdvancedOptions += "\
\n<<option chkSinglePageMode>> Display one tiddler at a time \
\n<<option chkSinglePagePermalink>> Automatically permalink current tiddler \
\n<<option chkSinglePageAutoScroll>> Automatically scroll tiddler into view (if needed) \
\n<<option chkTopOfPageMode>> Always open tiddlers at the top of the page \
\n<<option chkBottomOfPageMode>> Always open tiddlers at the bottom of the page";
}
config.SPMTimer = 0;
config.lastURL = window.location.hash;
function checkLastURL()
{
if (!config.options.chkSinglePageMode)
{ window.clearInterval(config.SPMTimer); config.SPMTimer=0; return; }
if (config.lastURL == window.location.hash)
return;
var tiddlerName = convertUTF8ToUnicode(decodeURIComponent(window.location.hash.substr(1)));
tiddlerName=tiddlerName.replace(/\[\[/,"").replace(/\]\]/,""); // strip any [[ ]] bracketing
if (tiddlerName.length) story.displayTiddler(null,tiddlerName,1,null,null);
}
if (Story.prototype.SPM_coreDisplayTiddler==undefined) Story.prototype.SPM_coreDisplayTiddler=Story.prototype.displayTiddler;
Story.prototype.displayTiddler = function(srcElement,title,template,animate,slowly)
{
if (config.options.chkSinglePageMode)
story.closeAllTiddlers(title);
else if (config.options.chkTopOfPageMode)
arguments[0]=null;
else if (config.options.chkBottomOfPageMode)
arguments[0]="bottom";
if (config.options.chkSinglePageMode && config.options.chkSinglePagePermalink && !config.browser.isSafari) {
window.location.hash = encodeURIComponent(convertUnicodeToUTF8(String.encodeTiddlyLink(title)));
config.lastURL = window.location.hash;
document.title = wikifyPlain("SiteTitle") + " - " + title;
if (!config.SPMTimer) config.SPMTimer=window.setInterval(function() {checkLastURL();},1000);
}
this.SPM_coreDisplayTiddler.apply(this,arguments); // let CORE render tiddler
var tiddlerElem=document.getElementById(story.idPrefix+title);
if (tiddlerElem&&config.options.chkSinglePageAutoScroll) {
var yPos=ensureVisible(tiddlerElem); // scroll to top of tiddler
var isTopTiddler=(tiddlerElem.previousSibling==null);
if (config.options.chkSinglePageMode||config.options.chkTopOfPageMode||isTopTiddler)
yPos=0; // scroll to top of page instead of top of tiddler
if (config.options.chkAnimate) // defer scroll until 200ms after animation completes
setTimeout("window.scrollTo(0,"+yPos+")",config.animDuration+200);
else
window.scrollTo(0,yPos); // scroll immediately
}
}
if (Story.prototype.SPM_coreDisplayTiddlers==undefined) Story.prototype.SPM_coreDisplayTiddlers=Story.prototype.displayTiddlers;
Story.prototype.displayTiddlers = function(srcElement,titles,template,unused1,unused2,animate,slowly)
{
// suspend single-page mode (and/or top/bottom display options) when showing multiple tiddlers
var saveSPM=config.options.chkSinglePageMode; config.options.chkSinglePageMode=false;
var saveTPM=config.options.chkTopOfPageMode; config.options.chkTopOfPageMode=false;
var saveBPM=config.options.chkBottomOfPageMode; config.options.chkBottomOfPageMode=false;
this.SPM_coreDisplayTiddlers.apply(this,arguments);
config.options.chkBottomOfPageMode=saveBPM;
config.options.chkTopOfPageMode=saveTPM;
config.options.chkSinglePageMode=saveSPM;
}
an online information resource on the genome data of the human gut microbiota
[img[http://www.imcpl.org/kids/guides/images/digestivesystem.gif]]
Ref: Img from Indianapolis Marion County Public Library
http://www.imcpl.org/
The human body serves as a great habitat to many microorganisms, with their cells outnumbering human cells by a factor of ten to one. A large amount of these microorganisms live within the gastrointestinal tract, usually living as commensals until their virulence factors are turned on, after which they act as pathogens and give us various illnesses,
/***
Contains the stuff you need to use Tiddlyspot
Note you must also have UploadPlugin installed
***/
//{{{
// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'hong123';
// 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)
// 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,{
'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 Guides|http://tiddlywikiguides.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help. If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// @@ We hope you like using your tiddlyspot.com site. Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),
'TspotControls':[
"| tiddlyspot password:|<<option pasUploadPassword>>|",
"| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<<br>>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
"| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[announcements|http://announce.tiddlyspot.com/]], [[blog|http://tiddlyspot.com/blog/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].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"),
'TspotOptions':[
"tiddlyspot password:",
"<<option pasUploadPassword>>",
""
].join("\n")
});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 19/04/2008 23:29:38 | Hong | [[/|http://hong123.tiddlyspot.com/]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 20/04/2008 15:34:19 | Hong | [[/|http://hong123.tiddlyspot.com/]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . | ok |
| 20/04/2008 15:45:05 | Hong | [[/|http://hong123.tiddlyspot.com/]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . | ok |
| 20/04/2008 16:05:48 | Hong | [[/|http://hong123.tiddlyspot.com/]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 20/04/2008 16:05:52 | Hong | [[/|http://hong123.tiddlyspot.com/]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 21/04/2008 03:47:30 | Hong | [[/|http://hong123.tiddlyspot.com/#%5B%5BList%20all%20Bacteria%5D%5D]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . | ok |
| 21/04/2008 04:55:05 | Hong | [[/|http://hong123.tiddlyspot.com/#%5B%5BHuman%20Microbiome%20Project%5D%5D]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 21/04/2008 05:31:58 | Hong | [[/|http://hong123.tiddlyspot.com/#%5B%5BA.%20odontolyticus%5D%5D]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 21/04/2008 10:10:33 | Hong | [[/|http://hong123.tiddlyspot.com/#Acknowledgements]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
| 21/04/2008 13:44:10 | Hong | [[/|http://hong123.tiddlyspot.com/#SinglePageModePlugin]] | [[store.cgi|http://hong123.tiddlyspot.com/store.cgi]] | . | [[index.html | http://hong123.tiddlyspot.com/index.html]] | . |
/***
|''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:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.0|
|''Date:''|May 5, 2007|
|''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 (#3125)|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
major: 4, minor: 1, revision: 0,
date: new Date("May 5, 2007"),
source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0 (#3125)'
};
//
// 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
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}
]);
},
refreshOptions: function(listWrapper) {
var uploadOpts = [
"txtUploadUserName",
"pasUploadPassword",
"txtUploadStoreUrl",
"txtUploadDir",
"txtUploadFilename",
"txtUploadBackupDir",
"chkUploadLog",
"txtUploadLogMaxLine",
]
var opts = [];
for(i=0; i<uploadOpts.length; i++) {
var opt = {};
opts.push()
opt.option = "";
n = uploadOpts[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 = 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,null,null,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 = Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
bidix.upload.httpUpload(rssUploadParams,convertUnicodeToUTF8(generateRss()),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 == httpStatus.NotFound)
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; 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');
/* don't want this for tiddlyspot sites
// Backstage
merge(config.tasks,{
uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");
*/
//}}}
http://hong1234.tiddlyspot.com/
Type the text for 'virulence factors'