Skip to content

Instantly share code, notes, and snippets.

View Arlen22's full-sized avatar

Arlen22

View GitHub Profile
@Arlen22
Arlen22 / $:_Arlen22_toggle-centered-button
Last active August 29, 2015 13:57
Two tiddlers which pass a create argument to the fieldmangler widget. They are designed for use in a topmenu in TW5.
\define createStateTiddler()
tags: $:/tags/stylesheet
$(default)$
\end
\define state-1-css()
\end
\define state-2-css()
@media (min-width: 770px) { .story-river { margin: 0 auto; } .sidebar-header { left: 50%; right: 0; padding-left: 413px; } }
@Arlen22
Arlen22 / fieldmangler.js:execute()
Created March 27, 2014 13:09
Add create param to fieldmangler.js using x-tiddler deserializer. (public domain)
FieldManglerWidget.prototype.execute = function() {
// Get our parameters
this.mangleTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
this.createText = this.getAttribute("create",false);
// Process create param
if(this.createText) {
var createTiddler = $tw.wiki.deserializeTiddlers("application/x-tiddler",this.createText);
createTiddler[0]['title'] = this.mangleTitle;
if(!this.wiki.tiddlerExists(this.mangleTitle))
this.wiki.addTiddler(createTiddler[0]);
@Arlen22
Arlen22 / New Journal button
Last active August 29, 2015 13:57
New Journal buttons (public domain)
\define tiddlerText()
title: My New Tiddler
This is a test. It should show an unsubstituted variable with a message. $($(test)$)$
\end
<$set name="test" value="substituteVariables works!" >
<$button message="tw-new-tiddler" class="btn-invisible" param=<<tiddlerText>> >{{$:/core/images/new-button}}</$button>
<$button message="tw-new-tiddler" class="btn-invisible" param=<<substituteVariables tiddler:"new-tiddler-test" >> >{{$:/core/images/new-button}}</$button>
</$set>
@Arlen22
Arlen22 / gist:11149776
Created April 21, 2014 17:31
macrodef changes for external macro body
/*\
title: $:/core/modules/parsers/wikiparser/rules/macrodef.js
type: application/javascript
module-type: wikirule
Wiki pragma rule for macro definitions
```
\define name(param:defaultvalue,param2:defaultvalue)
definition text, including $param$ markers
@Arlen22
Arlen22 / gist:11149813
Last active August 29, 2015 14:00
macrodef - macro definition tiddler
/*\
title: $:/core/modules/parsers/wikiparser/rules/macrodef.js
type: application/javascript
module-type: wikirule
Wiki pragma rule for macro definitions
```
\define name(param:defaultvalue,param2:defaultvalue)
definition text, including $param$ markers
this.stateTitle = this.state;
this.readState();
// Construct the child widgets
- var childNodes = this.isOpen ? this.parseTreeNode.children : [];
- this.hasChildNodes = this.isOpen;
+ if(this.hasVariable("tv-static-output", "yes")) {
+ this.alwaysRender = true;
+ } else {
+ this.alwaysRender = false;
+ }
@Arlen22
Arlen22 / StaticTagMacro
Created January 8, 2015 22:31
Static Tag Macro demonstration
\define tag-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end
\define tag-body-inner(colour,fallbackTarget,colourA,colourB)
<$set name="foregroundColor" value=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>>
<$set name="backgroundColor" value="""$colour$"""><!--popup=<<qualify "$:/state/popup/tag">>-->
<$button popup=<<qualify "$:/state/popup/tag">> class="tc-btn-invisible tc-tag-label" style=<<tag-styles>> static="yes">
/*\
title: NodeWebKitSaver.js
type: application/javascript
module-type: saver
Handles saving changes via node.js in the browser (node-webkit).
\*/
(function(){
@Arlen22
Arlen22 / index.htm
Last active August 29, 2015 14:13
How to use node-webkit with tiddlywiki GitHub code.
<!doctype html>
<html>
<head></head>
<body class="tc-body">
<script>process.mainModule.exports.boot();</script>
</body>
</html>
@Arlen22
Arlen22 / electron.js
Last active November 12, 2019 21:56
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({