Skip to content

Instantly share code, notes, and snippets.

@Arlen22
Last active November 12, 2019 21:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arlen22/45f1a460c9e348fa50ad to your computer and use it in GitHub Desktop.
Save Arlen22/45f1a460c9e348fa50ad to your computer and use it in GitHub Desktop.
Another way to run the TiddlyWiki GitHub version
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const shell = electron.shell;
var mainWindow = null;
var arg2 = process.argv[2];
app.on('ready', function() {
global.file = arg2 ? arg2 : electron.dialog.showOpenDialog({ properties: [ 'openFile' ]});
if(!file) process.exit(0);
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
webPreferences: {
nodeIntegration: true
}
});
mainWindow.loadURL('file:///' + file);
mainWindow.on('closed', function() {
mainWindow = null;
});
mainWindow.maximize();
//Handle link click events
mainWindow.webContents.on('new-window', function(event, url){
event.preventDefault();
shell.openExternal(url);
});
});
<!doctype html>
<html>
<head></head>
<body class="tc-body">
<script>
global.$tw = global.require("./boot/bootprefix.js").bootprefix();
global.$tw.boot.argv = ['./editions/server'];
global.$tw = require("./boot/boot.js").TiddlyWiki(global.$tw);
</script>
</body>
</html>
@Arlen22
Copy link
Author

Arlen22 commented Jan 24, 2015

Download the files from GitHub, add index.htm to the TiddlyWiki folder, and then run node-webkit with start X:\path\to\nw.exe --url="%cd%\index.htm" (in a batch file).

@Arlen22
Copy link
Author

Arlen22 commented Dec 27, 2016

Or for Electron, download both electron.js and index.html and put them in the root TiddlyWiki folder (i.e. beside tiddlywiki.js). Then open command prompt and run /path/to/electron.exe electron.js index.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment