Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
Installation et customization new BidiXTW site.
Announce of new BidiXTW : It's BidiXTW version 5 !
Background: #fff
Foreground: #333
PrimaryPale: #FFBFBF
PrimaryLight: #BF2323
PrimaryMid: #BF2323
PrimaryDark: #660000
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #ff0000
<<viewPalette>>
<!--{{{-->
<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>
<div class='title' macro='view title'></div>
<div class="editLabel">Title</div><div class="editor" macro="edit title"></div>
<div class="editLabel">Tags</div><div class="editor" macro="edit tags"></div>
<div class="editorFooter"><span macro="message views.editor.tagPrompt"></span><span macro="tagChooser"></span></div>
<div macro="showWhenExists EditPanelTemplate">[[EditPanelTemplate]]</div>
<div class='editor' macro='edit text'></div>
<!--}}}-->
<<search>>
<<closeAll>>
<<newTiddler tag:News >>
<<newJournal title:'0DD/0MM/YYYY' label: "nouveau journal" tag:Changes tag:excludeLists>>
----
<<saveChanges>>
<<uploadToHome>>
<html><a href=download.php class='button'>download</a></html>
----
<<changeMode Reader>>
{{isdirty{<<tiddler IsDirty>>}}}<<changeMode Author>>
<<changeMode>>
Author : <<option txtUserName>>
<!--{{{-->
<div id='header' class='header'>
<div id='topMenu' refresh='content' tiddler='TopMenu'></div>
<div class='siteTitle'>
<span refresh='content' tiddler='IsDirty'></span>
<span refresh='content' tiddler='SiteTitle'></span>
</div>
<div class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></div>
</div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='AuthorMenu'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='AuthorSidebarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<<tabs txtMainTab "Chrono" "Affichage chronologique des éléments utilisateur" UserTabTimeline "Alpha" "Liste aphabétique des éléments utilisateur" TabUser "Index" "Liste des index utilisateur" UserTabTags>>
[[CommunStyleSheet]]
/*{{{*/
body {
margin: 0 30px 0 30px;
}
#sidebarTabs {
font-size: .8em;
line-height: 1em;
}
/*}}}*/
<!--{{{-->
<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler > fields syncing permalink references jump'></div>
<div class='title'>
<span class='title' macro='view title'></span>
<!--<span macro="miniTag">--></span>
</div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date [[DD MMM YYYY]]'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date [[DD MMM YYYY]]'></span>)</div>
<div class='tagged' macro='tags'></div>
<div class='tagClear'></div>
<div class='viewer' macro='view text wikified'></div>
<div macro="showWhenTagged [[systemList]]">
<div class='viewer' macro="listByTag '' created ''"></div>
</div>
<div class='tagging' macro='tagging'></div>
<div class='tagClear'></div>
<!--}}}-->
/***
|''Name:''|AutoWeavePlugin|
|''Description:''|Automatically adds brackets to nonwikiwords on saving a tiddler.|
|''Version:''|0.1 (March 09, 2007)|
|''Source:''|http://weave.tiddlyspot.com/index.html#AutoWeavePlugin|
|''Author:''|laurence man|
|''[[License]]:''|[[BSD open source license]]|
|''~CoreVersion:''|2.1.0|
|''Browser:''|Tested on: Firefox 2.0; InternetExplorer 6.0|
|''Patched:''|*Don't AutoWeave tiddlers tagged 'admin' <br>*changes [[excludeLists]] by [[admin]] in selected tiddlers<br>*don't AutoWeave when in adminMode|
!Description
Inspired by [[this|http://groups.google.com/group/TiddlyWiki/browse_thread/thread/93b8de752492ddc4/b0608ebb1149578c]] post on the tiddlywiki google group, and with helpful comments by Eric Shulman, this plugin automatically adds enclosing double brackets to nonwikiwords (i.e., auto linking them) on saving a tiddler. This does not affect the usual autolinking of wikiword tiddler titles.
A nonwikiword tiddler title will be double bracketed if it is found in the tiddler text, and if the title does not have any letters or numbers around it.
!Usage
By default only the first occurrence of each nonwikiword title in the text is auto-bracketed. To bracket all occurrences, change the following line in the below code:
{{{
var replaceOnlyFirst = false;
}}}
to
{{{
var replaceOnlyFirst = false;
}}}
You can also specify a list of tiddler titles that you do not want to be auto-bracketed. By default, the name of the tiddler containing the titles to exclude is called {{{noAutoLink}}}. That name can be specified by changing the following line in the code below:
{{{
var excludeThese = "noAutoLink";
}}}
to
{{{
var excludeThese = "whatever you want";
}}}
In your "noAutoTag" tiddler, each line should contain only one tiddler title to exclude from auto-bracketing. Don't add any spaces on that line unless they are in the tiddler title itself. For example:
{{{
montypython
xmas list - 2007
culture of capitalism - notes
}}}
!Problems/Limitations/Notes
* Can't handle tiddler titles with square brackets in them so they're ignored.
* Can choose to autolink only first occurrence of title, but if you edit the tiddler later and add that title into the tiddler text before the first occurrence of the title, it will be bracketed.
* Shadowed tiddlers and tiddlers tagged with "[[excludeLists]]" are not auto-bracketed.
!Code
***/
//{{{
TiddlyWiki.prototype.saveTiddler_weaveLinks =
TiddlyWiki.prototype.saveTiddler;
TiddlyWiki.prototype.saveTiddler =
function(title,newTitle,newBody,modifier,modified,tags)
{
/*
* BidiX : if mode = admin, no AutoWeave
*/
if ((config.macros.changeMode) && (config.macros.changeMode.currentMode == '') )
return this.saveTiddler_weaveLinks.apply(this, arguments);
// User settings
var replaceOnlyFirst = true;
var excludeThese = "noAutoLink";
// Don't tag the list of tiddler titles to exclude.
if (title == excludeThese)
return this.saveTiddler_weaveLinks.apply(this, arguments);
var tagArray = tags.readBracketedList();
if (tagArray && tagArray.contains('admin'))
return this.saveTiddler_weaveLinks.apply(this, arguments);
// Helpers
// ------------------------------------------------------------------------
// To sort titles into descending length.
var compareDescLen = function(a, b)
{
if (a.length == b.length) return 0;
return b.length - a.length;
}
var isBounded = function(start, end)
// [[Test]] if tiddler title has a non-alphanum char (or nothing) on each side.
// Takes both indices of the title match, along with the title itself.
{
var reAlphaNum = new RegExp("\[\A-Za-z0-9\]");
return !(start != 0 && reAlphaNum.test(newBody.substr(start - 1, 1)) ||
end != newBody.length - 1 &&
reAlphaNum.test( newBody.substr(end + 1, 1)));
}
var isBracketed = function(start, end)
// Is matched string within given indices enclosed in pairs of brackets?
// Assumes brackets aren't allowed in titles (even tiddler text);
// bumping into pair of non-enclosing brackets means string isn't enclosed.
{
var foundL = false;
var foundR = false;
// Start from char just before title up to second char in newBody.
for (var i = start - 1; i > 0; i--)
{
if (newBody.charAt(i) == ']' && newBody.charAt(i - 1) == ']')
return false;
if (newBody.charAt(i) == '[' && newBody.charAt(i - 1) == '[')
{
foundL = true;
break;
}
}
// Look from next char after title up to second last char.
for (var i = end + 1; i < newBody.length - 1; i++)
{
if (newBody.charAt(i) == '[' && newBody.charAt(i + 1) == '[')
return false;
if (newBody.charAt(i) == ']' && newBody.charAt(i + 1) == ']')
{
foundR = true;
break;
}
}
return foundL && foundR;
}
var isNonWikiWord = function(word)
// No brackets though they're allowed in tiddler titles.
{
return (word.indexOf(" ") != -1 ||
word.search(config.textPrimitives.wikiLink) == -1) &&
word.indexOf("[") == -1 &&
word.indexOf("]") == -1;
}
var isUsrExcluded = function(currTitle)
// Checks given tiddler title against those in the excluded list.
{
if (excludeArr)
{
for(var i = 0; i < excludeArr.length; i++)
if (excludeArr[i] == currTitle) return true;
}
return false;
}
// var tids = store.getTiddlers("title","excludeLists");
var tids = store.getTiddlers("title","admin");
var arr = new Array(tids.length); // Titles to use: to be filtered, sorted.
var arrLen = 0; // Number of titles.
var matchIdx; // Index of a matching title.
var searchIdx; // Searching from this index in newBody.
var excludeArr;
var titlesToExclude = store.getTiddlerText(excludeThese);
// split(/\n/) might not be ok with IE?
if (titlesToExclude) excludeArr = titlesToExclude.split('\n');
// Filter list of titles.
for (var i = 0; i < arr.length; i++)
{
if (isNonWikiWord(tids[i].title) && !isUsrExcluded(tids[i].title))
{
arr[arrLen] = tids[i].title;
arrLen++;
}
}
arr.sort(compareDescLen);
// Main loop
for (var i = 0; i < arrLen; i++)
{
searchIdx = 0; // Start search for title at start of newBody.
// If a match, replace if not bracketed and if it is free of alphanum
// on either side. Search again from end of matching title in newBody.
// Should maybe rewrite this using regexp.exec.
for ( ; ;)
{
matchIdx = newBody.indexOf(arr[i], searchIdx);
if (matchIdx == -1) break;
var brackets = isBracketed(matchIdx, matchIdx + arr[i].length - 1);
if (brackets && replaceOnlyFirst) break;
if (isBounded(matchIdx, matchIdx + arr[i].length - 1, arr[i])
&& !brackets)
{
newBody = newBody.substring(0, matchIdx) +
"[[" + arr[i] + "]]" +
newBody.substring(matchIdx + arr[i].length);
if (replaceOnlyFirst) break;
}
searchIdx = matchIdx + arr[i].length + 1;
}
}
return this.saveTiddler_weaveLinks.apply(this, arguments);
}
//}}}
<<tiddler BSDOpenSourceLicense>>
Copyright (c) 2005-2008, BidiX (http://BidiX.info)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*Neither the name of BidiX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
From ages we are looking for a method to manage backup files and I had something like this (http://groups.google.com/group/TiddlyWiki/msg/d8e5d0d6be082ada?hl=en&) on my TodoList for more than a year !
I've now coded a method in [[store.php]] that maintains the size of the backup directory on the web server near a constant size.
Here is how it works. In store.php each time a new backup file is stored, the backup directory is scanned for files with the same prefix as the uploaded file and it holds only :
*the last file of each preceding month,
*the last file for each preceding week of the current month
*the last file for each preceding day of the current week
*the last file for each preceding hour of the current day
*all the file of the current hour
Without the files of the current hour, the number of files in the backup directory for the last year is less than 24 + 7 + 5 + 12 = 48. With an average of 1Mo per backup file, the size of the backup folder should never reach 50 Mo for the last year and 12 Mo more for each previous year.
|''URL:''|http://tiddlyhome.bidix.info/systemServer/basicContent.html|
|''Description:''|Repository for BidiX's basicContent|
|''Author:''|BidiX|
Contact : [[BidiX @ bidix . info|mailto:BidiX@BidiX.info]]
URL : [[BidiX.info|http://BidiX.info/]]
Donation : [[Donation via Paypal|https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=BidiX%40bidix%2einfo&item_name=TiddlyWikiHacking%20Donations&item_number=Donations&no_shipping=2&no_note=1&tax=0¤cy_code=EUR&bn=PP%2dDonationsBF&charset=UTF%2d8]]
|''URL:''|http://tiddlywiki.bidix.info/|
|''Description:''|Repository for BidiX's TiddlyWiki Extensions|
|''Author:''|BidiX|
<<rssReader asHtml http://tiddlywiki.bidix.info/index.xml>>
The vertical used for BidiX's sites has been upgraded to NewsWiki Version 1.2.0.
To learn more on NewsWiki visit http://TiddlyHome.bidix.info/NewsWiki or in french http://TiddlyHome.bidix.info/NewsWikiFR
Comments and suggestions are welcome.
<<rssReader asHtml http://news.com.com/2547-1_3-0-20.xml>>
/***
''Name:'' CalendarPlugin
''Version:'' <<getversion calendar>> (<<getversiondate calendar "DD MMM YYYY">>)
''Author:'' SteveRumsby
''Configuration:''
|''First day of week:''|<<option txtCalFirstDay>>|(Monday = 0, Sunday = 6)|
|''First day of weekend:''|<<option txtCalStartOfWeekend>>|(Monday = 0, Sunday = 6)|
''Syntax:''
|{{{<<calendar>>}}}|Produce a full-year calendar for the current year|
|{{{<<calendar year>>}}}|Produce a full-year calendar for the given year|
|{{{<<calendar year month>>}}}|Produce a one-month calendar for the given month and year|
|{{{<<calendar thismonth>>}}}|Produce a one-month calendar for the current month|
|{{{<<calendar lastmonth>>}}}|Produce a one-month calendar for last month|
|{{{<<calendar nextmonth>>}}}|Produce a one-month calendar for next month|
***/
// //Modify this section to change the text displayed for the month and day names, to a different language for example. You can also change the format of the tiddler names linked to from each date, and the colours used.
// // ''[[Changes]] by ELS 2005.10.30:''
// // config.macros.calendar.handler()
// // ^^use "tbody" element for IE compatibility^^
// // ^^IE returns 2005 for current year, FF returns 105... fix year adjustment accordingly^^
// // createCalendarDays()
// // ^^use showDate() function (if defined) to render autostyled date with linked popup^^
// // calendar stylesheet definition
// // ^^use .calendar class-specific selectors, add text centering and margin settings^^
//{{{
config.macros.calendar = {};
config.macros.calendar.monthnames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
config.macros.calendar.daynames = ["M", "T", "W", "T", "F", "S", "S"];
config.macros.calendar.weekendbg = "#c0c0c0";
config.macros.calendar.monthbg = "#e0e0e0";
config.macros.calendar.holidaybg = "#ffc0c0";
//}}}
// //''Code section:''
// (you should not need to alter anything below here)//
//{{{
if(config.options.txtCalFirstDay == undefined)
config.options.txtCalFirstDay = 0;
if(config.options.txtCalStartOfWeekend == undefined)
config.options.txtCalStartOfWeekend = 5;
config.macros.calendar.tiddlerformat = "0DD/0MM/YYYY"; // This used to be changeable - for now, it isn't// <<smiley :-(>>
version.extensions.calendar = { major: 0, minor: 6, revision: 0, date: new Date(2006, 1, 22)};
config.macros.calendar.monthdays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
config.macros.calendar.holidays = [ ]; // Not sure this is required anymore - use reminders instead
//}}}
// //Is the given date a holiday?
//{{{
function calendarIsHoliday(date)
{
var longHoliday = date.formatString("0DD/0MM/YYYY");
var shortHoliday = date.formatString("0DD/0MM");
for(var i = 0; i < config.macros.calendar.holidays.length; i++) {
if(config.macros.calendar.holidays[i] == longHoliday || config.macros.calendar.holidays[i] == shortHoliday) {
return true;
}
}
return false;
}
//}}}
// //The main entry point - the macro handler.
// //Decide what sort of calendar we are creating (month or year, and which month or year)
// // Create the main calendar container and pass that to sub-ordinate functions to create the structure.
// ELS 2005.10.30: added creation and use of "tbody" for IE compatibility and fixup for year >1900//
// ELS 2005.10.30: fix year calculation for IE's getYear() function (which returns '2005' instead of '105')//
//{{{
config.macros.calendar.handler = function(place,macroName,params)
{
var calendar = createTiddlyElement(place, "table", null, "calendar", null);
var tbody = createTiddlyElement(calendar, "tbody", null, null, null);
var today = new Date();
var year = today.getYear();
if (year<1900) year+=1900;
if (params[0] == "thismonth")
{
cacheReminders(new Date(year, today.getMonth(), 1, 0, 0), 31);
createCalendarOneMonth(tbody, year, today.getMonth());
}
else if (params[0] == "lastmonth") {
var month = today.getMonth()-1; if (month==-1) { month=11; year--; }
cacheReminders(new Date(year, month, 1, 0, 0), 31);
createCalendarOneMonth(tbody, year, month);
}
else if (params[0] == "nextmonth") {
var month = today.getMonth()+1; if (month>11) { month=0; year++; }
cacheReminders(new Date(year, month, 1, 0, 0), 31);
createCalendarOneMonth(tbody, year, month);
}
else {
if (params[0]) year = params[0];
if(params[1])
{
cacheReminders(new Date(year, params[1]-1, 1, 0, 0), 31);
createCalendarOneMonth(tbody, year, params[1]-1);
}
else
{
cacheReminders(new Date(year, 0, 1, 0, 0), 366);
createCalendarYear(tbody, year);
}
}
window.reminderCacheForCalendar = null;
}
//}}}
//{{{
//This global variable is used to store reminders that have been cached
//while the calendar is being rendered. It will be renulled after the calendar is fully rendered.
window.reminderCacheForCalendar = null;
//}}}
//{{{
function cacheReminders(date, leadtime)
{
if (window.findTiddlersWithReminders == null)
return;
window.reminderCacheForCalendar = {};
var leadtimeHash = [];
leadtimeHash [0] = 0;
leadtimeHash [1] = leadtime;
var t = findTiddlersWithReminders(date, leadtimeHash, null, 1);
for(var i = 0; i < t.length; i++) {
//just tag it in the cache, so that when we're drawing days, we can bold this one.
window.reminderCacheForCalendar[t[i]["matchedDate"]] = "reminder:" + t[i]["params"]["title"];
}
}
//}}}
//{{{
function createCalendarOneMonth(calendar, year, mon)
{
var row = createTiddlyElement(calendar, "tr", null, null, null);
createCalendarMonthHeader(calendar, row, config.macros.calendar.monthnames[mon] + " " + year, true, year, mon);
row = createTiddlyElement(calendar, "tr", null, null, null);
createCalendarDayHeader(row, 1);
createCalendarDayRowsSingle(calendar, year, mon);
}
//}}}
//{{{
function createCalendarMonth(calendar, year, mon)
{
var row = createTiddlyElement(calendar, "tr", null, null, null);
createCalendarMonthHeader(calendar, row, config.macros.calendar.monthnames[mon] + " " + year, false, year, mon);
row = createTiddlyElement(calendar, "tr", null, null, null);
createCalendarDayHeader(row, 1);
createCalendarDayRowsSingle(calendar, year, mon);
}
//}}}
//{{{
function createCalendarYear(calendar, year)
{
var row;
row = createTiddlyElement(calendar, "tr", null, null, null);
var back = createTiddlyElement(row, "td", null, null, null);
var backHandler = function() {
removeChildren(calendar);
createCalendarYear(calendar, year-1);
};
createTiddlyButton(back, "<", "Previous year", backHandler);
back.align = "center";
var yearHeader = createTiddlyElement(row, "td", null, "calendarYear", year);
yearHeader.align = "center";
yearHeader.setAttribute("colSpan", 19);
var fwd = createTiddlyElement(row, "td", null, null, null);
var fwdHandler = function() {
removeChildren(calendar);
createCalendarYear(calendar, year+1);
};
createTiddlyButton(fwd, ">", "Next year", fwdHandler);
fwd.align = "center";
createCalendarMonthRow(calendar, year, 0);
createCalendarMonthRow(calendar, year, 3);
createCalendarMonthRow(calendar, year, 6);
createCalendarMonthRow(calendar, year, 9);
}
//}}}
//{{{
function createCalendarMonthRow(cal, year, mon)
{
var row = createTiddlyElement(cal, "tr", null, null, null);
createCalendarMonthHeader(cal, row, config.macros.calendar.monthnames[mon], false, year, mon);
createCalendarMonthHeader(cal, row, config.macros.calendar.monthnames[mon+1], false, year, mon);
createCalendarMonthHeader(cal, row, config.macros.calendar.monthnames[mon+2], false, year, mon);
row = createTiddlyElement(cal, "tr", null, null, null);
createCalendarDayHeader(row, 3);
createCalendarDayRows(cal, year, mon);
}
//}}}
//{{{
function createCalendarMonthHeader(cal, row, name, nav, year, mon)
{
var month;
if(nav) {
var back = createTiddlyElement(row, "td", null, null, null);
back.align = "center";
back.style.background = config.macros.calendar.monthbg;
/*
back.setAttribute("colSpan", 2);
var backYearHandler = function() {
var newyear = year-1;
removeChildren(cal);
cacheReminders(new Date(newyear, mon , 1, 0, 0), 31);
createCalendarOneMonth(cal, newyear, mon);
};
createTiddlyButton(back, "<<", "Previous year", backYearHandler);
*/
var backMonHandler = function() {
var newyear = year;
var newmon = mon-1;
if(newmon == -1) { newmon = 11; newyear = newyear-1;}
removeChildren(cal);
cacheReminders(new Date(newyear, newmon , 1, 0, 0), 31);
createCalendarOneMonth(cal, newyear, newmon);
};
createTiddlyButton(back, "<", "Previous month", backMonHandler);
month = createTiddlyElement(row, "td", null, "calendarMonthname", name)
// month.setAttribute("colSpan", 3);
month.setAttribute("colSpan", 5);
var fwd = createTiddlyElement(row, "td", null, null, null);
fwd.align = "center";
fwd.style.background = config.macros.calendar.monthbg;
// fwd.setAttribute("colSpan", 2);
var fwdMonHandler = function() {
var newyear = year;
var newmon = mon+1;
if(newmon == 12) { newmon = 0; newyear = newyear+1;}
removeChildren(cal);
cacheReminders(new Date(newyear, newmon , 1, 0, 0), 31);
createCalendarOneMonth(cal, newyear, newmon);
};
createTiddlyButton(fwd, ">", "Next month", fwdMonHandler);
/*
var fwdYear = createTiddlyElement(row, "td", null, null, null);
var fwdYearHandler = function() {
var newyear = year+1;
removeChildren(cal);
cacheReminders(new Date(newyear, mon , 1, 0, 0), 31);
createCalendarOneMonth(cal, newyear, mon);
};
createTiddlyButton(fwd, ">>", "Next year", fwdYearHandler);
*/
} else {
month = createTiddlyElement(row, "td", null, "calendarMonthname", name)
month.setAttribute("colSpan", 7);
}
month.align = "center";
month.style.background = config.macros.calendar.monthbg;
}
//}}}
//{{{
function createCalendarDayHeader(row, num)
{
var cell;
for(var i = 0; i < num; i++) {
for(var j = 0; j < 7; j++) {
var d = j + (config.options.txtCalFirstDay - 0);
if(d > 6) d = d - 7;
cell = createTiddlyElement(row, "td", null, null, config.macros.calendar.daynames[d]);
if(d == (config.options.txtCalStartOfWeekend-0) || d == (config.options.txtCalStartOfWeekend-0+1))
cell.style.background = config.macros.calendar.weekendbg;
}
}
}
//}}}
//{{{
function createCalendarDays(row, col, first, max, year, mon)
{
var i;
for(i = 0; i < col; i++) {
createTiddlyElement(row, "td", null, null, null);
}
var day = first;
for(i = col; i < 7; i++) {
var d = i + (config.options.txtCalFirstDay - 0);
if(d > 6) d = d - 7;
var daycell = createTiddlyElement(row, "td", null, null, null);
var isaWeekend = ((d == (config.options.txtCalStartOfWeekend-0) || d == (config.options.txtCalStartOfWeekend-0+1))? true:false);
if(day > 0 && day <= max) {
var celldate = new Date(year, mon, day);
// ELS 2005.10.30: use <<date>> macro's showDate() function to create popup
if (window.showDate) {
showDate(daycell,celldate,"popup","DD","DD-MMM-YYYY",true, isaWeekend);
} else {
if(isaWeekend) daycell.style.background = config.macros.calendar.weekendbg;
var title = celldate.formatString(config.macros.calendar.tiddlerformat);
if(calendarIsHoliday(celldate)) {
daycell.style.background = config.macros.calendar.holidaybg;
}
if(window.findTiddlersWithReminders == null) {
var link = createTiddlyLink(daycell, title, false);
link.appendChild(document.createTextNode(day));
} else {
var button = createTiddlyButton(daycell, day, title, onClickCalendarDate);
}
}
}
day++;
}
}
//}}}
// //We've clicked on a day in a calendar - create a suitable pop-up of options.
// //The pop-up should contain:
// // * a link to create a new entry for that date
// // * a link to create a new reminder for that date
// // * an <hr>
// // * the list of reminders for that date
//{{{
function onClickCalendarDate(e)
{
var button = this;
var date = button.getAttribute("title");
var dat = new Date(date.substr(6,4), date.substr(3,2)-1, date.substr(0, 2));
date = dat.formatString(config.macros.calendar.tiddlerformat);
var popup = createTiddlerPopup(this);
popup.appendChild(document.createTextNode(date));
var newReminder = function() {
var t = store.getTiddlers(date);
displayTiddler(null, date, 2, null, null, false, false);
if(t) {
document.getElementById("editorBody" + date).value += "\n<<reminder day:" + dat.getDate() +
" month:" + (dat.getMonth()+1) +
" year:" + (dat.getYear()+1900) + " title: >>";
} else {
document.getElementById("editorBody" + date).value = "<<reminder day:" + dat.getDate() +
" month:" + (dat.getMonth()+1) +
" year:" + (dat.getYear()+1900) + " title: >>";
}
};
var link = createTiddlyButton(popup, "New reminder", null, newReminder);
popup.appendChild(document.createElement("hr"));
var t = findTiddlersWithReminders(dat, [0,14], null, 1);
for(var i = 0; i < t.length; i++) {
link = createTiddlyLink(popup, t[i].tiddler, false);
link.appendChild(document.createTextNode(t[i].tiddler));
}
}
//}}}
//{{{
function calendarMaxDays(year, mon)
{
var max = config.macros.calendar.monthdays[mon];
if(mon == 1 && (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
max++;
}
return max;
}
//}}}
//{{{
function createCalendarDayRows(cal, year, mon)
{
var row = createTiddlyElement(cal, "tr", null, null, null);
var first1 = (new Date(year, mon, 1)).getDay() -1 - (config.options.txtCalFirstDay-0);
if(first1 < 0) first1 = first1 + 7;
var day1 = -first1 + 1;
var first2 = (new Date(year, mon+1, 1)).getDay() -1 - (config.options.txtCalFirstDay-0);
if(first2 < 0) first2 = first2 + 7;
var day2 = -first2 + 1;
var first3 = (new Date(year, mon+2, 1)).getDay() -1 - (config.options.txtCalFirstDay-0);
if(first3 < 0) first3 = first3 + 7;
var day3 = -first3 + 1;
var max1 = calendarMaxDays(year, mon);
var max2 = calendarMaxDays(year, mon+1);
var max3 = calendarMaxDays(year, mon+2);
while(day1 <= max1 || day2 <= max2 || day3 <= max3) {
row = createTiddlyElement(cal, "tr", null, null, null);
createCalendarDays(row, 0, day1, max1, year, mon); day1 += 7;
createCalendarDays(row, 0, day2, max2, year, mon+1); day2 += 7;
createCalendarDays(row, 0, day3, max3, year, mon+2); day3 += 7;
}
}
//}}}
//{{{
function createCalendarDayRowsSingle(cal, year, mon)
{
var row = createTiddlyElement(cal, "tr", null, null, null);
var first1 = (new Date(year, mon, 1)).getDay() -1 - (config.options.txtCalFirstDay-0);
if(first1 < 0) first1 = first1+ 7;
var day1 = -first1 + 1;
var max1 = calendarMaxDays(year, mon);
while(day1 <= max1) {
row = createTiddlyElement(cal, "tr", null, null, null);
createCalendarDays(row, 0, day1, max1, year, mon); day1 += 7;
}
}
//}}}
// //ELS 2005.10.30: added styles
//{{{
setStylesheet(".calendar, .calendar table, .calendar th, .calendar tr, .calendar td { font-size:10pt; text-align:center; } .calendar, .calendar a { margin:0px !important; padding:0px !important; }", "calendarStyles");
//}}}
/***
|''Name:''|ChangeModePlugin|
|''Description:''|Change template and styleSheet|
|''Credits:''|SaqImtiaz for is PresentationPlugin|
|''Version:''|0.0.4|
|''Date:''|Jun 5, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#changeModePlugin|
|''Usage:''|{{{<<changeMode [newMode]>>}}}<br>{{{newMode: if omitted the default mode is applied}}}|
|''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.ChangeModePlugin =
{
major: 0, minor: 0, revision: 4,
date: new Date("Jun 9, 2007"),
source: 'http://tiddlywiki.bidix.info/#ChangeModePlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0'
};
// From SaqImtiaz's PresentationPlugin
//---------------------------------------------------
TiddlyWiki.prototype.isTiddler= function (title)
{
return store.tiddlerExists(title) || store.isShadowTiddler(title);
};
TiddlyWiki.prototype.removeNotification = function(title,fn)
{
for (var i=0; i<this.namedNotifications.length; i++)
if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
this.namedNotifications.splice(i,1);
};
Story.prototype.chooseTemplateForTiddler_core = Story.prototype.chooseTemplateForTiddler;
Story.prototype.chooseTemplateForTiddler = function(title,template)
{
if (!template)
template = DEFAULT_VIEW_TEMPLATE;
var mode = config.macros.changeMode.currentMode;
if (template == DEFAULT_VIEW_TEMPLATE) {
if (store.isTiddler(mode+"ViewTemplate"))
return mode+"ViewTemplate";
} else if (template == DEFAULT_EDIT_TEMPLATE) {
if (store.isTiddler(mode+"EditTemplate"))
return mode+"EditTemplate";
}
return this.chooseTemplateForTiddler_core(title,template);
}
Story.prototype.lewcidrefreshAllTiddlers = function()
{
var place = document.getElementById(this.container);
var e = place.firstChild;
if(!e) return;
this.refreshTiddler(e.getAttribute("tiddler"),null,true);
while((e = e.nextSibling) != null)
this.refreshTiddler(e.getAttribute("tiddler"),null,true);
}
//---------------------------------------------------
// manage different modes
//
// config.macros.changeMode.initMode: the name of the initial Mode
// config.macros.changeMode.readOnlyModes: array containing readOnly mode (no Backstage and readOnly)
//
config.macros.changeMode =
{
currentMode: '', // defaultMode
initMode: 'Reader',
readOnlyModes : ['Reader'],
noBackstage : ['Reader', 'Author'],
singlePageMode: ['Reader', 'Author'],
lingo: {
label: "%0 Mode",
prompt: "Change the current mode to '%0'",
modeName: {
Author: 'Author',
Reader: 'Reader',
'': '(default)'
}
},
handler: function(place,macroName,params) {
var newMode = (params[0] ? params[0]: ""); // default to ''
var newModeName = (this.lingo.modeName[newMode] ? this.lingo.modeName[newMode]: newMode); // default to ''
var label = this.lingo.label.format([newModeName]);
var prompt = this.lingo.prompt.format([newModeName]);
createTiddlyButton(place, label, prompt, function() {config.macros.changeMode.action(newMode);}, null, null, null);
},
action: function(template) {
config.macros.changeMode.applyMode(template);
},
defaults: [
{name: "StyleSheet", notify: refreshStyles},
{name: "PageTemplate", notify: refreshPageTemplate}
],
applyMode: function (newMode) {
var oldMode = this.currentMode;
var oldStyleElement = document.getElementById(oldMode+"StyleSheet");
if (oldStyleElement) {
oldStyleElement.parentNode.removeChild(oldStyleElement);
}
// change Palette
if (store.isTiddler(newMode + 'ColorPalette')) {
var tiddler = new Tiddler('ColorPalette');
tiddler.tags.push('admin');
if (!newMode) {
if (store.isTiddler('defaultColorPalette'))
tiddler.text = store.getTiddlerText('defaultColorPalette');
else
tiddler.text = config.shadowTiddlers['ColorPalette'];
} else {
tiddler.text = store.getTiddlerText(newMode + 'ColorPalette');
}
store.addTiddler(tiddler);
}
for (var i=0; i< this.defaults.length; i++)
{
var name = this.defaults[i]["name"];
var newElement = store.isTiddler(newMode + name) ? newMode + name : name;
store.removeNotification(oldMode + name, this.defaults[i]["notify"]);
store.addNotification(newElement,this.defaults[i]["notify"]);
store.notify(newElement); //just one do blanket notify instead?
}
if (backstage && !backstage.button)
backstage.init();
// change readOnly
if (this.readOnlyModes.indexOf(newMode) == -1) {
readOnly = false;
}
else {
readOnly = true;
}
// change backstage display
if (backstage && backstage.button) {
if (this.noBackstage.indexOf(newMode) == -1) {
backstage.button.style.display = "block";
}
else {
backstage.hide();
backstage.button.style.display = "none";
}
// change singlePageMode
if (this.singlePageMode.indexOf(newMode) == -1) {
config.options.chkSinglePageMode = false;
}
else {
config.options.chkSinglePageMode= true;
}
}
this.currentMode = newMode;
story.lewcidrefreshAllTiddlers ();
// store.refreshPalette();
store.notifyAll();
},
init: function() {
if (!store.isTiddler('defaultColorPalette'))
config.shadowTiddlers['defaultColorPalette'] = config.shadowTiddlers['ColorPalette'];
config.macros.changeMode.applyMode(this.initMode);
}
}
config.paramifiers.mode = {
onconfig: function(mode) {
if (mode == 'false')
config.macros.changeMode.initMode = null;
else
config.macros.changeMode.initMode = mode;
}
};
//}}}
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {
background:[[ColorPalette::Background]];
margin:0 auto;
font-size: 85%;
color: [[ColorPalette::Foreground]];
position: relative;
font-family: Helvetica, Arial, sans-serif;
}
h1,h2,h3,h4,h5 {
font-weight: normal;
padding-left: 0;
color: [[ColorPalette::TertiaryDark]];
background: transparent;
}
h1 {font-size: 1.5em; font-weight: normal;border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2 {font-size: 1.3em; border-bottom:0px;}
h3 {font-size: 1.1em; border-bottom:0px;}
h4 {font-size: 1em;}
h5 {font-size: .9em;}
ul, ul ul, ul ul ul {
list-style-image: url(http://tiddlyhome.bidix.info/_th/images/square.gif) ;
}
a {
color: [[ColorPalette::PrimaryMid]];
}
a:hover {
color: [[ColorPalette::PrimaryMid]];
background:transparent;
border-bottom:1px solid [[ColorPalette::PrimaryMid]];
}
.button {
color: [[ColorPalette::PrimaryMid]];
font-weight:bold;
}
#header {
background: [[ColorPalette::Background]];
padding: 0 0 0 0.4em;
height:1%;
}
.siteTitle {
padding: 1.5em 0 0 0;
font-weight: normal;
font-size: 3em;
color: [[ColorPalette::TertiaryDark]] ;
}
.siteSubtitle {
width: 33em;
padding: 0.3em 0em 0.2em 1em;
font-weight: bold;
font-size: 1em;
background: [[ColorPalette::PrimaryMid]];
color: [[ColorPalette::Background]];
}
#displayArea {
margin-left:0.5em;
margin-right:17.3em;
margin-top:3em;
padding-top:0em;
padding-bottom:10px;
padding-left: 1em;
}
/*}}}*/
/***
!!Sidebar
***/
/*{{{*/
#sidebar {
position:absolute;
width: 14em;
border-left:1px solid [[ColorPalette::TertiaryLight]];
padding-left:15px;
margin-top:0.5em;
font-size:1em;
line-height:1.5em;
font-family: Arial,em sans-serif;
background-color: [[ColorPalette::Background]];
}
#sidebar a {
display: inline;
font-weight: normal;
}
#sidebar h1,#sidebar h2,#sidebar h3,#sidebar h4,#sidebar h5 {
font-weight: normal;
margin-bottom:0em;
}
#sidebar h1 {
margin-left:-0.5em;
margin-bottom:0em;
}
#sidebar hr {
border:0;
border-bottom:1px solid [[ColorPalette::TertiaryLight]];
margin: 1em 0;
margin-left:-0.5em;
}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
/*}}}*/
/***
!!viewer
***/
/*{{{*/
.title {
font-size: 1.5em;
font-weight: normal;
color: [[ColorPalette::TertiaryDark]];
background:transparent;
margin: 0;
margin-bottom: .5em;
padding:0;
}
.viewer {
line-height:1.5em;
}
.tiddler {
padding:0;
margin:0;
padding-bottom:0.5em;
}
.externalLink {font-weight:bold;}
.externalLink:hover {border:none;}
.toolbar { visibility:hidden; }
.selected .toolbar { visibility:visible; }
.tagged, .tagging { float:left; }
.tagged li, .tagging li { display:inline; }
.tagged, .tagging { background:transparent !important; border:0 !important; }
.tagged .button {color: [[ColorPalette::TiertiaryPale]] !important; }
/*}}}*/
/***
!!Editor
***/
/*{{{*/
.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
/*}}}*/
/***
!!TopMenu
***/
/*{{{*/
#topMenu {
positon:relative; float:right; display:inline;
margin-left:3em;
margin-top:1em;
padding: 0.8em 0em;
}
#topMenu br {display:none; }
#topMenu a, #topMenu .tiddlyLink, #topMenu .button {
margin:0 1em;
color: [[ColorPalette::Foreground]];
margin-right:0;
margin-left:2em;
font-size: 18px;
font-family: Helvetica, sans-serif;
font-weight: normal;
font-style: normal;
}
#topMenu a:hover, #topMenu .activebutton {
border-bottom:5px
solid [[ColorPalette::PrimaryMid]];
}
.calendar, .calendar table, .calendar th, .calendar tr, .calendar td { font-size:12pt; text-align:center; } .calendar, .calendar a { margin:0px !important; padding:0px !important; }
/*}}}*/
/*{{{*/
@media print {
#topMenu {display: none ! important;}
}
/*}}}*/
#install [[download.php]] as a file on the webserver in the TiddlyWiki folder. Perhaps near by store.php
#Simply put {{{[[download|download.php?]]}}} in the SideBarOptions of TiddlyWiki*
#download as an attachement in one click on this link when viewed over HTTP
* If it is named index.html else put {{{[[download|download.php?file=yourTW.html]]}}}
----
| Name | Type |Version | Date | Core | Requires |
|[[download.php]] | serverside script | 1.1.1 | 2008-08-22 | | |
|HistoryPlugin | plugin | 1.0.0 | 2008-03-23 | 2.3 | |
|HttpGetMacro | plugin | 2.0.0 | Mar 18, 2007 | 2.2 | |
|IsDirtyPlugin | plugin | 1.0.2 | Apr 30, 2007 | 2.2 | |
|GenerateRssByTagPlugin | plugin | 1.0.3 | May 17, 2007 | 2.2 | |
|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack) | plugin | 1.1.0 | Mar 17, 2007 | 2.2 | |
|[[news.php]] | serverside script | 2.0.1 | May 13, 2007 | | |
|PasswordOptionPlugin | plugin | 1.0.1 | Jan 19, 2007 | 2.2 | |
|[[proxy.php]] | serverside script | 2.2.0 | Aug 3, 2007 | | [[allowedsites.txt]] |
|RSSReaderPlugin | plugin | 1.1.2 | 2008-09-02 | 2.2 | |
|[[store.php]] | serverside script | 1.6.1 | Aug 17, 2007 | | |
|[[storeTiddler.php]] | serverside script | 1.2.1 | 2008-05-06 | | |
|UploadPlugin | plugin | 4.1.4 | 2008-08-11 | 2.2 | PasswordOptionPlugin <<tag UploadService>> |
|UploadTiddlerMacro | plugin | 1.0.0 | 2008-09-30 | 2.2 | UploadTiddlerPlugin <<tag UploadService>> |
|UploadTiddlerPlugin | plugin | 1.2.2 | 2008-09-13 | 2.2 | PasswordOptionPlugin <<tag UploadService>> |
|UploadPluginLingoEN | plugin | 4.1.0 | May 8, 2007 | 2.2 | UploadPlugin |
|UploadPluginLingoFR | plugin | 4.1.0 | May 8, 2007 | 2.2 | UploadPlugin |
|UploadPluginLingoCA*<br>*Thanks to PacoRivière | plugin | 4.1.0 | July 15, 2007 | 2.2 | UploadPlugin |
|UploadToFileMacro | plugin | 2.0.1 | Apr 21, 2007 | 2.2 | UploadPlugin |
|UploadToHomeMacro | plugin | 0.0.2 | Apr 21, 2007 | 2.2 | UploadPlugin |
|--WebDAVSavingPlugin-- | --plugin-- | --0.2.1-- | --Apr 21, 2007-- | --2.2-- |Not maintained : Use SaqImtiaz [[WebDavPlugin|http://trac.tiddlywiki.org/browser/Trunk/contributors/SaqImtiaz/plugins/WebDavPlugin.js]]|
/***
|''Name:''|ForEachTiddlerPlugin|
|''Version:''|1.0.6 (2006-09-16)|
|''Source:''|http://tiddlywiki.abego-software.de/#ForEachTiddlerPlugin|
|''Author:''|UdoBorkowski (ub [at] abego-software [dot] de)|
|''Licence:''|[[BSD open source license (abego Software)|http://www.abego-software.de/legal/apl-v10.html]]|
|''Copyright:''|© 2005-2006 [[abego Software|http://www.abego-software.de]]|
|''TiddlyWiki:''|1.2.38+, 2.0|
|''Browser:''|Firefox 1.0.4+; Firefox 1.5; InternetExplorer 6.0|
!Description
Create customizable lists, tables etc. for your selections of tiddlers. Specify the tiddlers to include and their order through a powerful language.
''Syntax:''
|>|{{{<<}}}''forEachTiddler'' [''in'' //tiddlyWikiPath//] [''where'' //whereCondition//] [''sortBy'' //sortExpression// [''ascending'' //or// ''descending'']] [''script'' //scriptText//] [//action// [//actionParameters//]]{{{>>}}}|
|//tiddlyWikiPath//|The filepath to the TiddlyWiki the macro should work on. When missing the current TiddlyWiki is used.|
|//whereCondition//|(quoted) JavaScript boolean expression. May refer to the build-in variables {{{tiddler}}} and {{{context}}}.|
|//sortExpression//|(quoted) JavaScript expression returning "comparable" objects (using '{{{<}}}','{{{>}}}','{{{==}}}'. May refer to the build-in variables {{{tiddler}}} and {{{context}}}.|
|//scriptText//|(quoted) JavaScript text. Typically defines JavaScript functions that are called by the various JavaScript expressions (whereClause, sortClause, action arguments,...)|
|//action//|The action that should be performed on every selected tiddler, in the given order. By default the actions [[addToList|AddToListAction]] and [[write|WriteAction]] are supported. When no action is specified [[addToList|AddToListAction]] is used.|
|//actionParameters//|(action specific) parameters the action may refer while processing the tiddlers (see action descriptions for details). <<tiddler [[JavaScript in actionParameters]]>>|
|>|~~Syntax formatting: Keywords in ''bold'', optional parts in [...]. 'or' means that exactly one of the two alternatives must exist.~~|
See details see [[ForEachTiddlerMacro]] and [[ForEachTiddlerExamples]].
!Revision history
* v1.0.6 (2006-09-16)
** Context provides "viewerTiddler", i.e. the tiddler used to view the macro. Most times this is equal to the "inTiddler", but when using the "tiddler" macro both may be different.
** Support "begin", "end" and "none" expressions in "write" action
* v1.0.5 (2006-02-05)
** Pass tiddler containing the macro with wikify, context object also holds reference to tiddler containing the macro ("inTiddler"). Thanks to SimonBaird.
** Support Firefox 1.5.0.1
** Internal
*** Make "JSLint" conform
*** "Only install once"
* v1.0.4 (2006-01-06)
** Support TiddlyWiki 2.0
* v1.0.3 (2005-12-22)
** Features:
*** Write output to a file supports multi-byte environments (Thanks to Bram Chen)
*** Provide API to access the forEachTiddler functionality directly through JavaScript (see getTiddlers and performMacro)
** Enhancements:
*** Improved error messages on InternetExplorer.
* v1.0.2 (2005-12-10)
** Features:
*** context object also holds reference to store (TiddlyWiki)
** Fixed Bugs:
*** ForEachTiddler 1.0.1 has broken support on win32 Opera 8.51 (Thanks to BrunoSabin for reporting)
* v1.0.1 (2005-12-08)
** Features:
*** Access tiddlers stored in separated TiddlyWikis through the "in" option. I.e. you are no longer limited to only work on the "current TiddlyWiki".
*** Write output to an external file using the "toFile" option of the "write" action. With this option you may write your customized tiddler exports.
*** Use the "script" section to define "helper" JavaScript functions etc. to be used in the various JavaScript expressions (whereClause, sortClause, action arguments,...).
*** Access and store context information for the current forEachTiddler invocation (through the build-in "context" object) .
*** Improved script evaluation (for where/sort clause and write scripts).
* v1.0.0 (2005-11-20)
** initial version
!Code
***/
//{{{
//============================================================================
//============================================================================
// ForEachTiddlerPlugin
//============================================================================
//============================================================================
// Only install once
if (!version.extensions.ForEachTiddlerPlugin) {
if (!window.abego) window.abego = {};
version.extensions.ForEachTiddlerPlugin = {
major: 1, minor: 0, revision: 6,
date: new Date(2006,8,16),
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-2006 (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: 5, date: new Date(2006,2,5), 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.";
}
// 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 tiddlyWiki = new TiddlyWiki();
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 */
//}}}
/***
!Licence and Copyright
Copyright (c) abego Software ~GmbH, 2005 ([[www.abego-software.de|http://www.abego-software.de]])
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of abego Software nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
***/
GenerateRssByTagPlugin overwrite the core generateRSS() function. And defines a txtRssTag option : <<option txtRssTag>> to specify the tag to use (defaulted to ''"toRSS"'' ).
Only tiddlers with this specific tag are inluded in the RSSFeed. If no tiddlers are selected then works with the old behaviour. (see ticket #270: http://trac.tiddlywiki.org/tiddlywiki/ticket/270).
Because the generateRSS mechanism should change in TW 2.3 this enhancement should not go in the core .
Hint : You can add {{{<<option txtRssTag>>}}} in AdvancedOptions
/***
|''Name:''|GenerateRssByTagPlugin|
|''Description:''|Only tiddlers with a specific tag are inluded in the RSSFeed. If no tiddlers are selected then works as before. (see ticket #270: http://trac.tiddlywiki.org/tiddlywiki/ticket/270). <br>RssTag: <<option txtRssTag>>|
|''Version:''|1.0.2|
|''Date:''|Apr 20, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#GenerateRssByTagPlugin|
|''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.GenerateRssByTagPlugin = {
major: 1, minor: 0, revision: 2,
date: new Date("Apr 20, 2007"),
source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0 (Beta 5)'
};
if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.generateRssByTag = function()
{
var s = [];
var d = new Date();
var u = store.getTiddlerText("SiteUrl");
// Assemble the header
s.push("<" + "?xml version=\"1.0\"" + " encoding='UTF-8' " + "?" + ">");
s.push("<rss version=\"2.0\">");
s.push("<channel>");
s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
if(u)
s.push("<link>" + u.htmlEncode() + "</link>");
s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
s.push("<language>en-us</language>");
s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
s.push("<generator>TiddlyWiki " + version.major + "." + version.minor + "." + version.revision + "</generator>");
// The body
var tiddlers;
if (config.options.txtRssTag && store.getTaggedTiddlers(config.options.txtRssTag).length > 0)
tiddlers = store.getTaggedTiddlers(config.options.txtRssTag,"modified");
else
tiddlers = store.getTiddlers("modified","[[excludeLists]]");
var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
for (var t=tiddlers.length-1; t>=n; t--)
s.push(tiddlers[t].saveToRss(u));
// And footer
s.push("</channel>");
s.push("</rss>");
// Save it all
return s.join("\n");
};
//
// Initializations
//
bidix.generateRss = generateRss; // backup core version
generateRss = bidix.generateRssByTag; // install new one
config.options.txtRssTag = "toRSS"; // default RssTag. use <<option txtRssTag>> to overwritte
merge(config.optionsDesc,{txtRssTag: "Only tiddlers with this tag will be included in the RSS Feed."});
//}}}
Above are sites allowed to be accessed
----
<<HttpGet "proxy.php?list" html>>
----
This file is a TiddlyWiki. It uses NewsWiki a vertical customization for publication.
This NewsWiki uses 3 modes:
*<<changeMode Reader>>: browse and navigate into the content in readOnly mode.
*<<changeMode Author>>: for managing content (tiddlers, tags and perhaps Menus) and publishing (Save to web) the TiddlyWiki.
*<<changeMode>>: is the default mode when start:safe or plugin errors. This mode has the basic TiddlyWiki presentation and behaviour.
BidiXTW is now hosted at http://TiddlyHome.bidix.info/BidiXTW/. You can setup your own TiddlyHome as explain at http://TiddlyHome.bidix.info/.
!Stay tuned
<<tiddler [[Stay tuned]]>>
/***
| Name|HideWhenPlugin|
| Description|Allows conditional inclusion/exclusion in templates|
| Version|3.0 ($Rev: 1845 $)|
| Date|$Date: 2007-03-16 15:19:22 +1000 (Fri, 16 Mar 2007) $|
| Source|http://mptw.tiddlyspot.com/#HideWhenPlugin|
| Author|Simon Baird <simon.baird@gmail.com>|
| [[License]]|http://mptw.tiddlyspot.com/#TheBSDLicense|
For use in ViewTemplate and EditTemplate. Example usage:
{{{<div macro="showWhenTagged Task">[[TaskToolbar]]</div>}}}
{{{<div macro="showWhen tiddler.modifier == 'BartSimpson'"><img src="bart.gif"/></div>}}}
***/
//{{{
window.removeElementWhen = function(test,place) {
if (test) {
removeChildren(place);
place.parentNode.removeChild(place);
}
};
merge(config.macros,{
hideWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( eval(paramString), place);
}},
showWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !eval(paramString), place);
}},
hideWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAll(params), place);
}},
showWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAll(params), place);
}},
hideWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAny(params), place);
}},
showWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAny(params), place);
}},
hideWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( tiddler.tags.containsAll(params), place);
}},
showWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !tiddler.tags.containsAll(params), place);
}},
hideWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0]), place);
}},
showWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) {
removeElementWhen( !(store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0])), place);
}}
});
//}}}
/***
|''Name:''|HistoryPlugin|
|''Description:''|Limits to only one tiddler open. Manages an history stack and provides macro to navigate in this history (<<history>><<back>><<forward>>).|
|''Version:''|1.0.0|
|''Date:''|2008-03-23|
|''Source:''|http://tiddlywiki.bidix.info/#HistoryPlugin|
|''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.3.0|
***/
//{{{
Story.prototype.tiddlerHistory = [];
Story.prototype.historyCurrentPos = -1;
Story.prototype.currentTiddler = null;
Story.prototype.maxPos = 11;
Story.prototype.old_history_displayTiddler = Story.prototype.displayTiddler;
Story.prototype.displayTiddler = function(srcElement,title,template,animate,slowly)
{
title = ((typeof title === "string") ? title : title.title);
//SinglePageMode
if (this.currentTiddler) this.closeTiddler(this.currentTiddler);
if (template == 2) {
//switch to Edit mode : don't manage
story.old_history_displayTiddler(null,title,template,animate,slowly);
return;
}
// if same tiddler no change
if (this.tiddlerHistory[this.historyCurrentPos] == title) {
this.currentTiddler = title;
story.old_history_displayTiddler(null,title,template,animate,slowly);
return;
}
if (this.historyCurrentPos == this.tiddlerHistory.length -1) {
// bottom of stack
this.tiddlerHistory.push(title);
if (this.tiddlerHistory.length > 11) {
this.tiddlerHistory.shift();
} else {
this.historyCurrentPos += 1;
}
} else {
// middle of stack
this.historyCurrentPos += 1;
if (this.tiddlerHistory[this.historyCurrentPos] != title) {
// path change => cut history
this.tiddlerHistory[this.historyCurrentPos] = title;
var a = [];
for(var i = 0; i <= this.historyCurrentPos;i++) {
a[i] = this.tiddlerHistory[i];
}
this.tiddlerHistory = a;
}
}
this.currentTiddler = title;
story.old_history_displayTiddler(null,title,template,animate,true);
scrollTo(0, 1);
}
Story.prototype.old_history_closeTiddler = Story.prototype.closeTiddler;
Story.prototype.closeTiddler = function(title,animate,slowly)
{
this.currentTiddler = null;
story.old_history_closeTiddler.apply(this,arguments);
}
config.macros.history = {};
config.macros.history.action = function(event) {
var popup = Popup.create(this);
if(popup)
{
if (!story.tiddlerHistory.length)
createTiddlyText(popup,"No history");
else
{
var c = story.tiddlerHistory.length;
for (i=0; i<c;i++ )
{
var elmt = createTiddlyElement(popup,"li");
var btn = createTiddlyButton(elmt,story.tiddlerHistory[i],story.tiddlerHistory[i],config.macros.history.onClick);
btn.setAttribute("historyPos",i);
}
}
}
Popup.show(popup,false);
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
return false;
}
config.macros.history.handler = function(place,macroName,params)
{
createTiddlyButton(place, 'history', 'history', config.macros.history.action);
}
config.macros.history.onClick = function(ev)
{
var e = ev ? ev : window.event;
var historyPos = this.getAttribute("historyPos");
story.historyCurrentPos = historyPos -1;
story.displayTiddler(null,story.tiddlerHistory[historyPos]);
return false;
};
config.macros.back = {};
config.macros.back.action = function() {
if (story.historyCurrentPos > 0) {
if (story.currentTiddler) story.closeTiddler(story.currentTiddler);
story.historyCurrentPos = story.historyCurrentPos -2;
story.displayTiddler(null,story.tiddlerHistory[story.historyCurrentPos+1]);
} else {
//if (story.currentTiddler) story.old_history_displayTiddler(null,story.currentTiddler);
};
return false;
}
config.macros.back.handler = function(place,macroName,params)
{
createTiddlyButton(place, '<', 'back', config.macros.back.action,"backButton");
}
config.macros.forward = {};
config.macros.forward.action = function() {
if (story.historyCurrentPos < story.tiddlerHistory.length -1) {
if (story.currentTiddler) story.closeTiddler(story.currentTiddler);
//story.historyCurrentPos = story.historyCurrentPos;
story.displayTiddler(null,story.tiddlerHistory[story.historyCurrentPos+1]);
} else {
//if (story.currentTiddler) story.old_history_displayTiddler(null,story.currentTiddler);
}
return false;
}
config.macros.forward.handler = function(place,macroName,params)
{
createTiddlyButton(place, '>', 'forward', config.macros.forward.action, "ibutton");
}
//}}}
I have extracted HistoryPlugin from [[iplugin.js|http://itw.bidix.info/#iPlugins]], the external file containaing all plugins for [[iTW|http://itw.bidix.info/]], in a stand alone plugin available at http://tiddlywiki.bidix.info/#HistoryPlugin
Enjoy HistoryPlugin
To upload a TiddlyWiki on your web server:
#Import UploadPlugin from BidiXTW aka http://TiddlyWiki.bidix.info/
#Install an UploadService on your web server by configuring this scripts [[store.php]]
#set an {{{<<upload [params]>>}}} button for example in your SideBarOptions with {{{params}}} or UploadOptions as describe in UploadPluginDoc
#click on the <<upload>> button
Or sign at http://TiddlySpot.com/
/***
|''Name:''|HttpGetMacro|
|''Description:''|Submit an HttpGet and display the response|
|''Version:''|2.0.0|
|''Date:''|Mar 18, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#HttpGetMacro|
|''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|
***/
//{{{
config.macros.HttpGet = {
cache: [], // url => responseText
messages: {
401: "%0 unauthorized (HTTP status:401).",
403: "%0 forbidden (HTTP status:403).",
404: "%0 not found (HTTP status:404).",
405: "Method not allowed to access %0 (HTTP status: 405)."
},
handler: function(place,macroName,params,wikifier,paramString,tiddler){
var url = params[0];
var format = params[1];
wikify("^^<<HttpGetUpdate "+url+" [[" + tiddler.title + "]]>>^^\n",place);
var div = createTiddlyElement(place, "div", "HttpGet");
if (this.cache[url]) {
this.display(this.cache[url], format, div);
}
else {
this.get(url, format, div);
}
},
get: function(url, format, place) {
var params = {
format: format,
place: place
};
var r = loadRemoteFile(url,config.macros.HttpGet.display,params);
if (typeof r == "string")
displayMessage(r);
return r;
},
display: function(status,params,responseText,url,xhr) {
if (status) {
if (params['format'] == 'html') {
wikify("<html>"+responseText+"</html>", params['place']);
}
else { //text
wikify(responseText, params['place']);
}
} else {
if (config.macros.HttpGet.messages[xhr.status])
displayMessage(config.macros.HttpGet.messages[xhr.status].format([url]));
else
displayMessage("HTTP Error " + xhr.status + " in accessing " + url);
}
}
};
config.macros.HttpGetUpdate = {
label: "Update",
prompt: "Clear the cache and redisplay this tiddler",
handler: function(place,macroName,params) {
var url = params[0];
var tiddlerTitle = params[1];
createTiddlyButton(place, this.label, this.prompt,
function () {
if (config.macros.HttpGet.cache[url]) {
config.macros.rssReader.cache[url] = null;
}
story.refreshTiddler(tiddlerTitle,null, true);
return false;});
}
};
//}}}
/***
|''Name:''|IsDirtyPlugin|
|''Description:''|When the TiddlyWiki needs to be saved the tiddler named IsDirty contains ' * ' else it is empty. IsDirty tiddler is also appended in front of the browser page title.<br>Hint: Put it in front of your SiteTitle in your PageTemplate or in your MainMenu as an indicator.<br>For now IsDirty: <<tiddler IsDirty>>|
|''Version:''|1.0.1|
|''Date:''|Mar 20, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#IsDirtyPlugin|
|''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.IsDirtyPlugin = {
major: 1, minor: 0, revision: 1,
date: new Date("Mar 20, 2007"),
source: 'http://tiddlywiki.bidix.info/#IsDirtyPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0'
};
if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};
bidix.setDirty = TiddlyWiki.prototype.setDirty;
bidix.initIsDirty = function()
{
var tags = "[[excludeLists]] [[excludeSearch]]";
var tiddler = store.getTiddler("IsDirty");
if (!tiddler) {
tiddler = new Tiddler("IsDirty");
//tiddler.set(title,text,modifier,modified,tags,created,fields)
tiddler.set(null,null,null,null,tags,null,null);
store.addTiddler(tiddler);
}
tiddler.set(null,"",null,null,null,null,null);
return tiddler;
};
TiddlyWiki.prototype.setDirty = function(dirty)
{
var indic = " * ";
var oldDirty = this.isDirty ();
bidix.setDirty.apply(this,arguments);
var tiddler = bidix.initIsDirty();
if (dirty)
tiddler.set(null,indic,null,null,null,null,null);
else
tiddler.set(null," ",null,null,null,null,null);
story.refreshTiddler(tiddler.title);
store.notify(tiddler.title, true);
refreshPageTitle();
};
bidix.refreshPageTitle = function()
{
document.title = wikifyPlain("IsDirty") + wikifyPlain("SiteTitle") + " - " + wikifyPlain("SiteSubtitle");
};
bidix.core.refreshPageTitle = refreshPageTitle ;
refreshPageTitle = bidix.refreshPageTitle;
bidix.initIsDirty();
//}}}
<<forEachTiddler
where
'tiddler.tags.contains("toRSS") /*&& tiddler.tags.contains("toRSS")*/'
sortBy
'store.getValue(tiddler,"created")'
descending
write
'"\n@@font-size:1.5em;[["+tiddler.title+"]]@@@@color:#999; - " + Date.convertFromYYYYMMDDHHMM(store.getValue(tiddler,"created")).formatString("YYYY/0MM/0DD")+" - "+tiddler.modifier+"@@\n" +
"{{excerpt{\n" +
(tiddler.text.match("/%%/") ?
tiddler.text.substr(0,tiddler.text.indexOf("/%%/")) :
tiddler.text.substr(0,300)) +
" ...\n[[more ...|"+tiddler.title+"]]\n----\n}}}";'
>>
<<rssReader asText http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml>>
<<rssReader asHtml http://www.liberation.fr/interactif/rss/actualites/>>
<<tiddler BSDOpenSourceLicense>>
//{{{
//thanks Simon!
Array.prototype.tiddlerList = function(listFormat,max) {
var output = "";
if (!listFormat) listFormat = "'[[' + tiddler.title + ']] - ' + tiddler.created.formatString('0DD/0MM/YY') + ' - ' + tiddler.modifier + '\\n'";
if (!max) var max = this.length;
if (this.length > 0 && this[0] instanceof Tiddler) {
for (var i=0;i<max;i++) {
var tiddler = this[i];
output += eval(listFormat);
}
}
return output;
}
// tag, sorted, listformat, max(0), noReverse(true)
config.macros.listByTag = {};
config.macros.listByTag.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
params[0] = (params[0] ? params[0] : tiddler.title);
var tiddlers = store.getTaggedTiddlers(params[0],params[1]);
if (params[3] == 0) params[3] = null;
if (! params[4])
tiddlers = tiddlers.reverse();
wikify(tiddlers.tiddlerList(params[2],params[3]),place,null,tiddler);
};
//}}}
/***
|''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,cal