Welcome to TiddlyWiki created by Jeremy Ruston; Copyright © 2004-2007 Jeremy Ruston, Copyright © 2007-2011 UnaMesa Association
!Explanation
#In the paths section set the path followed by the tags, separated by ::
#In the Tagall section set the tag needs to given to every file, the tag docs is used by the plugin to identify tiddlers that are generated by the AutoLinkerPlugin
#Selecting files based on extension is not functional yet
!!Paths
backup::bc
!!Tagall
docs newdocs excludeLists
!!Only files with the extension
pdf jpg
/***
|''Name:''|AutoLinkerPlugin |
|''Date:''|20-01-2012 |
|''Version:''|1.1|
|''Type:''|plugin|
|''Author:''|Okido|
|''Documentation:''|see [[AutoLinkerPluginInfo]] |
|''~SourceCode:''|All materials are presented on an "as-is" basis and are subject to change without notice. The author of this document makes no claims regarding the suitability or reliability of the information presented, and assumes no liability for any damages that may occur as a result of its use. |
|''Licence:''|Creative Commons Attribution-NonCommercial-ShareAlike 3.0 |
|''~CoreVersion:''|2.6.0|
|''Browser:''|Firefox 3.5 or better |
|''Description:''|Get file names from a folder and use the name for a tiddler |
|''Credits:''|Kudos to [[Eric Shulman from TiddlyTools|http://www.tiddlytools.com/]] for the code I could re-use from his showlocaldir plugin |
***/
/***
!!!Documentation
>see [[AutoLinkerPluginInfo]]
!!!Revisions
<<<
20-01-2012 [1.1] Resolved replacement issue in template, cleaned the code a little
07-10-2011 [1.0] Initial release, still experimental
<<<
!!!Code
***/
<!--{{{-->
config.macros.autoLinker={};
config.macros.autoLinker.handler= function(place,macroName,params,wikifier,paramString,tiddler)
{ var label = params[0]||"Refresh Docs";
var tooltip = params[1]||"You are going to start a read action on your local drive!!!";
createTiddlyButton(place,label,tooltip,this.onclick);
}
config.macros.autoLinker.onclick= function() {
var path=[]; var header = ''; var tot = 0; var reg=[]; var reg_tag=[];
var line=[]; var file_list=[]; var all=[]; var file_paths='';
var tagslist = " "; /* tags that are added to the generated tiddlers */
var pts=[];
var debug = 0;
var deb = '\'\'Debug Info\'\' ' + '\n' ;
/* read the folder names in AutoLinkerData and create an array with path and tag */
var autolinkerdata = 'AutoLinkerData' ;
if (!store.tiddlerExists(autolinkerdata)) { /* if tiddler AutoLinkerData does not exits create one */
var newBody = '!Paths' + '\n' + 'backup::back' + '\n' + '!Tagall' + '\n' + 'docs' ;
store.saveTiddler(autolinkerdata, autolinkerdata, newBody, config.options.txtUserName, new Date(), 'autolinker');
}
var text = store.getTiddlerText("AutoLinkerData##Paths");
var lines = text.split('\n');
for( p = 0 ; p < lines.length ; p++ ) {
pts.push({ path:lines[p].split('::')[0], tag:lines[p].split('::')[1]}) ; // split around :: empty values are empty
if (debug) { deb += pts[pts.length-1].tag.toString(); }
}
var tagslist = store.getTiddlerText("AutoLinkerData##Tagall");
// file reading for IE and Firefox
window.getCurrentFolder=function() {
var h=document.location.href;
return getLocalPath(decodeURIComponent(h.substr(0,h.lastIndexOf("/")+1)));
}
window.getParentFolder=function(cwd) {
var lastchar=cwd.substr(cwd.length-1,1);
if (lastchar=="/" || lastchar=="\\") cwd=cwd.substr(0,cwd.length-1);
var pos=cwd.lastIndexOf("/"); if (pos==-1) pos=cwd.lastIndexOf("\\");
return pos!=-1?cwd.substr(0,pos+1):null;
}
window.getFileList=function(cwd) { // returns array of file info (path,name,size,isFolder,url,modified)
var files=[];
if (config.browser.isIE) {
cwd=cwd.replace(/\//g,"\\");
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists(cwd)) return [];
var dir=fso.GetFolder(cwd);
for(var f=new Enumerator(dir.SubFolders); !f.atEnd(); f.moveNext())
files.push({ path:f.item().path, name:f.item().name, size:f.item().size,
url:"file:///"+f.item().path.replace(/\\/g,"/"), isFolder:fso.FolderExists(f.item().path),
modified:new Date(f.item().DateLastModified).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
for(var f=new Enumerator(dir.Files); !f.atEnd(); f.moveNext())
files.push({ path:f.item().path, name:f.item().name, size:f.item().size,
url:"file:///"+f.item().path.replace(/\\/g,"/"), isFolder:fso.FolderExists(f.item().path),
modified:new Date(f.item().DateLastModified).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
} else { // FF
if(!window.Components) return;
try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
catch(e) { alert(e.description?e.description:e.toString()); return null; }
var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
try { file.initWithPath(cwd); } catch(e) { return []; }
if (!file.exists() || !file.isDirectory()) { return []; }
var folder=file.directoryEntries;
while (folder.hasMoreElements()) {
var f=folder.getNext().QueryInterface(Components.interfaces.nsILocalFile);
if (f instanceof Components.interfaces.nsILocalFile)
files.push({path:f.path, name:f.leafName, size:f.fileSize,
isFolder:f.isDirectory(), url:"file:///"+f.path.replace(/\\/g,"/"),
modified:new Date(f.lastModifiedTime).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
}
}
return files;
}
// Convert file date to TW date format
date_conv = function(date) {
date = date.replace(' ','.');
date = date.split('.');
return new Date(date[0],date[1]-1,date[2]); // date of file creation
}
// Write a tiddler with the file name found on disk, use the tiddler body with a template
write_tiddler = function(title,date) {
header += '[[' + title + ']]' + '\n';
var newTitle = title; // tiddler title
var meta = title.substr(title.lastIndexOf('\\')+1);
// tiddler by template
var tid_exist = store.tiddlerExists('AutoLinkerTemplate');
if (tid_exist == true ) {
var tids = store.getTiddler('AutoLinkerTemplate');
newBody = tids.text;
newBody = newBody.replace(/code_insert_1/g, title );
newBody = newBody.replace(/code_insert_2/g, title );
}
else { newBody = '|Link |' + '[[' + title + '|./' + title +']] |' + '\n'; }
/* add tags based on the folder name */
var tag_extra = " ";
var path_filter = [];
for ( x = 0 ; x < pts.length ; x++ ) {
// deb += '\n'+ x + '\n' + newTitle + '\n' + pts[x].path + '\n' + pts[x].tag.toString() + '\n';
// deb += '\n'+ 'pts >> '+ pts[x].tag.toString() + '\n' ;
// filter the path name out
/* windows */
var slash = '\/' ;
if(navigator.platform == 'Win32' ) { /* windows */
slash ='\\' ; }
/*linux */
path_filter = newTitle.split(slash);
var tes = newTitle.replace(slash + path_filter[path_filter.length-1], '') ;
// deb += '\n' + 'path-filename: ' + tes + '\n' + '- ' + path_filter[path_filter.length-1] ;
if (tes == pts[x].path.toString() ) {
// deb += '\n'+ 'pts match >> '+ pts[x].tag.toString() + '\n' ;
var ta = pts[x].tag.toString() ;
tag_extra += ta ;
}
}
store.saveTiddler(newTitle, newTitle, newBody, config.options.txtUserName, date_conv(date), tagslist + tag_extra);
store.setValue(newTitle,"meta",meta); // save the title as meta data, can be used for list generation of file names are poor
store.setValue(newTitle,"custom_time",date); // save the date for sorting
}
/* main loop to get all file names in all folders */
for( p = 0 ; p < pts.length ; p++ ) {
var cwd = getCurrentFolder() + pts[p].path ; /* sub folder were the docs are located */
// deb += cwd.toString() ;
file_list = file_list.concat(getFileList(cwd));
file_paths += pts[p].path + ' '; /* make a string with all folders for the AutoLinkerReport */
}
// report_header(); /* create the report header */
header =
'!AutoLinkerReport'
+ ' ' + new Date().formatString("0DD-0MM-YYYY 0hh:0mm:0ss") + '\n'
+ 'Scanned folders: ' + file_paths + '\n'
+ 'Number of files found: ' + file_list.length + '\n'
+ 'Tags used for every folder: ' + tagslist + '\n'
+ 'Username: ' + config.options.txtUserName + '\n'
+ '!!Tiddlers added' + '\n';
// write a tiddler if the tiddler name not exists
for (var i=0; i<file_list.length; i++) {
line=([file_list[i].path,file_list[i].name,file_list[i].url,file_list[i].size,file_list[i].modified]);
basic_line = line[0].replace(getCurrentFolder(),'');
store.tiddlerExists(basic_line)?"Y": write_tiddler(basic_line, line[4]);
}
// check if a tiddler title matches with the file name list
exist_file = function(title) {
exist = false;
for( y = 0 ; y < file_list.length ; y++ ) {
if ( file_list[y].path.replace(getCurrentFolder(),'') == title ) { return true; }
}
return false;
}
// create a list of tiddlers that mis the correspondending file
var files_missing = '';
var tids=store.getTaggedTiddlers('docs');
for( i = 0 ; i < tids.length ; i++ ) {
if ( exist_file(tids[i].title) == false ) {
insert = '[['+ tids[i].title + ']]' + '\n';
if (files_missing.indexOf(insert)==-1) { files_missing += insert; } // check on same name but different path
store.saveTiddler(tids[i].title, tids[i].title, tids[i].text, tids[i].modifier, tids[i].modified, 'test', tids[i].fields);
}
}
/* Complete AutoLinkerReport */
var newTitle = 'AutoLinkerReport'; // tiddler with name: AutoLinkerReport
var newBody='';
if (store.tiddlerExists(newTitle)) { var newBody = store.getTiddlerText(newTitle); }
newBody = header + ('!!Tiddlers tagged but no file found') + '\n' + files_missing + '\n' + '\n' + '<hr>' + '<hr>' + '\n' + newBody;
if (debug) {newBody = newBody + deb;}
// var dt = new Date(); // convert date toTW formaat
var newTags = 'autolinker' ; // empty tags list
store.saveTiddler(newTitle, newTitle, newBody, config.options.txtUserName, new Date(), newTags);
saveChanges(); // save the file
}
<!--}}}-->
/***
|''Name:''|AutoLinkerPlugin |
|''Version:''|07-10-2011 |
|''Type:''|plugin|
|''Author:''|Okido|
|''Documentation:''|Not yet, see comments in the code |
|''~SourceCode:''|All materials are presented on an "as-is" basis and are subject to change without notice. The author of this document makes no claims regarding the suitability or reliability of the information presented, and assumes no liability for any damages that may occur as a result of its use. |
|''Licence:''|Creative Commons Attribution-NonCommercial-ShareAlike 3.0 |
|''~CoreVersion:''|2.6.0|
|''Browser:''|Firefox 3.5 or better |
|''Credits:''|Kudos to [[Eric Shulman TiddlyTools|http://www.tiddlytools.com/]] for the code I could use from his showlocaldir plugin |
***/
/***
!Version history
* This is still the beta bersion
* It links files names to tiddlers and generates a tiddler with content tags etc.
* Todo: replace the hard coded items
* Include <<autoLinker>> in the in the sidebaroptions to start the plugin
* no release yet, be carefull update important data before trying this code
***/
//{{{
config.macros.autoLinker={};
config.macros.autoLinker.handler= function(place,macroName,params,wikifier,paramString,tiddler)
{ var label = params[0]||"Refresh Docs";
var tooltip = params[1]||"You are going to start a read action on your local drive!!!";
createTiddlyButton(place,label,tooltip,this.onclick); }
config.macros.autoLinker.onclick= function() {
var path=[]; var fout = ''; var tot = 0; var reg=[]; var reg_tag=[];
var line=[]; var file_list=[]; var all=[]; var file_paths='';
var tagslist = ' docs excludeLists'; // tags that are added to the generated tiddlers
// directory names, more paths just add them, use the right syntax, the number should be 0,1,2,3,4,5,6,7...... aso
path[0]= 'docs' ;
path[1]= 'backup' ;
// file reading for IE and Firefox
window.getCurrentFolder=function() {
var h=document.location.href;
return getLocalPath(decodeURIComponent(h.substr(0,h.lastIndexOf("/")+1)));
}
window.getParentFolder=function(cwd) {
var lastchar=cwd.substr(cwd.length-1,1);
if (lastchar=="/" || lastchar=="\\") cwd=cwd.substr(0,cwd.length-1);
var pos=cwd.lastIndexOf("/"); if (pos==-1) pos=cwd.lastIndexOf("\\");
return pos!=-1?cwd.substr(0,pos+1):null;
}
window.getFileList=function(cwd) { // returns array of file info (path,name,size,isFolder,url,modified)
var files=[];
if (config.browser.isIE) {
cwd=cwd.replace(/\//g,"\\");
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists(cwd)) return [];
var dir=fso.GetFolder(cwd);
for(var f=new Enumerator(dir.SubFolders); !f.atEnd(); f.moveNext())
files.push({ path:f.item().path, name:f.item().name, size:f.item().size,
url:"file:///"+f.item().path.replace(/\\/g,"/"), isFolder:fso.FolderExists(f.item().path),
modified:new Date(f.item().DateLastModified).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
for(var f=new Enumerator(dir.Files); !f.atEnd(); f.moveNext())
files.push({ path:f.item().path, name:f.item().name, size:f.item().size,
url:"file:///"+f.item().path.replace(/\\/g,"/"), isFolder:fso.FolderExists(f.item().path),
modified:new Date(f.item().DateLastModified).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
} else { // FF
if(!window.Components) return;
try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
catch(e) { alert(e.description?e.description:e.toString()); return null; }
var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
try { file.initWithPath(cwd); } catch(e) { return []; }
if (!file.exists() || !file.isDirectory()) { return []; }
var folder=file.directoryEntries;
while (folder.hasMoreElements()) {
var f=folder.getNext().QueryInterface(Components.interfaces.nsILocalFile);
if (f instanceof Components.interfaces.nsILocalFile)
files.push({path:f.path, name:f.leafName, size:f.fileSize,
isFolder:f.isDirectory(), url:"file:///"+f.path.replace(/\\/g,"/"),
modified:new Date(f.lastModifiedTime).formatString("YYYY.0MM.0DD 0hh:0mm:0ss")});
}
}
return files;
}
// Generate the text for the AutoLinkerReport
listresults = function() {
fout += '!AutoLinkerReport' + ' ' + new Date().formatString("0DD-0MM-YYYY 0hh:0mm:0ss") + '\n';
fout += 'Scanned paths : ' + file_paths + '\n';
fout += 'Number of files found: ' + file_list.length + '\n';
fout += 'Tags used: ' + tagslist + '\n';
fout += 'Username: ' + config.options.txtUserName + '\n';
fout += '!!Added tiddlers' + '\n';
}
// Convert file date to TW date format
date_conv = function(date) {
date = date.replace(' ','.');
date = date.split('.');
return new Date(date[0],date[1]-1,date[2]); // date of file creation
}
// Write a tiddler with the filename found on disk, use the tiddler body with a template
write_tiddler = function(title,date) {
fout+= '[[' + title + ']]' + '\n';
var newTitle = title; // tiddler title
var meta = title.substr(title.lastIndexOf('\\')+1);
// tiddler by template
var tid_exist = store.tiddlerExists('AutoLinkerTemplate');
if (tid_exist == true ) {
var tids = store.getTiddler('AutoLinkerTemplate');
newBody = tids.text;
newBody = newBody.replace('code_insert_1', title );
newBody = newBody.replace('code_insert_2', title );
}
else { newBody = '|Link |' + '[[' + title + '|./' + title +']] |' + '\n'; }
tag_lister = '';
// tag_lister = '';
var tag_regex = new RegExp('backup');
var test_resultaat = newTitle;
if ( tag_regex.test(test_resultaat) ) {
tag_lister = ' backup ' ;
}
store.saveTiddler(newTitle, newTitle, newBody, config.options.txtUserName, date_conv(date), tagslist+tag_lister);
store.setValue(newTitle,"meta",meta); // save the title as meta data, can be used for list generation of file names are poor
store.setValue(newTitle,"custom_time",date); // save the date for sorting
}
// main loop to get all file names in all paths
for( p = 0 ; p < path.length ; p++ ) {
var cwd = getCurrentFolder() + path[p] ; //sub folder were the docs are located
file_list = file_list.concat(getFileList(cwd));
file_paths += path[p] + ' '; // make a string with all paths searched for report
}
// print the results of loading files
listresults();
// write a tiddler if the tiddler name not exists
for (var i=0; i<file_list.length; i++) {
line=([file_list[i].path,file_list[i].name,file_list[i].url,file_list[i].size,file_list[i].modified]);
basic_line = line[0].replace(getCurrentFolder(),'');
var tid = store.tiddlerExists(basic_line)?"Y": write_tiddler(basic_line,line[4]);
// write_tiddler(basic_line,line[4]);
}
// check if a tiddler title matches with the file name list
exist_file = function(title) {
exist = false;
for( y = 0 ; y < file_list.length ; y++ ) {
if ( file_list[y].path.replace(getCurrentFolder(),'') == title ) { return true; }
}
return false;
}
// create a list of tiddlers that mis the correspondending file
var files_missing = '';
var tids=store.getTaggedTiddlers('docs');
for( i = 0 ; i < tids.length ; i++ ) {
if ( exist_file(tids[i].title) == false ) {
insert = '[['+ tids[i].title + ']]' + '\n';
if (files_missing.indexOf(insert)==-1) { files_missing += insert; } // check on same name but different path
}
}
// autoLinkerReport creation
var newTitle = 'AutoLinkerReport'; // tiddler with name: AutoLinkerReport
var newBody='';
if (store.tiddlerExists(newTitle)) { var newBody = store.getTiddlerText(newTitle); }
newBody = fout + ('!!Tiddlers tagged but no file') + '\n' + files_missing + '\n' + '\n' + '<hr>' + '<hr>' + '\n' + newBody;
var dt = new Date(); // convert date toTW formaat
var newTags = '' ; // empty tags list
store.saveTiddler(newTitle, newTitle, newBody, config.options.txtUserName, dt, newTags);
saveChanges(); // save the file
}
//}}}
!Version [1.0] to [1.1]
*Solved a template replace problem
*Paths are no longer hard coded but put in a AutoLinkerData Tiddler <nowiki> <<<<< </nowiki> MAJOR CHANGE !!!!!
*AutoLinkerData contains a field for file extensions, this will be implemented soon
!AutoLinkerPlugin
This plugin is still beta, be careful for data loss !!!
!!Functionality:
# The plugin scans a folders
# Creates a tiddler with the folder name
# Adds tags based on the specific folder
# Reports about missing files
# More info can be found in the plugin
# It is configured to scan the folder "backup" and "docs"
# The folders can only be sub folders relative to the folder of TW
# Plugin does only work on a local file system
# The TW is not interchangable between Win, Mac and Linux due to / and \ issue, this needs to be solved
You need two Tiddlers to get it working: AutoLinkerPlugin and AutoLinkerTemplate
Any problems please report on: [[TiddlyWiki Google Groups|https://groups.google.com/group/TiddlyWiki/topics?gvc=2&hl=en]]
Link to file: [[code_insert_1|./code_insert_2]]
To get started with this blank [[TiddlyWiki]], you'll need to modify the following tiddlers:
* [[SiteTitle]] & [[SiteSubtitle]]: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* [[MainMenu]]: The menu (usually on the left)
* [[DefaultTiddlers]]: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
/***
|''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);
}
//}}}
[[AutoLinkerPlugin]]
[[AutoLinkerPluginInfo]]
[[AutoLinkerTemplate]]
[[AutoLinkerData]]
----
[[WelcomeToTiddlyspot]]
/***
|''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"
});
*/
//}}}
<<search>><<closeAll>><<permaview>><<newTiddler>><<autoLinker>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<tiddler TspotSidebar>><<option txtUserName>>[[WelcomeToTiddlyspot]]<<slider chkSliderOptionsPanel OptionsPanel "options ยป" "Change TiddlyWiki advanced options">>
/***
|Name|SinglePageModePlugin|
|Source|http://www.TiddlyTools.com/#SinglePageModePlugin|
|Documentation|http://www.TiddlyTools.com/#SinglePageModePluginInfo|
|Version|2.9.7|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements|
|~CoreVersion|2.1|
|Type|plugin|
|Description|Show tiddlers one at a time with automatic permalink, or always open tiddlers at top/bottom of page.|
This plugin allows you to configure TiddlyWiki to navigate more like a traditional multipage web site with only one tiddler displayed at a time.
!!!!!Documentation
>see [[SinglePageModePluginInfo]]
!!!!!Configuration
<<<
<<option chkSinglePageMode>> Display one tiddler at a time
><<option chkSinglePagePermalink>> Automatically permalink current tiddler
><<option chkSinglePageKeepFoldedTiddlers>> Don't close tiddlers that are folded
><<option chkSinglePageKeepEditedTiddlers>> Don't close tiddlers that are being edited
<<option chkTopOfPageMode>> Open tiddlers at the top of the page
<<option chkBottomOfPageMode>> Open tiddlers at the bottom of the page
<<option chkSinglePageAutoScroll>> Automatically scroll tiddler into view (if needed)
Notes:
* The "display one tiddler at a time" option can also be //temporarily// set/reset by including a 'paramifier' in the document URL: {{{#SPM:true}}} or {{{#SPM:false}}}.
* If more than one display mode is selected, 'one at a time' display takes precedence over both 'top' and 'bottom' settings, and if 'one at a time' setting is not used, 'top of page' takes precedence over 'bottom of page'.
* When using Apple's Safari browser, automatically setting the permalink causes an error and is disabled.
<<<
!!!!!Revisions
<<<
2010.11.30 2.9.7 use story.getTiddler()
2008.10.17 2.9.6 changed chkSinglePageAutoScroll default to false
| Please see [[SinglePageModePluginInfo]] for previous revision details |
2005.08.15 1.0.0 Initial Release. Support for BACK/FORWARD buttons adapted from code developed by Clint Checketts.
<<<
!!!!!Code
***/
//{{{
version.extensions.SinglePageModePlugin= {major: 2, minor: 9, revision: 7, date: new Date(2010,11,30)};
//}}}
//{{{
config.paramifiers.SPM = { onstart: function(v) {
config.options.chkSinglePageMode=eval(v);
if (config.options.chkSinglePageMode && config.options.chkSinglePagePermalink && !config.browser.isSafari) {
config.lastURL = window.location.hash;
if (!config.SPMTimer) config.SPMTimer=window.setInterval(function() {checkLastURL();},1000);
}
} };
//}}}
//{{{
if (config.options.chkSinglePageMode==undefined)
config.options.chkSinglePageMode=false;
if (config.options.chkSinglePagePermalink==undefined)
config.options.chkSinglePagePermalink=true;
if (config.options.chkSinglePageKeepFoldedTiddlers==undefined)
config.options.chkSinglePageKeepFoldedTiddlers=false;
if (config.options.chkSinglePageKeepEditedTiddlers==undefined)
config.options.chkSinglePageKeepEditedTiddlers=false;
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=false;
//}}}
//{{{
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; // no change in hash
var tids=decodeURIComponent(window.location.hash.substr(1)).readBracketedList();
if (tids.length==1) // permalink (single tiddler in URL)
story.displayTiddler(null,tids[0]);
else { // restore permaview or default view
config.lastURL = window.location.hash;
if (!tids.length) tids=store.getTiddlerText("DefaultTiddlers").readBracketedList();
story.closeAllTiddlers();
story.displayTiddlers(null,tids);
}
}
if (Story.prototype.SPM_coreDisplayTiddler==undefined)
Story.prototype.SPM_coreDisplayTiddler=Story.prototype.displayTiddler;
Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,slowly)
{
var title=(tiddler instanceof Tiddler)?tiddler.title:tiddler;
var tiddlerElem=story.getTiddler(title); // ==null unless tiddler is already displayed
var opt=config.options;
var single=opt.chkSinglePageMode && !startingUp;
var top=opt.chkTopOfPageMode && !startingUp;
var bottom=opt.chkBottomOfPageMode && !startingUp;
if (single) {
story.forEachTiddler(function(tid,elem) {
// skip current tiddler and, optionally, tiddlers that are folded.
if ( tid==title
|| (opt.chkSinglePageKeepFoldedTiddlers && elem.getAttribute("folded")=="true"))
return;
// if a tiddler is being edited, ask before closing
if (elem.getAttribute("dirty")=="true") {
if (opt.chkSinglePageKeepEditedTiddlers) return;
// if tiddler to be displayed is already shown, then leave active tiddler editor as is
// (occurs when switching between view and edit modes)
if (tiddlerElem) return;
// otherwise, ask for permission
var msg="'"+tid+"' is currently being edited.\n\n";
msg+="Press OK to save and close this tiddler\nor press Cancel to leave it opened";
if (!confirm(msg)) return; else story.saveTiddler(tid);
}
story.closeTiddler(tid);
});
}
else if (top)
arguments[0]=null;
else if (bottom)
arguments[0]="bottom";
if (single && opt.chkSinglePagePermalink && !config.browser.isSafari) {
window.location.hash = encodeURIComponent(String.encodeTiddlyLink(title));
config.lastURL = window.location.hash;
document.title = wikifyPlain("SiteTitle") + " - " + title;
if (!config.SPMTimer) config.SPMTimer=window.setInterval(function() {checkLastURL();},1000);
}
if (tiddlerElem && tiddlerElem.getAttribute("dirty")=="true") { // editing... move tiddler without re-rendering
var isTopTiddler=(tiddlerElem.previousSibling==null);
if (!isTopTiddler && (single || top))
tiddlerElem.parentNode.insertBefore(tiddlerElem,tiddlerElem.parentNode.firstChild);
else if (bottom)
tiddlerElem.parentNode.insertBefore(tiddlerElem,null);
else this.SPM_coreDisplayTiddler.apply(this,arguments); // let CORE render tiddler
} else
this.SPM_coreDisplayTiddler.apply(this,arguments); // let CORE render tiddler
var tiddlerElem=story.getTiddler(title);
if (tiddlerElem&&opt.chkSinglePageAutoScroll) {
// scroll to top of page or top of tiddler
var isTopTiddler=(tiddlerElem.previousSibling==null);
var yPos=isTopTiddler?0:ensureVisible(tiddlerElem);
// if animating, defer scroll until after animation completes
var delay=opt.chkAnimate?config.animDuration+10:0;
setTimeout("window.scrollTo(0,"+yPos+")",delay);
}
}
if (Story.prototype.SPM_coreDisplayTiddlers==undefined)
Story.prototype.SPM_coreDisplayTiddlers=Story.prototype.displayTiddlers;
Story.prototype.displayTiddlers = function() {
// suspend single/top/bottom modes when showing multiple tiddlers
var opt=config.options;
var saveSPM=opt.chkSinglePageMode; opt.chkSinglePageMode=false;
var saveTPM=opt.chkTopOfPageMode; opt.chkTopOfPageMode=false;
var saveBPM=opt.chkBottomOfPageMode; opt.chkBottomOfPageMode=false;
this.SPM_coreDisplayTiddlers.apply(this,arguments);
opt.chkBottomOfPageMode=saveBPM;
opt.chkTopOfPageMode=saveTPM;
opt.chkSinglePageMode=saveSPM;
}
//}}}
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{
// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'atl';
// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too
// disable autosave in d3
if (window.location.protocol != "file:")
config.options.chkGTDLazyAutoSave = false;
// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}
// create some shadow tiddler content
merge(config.shadowTiddlers,{
'TspotOptions':[
"tiddlyspot password:",
"<<option pasUploadPassword>>",
""
].join("\n"),
'TspotControls':[
"| tiddlyspot password:|<<option pasUploadPassword>>|",
"| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
"| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),
'WelcomeToTiddlyspot':[
"This document is a ~TiddlyWiki from tiddlyspot.com. A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //What now?// @@ Before you can save any changes, you need to enter your password in the form below. Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
"<<tiddler TspotControls>>",
"See also GettingStarted.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working online// @@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// @@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick. You can make changes and save them locally without being connected to the Internet. When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Help!// @@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]]. Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help. If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// @@ We hope you like using your tiddlyspot.com site. Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),
'TspotSidebar':[
"<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n")
});
//}}}
| 01/03/2018 14:10:50 | | [[/|http://atl.tiddlyspot.com/]] | [[store.cgi|http://atl.tiddlyspot.com/store.cgi]] | . | [[index.html | http://atl.tiddlyspot.com/index.html]] | . | ok |
| 01/03/2018 14:10:58 | | [[/|http://atl.tiddlyspot.com/]] | [[store.cgi|http://atl.tiddlyspot.com/store.cgi]] | . | [[index.html | http://atl.tiddlyspot.com/index.html]] | . | ok |
| 01/03/2018 14:11:25 | | [[/|http://atl.tiddlyspot.com/]] | [[store.cgi|http://atl.tiddlyspot.com/store.cgi]] | . | [[index.html | http://atl.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
major: 4, minor: 1, revision: 3,
date: new Date("Feb 24, 2008"),
source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0'
};
//
// Environment
//
if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false; // true to activate both in Plugin and UploadService
//
// Upload Macro
//
config.macros.upload = {
// default values
defaultBackupDir: '', //no backup
defaultStoreScript: "store.php",
defaultToFilename: "index.html",
defaultUploadDir: ".",
authenticateUser: true // UploadService Authenticate User
};
config.macros.upload.label = {
promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
promptParamMacro: "Save and Upload this TiddlyWiki in %0",
saveLabel: "save to web",
saveToDisk: "save to disk",
uploadLabel: "upload"
};
config.macros.upload.messages = {
noStoreUrl: "No store URL in parmeters or options",
usernameOrPasswordMissing: "Username or password missing"
};
config.macros.upload.handler = function(place,macroName,params) {
if (readOnly)
return;
var label;
if (document.location.toString().substr(0,4) == "http")
label = this.label.saveLabel;
else
label = this.label.uploadLabel;
var prompt;
if (params[0]) {
prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0],
(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
} else {
prompt = this.label.promptOption;
}
createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};
config.macros.upload.action = function(params)
{
// for missing macro parameter set value from options
if (!params) params = {};
var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
var username = params[4] ? params[4] : config.options.txtUploadUserName;
var password = config.options.pasUploadPassword; // for security reason no password as macro parameter
// for still missing parameter set default value
if ((!storeUrl) && (document.location.toString().substr(0,4) == "http"))
storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
if (storeUrl.substr(0,4) != "http")
storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
if (!toFilename)
toFilename = bidix.basename(window.location.toString());
if (!toFilename)
toFilename = config.macros.upload.defaultToFilename;
if (!uploadDir)
uploadDir = config.macros.upload.defaultUploadDir;
if (!backupDir)
backupDir = config.macros.upload.defaultBackupDir;
// report error if still missing
if (!storeUrl) {
alert(config.macros.upload.messages.noStoreUrl);
clearMessage();
return false;
}
if (config.macros.upload.authenticateUser && (!username || !password)) {
alert(config.macros.upload.messages.usernameOrPasswordMissing);
clearMessage();
return false;
}
bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password);
return false;
};
config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir)
{
if (!storeUrl)
return null;
var dest = bidix.dirname(storeUrl);
if (uploadDir && uploadDir != '.')
dest = dest + '/' + uploadDir;
dest = dest + '/' + toFilename;
return dest;
};
//
// uploadOptions Macro
//
config.macros.uploadOptions = {
handler: function(place,macroName,params) {
var wizard = new Wizard();
wizard.createWizard(place,this.wizardTitle);
wizard.addStep(this.step1Title,this.step1Html);
var markList = wizard.getElement("markList");
var listWrapper = document.createElement("div");
markList.parentNode.insertBefore(listWrapper,markList);
wizard.setValue("listWrapper",listWrapper);
this.refreshOptions(listWrapper,false);
var uploadCaption;
if (document.location.toString().substr(0,4) == "http")
uploadCaption = config.macros.upload.label.saveLabel;
else
uploadCaption = config.macros.upload.label.uploadLabel;
wizard.setButtons([
{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption,
onClick: config.macros.upload.action},
{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
]);
},
options: [
"txtUploadUserName",
"pasUploadPassword",
"txtUploadStoreUrl",
"txtUploadDir",
"txtUploadFilename",
"txtUploadBackupDir",
"chkUploadLog",
"txtUploadLogMaxLine"
],
refreshOptions: function(listWrapper) {
var opts = [];
for(i=0; i<this.options.length; i++) {
var opt = {};
opts.push();
opt.option = "";
n = this.options[i];
opt.name = n;
opt.lowlight = !config.optionsDesc[n];
opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
opts.push(opt);
}
var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
for(n=0; n<opts.length; n++) {
var type = opts[n].name.substr(0,3);
var h = config.macros.option.types[type];
if (h && h.create) {
h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
}
}
},
onCancel: function(e)
{
backstage.switchTab(null);
return false;
},
wizardTitle: "Upload with options",
step1Title: "These options are saved in cookies in your browser",
step1Html: "<input type='hidden' name='markList'></input><br>",
cancelButton: "Cancel",
cancelButtonPrompt: "Cancel prompt",
listViewTemplate: {
columns: [
{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
{name: 'Option', field: 'option', title: "Option", type: 'String'},
{name: 'Name', field: 'name', title: "Name", type: 'String'}
],
rowClasses: [
{className: 'lowlight', field: 'lowlight'}
]}
};
//
// upload functions
//
if (!bidix.upload) bidix.upload = {};
if (!bidix.upload.messages) bidix.upload.messages = {
//from saving
invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
backupSaved: "Backup saved",
backupFailed: "Failed to upload backup file",
rssSaved: "RSS feed uploaded",
rssFailed: "Failed to upload RSS feed file",
emptySaved: "Empty template uploaded",
emptyFailed: "Failed to upload empty template file",
mainSaved: "Main TiddlyWiki file uploaded",
mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
//specific upload
loadOriginalHttpPostError: "Can't get original file",
aboutToSaveOnHttpPost: 'About to upload on %0 ...',
storePhpNotFound: "The store script '%0' was not found."
};
bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
var callback = function(status,uploadParams,original,url,xhr) {
if (!status) {
displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
return;
}
if (bidix.debugMode)
alert(original.substr(0,500)+"\n...");
// Locate the storeArea div's
var posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
bidix.upload.uploadRss(uploadParams,original,posDiv);
};
if(onlyIfDirty && !store.isDirty())
return;
clearMessage();
// save on localdisk ?
if (document.location.toString().substr(0,4) == "file") {
var path = document.location.toString();
var localPath = getLocalPath(path);
saveChanges();
}
// get original
var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
var originalPath = document.location.toString();
// If url is a directory : add index.html
if (originalPath.charAt(originalPath.length-1) == "/")
originalPath = originalPath + "index.html";
var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
var log = new bidix.UploadLog();
log.startUpload(storeUrl, dest, uploadDir, backupDir);
displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
if (bidix.debugMode)
alert("about to execute Http - GET on "+originalPath);
var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
bidix.upload.uploadRss = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
if(status) {
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
bidix.upload.uploadMain(params[0],params[1],params[2]);
} else {
displayMessage(bidix.upload.messages.rssFailed);
}
};
// do uploadRss
if(config.options.chkGenerateAnRssFeed) {
var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
var rssString = generateRss();
// no UnicodeToUTF8 conversion needed when location is "file" !!!
if (document.location.toString().substr(0,4) != "file")
rssString = convertUnicodeToUTF8(rssString);
bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
} else {
bidix.upload.uploadMain(uploadParams,original,posDiv);
}
};
bidix.upload.uploadMain = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
var log = new bidix.UploadLog();
if(status) {
// if backupDir specified
if ((params[3]) && (responseText.indexOf("backupfile:") > -1)) {
var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
}
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
store.setDirty(false);
log.endUpload("ok");
} else {
alert(bidix.upload.messages.mainFailed);
displayMessage(bidix.upload.messages.mainFailed);
log.endUpload("failed");
}
};
// do uploadMain
var revised = bidix.upload.updateOriginal(original,posDiv);
bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};
bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
var localCallback = function(status,params,responseText,url,xhr) {
url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
if (xhr.status == 404)
alert(bidix.upload.messages.storePhpNotFound.format([url]));
if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
alert(responseText);
if (responseText.indexOf("Debug mode") >= 0 )
responseText = responseText.substring(responseText.indexOf("\n\n")+2);
} else if (responseText.charAt(0) != '0')
alert(responseText);
if (responseText.charAt(0) != '0')
status = null;
callback(status,params,responseText,url,xhr);
};
// do httpUpload
var boundary = "---------------------------"+"AaB03x";
var uploadFormName = "UploadPlugin";
// compose headers data
var sheader = "";
sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
sheader += uploadFormName +"\"\r\n\r\n";
sheader += "backupDir="+uploadParams[3] +
";user=" + uploadParams[4] +
";password=" + uploadParams[5] +
";uploaddir=" + uploadParams[2];
if (bidix.debugMode)
sheader += ";debug=1";
sheader += ";;\r\n";
sheader += "\r\n" + "--" + boundary + "\r\n";
sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
sheader += "Content-Length: " + data.length + "\r\n\r\n";
// compose trailer data
var strailer = new String();
strailer = "\r\n--" + boundary + "--\r\n";
data = sheader + data + strailer;
if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
if (!posDiv)
posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
store.allTiddlersAsHtml() + "\n" +
original.substr(posDiv[1]);
var newSiteTitle = getPageTitle().htmlEncode();
revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
return revised;
};
//
// UploadLog
//
// config.options.chkUploadLog :
// false : no logging
// true : logging
// config.options.txtUploadLogMaxLine :
// -1 : no limit
// 0 : no Log lines but UploadLog is still in place
// n : the last n lines are only kept
// NaN : no limit (-1)
bidix.UploadLog = function() {
if (!config.options.chkUploadLog)
return; // this.tiddler = null
this.tiddler = store.getTiddler("UploadLog");
if (!this.tiddler) {
this.tiddler = new Tiddler();
this.tiddler.title = "UploadLog";
this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
this.tiddler.created = new Date();
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
}
return this;
};
bidix.UploadLog.prototype.addText = function(text) {
if (!this.tiddler)
return;
// retrieve maxLine when we need it
var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
if (isNaN(maxLine))
maxLine = -1;
// add text
if (maxLine != 0)
this.tiddler.text = this.tiddler.text + text;
// Trunck to maxLine
if (maxLine >= 0) {
var textArray = this.tiddler.text.split('\n');
if (textArray.length > maxLine + 1)
textArray.splice(1,textArray.length-1-maxLine);
this.tiddler.text = textArray.join('\n');
}
// update tiddler fields
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
// refresh and notifiy for immediate update
story.refreshTiddler(this.tiddler.title);
store.notify(this.tiddler.title, true);
};
bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir, backupDir) {
if (!this.tiddler)
return;
var now = new Date();
var text = "\n| ";
var filename = bidix.basename(document.location.toString());
if (!filename) filename = '/';
text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
text += config.options.txtUserName + " | ";
text += "[["+filename+"|"+location + "]] |";
text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
text += uploadDir + " | ";
text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
text += backupDir + " |";
this.addText(text);
};
bidix.UploadLog.prototype.endUpload = function(status) {
if (!this.tiddler)
return;
this.addText(" "+status+" |");
};
//
// Utilities
//
bidix.checkPlugin = function(plugin, major, minor, revision) {
var ext = version.extensions[plugin];
if (!
(ext &&
((ext.major > major) ||
((ext.major == major) && (ext.minor > minor)) ||
((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
// write error in PluginManager
if (pluginInfo)
pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
}
};
bidix.dirname = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(0, lastpos);
} else {
return filePath.substring(0, filePath.lastIndexOf("\\"));
}
};
bidix.basename = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("#")) != -1)
filePath = filePath.substring(0, lastpos);
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(lastpos + 1);
} else
return filePath.substring(filePath.lastIndexOf("\\")+1);
};
bidix.initOption = function(name,value) {
if (!config.options[name])
config.options[name] = value;
};
//
// Initializations
//
// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);
// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");
//optionsDesc
merge(config.optionsDesc,{
txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
txtUploadUserName: "Upload Username",
pasUploadPassword: "Upload Password",
chkUploadLog: "do Logging in UploadLog (default: true)",
txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});
// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');
// Backstage
merge(config.tasks,{
uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");
//}}}
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://atl.tiddlyspot.com/controlpanel]] (your control panel username is //atl//).
<<tiddler TspotControls>>
See also GettingStarted.
@@font-weight:bold;font-size:1.3em;color:#444; //Working online// @@ You can edit this ~TiddlyWiki right now, and save your changes using the "save to web" button in the column on the right.
@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// @@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick. You can make changes and save them locally without being connected to the Internet. When you're ready to sync up again, just click "upload" and your ~TiddlyWiki will be saved back to tiddlyspot.com.
@@font-weight:bold;font-size:1.3em;color:#444; //Help!// @@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]]. Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help. If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].
@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// @@ We hope you like using your tiddlyspot.com site. Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions.
/***
|''Name:''|zzz_config|
|''Version:''|10-01-2012 |
|''Type:''|Configuration of TW settings |
|''Source:''||
|''Author:''|Okido|
|''Documentation:''|None |
|''~SourceCode:''| |
|''Licence:''| |
|''~CoreVersion:''|2.6.0|
|''Browser:''|Firefox 3.5 or better|
***/
config.options.chkShowQuickEdit=true;
config.options.chkSinglePageMode=true;
config.options.chkSinglePagePermalink= false;
config.options.txtBackupFolder="backup";
config.options.txtUserName="Okido";
config.options.chkAnimate=false;
config.views.editor.tagPrompt=" ";
config.options.txtMaxEditRows=140;
config.macros.edit.cancelMsg = "";
config.macros.edit.saveMsg = "";
config.options.chkBreadcrumbsLimit=true;
config.options.txtBreadcrumbsLimit=10;