Gimcrack'd

an exhibition of
narrative and machinery

download to iPod

this story's rss feed

view source

Hello world.
Hello world.
Hello world.
You can convert a ~TiddlyWiki you've already created to a lightweight Twinkie version right on this Web page. The main disadvantage of this process is you'll have to do it every time you want to make changes.\n\nLocate your ~TiddlyWiki file below and click the ''Twinkatize'' button to bind it to Twinkie. You'll be given a new copy of your file ready to be viewed over the Web.\n\n<html>\n<form enctype="multipart/form-data" method="post" action="twinkatize.php">\n<input type="file" name="source" /><br /><br />\n<input type="submit" value="Twinkatize" />\n</form>\n</html>
This macro closes all tiddlers with the passed tag. It does so slowly, so that the user can see what's happening. Modifying this macro to do it instantly would be trivial. Also bear in mind it does it as soon as the tiddler the macro is invoked in appears -- it doesn't display a button.\n\n''Example usage:''\n<html>&lt;&lt;closeTag 'moviereviews'&gt;&gt;</html>\n\n[[See CloseTagMacro in action]]\n[[View CloseTagMacro source code]]
You can convert a ~TiddlyWiki you've already created to a version for iPods right on this Web page. Locate your ~TiddlyWiki file below and click the ''iPodize'' button to convert it. You'll be given a zipped archive of files that can be copied to an iPod -- instructions on how to do this will be included in the archive.\n\n''This converter is experimental.'' You'll want to try things out on an iPod to make sure it is workable -- not all ~TiddlyWiki features will work on an iPod. If you notice something incorrect, please consider making a [[bug report]].\n\n<html>\n<form enctype="multipart/form-data" method="post" action="ipodize.php">\n<input type="file" name="source" /><br /><br />\n<input type="submit" value="iPodize" />\n</form>\n</html>
[[What's this?]]\n[[Licensing]]
This macro simply pops open a new window, passing along the first parameter. It's pretty specific to Gimcrack'd, but you may find it useful to adapt to your own needs.\n\n''Example usage'':\n<html>&lt;&lt;email 'Chris'&gt;&gt;</html>\n\n[[See EmailMacro in action]]\n[[View EmailMacro source code]]
~TiddlyWiki 1.2.39 by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)\n\nPublished under a BSD open source license\n\nCopyright (c) Osmosoft Limited 2005\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\nRedistributions 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.\n\nNeither the name of the Osmosoft Limited nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS 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.
This doesn't disable any of the other links.
The macros published on this page is published via the [[BSD license|http://en.wikipedia.org/wiki/BSD_License]], which essentially means that you may use it for any purpose (including commercial ones) so long as [[this copyright notice]] is retained.\n\nTwinkie is a derivative work of Jeremy Ruston's ~TiddlyWiki code, which is <html>&copy;</html> 2005 Osmosoft and is published via a BSD license as well. ([[Full notice]])\n\nThe licensing for Twee is a little complicated. The code in //twee//, //untwee//, and //tiddlywiki.php// is licensed under the [[GNU General Public License|http://www.gnu.org/copyleft/gpl.html]]. The file //zip.php// comes from the [[phpMyAdmin|http://www.phpmyadmin.net/]] project, and is used under the terms of the GPL. There are header files included with the Twee download that are derived from Jeremy Ruston's ~TiddlyWiki code, and as such fall under the [[BSD license|http://en.wikipedia.org/wiki/BSD_License]]. And finally, the default readme that comes with the iPod content that Twee produces is covered under the [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]].\n\nWhew!
Macros are little bits of code you can embed into a ~TiddlyWiki to make it behave in interesting ways. [[Chris|/#Chris]] has written several for this Web site:\n* [[Email]]\n* [[CloseTag]]\n* [[SelfishLink]]\n* [[SetFlag, IfFlag, and IfNotFlag]]\nYou can put them into your own ~TiddlyWiki but creating a new tiddler, pasting the code inside, and then giving it the ''systemConfig'' tag.
[[What's this?]]<html> &nbsp;&middot;&nbsp; </html>[[Licensing]]<html> &nbsp;&middot;&nbsp; </html>[[Twinkie]]<html> &nbsp;&middot;&nbsp; </html>[[Twee]]<html> &nbsp;&middot;&nbsp; </html>[[Macros]]
Now the other links are disabled.
First open these: [[1]] [[2]] [[3]]\nThen click [[this link]] to close them
<<email 'Chris'>>
First, [[see what flags are set]].\n\nThen, [[set the test flag]].\n\nThe tiddler doesn't change until you close it, then re-open it: [[see what flags are set]].
You can only click one of these links:\n* <<selfishLink 'Try me'>>\n* <<selfishLink 'No, me instead'>>\n* [[Here's a regular link]]
A ~SelfishLink is so greedy it will disable any other links in the same tiddler when the user clicks it. It's great for creating Choose Your Own Adventure kinds of stories. The disabled links are given the CSS class 'disabled,' so you can style them however you like.\n\nBe very careful about using ~SelfishLinks as you edit a ~TiddlyWiki. Because it changes a tiddler's contents on the fly (to prevent cheating), if you save changes after clicking a ~SelfishLink, you'll end up disabling your links permanently.\n\nThis includes a special handler that catches users clicking the ''Close All'' button and automatically restores the original version of a tiddler changed by a ~SelfishLink. To do this, you'll need to make a second copy of each tiddler you want to preserve, and call it ''//name//_shadow''. i.e. If you want to save a tiddler named ''helloWorld'', you should duplicate it a tiddler named ''helloWorld_shadow''.\n\nIf this behavior seems weird to you, you can cut out that part of the source code. It's the second and third stanzas in the source.\n\n''Example usage:''\n<html>&lt;&lt;selfishLink 'tiddler to open'&gt;&gt;</html>\n\n[[See SelfishLinkMacro in action]]\n[[View SelfishLinkMacro source code]]
These macros give ~TiddlyWikis the ability to remember what the user has done, and then change their contents accordingly. You use ''setFlag'' to remember something, then ''ifFlag'' or ''ifNotFlag'' to check for its presence. \n\n''Example usage:''\n<html>&lt;&lt;setFlag 'atebreakfast'&gt;&gt;</html>\n<html>&lt;&lt;ifFlag 'breakfast' 'Good to hear you're eating healthily.'&gt;&gt;</html>\n<html>&lt;&lt;ifNotFlag 'breakfast' 'But breakfast is the //most// important meal of the day!'&gt;&gt;</html>\n\nYou can put any kind of ~TiddlyWiki formatting inside a ''ifFlag'' or ''ifNotFlag'' call. Right now there isn't a ''clearFlag'' macro, but it wouldn't be hard to do.\n\nThese macros go hand-in-hand with the [[SelfishLink]] one so that you can remember what choices a user has made.\n\n[[See FlagMacros in action]]\n[[View FlagMacros source code]]
Code and Other Oddments
Gimcrack'd
http://www.gimcrackd.com/etc/src/
Now the other links are disabled.
Twee is a supersimple [[markup language]] for ~TiddlyWikis. It was invented when [[Chris|/#Chris]] spilled water on his laptop's trackpad, which knocked it out of commission temporarily, and he still wanted to work on his ~TiddlyWiki.\n\nIn short, Twee lets you turn plain text files that look like this:<html><pre>:: Twee [systemConfig]\nTwee is a supersimple [[markup language]] for ~TiddlyWikis.</pre></html>... into living, breathing ~TiddlyWikis. Right now, it allows you to target the latest version of ~TiddlyWiki, ~TiddlyWiki 1.2.39, [[Twinkie]], and iPods. It also includes //untwee//, a tool that converts existing ~TiddlyWikis to Twee source code.\n* [[Why would you want to use Twee?]]\n* [[Why wouldn't you want to use Twee?]]\nIf you're ready to try it out, you should check out the brief explanation of [[Twee syntax]] and maybe grab some [[Twee syntax modes]] for your text editor before you start rocking out.\n\nIf you have the command-line version PHP 5 installed on your computer, you can use Twee right from your favorite [[bash prompt|http://en.wikipedia.org/wiki/Unix_shell]]. (OS X users, please keep in mind that you probably have PHP 4, but [[updating|http://www.entropy.ch/software/macosx/php/]] isn't hard.)\n\nNormal human beings can use Twee right here on this Web page:\n* [[Twee your files online]]\n* [[Untwee a TiddlyWiki online]]\n* [[Convert your TiddlyWiki to iPod format online]]\n* [[Download Twee|twee.zip]] (96k)
To create a tiddler, type two colons, then its name, and then put any tags you want it to have between single brackets, like so:<html><pre>:: Title [oneTag otherTag]</pre></html>Then hit return and start typing your tiddler, just like you'd type when you're working with ~TiddlyWikis normally.\n\nYou need to be sure to write four tiddlers in your Twee source code: ~SiteTitle, ~SiteSubtitle, ~DefaultTiddlers, and ~MainMenu. These correspond to the [[special tiddlers|http://tiddlywiki.com/#SpecialTiddlers]] you should define for any ~TiddlyWiki anyway, but without them, your output will look pretty weird.\n\nThat's it! Seriously. If you're still confused, you may want to check out [[this example|example.tw]].
[[Download Emacs mode|twee-emacs.zip]] (1k)\n[[Download SubEthaEdit mode|twee-see.zip]] (8k)\n\nThese are pretty rudimentary for now, so improvements and additions are welcome.
You can feed as many source files into the compiler as you like -- click the plus button to add them in. The ''Target'' menu lets you choose what kind of ~TiddlyWiki to create.\n\n<html>\n<form action="twee.php" method="post" enctype="multipart/form-data">\n<input type="hidden" name="MAX_FILE_SIZE" value="200000" />\n \n<p>\n<label>Files</label><br />\n<input type="file" name="file1" />\n<input type="button" value="+" onclick="addFile()"><br />\n<span id="morefiles"></span>\n</p>\n\n<p>\n<label>Author</label>\n<input type="text" name="a" value="YourName" />\n</p>\n\n<p>\n<label>Target</label>\n<select name="t">\n<option value="tw">TiddlyWiki 1.2.39</option>\n<option value="tw2" selected>TiddlyWiki 2.0.4</option>\n<option value="twinkie">Twinkie</option>\n<option value="ipod">iPod</option>\n</select>\n</p>\n\n<p>\n<input type="submit" value="Twee" />\n</p>\n\n</form>\n</html>
var files = 1;\n\nfunction addFile()\n{\n files++;\n document.getElementById('morefiles').innerHTML += '<span id="file' + files +\n '"><input type="file" name="file' + files + '" /> <input type="button" ' +\n 'value="-" onclick="remove(\s'file' + files + '\s')" /><br />';\n}\n\nfunction remove (id)\n{\n files--;\n document.getElementById(id).parentNode.removeChild(document.getElementById(id));\n}\n\nfunction enable (which)\n{\n if (which == 'url')\n {\n document.getElementById('url').disabled = false;\n document.getElementById('file').disabled = true;\n document.getElementById('file').value = '';\n }\n else\n {\n document.getElementById('url').disabled = true;\n document.getElementById('url').value = '';\n document.getElementById('file').disabled = false;\n } \n}
Twinkie is a stripped-down version of the [[TiddlyWiki|http://www.tiddlywiki.com/]] source code. Its aim is to make read-only versions of ~TiddlyWikis available on the Web with a minimum of load time. It's not a very exciting piece of work. It's just the ~TiddlyWiki code stripped of as much as possible.\n\nTwinkie makes some key assumptions:\n* The files you will be feeding it will have all the tiddlers necessary for normal operation\n* You will set the title of the page by editing its source code\n* You will set styles through an external CSS file\n* Any macros you need are included manually (including those normally built into ~TiddlyWiki)\n[[Download compressed version|/lib/twinkie.js]] (39k)\n[[Download human-readable version|twinkiesrc.js]] (63k)\n[[Bind a TiddlyWiki file to Twinkie online]]\n\nAdditions to the code have been set off with a @@font-family: monospace;background-color: none; TWINKIE:@@ comment. They are pretty minor.\n\nYou may also be interested in the [[Twinkie PHP bridge]], which allows a file to be edited locally and then published read-only simultaneously without having to edit any source code.\n\nThe compressed version of Twinkie was produced with [[Dojo ShrinkSafe|http://alex.dojotoolkit.org/shrinksafe/]].
This is a small bit of glue that rewrites key parts of a ~TiddlyWiki source file so that it uses Twinkie when viewed on a remote Web server, but still remains editable locally.\n\nIt assumes:\n* You have the original ~TiddlyWiki source code abstracted to an external ~JavaScript file in the same directory as ''twinkie.js''\n* Your ~TiddlyWiki file is in the same directory as this script, and is named ''src.html''\n* The RSS feed for your ~TiddlyWiki file, if there is one, is in the same directory and is named ''src.xml''\n* You have a file in the same directory named ''style.css'' that contains all styles for your document\n* There's also a file at ''/lib/fringe.html'' you'd like to include in all documents -- well, this is probably not true for you, but removing it from the code is simple\nIt's handy to name this file ''index.php'', as this will make it the default file for the directory on most Apache setups.\n\n[[Download source|bridge.phps]] (< 1k)
You can either decompile a file you have on your computer or a ~TiddlyWiki published on the Web.\n\n<html>\n<form action="untwee.php" method="post" enctype="multipart/form-data">\n<input type="hidden" name="MAX_FILE_SIZE" value="300000" />\n\n<p>\n<label>\n<input type="radio" name="input_type" value="url" checked onclick="enable('url')" />\nURL\n</label>\n<input type="text" name="url" id="url" />\n</p>\n\n<p>\n<label>\n<input type="radio" name="input_type" value="file" onclick="enable('file')" />\nFile\n</label>\n<input type="file" name="file" id="file" disabled />\n</p>\n\n<p>\n<input type="checkbox" name="use_tw" value="yes" />Name the file .tw? <i>(May cause problems on Windows)</i>\n</p>\n\n<p>\n<input type="submit" value="Untwee" />\n</p>\n\n</form>\n</html>
version.extensions.closeTag = {major: 0, minor: 1, revision: 0};\n\n\nconfig.macros.closeTag = \n{\n text: "closeTag"\n};\n\nconfig.macros.closeTag.handler = function (place, macroName, params)\n{\n var self = config.macros.closeTag;\n self.toClose = store.getTaggedTiddlers(params);\n self.closeInterval = window.setInterval('config.macros.closeTag.closeTick()', 25);\n};\n\nconfig.macros.closeTag.closeTick = function()\n{\n var self = config.macros.closeTag;\n\n if (! self.toClose.length)\n {\n window.clearInterval(self.closeInterval);\n return;\n };\n \n if (document.getElementById('tiddler' + self.toClose[0].title))\n closeTiddler(self.toClose[0].title, false);\n else\n self.toClose.shift();\n};
version.extensions.email = {major: 0, minor: 1, revision: 0};\n\nconfig.macros.email = \n{\n text: 'email',\n label: 'Send an email'\n};\n\nconfig.macros.email.handler = function (place, macroName, params)\n{\n var link = document.createElement('a');\n link.href = '/etc/email/?p=' + params[0];\n link.className = 'externalLink';\n link.innerHTML = 'Email ' + params[0];\n \n link.onclick = function()\n {\n window.open('/etc/email/?p=' + params, null, 'width=315,height=400,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');\n return false;\n };\n \n place.appendChild(link);\n\n};
version.extensions.setFlag = {major: 0, minor: 1, revision: 0};\n\nconfig.macros.setFlag = \n{\n text: 'setFlag'\n};\n\nconfig.macros.setFlag.flags = new Object();\n\nconfig.macros.setFlag.handler = function (place, macroName, params)\n{\n config.macros.setFlag.flags[params[0]] = true;\n};\n\nversion.extensions.ifFlag = {major: 0, minor: 1, revision: 0};\n\nconfig.macros.ifFlag = \n{\n text: 'ifFlag'\n};\n\nconfig.macros.ifFlag.handler = function (place, macroName, params)\n{\n if (config.macros.setFlag.flags[params[0]])\n {\n var node = createTiddlyElement(place, 'span');\n wikify(params[1], node);\n };\n};\n\nversion.extensions.ifNotFlag = {major: 0, minor: 1, revision: 0};\n\nconfig.macros.ifNotFlag = \n{\n text: 'ifNotFlag'\n};\n\nconfig.macros.ifNotFlag.handler = function (place, macroName, params)\n{\n if (! config.macros.setFlag.flags[params[0]])\n {\n var node = createTiddlyElement(place, 'span');\n wikify(params[1], node);\n };\n};
version.extensions.selfishLink = {major: 0, minor: 1, revision: 0};\n\nconfig.macros.selfishLink = \n{\n text: 'selfishLink'\n};\n\nconfig.macros.selfishLink.handler = function (place, macroName, params)\n{\n var link = document.createElement('a');\n link.href = '#';\n link.className = 'tiddlyLinkExisting';\n link.innerHTML = params;\n link.onclick = function() { selfishLinkActivate(link, params[0]); };\n place.appendChild(link);\n\n\n function selfishLinkActivate (node, destination)\n { \n var parent_div = node.parentNode.parentNode;\n var title = findContainingTiddler(node).id.substr(7);\n var links = parent_div.getElementsByTagName('a');\n var trashed = new Array();\n \n for (var i = 0; i < links.length; i++)\n if (links[i] != node)\n {\n var span = document.createElement('span');\n span.innerHTML = links[i].innerHTML;\n span.className = 'disabled';\n links[i].parentNode.insertBefore(span, links[i].nextSibling);\n trashed.push(links[i]);\n };\n \n for (var i = 0; i < trashed.length; i++)\n trashed[i].parentNode.removeChild(trashed[i]);\n \n store.tiddlers[title].text = '<html>' + parent_div.innerHTML + '</html>'; \n displayTiddler(node, destination, 1, null, null, null, false, false);\n };\n};\n\nfunction restoreShadowed()\n{\n for (i in store.tiddlers)\n if (title = store.tiddlers[i].title.match(/(.*)_shadow$/))\n store.tiddlers[title[1]].text = store.tiddlers[i].text;\n}\n\nconfig.macros.closeAll.handler = function(place)\n{\n createTiddlyButton(place,this.label,this.prompt,function () {closeAllTiddlers(); refreshShadowed(); restart(); return false;});\n}
This is a catalog of all the code that makes this Web site work. It's probably only of interest to hackers or folks otherwise curious as to how it all works. Feel free to use the code here in your own projects -- the one caveat being that it is provided without any kind of warranty or promise of support. i.e. if it works for you, that's great. If not, sorry.\n\nThere are three kinds of things here:\n* [[Twinkie]]\n* [[Twee]]\n* [[Macros]]\nIf you have other questions about this code, feel free to <<email 'Chris'>>.
* You can use your [[favorite text editor|http://en.wikipedia.org/wiki/Editor_war]] to write your tiddlers, as well as to edit CSS and ~JavaScript for macros. Spell-checking your ~TiddlyWiki is also easy.\n* You can split up your ~TiddlyWiki into several files, making editing potentially less confusing.\n* No worrying about getting burned by browser crashes in the middle of writing. (You can turn on ~AutoSave while you write a normal ~TiddlyWiki, of course.)\n* Copyeditors and proofers enjoy working on flat text files, where everything is out in plain sight. \n* Converting your work to the latest version of ~TiddlyWiki is a snap.\n* You can now convert your ~TiddlyWiki into an iPod-readable version.
* You lose your timeline. All your tiddlers will have the same date -- when you used Twee to generate your ~TiddlyWiki.\n* You also lose your RSS feed. Twee isn't smart enough yet to figure out what changed between versions of a ~TiddlyWiki.\n* It's not as fun to edit, since you have to keep track of tiddler names yourself and you can't do that whole click-to-edit thing.\n* You have to run Twee every time you make a change and want to see what it looks like.
Bug reports regarding Twee's iPod output may be emailed to [[Chris|/#Chris]]. Please don't send a 400k ~TiddlyWiki file with just a message that says "it doesn't work." Specify exactly what it should do, and what it's currently doing wrong. Also, it would be really helpful if you can [[distill the bug down|http://www.chiark.greenend.org.uk/~sgtatham/bugs.html]] to a handful of tiddlers instead of a full-fledged ~TiddlyWiki.\n\nPlease bear in mind that iPods can't display any formatting at all -- not even bold or italics. Nor can they show pictures.
A markup language is different from a programming language; it lets you describe how something looks instead of how it acts.
<<ifNotFlag 'test' 'The test flag has not been set yet.'>><<ifFlag 'test' 'The test flag is set!'>>
<<setFlag 'test'>>You've just set the test flag.
Copyright <html>&copy;</html> Chris Klimas 2005\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n* 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.\n* The name of Chris Klimas may not be used to endorse or promote products derived from this software without specific prior written permission.\nTHIS 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.\n\nKind of serious for a little bit of ~JavaScript, eh?
<<closeTag 'closeme'>>Ta da!