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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.15" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="/assets/css/theme.css">
  8. <link rel="alternate" href="/rss.xml" type="application/rss+xml" title="Pleasant Programmer">
  9. <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
  10. <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  11. <title>TiddlyWiki in the Sky (or TiddlyWeb for TW5) - Pleasant Programmer</title>
  12. </head>
  13. <body>
  14. <header id="header" role="banner">
  15. <div id="thomas">
  16. <img src="/assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
  17. <img src="/assets/img/thomas.png" alt="Pleasant Programmer">
  18. </div>
  19. <h1 class="site-title"><a href="/">Pleasant Programmer</a></h1>
  20. <nav id="menu" role="navigation">
  21. <ul>
  22. <li class="twitter">
  23. <a href="http://twitter.com/pleasantprog">@pleasantprog</a>
  24. </li>
  25. <li><a href="/posts.html">archives</a></li>
  26. <li><a href="/tags/index.html">tags</a></li>
  27. <li><a href="/rss.xml">rss</a></li>
  28. </ul>
  29. </nav>
  30. </header>
  31. <div id="container">
  32. <main id="content" role="main">
  33. <article itemscope itemtype="http://schema.org/BlogPosting">
  34. <h1 class="p-name entry-title" itemprop="headline name">
  35. <a href="/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html">TiddlyWiki in the Sky (or TiddlyWeb for TW5)</a></h1>
  36. <small>
  37. <span class="dateline">Posted: <time itemprop="datePublished" datetime="2015-12-24">2015-12-24</time></span>
  38. | More posts about
  39. <a class="tag p-category" href="/tags/sysadmin.html" rel="tag">
  40. sysadmin
  41. </a>
  42. <a class="tag p-category" href="/tags/tiddlywiki.html" rel="tag">
  43. tiddlywiki
  44. </a>
  45. </small>
  46. <div class="e-content entry-content" itemprop="entry-text">
  47. <p>I&rsquo;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&rsquo;t need a backend, it would just save itself as an all new HTML file with all your posts inside. I&rsquo;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&rsquo;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&rsquo;re just looking for a simple server setup for TiddlyWiki5, it has native support for that on its own. There&rsquo;s plenty of documentation on the site. But if you&rsquo;re looking for more advanced features (like storing your posts in git or a database), then you&rsquo;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&rsquo;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. <h2 id="setting-up-tiddlywiki:1f502be524b8b2be2ec53e61b7c9a5cf">Setting Up TiddlyWiki</h2>
  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 &ldquo;editions&rdquo;, that we can use for our setup. Assuming you already have it installed, create the wiki using</p>
  53. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">tiddlywiki mywiki --init tw5tank <span style="color: #408080; font-style: italic"># create wiki from template</span>
  54. </pre></div>
  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&rsquo;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&rsquo;re just testing locally. With everything configured, you can build the new wiki by running</p>
  56. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">tiddlywiki mywiki --build
  57. </pre></div>
  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. <h2 id="setting-up-tiddlyweb:1f502be524b8b2be2ec53e61b7c9a5cf">Setting Up TiddlyWeb</h2>
  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&rsquo;t really needed, so we won&rsquo;t go with that. So first, we&rsquo;ll need to install TiddlyWeb and any plugins we might want to use.</p>
  61. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">pip install tiddlyweb tiddlywebplugins.status tiddlywebplugins.cherrypy tiddlywebplugins.cors
  62. </pre></div>
  63. <p>Next, we&rsquo;ll need the tiddlyweb configuration in <code>tiddlywebconfig.py</code></p>
  64. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #408080; font-style: italic"># A basic configuration.</span>
  65. <span style="color: #408080; font-style: italic"># `pydoc tiddlyweb.config` for details on configuration items.</span>
  66. <span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">tiddlywebplugins.status</span>
  67. config <span style="color: #666666">=</span> {
  68. <span style="color: #BA2121">&#39;system_plugins&#39;</span>: [<span style="color: #BA2121">&#39;tiddlywebplugins.status&#39;</span>, <span style="color: #BA2121">&#39;tiddlywebplugins.cors&#39;</span>],
  69. <span style="color: #BA2121">&#39;secret&#39;</span>: <span style="color: #BA2121">&#39;36c98d6d14618c79f0ed2d49cd1b9e272d8d4bd0&#39;</span>,
  70. <span style="color: #BA2121">&#39;wsgi_server&#39;</span>: <span style="color: #BA2121">&#39;tiddlywebplugins.cherrypy&#39;</span>,
  71. <span style="color: #BA2121">&#39;cors.enable_non_simple&#39;</span>: <span style="color: #008000">True</span>
  72. }
  73. original_gather_data <span style="color: #666666">=</span> tiddlywebplugins<span style="color: #666666">.</span>status<span style="color: #666666">.</span>_gather_data
  74. <span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">_status_gather_data</span>(environ):
  75. data <span style="color: #666666">=</span> original_gather_data(environ)
  76. data[<span style="color: #BA2121">&#39;space&#39;</span>] <span style="color: #666666">=</span> {<span style="color: #BA2121">&#39;recipe&#39;</span>: <span style="color: #BA2121">&#39;default&#39;</span>}
  77. <span style="color: #008000; font-weight: bold">return</span> data
  78. tiddlywebplugins<span style="color: #666666">.</span>status<span style="color: #666666">.</span>_gather_data <span style="color: #666666">=</span> _status_gather_data
  79. </pre></div>
  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 &ldquo;recipe&rdquo;</li>
  84. <li>using cherrypy server instead of the buggy default one</li>
  85. <li>using cors since we&rsquo;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. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">twanager recipe default <span style="color: #BA2121">&lt;&lt;EOF</span>
  89. <span style="color: #BA2121">desc: standard TiddlyWebWiki environment</span>
  90. <span style="color: #BA2121">policy: {&quot;read&quot;: [], &quot;create&quot;: [], &quot;manage&quot;: [&quot;R:ADMIN&quot;], &quot;accept&quot;: [], &quot;write&quot;: [&quot;R:ADMIN&quot;], &quot;owner&quot;: &quot;administrator&quot;, &quot;delete&quot;: [&quot;R:ADMIN&quot;]}</span>
  91. <span style="color: #BA2121">/bags/default/tiddlers</span>
  92. <span style="color: #BA2121">EOF</span>
  93. twanager bag default <span style="color: #BA2121">&lt;&lt;EOF</span>
  94. <span style="color: #BA2121">{&quot;policy&quot;: {&quot;read&quot;: [], &quot;create&quot;: [], &quot;manage&quot;: [&quot;R:ADMIN&quot;], &quot;accept&quot;: [], &quot;write&quot;: [], &quot;owner&quot;: &quot;administrator&quot;, &quot;delete&quot;: []}}</span>
  95. <span style="color: #BA2121">EOF</span>
  96. </pre></div>
  97. <p>Finally, we can start the TiddlyWeb server</p>
  98. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">twanager server
  99. </pre></div>
  100. <h2 id="putting-it-all-together:1f502be524b8b2be2ec53e61b7c9a5cf">Putting it all together</h2>
  101. <p>Once you have the TiddlyWeb server running, you can just go to wherever you&rsquo;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&rsquo;s done it&rsquo;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&rsquo;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. <aside class="postpromonav">
  106. <nav>
  107. <ul class="pager clearfix">
  108. <li class="previous">
  109. <a href="/posts/cloudflare-shenanigans.html" rel="prev" title="Cloudflare Shenanigans">&larr; Previous post</a>
  110. </li>
  111. <li class="next">
  112. <a href="/posts/is-my-terminal-window-active.html" rel="next" title="Is My Terminal Window Active?">Next post &rarr;</a>
  113. </li>
  114. </ul>
  115. </nav>
  116. </aside>
  117. <section class="comments">
  118. <div id="disqus_thread"></div>
  119. <script type="text/javascript">
  120. var disqus_shortname = 'pleasantprog';
  121. var disqus_url = 'http:\/\/pleasantprogrammer.com\/posts\/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html';
  122. var disqus_title = 'TiddlyWiki in the Sky (or TiddlyWeb for TW5)';
  123. var disqus_identifier = 'cache/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html';
  124. (function() {
  125. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  126. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  127. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  128. })();
  129. </script>
  130. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  131. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  132. </section>
  133. </article>
  134. </main>
  135. <footer id="footer" role="contentinfo">
  136. <p>
  137. <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
  138. <img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png">
  139. </a> &copy; 2015 Thomas Dy - Powered by <a href="http://gohugo.io">Hugo</a></p>
  140. </footer>
  141. </div>
  142. <script src="/assets/js/konami.js"></script>
  143. <script>
  144. var easter_egg = new Konami();
  145. easter_egg.code = function() {
  146. var el = document.getElementById('thomas');
  147. if(el.className == "whoa") {
  148. el.className = "";
  149. }
  150. else {
  151. el.className = "whoa";
  152. }
  153. document.body.scrollTop = document.documentElement.scrollTop = 0;
  154. }
  155. easter_egg.load();
  156. </script>
  157. </body>
  158. </html>