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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.36" />
  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="/pages/projects.html">projects</a></li>
  26. <li><a href="/posts.html">archives</a></li>
  27. <li><a href="/tags.html">tags</a></li>
  28. <li><a href="/rss.xml">rss</a></li>
  29. </ul>
  30. </nav>
  31. </header>
  32. <div id="container">
  33. <main id="content" role="main">
  34. <article itemscope itemtype="http://schema.org/BlogPosting">
  35. <h1 class="p-name entry-title" itemprop="headline name">
  36. <a href="/posts/tiddlywiki-in-the-sky-or-tiddlyweb-for-tw5.html">TiddlyWiki in the Sky (or TiddlyWeb for TW5)</a></h1>
  37. <small>
  38. <span class="dateline">Posted: <time itemprop="datePublished" datetime="2015-12-24">2015-12-24</time></span>
  39. | More posts about
  40. <a class="tag p-category" href="/tags/sysadmin.html" rel="tag">
  41. sysadmin
  42. </a>
  43. <a class="tag p-category" href="/tags/tiddlywiki.html" rel="tag">
  44. tiddlywiki
  45. </a>
  46. </small>
  47. <div class="e-content entry-content" itemprop="entry-text">
  48. <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>
  49. <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>
  50. <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>
  51. <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>
  52. <h2 id="setting-up-tiddlywiki">Setting Up TiddlyWiki</h2>
  53. <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>
  54. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-sh" data-lang="sh"><span></span>tiddlywiki mywiki --init tw5tank <span style="color: #408080; font-style: italic"># create wiki from template</span>
  55. </code></pre></div>
  56. <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>
  57. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-sh" data-lang="sh"><span></span>tiddlywiki mywiki --build
  58. </code></pre></div>
  59. <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>
  60. <h2 id="setting-up-tiddlyweb">Setting Up TiddlyWeb</h2>
  61. <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>
  62. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-sh" data-lang="sh"><span></span>pip install tiddlyweb tiddlywebplugins.status tiddlywebplugins.cherrypy tiddlywebplugins.cors
  63. </code></pre></div>
  64. <p>Next, we&rsquo;ll need the tiddlyweb configuration in <code>tiddlywebconfig.py</code></p>
  65. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-python" data-lang="python"><span></span><span style="color: #408080; font-style: italic"># A basic configuration.</span>
  66. <span style="color: #408080; font-style: italic"># `pydoc tiddlyweb.config` for details on configuration items.</span>
  67. <span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">tiddlywebplugins.status</span>
  68. config <span style="color: #666666">=</span> {
  69. <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>],
  70. <span style="color: #BA2121">&#39;secret&#39;</span>: <span style="color: #BA2121">&#39;36c98d6d14618c79f0ed2d49cd1b9e272d8d4bd0&#39;</span>,
  71. <span style="color: #BA2121">&#39;wsgi_server&#39;</span>: <span style="color: #BA2121">&#39;tiddlywebplugins.cherrypy&#39;</span>,
  72. <span style="color: #BA2121">&#39;cors.enable_non_simple&#39;</span>: <span style="color: #008000">True</span>
  73. }
  74. original_gather_data <span style="color: #666666">=</span> tiddlywebplugins<span style="color: #666666">.</span>status<span style="color: #666666">.</span>_gather_data
  75. <span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">_status_gather_data</span>(environ):
  76. data <span style="color: #666666">=</span> original_gather_data(environ)
  77. 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>}
  78. <span style="color: #008000; font-weight: bold">return</span> data
  79. tiddlywebplugins<span style="color: #666666">.</span>status<span style="color: #666666">.</span>_gather_data <span style="color: #666666">=</span> _status_gather_data
  80. </code></pre></div>
  81. <p>The tweaks involved are:</p>
  82. <ul>
  83. <li>using the status plugin which the wiki requires</li>
  84. <li>monkeypatching the status plugin for the wiki to use the correct &ldquo;recipe&rdquo;</li>
  85. <li>using cherrypy server instead of the buggy default one</li>
  86. <li>using cors since we&rsquo;re not hosting the wiki itself on the same server</li>
  87. </ul>
  88. <p>With that, we just need to create the store that will hold our data</p>
  89. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-sh" data-lang="sh"><span></span>twanager recipe default <span style="color: #BA2121">&lt;&lt;EOF</span>
  90. <span style="color: #BA2121">desc: standard TiddlyWebWiki environment</span>
  91. <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>
  92. <span style="color: #BA2121">/bags/default/tiddlers</span>
  93. <span style="color: #BA2121">EOF</span>
  94. twanager bag default <span style="color: #BA2121">&lt;&lt;EOF</span>
  95. <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>
  96. <span style="color: #BA2121">EOF</span>
  97. </code></pre></div>
  98. <p>Finally, we can start the TiddlyWeb server</p>
  99. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><code class="language-sh" data-lang="sh"><span></span>twanager server
  100. </code></pre></div>
  101. <h2 id="putting-it-all-together">Putting it all together</h2>
  102. <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>
  103. <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>
  104. <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>
  105. </div>
  106. <aside class="postpromonav">
  107. <nav>
  108. <ul class="pager clearfix">
  109. <li class="previous">
  110. <a href="/posts/is-my-terminal-window-active.html" rel="prev" title="Is My Terminal Window Active?">&larr; Previous post</a>
  111. </li>
  112. <li class="next">
  113. <a href="/posts/cloudflare-shenanigans.html" rel="next" title="Cloudflare Shenanigans">Next post &rarr;</a>
  114. </li>
  115. </ul>
  116. </nav>
  117. </aside>
  118. <section class="comments">
  119. <script
  120. data-isso="https://isso.pleasantprogrammer.com/"
  121. data-isso-require-author="true"
  122. data-isso-vote="false"
  123. src="https://isso.pleasantprogrammer.com/js/embed.min.js">
  124. </script>
  125. <section id="isso-thread"></section>
  126. </section>
  127. </article>
  128. </main>
  129. <footer id="footer" role="contentinfo">
  130. <p>
  131. <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
  132. <img alt="CC-BY-SA" style="border-width:0" src="https://licensebuttons.net/l/by-sa/3.0/80x15.png">
  133. </a> &copy; 2018 Thomas Dy - Powered by <a href="http://gohugo.io">Hugo</a></p>
  134. </footer>
  135. </div>
  136. <script src="/assets/js/konami.js"></script>
  137. <script>
  138. var easter_egg = new Konami();
  139. easter_egg.code = function() {
  140. var el = document.getElementById('thomas');
  141. if(el.className == "whoa") {
  142. el.className = "";
  143. }
  144. else {
  145. el.className = "whoa";
  146. }
  147. document.body.scrollTop = document.documentElement.scrollTop = 0;
  148. }
  149. easter_egg.load();
  150. </script>
  151. </body>
  152. </html>