tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE html>
  2. <html prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article# " vocab="http://ogp.me/ns" lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>TiddlyWiki in the Sky (or TiddlyWeb for TW5) | Pleasant Programmer</title>
  7. <link href="../assets/css/rst.css" rel="stylesheet" type="text/css">
  8. <link href="../assets/css/code.css" rel="stylesheet" type="text/css">
  9. <link href="../assets/css/theme.css" rel="stylesheet" type="text/css">
  10. <link href="../assets/css/custom.css" rel="stylesheet" type="text/css">
  11. <link rel="alternate" type="application/rss+xml" title="RSS" href="../rss.xml">
  12. <link rel="canonical" href="http://pleasantprogrammer.com/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html">
  13. <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script><script type="text/javascript">try{Typekit.load();}catch(e){}</script><!--[if lt IE 9]><script src="../assets/js/html5.js"></script><![endif]--><meta name="author" content="Thomas Dy">
  14. <link rel="prev" href="is-my-terminal-window-active.html" title="Is My Terminal Window Active?" type="text/html">
  15. <link rel="next" href="cloudflare-shenanigans.html" title="Cloudflare Shenanigans" type="text/html">
  16. <meta property="og:site_name" content="Pleasant Programmer">
  17. <meta property="og:title" content="TiddlyWiki in the Sky (or TiddlyWeb for TW5)">
  18. <meta property="og:url" content="http://pleasantprogrammer.com/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html">
  19. <meta property="og:description" content="I've always liked TiddlyWiki. Back when it first came out, it was really amazing. A wiki all in one file, that worked in the browser. It didn't need a backend, it would just save itself as an all new ">
  20. <meta property="og:type" content="article">
  21. <meta property="article:published_time" content="2015-12-24T14:48:20+08:00">
  22. <meta property="article:tag" content="sysadmin tiddlywiki">
  23. </head>
  24. <body>
  25. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  26. <header id="header" role="banner"><div class="thomas">
  27. <img src="../assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS"><img src="../assets/img/thomas.png" alt="Pleasant Programmer">
  28. </div>
  29. <h1 id="brand"><a href="http://pleasantprogrammer.com/" title="Pleasant Programmer" rel="home">
  30. <span id="blog-title">Pleasant Programmer</span>
  31. </a></h1>
  32. <nav id="menu" role="navigation"><ul>
  33. <li class="twitter"><a href="http://twitter.com/pleasantprog">@pleasantprog</a></li>
  34. <li><a href="../archive.html">Archives</a></li>
  35. <li><a href="../categories/index.html">Tags</a></li>
  36. <li><a href="../rss.xml">RSS</a></li>
  37. </ul></nav></header><div id="container">
  38. <main id="content" role="main"><article class="post-text h-entry hentry postpage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h1 class="p-name entry-title" itemprop="headline name"><a href="#" class="u-url">TiddlyWiki in the Sky (or TiddlyWeb for TW5)</a></h1>
  39. <small>
  40. <span class="dateline">Posted: <a href="#" rel="bookmark"><time class="published dt-published" datetime="2015-12-24T14:48:20+08:00" itemprop="datePublished" title="2015-12-24 14:48">2015-12-24 14:48</time></a></span>
  41. |
  42. More posts about
  43. <a class="tag p-category" href="../categories/sysadmin-tiddlywiki.html" rel="tag">sysadmin tiddlywiki</a>
  44. </small>
  45. </header><div class="e-content entry-content" itemprop="articleBody text">
  46. <div>
  47. <p>I've always liked <a href="http://tiddlywiki.com">TiddlyWiki</a>. Back when it first came out, it was really amazing. A wiki all in one file, that worked in the browser. It didn't need a backend, it would just save itself as an all new HTML file with all your posts inside. I've used it a lot over the years, as a personal wiki/journal and a class notebook. I even had a blog with it at one point using one of the server-side forks.</p>
  48. <p>Now, there's TiddlyWiki5 which is a rewrite of the original TiddlyWiki that looks a whole lot snazzier, and I assume has better architecture overall. It also has experimental support for all the server-side platforms (particularly TiddlyWeb) that have cropped up.</p>
  49. <p>If you're just looking for a simple server setup for TiddlyWiki5, it has native support for that on its own. There's plenty of documentation on the site. But if you're looking for more advanced features (like storing your posts in git or a database), then you'll need to use it with TiddlyWeb. The problem is that most of the documentation for TiddlyWeb still refers to the old TiddlyWiki.</p>
  50. <p>To support TiddlyWiki5, we'll need a version of the wiki which has the TiddlyWeb plugin already installed and configured. After that, some tweaking is necessary to get TiddlyWeb to provide what the wiki requires.</p>
  51. <h3>Setting Up TiddlyWiki</h3>
  52. <p>TiddlyWiki5 provides a command line tool via <code>npm</code> that allows building custom versions of the wiki. In fact, it comes with templates, called "editions", that we can use for our setup. Assuming you already have it installed, create the wiki using</p>
  53. <pre class="code literal-block">tiddlywiki mywiki --init tw5tank # create wiki from template
  54. </pre>
  55. <p>This creates a wiki intended for use with <a href="https://tank.peermore.com/">Tank</a>, which is built on top of TiddlyWeb. From here, you should look in <code>mywiki/tiddlers/system</code> which contain the entries for <code>SiteTitle</code>, <code>SiteSubtitle</code>, <code>DefaultTiddlers</code>, and <code>tiddlyweb-host</code>. The first 3 should be configured however you want. These are necessary because they're needed before the wiki can load them from the server. <code>tiddlyweb-host</code> contains the location of the TiddlyWeb server, this should be <code>http://localhost:8080/</code> if you're just testing locally. With everything configured, you can build the new wiki by running</p>
  56. <pre class="code literal-block">tiddlywiki mywiki --build
  57. </pre>
  58. <p>This will output the wiki to <code>mywiki/output/tw5tank.html</code>. You can now serve it using your favorite local webserver, like <code>python -m http.server</code>.</p>
  59. <h3>Setting Up TiddlyWeb</h3>
  60. <p>The TiddlyWeb tutorial recommends using <code>tiddlywebwiki</code> which has all the plugins setup for a nice wiki instance for the old TiddlyWiki. It has a lot of features that aren't really needed, so we won't go with that. So first, we'll need to install TiddlyWeb and any plugins we might want to use.</p>
  61. <pre class="code literal-block">pip install tiddlyweb tiddlywebplugins.status tiddlywebplugins.cherrypy tiddlywebplugins.cors
  62. </pre>
  63. <p>Next, we'll need the tiddlyweb configuration in <code>tiddlywebconfig.py</code></p>
  64. <pre class="code literal-block"><span class="c"># A basic configuration.</span>
  65. <span class="c"># `pydoc tiddlyweb.config` for details on configuration items.</span>
  66. <span class="kn">import</span> <span class="nn">tiddlywebplugins.status</span>
  67. <span class="n">config</span> <span class="o">=</span> <span class="p">{</span>
  68. <span class="s">'system_plugins'</span><span class="p">:</span> <span class="p">[</span><span class="s">'tiddlywebplugins.status'</span><span class="p">,</span> <span class="s">'tiddlywebplugins.cors'</span><span class="p">],</span>
  69. <span class="s">'secret'</span><span class="p">:</span> <span class="s">'36c98d6d14618c79f0ed2d49cd1b9e272d8d4bd0'</span><span class="p">,</span>
  70. <span class="s">'wsgi_server'</span><span class="p">:</span> <span class="s">'tiddlywebplugins.cherrypy'</span><span class="p">,</span>
  71. <span class="s">'cors.enable_non_simple'</span><span class="p">:</span> <span class="bp">True</span>
  72. <span class="p">}</span>
  73. <span class="n">original_gather_data</span> <span class="o">=</span> <span class="n">tiddlywebplugins</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">_gather_data</span>
  74. <span class="k">def</span> <span class="nf">_status_gather_data</span><span class="p">(</span><span class="n">environ</span><span class="p">):</span>
  75. <span class="n">data</span> <span class="o">=</span> <span class="n">original_gather_data</span><span class="p">(</span><span class="n">environ</span><span class="p">)</span>
  76. <span class="n">data</span><span class="p">[</span><span class="s">'space'</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s">'recipe'</span><span class="p">:</span> <span class="s">'default'</span><span class="p">}</span>
  77. <span class="k">return</span> <span class="n">data</span>
  78. <span class="n">tiddlywebplugins</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">_gather_data</span> <span class="o">=</span> <span class="n">_status_gather_data</span>
  79. </pre>
  80. <p>The tweaks involved are:</p>
  81. <ul>
  82. <li>using the status plugin which the wiki requires</li>
  83. <li>monkeypatching the status plugin for the wiki to use the correct "recipe"</li>
  84. <li>using cherrypy server instead of the buggy default one</li>
  85. <li>using cors since we're not hosting the wiki itself on the same server</li>
  86. </ul>
  87. <p>With that, we just need to create the store that will hold our data</p>
  88. <pre class="code literal-block">twanager recipe default &lt;&lt;EOF
  89. desc: standard TiddlyWebWiki environment
  90. policy: {"read": [], "create": [], "manage": ["R:ADMIN"], "accept": [], "write": ["R:ADMIN"], "owner": "administrator", "delete": ["R:ADMIN"]}
  91. /bags/default/tiddlers
  92. EOF
  93. twanager bag default &lt;&lt;EOF
  94. {"policy": {"read": [], "create": [], "manage": ["R:ADMIN"], "accept": [], "write": [], "owner": "administrator", "delete": []}}
  95. EOF
  96. </pre>
  97. <p>Finally, we can start the TiddlyWeb server</p>
  98. <pre class="code literal-block">twanager server
  99. </pre>
  100. <h3>Putting it all together</h3>
  101. <p>Once you have the TiddlyWeb server running, you can just go to wherever you're hosting the wiki html and it should work. You can try creating some posts, and the check mark on the sidebar should be red for a while and then turn black. Once that's done it's saved. You can refresh your browser and your posts should still be there.</p>
  102. <p>At this point, you can start customizing your TiddlyWeb instance, by changing your store to something like a database, or adding authorization. You can also tweak the server setup so you won't need CORS anymore.</p>
  103. <p>TiddlyWiki5 is still relatively new. I hope that eventually, support for server-side and the plugin ecosystem grows to be as great as the old TiddlyWiki.</p>
  104. </div>
  105. </div>
  106. <aside class="postpromonav"><nav><ul class="pager clearfix">
  107. <li class="previous">
  108. <a href="is-my-terminal-window-active.html" rel="prev" title="Is My Terminal Window Active?">← Previous post</a>
  109. </li>
  110. <li class="next">
  111. <a href="cloudflare-shenanigans.html" rel="next" title="Cloudflare Shenanigans">Next post →</a>
  112. </li>
  113. </ul></nav></aside><section class="comments"><div id="disqus_thread"></div>
  114. <script>
  115. var disqus_shortname ="pleasantprog",
  116. disqus_url="http://pleasantprogrammer.com/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html",
  117. disqus_title="TiddlyWiki in the Sky (or TiddlyWeb for TW5)",
  118. disqus_identifier="cache/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html",
  119. disqus_config = function () {
  120. this.language = "en";
  121. };
  122. (function() {
  123. var dsq = document.createElement('script'); dsq.async = true;
  124. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  125. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  126. })();
  127. </script><noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a>
  128. </noscript>
  129. <a href="//disqus.com" class="dsq-brlink" rel="nofollow">Comments powered by <span class="logo-disqus">Disqus</span></a>
  130. </section></article><script>var disqus_shortname="pleasantprog";(function(){var a=document.createElement("script");a.async=true;a.src="//"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script></main><footer id="footer" role="contentinfo"><p><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"></a> © 2015 Thomas Dy - Powered by <a href="http://getnikola.com">Nikola</a></p>
  131. </footer>
  132. </div>
  133. <script src="../assets/js/konami.js"></script><script src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>
  134. var easter_egg = new Konami();
  135. easter_egg.code = function() {
  136. $(".thomas").toggleClass("whoa");
  137. $("body").scrollTop(0);
  138. }
  139. easter_egg.load();
  140. // love you, thomas!
  141. // yours, @_phi + @meggykawsek
  142. </script>
  143. </body>
  144. </html>