mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 12:19:11 +00:00
Merge pull request #276 from davidjade/master
Added TiddlyIE and FSO saver modules
This commit is contained in:
commit
761b66028d
1
bld.cmd
1
bld.cmd
@ -38,6 +38,7 @@ node .\tiddlywiki.js ^
|
|||||||
--rendertiddler ReadMe .\readme.md text/html ^
|
--rendertiddler ReadMe .\readme.md text/html ^
|
||||||
--rendertiddler ContributingTemplate .\contributing.md text/html ^
|
--rendertiddler ContributingTemplate .\contributing.md text/html ^
|
||||||
--rendertiddler $:/editions/tw5.com/download-empty %TW5_BUILD_OUTPUT%\empty.html text/plain ^
|
--rendertiddler $:/editions/tw5.com/download-empty %TW5_BUILD_OUTPUT%\empty.html text/plain ^
|
||||||
|
--rendertiddler $:/editions/tw5.com/download-empty %TW5_BUILD_OUTPUT%\empty.hta text/plain ^
|
||||||
--rendertiddler $:/core/templates/static.template.html %TW5_BUILD_OUTPUT%\static.html text/plain ^
|
--rendertiddler $:/core/templates/static.template.html %TW5_BUILD_OUTPUT%\static.html text/plain ^
|
||||||
--rendertiddler $:/core/templates/static.template.css %TW5_BUILD_OUTPUT%\static\static.css text/plain ^
|
--rendertiddler $:/core/templates/static.template.css %TW5_BUILD_OUTPUT%\static\static.css text/plain ^
|
||||||
--rendertiddlers [!is[system]] $:/core/templates/static.tiddler.html %TW5_BUILD_OUTPUT%\static text/plain ^
|
--rendertiddlers [!is[system]] $:/core/templates/static.tiddler.html %TW5_BUILD_OUTPUT%\static text/plain ^
|
||||||
|
1
bld.sh
1
bld.sh
@ -39,6 +39,7 @@ node ./tiddlywiki.js \
|
|||||||
--rendertiddler ReadMe ./readme.md text/html \
|
--rendertiddler ReadMe ./readme.md text/html \
|
||||||
--rendertiddler ContributingTemplate ./contributing.md text/html \
|
--rendertiddler ContributingTemplate ./contributing.md text/html \
|
||||||
--rendertiddler $:/editions/tw5.com/download-empty $TW5_BUILD_OUTPUT/empty.html text/plain \
|
--rendertiddler $:/editions/tw5.com/download-empty $TW5_BUILD_OUTPUT/empty.html text/plain \
|
||||||
|
--rendertiddler $:/editions/tw5.com/download-empty $TW5_BUILD_OUTPUT/empty.hta text/plain \
|
||||||
--rendertiddler $:/core/templates/static.template.html $TW5_BUILD_OUTPUT/static.html text/plain \
|
--rendertiddler $:/core/templates/static.template.html $TW5_BUILD_OUTPUT/static.html text/plain \
|
||||||
--rendertiddler $:/core/templates/static.template.css $TW5_BUILD_OUTPUT/static/static.css text/plain \
|
--rendertiddler $:/core/templates/static.template.css $TW5_BUILD_OUTPUT/static/static.css text/plain \
|
||||||
--rendertiddlers [!is[system]] $:/core/templates/static.tiddler.html $TW5_BUILD_OUTPUT/static text/plain \
|
--rendertiddlers [!is[system]] $:/core/templates/static.tiddler.html $TW5_BUILD_OUTPUT/static text/plain \
|
||||||
|
75
core/modules/savers/fsosaver.js
Normal file
75
core/modules/savers/fsosaver.js
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/savers/fsosaver.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: saver
|
||||||
|
|
||||||
|
Handles saving changes via MS FileSystemObject ActiveXObject
|
||||||
|
|
||||||
|
Note: Since TiddlyWiki's markup contains the MOTW, the FileSystemObject normally won't be available.
|
||||||
|
However, if the wiki is loaded as an .HTA file (Windows HTML Applications) then the FSO can be used.
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Select the appropriate saver module and set it up
|
||||||
|
*/
|
||||||
|
var FSOSaver = function(wiki) {
|
||||||
|
};
|
||||||
|
|
||||||
|
FSOSaver.prototype.save = function(text,method,callback) {
|
||||||
|
// Bail out unless this is a save (rather than a download)
|
||||||
|
if(method !== "save") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get the pathname of this document
|
||||||
|
var pathname = unescape(document.location.pathname);
|
||||||
|
// Test for a Windows path of the form /x:\blah...
|
||||||
|
if(/^\/[A-Z]\:\\[^\\]+/i.test(pathname)) { // ie: ^/[a-z]:/[^/]+
|
||||||
|
// Remove the leading slash
|
||||||
|
pathname = pathname.substr(1);
|
||||||
|
} else if (document.location.hostname !== "" && /^\/\\[^\\]+\\[^\\]+/i.test(pathname)) { // test for \\server\share\blah... - ^/[^/]+/[^/]+
|
||||||
|
// Remove the leading slash
|
||||||
|
pathname = pathname.substr(1);
|
||||||
|
// reconstruct UNC path
|
||||||
|
pathname = "\\\\" + document.location.hostname + pathname;
|
||||||
|
} else return false;
|
||||||
|
|
||||||
|
// Save the file (as UTF-16)
|
||||||
|
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||||
|
var file = fso.OpenTextFile(pathname,2,-1,-1);
|
||||||
|
|
||||||
|
file.Write(text);
|
||||||
|
file.Close();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Information about this saver
|
||||||
|
*/
|
||||||
|
FSOSaver.prototype.info = {
|
||||||
|
name: "FSOSaver",
|
||||||
|
priority: 120
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Static method that returns true if this saver is capable of working
|
||||||
|
*/
|
||||||
|
exports.canSave = function(wiki) {
|
||||||
|
try {
|
||||||
|
return (window.location.protocol === "file:") && !!(new ActiveXObject("Scripting.FileSystemObject"));
|
||||||
|
} catch(e) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create an instance of this saver
|
||||||
|
*/
|
||||||
|
exports.create = function(wiki) {
|
||||||
|
return new FSOSaver(wiki);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
73
core/modules/savers/tiddlyie.js
Normal file
73
core/modules/savers/tiddlyie.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/savers/tiddlyie.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: saver
|
||||||
|
|
||||||
|
Handles saving changes via Internet Explorer BHO extenion (TiddlyIE)
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Select the appropriate saver module and set it up
|
||||||
|
*/
|
||||||
|
var TiddlyIESaver = function(wiki) {
|
||||||
|
};
|
||||||
|
|
||||||
|
TiddlyIESaver.prototype.save = function(text,method,callback) {
|
||||||
|
// Bail out unless this is a save (rather than a download)
|
||||||
|
if(method !== "save") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// check existence of TiddlyIE BHO extension (note: only works after document is complete)
|
||||||
|
if(typeof(window.TiddlyIE) != "undefined") {
|
||||||
|
// Get the pathname of this document
|
||||||
|
var pathname = unescape(document.location.pathname);
|
||||||
|
// Test for a Windows path of the form /x:/blah...
|
||||||
|
if(/^\/[A-Z]\:\/[^\/]+/i.test(pathname)) { // ie: ^/[a-z]:/[^/]+ (is this better?: ^/[a-z]:/[^/]+(/[^/]+)*\.[^/]+ )
|
||||||
|
// Remove the leading slash
|
||||||
|
pathname = pathname.substr(1);
|
||||||
|
// Convert slashes to backslashes
|
||||||
|
pathname = pathname.replace(/\//g,"\\");
|
||||||
|
} else if(document.hostname !== "" && /^\/[^\/]+\/[^\/]+/i.test(pathname)) { // test for \\server\share\blah... - ^/[^/]+/[^/]+
|
||||||
|
// Convert slashes to backslashes
|
||||||
|
pathname = pathname.replace(/\//g,"\\");
|
||||||
|
// reconstruct UNC path
|
||||||
|
pathname = "\\\\" + document.location.hostname + pathname;
|
||||||
|
} else return false;
|
||||||
|
|
||||||
|
// Prompt the user to save the file
|
||||||
|
window.TiddlyIE.save(pathname, text);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Information about this saver
|
||||||
|
*/
|
||||||
|
TiddlyIESaver.prototype.info = {
|
||||||
|
name: "tiddlyiesaver",
|
||||||
|
priority: 1500
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Static method that returns true if this saver is capable of working
|
||||||
|
*/
|
||||||
|
exports.canSave = function(wiki) {
|
||||||
|
return (window.location.protocol === "file:");
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create an instance of this saver
|
||||||
|
*/
|
||||||
|
exports.create = function(wiki) {
|
||||||
|
return new TiddlyIESaver(wiki);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
5
core/templates/MOTW.html.tid
Normal file
5
core/templates/MOTW.html.tid
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
title: $:/core/templates/MOTW.html
|
||||||
|
|
||||||
|
\rules only filteredtranscludeinline transcludeinline entity
|
||||||
|
<!-- The following comment is called a MOTW comment and is necessary for the TiddlyIE Internet Explorer extension. -->
|
||||||
|
<!-- saved from url=(0021)http://TiddlyWiki.com -->
|
@ -2,8 +2,10 @@ title: $:/core/templates/tiddlywiki5.html
|
|||||||
|
|
||||||
\rules only filteredtranscludeinline transcludeinline
|
\rules only filteredtranscludeinline transcludeinline
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
{{$:/core/templates/MOTW.html}}
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Force IE standards mode for Intranet and HTA - should be the first meta -->
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<meta name="application-name" content="TiddlyWiki" />
|
<meta name="application-name" content="TiddlyWiki" />
|
||||||
<meta name="generator" content="TiddlyWiki" />
|
<meta name="generator" content="TiddlyWiki" />
|
||||||
|
9
editions/tw5.com/tiddlers/definitions/TiddlyIE.tid
Normal file
9
editions/tw5.com/tiddlers/definitions/TiddlyIE.tid
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
created: 20131211220000000
|
||||||
|
modified: 20131211224200000
|
||||||
|
tags: definitions
|
||||||
|
title: TiddlyIE
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
TiddlyIE is an extension for Internet Explorer that allows standalone TiddlyWiki files to save their changes directly to the file system. TiddlyIE works with the desktop version of Internet Explorer.
|
||||||
|
|
||||||
|
See [[Saving with TiddlyIE]].
|
19
editions/tw5.com/tiddlers/saving/Saving with TiddlyIE.tid
Normal file
19
editions/tw5.com/tiddlers/saving/Saving with TiddlyIE.tid
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
created: 20131211220000000
|
||||||
|
modified: 20131211224900000
|
||||||
|
tags: howto
|
||||||
|
title: Saving with TiddlyIE
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
# Install the TiddlyIE add-on from:
|
||||||
|
#* https://github.com/davidjade/TiddlyIE/releases
|
||||||
|
# Restart Internet Explorer. IE will prompt you to enable the TiddlyIE add-on.
|
||||||
|
#> You may also see a prompt to enable the //Microsoft Script Runtime//
|
||||||
|
# [[Download]] an empty TiddlyWiki by clicking this button:
|
||||||
|
#> {{$:/editions/tw5.com/snippets/download-empty-button}}
|
||||||
|
#> Your browser may ask you to accept the download before it begins
|
||||||
|
# Locate the file you just downloaded
|
||||||
|
#* You may rename it, but be sure to keep the `.html` extension
|
||||||
|
# Open the file in Internet Explorer
|
||||||
|
# Try creating a new tiddler using the ''plus'' {{$:/core/images/new-button}} button in the sidebar. Type some content for the tiddler, and click the {{$:/core/images/done-button}} ''tick'' button
|
||||||
|
# Save your changes by clicking the {{$:/core/images/save-button}} ''download'' button in the sidebar. Internet Explorer will ask for your consent to save the file locally by presenting a file ''Save As'' dialog.
|
||||||
|
# Refresh the browser window to verify that your changes have been saved correctly
|
Loading…
Reference in New Issue
Block a user