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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.88.0" />
  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"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">tiddlywiki mywiki --init tw5tank <span style="color:#007f7f"># create wiki from template</span>
  55. </code></pre></div><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"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">tiddlywiki mywiki --build
  57. </code></pre></div><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>
  58. <h2 id="setting-up-tiddlyweb">Setting Up TiddlyWeb</h2>
  59. <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>
  60. <div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">pip install tiddlyweb tiddlywebplugins.status tiddlywebplugins.cherrypy tiddlywebplugins.cors
  61. </code></pre></div><p>Next, we&rsquo;ll need the tiddlyweb configuration in <code>tiddlywebconfig.py</code></p>
  62. <div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#007f7f"># A basic configuration.</span>
  63. <span style="color:#007f7f"># `pydoc tiddlyweb.config` for details on configuration items.</span>
  64. <span style="color:#fff;font-weight:bold">import</span> tiddlywebplugins.status
  65. config = {
  66. <span style="color:#0ff;font-weight:bold">&#39;system_plugins&#39;</span>: [<span style="color:#0ff;font-weight:bold">&#39;tiddlywebplugins.status&#39;</span>, <span style="color:#0ff;font-weight:bold">&#39;tiddlywebplugins.cors&#39;</span>],
  67. <span style="color:#0ff;font-weight:bold">&#39;secret&#39;</span>: <span style="color:#0ff;font-weight:bold">&#39;36c98d6d14618c79f0ed2d49cd1b9e272d8d4bd0&#39;</span>,
  68. <span style="color:#0ff;font-weight:bold">&#39;wsgi_server&#39;</span>: <span style="color:#0ff;font-weight:bold">&#39;tiddlywebplugins.cherrypy&#39;</span>,
  69. <span style="color:#0ff;font-weight:bold">&#39;cors.enable_non_simple&#39;</span>: <span style="color:#fff;font-weight:bold">True</span>
  70. }
  71. original_gather_data = tiddlywebplugins.status._gather_data
  72. <span style="color:#fff;font-weight:bold">def</span> _status_gather_data(environ):
  73. data = original_gather_data(environ)
  74. data[<span style="color:#0ff;font-weight:bold">&#39;space&#39;</span>] = {<span style="color:#0ff;font-weight:bold">&#39;recipe&#39;</span>: <span style="color:#0ff;font-weight:bold">&#39;default&#39;</span>}
  75. <span style="color:#fff;font-weight:bold">return</span> data
  76. tiddlywebplugins.status._gather_data = _status_gather_data
  77. </code></pre></div><p>The tweaks involved are:</p>
  78. <ul>
  79. <li>using the status plugin which the wiki requires</li>
  80. <li>monkeypatching the status plugin for the wiki to use the correct &ldquo;recipe&rdquo;</li>
  81. <li>using cherrypy server instead of the buggy default one</li>
  82. <li>using cors since we&rsquo;re not hosting the wiki itself on the same server</li>
  83. </ul>
  84. <p>With that, we just need to create the store that will hold our data</p>
  85. <div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">twanager recipe default <span style="color:#0ff;font-weight:bold">&lt;&lt;EOF
  86. </span><span style="color:#0ff;font-weight:bold">desc: standard TiddlyWebWiki environment
  87. </span><span style="color:#0ff;font-weight:bold">policy: {&#34;read&#34;: [], &#34;create&#34;: [], &#34;manage&#34;: [&#34;R:ADMIN&#34;], &#34;accept&#34;: [], &#34;write&#34;: [&#34;R:ADMIN&#34;], &#34;owner&#34;: &#34;administrator&#34;, &#34;delete&#34;: [&#34;R:ADMIN&#34;]}
  88. </span><span style="color:#0ff;font-weight:bold">
  89. </span><span style="color:#0ff;font-weight:bold">/bags/default/tiddlers
  90. </span><span style="color:#0ff;font-weight:bold">EOF</span>
  91. twanager bag default <span style="color:#0ff;font-weight:bold">&lt;&lt;EOF
  92. </span><span style="color:#0ff;font-weight:bold">{&#34;policy&#34;: {&#34;read&#34;: [], &#34;create&#34;: [], &#34;manage&#34;: [&#34;R:ADMIN&#34;], &#34;accept&#34;: [], &#34;write&#34;: [], &#34;owner&#34;: &#34;administrator&#34;, &#34;delete&#34;: []}}
  93. </span><span style="color:#0ff;font-weight:bold">EOF</span>
  94. </code></pre></div><p>Finally, we can start the TiddlyWeb server</p>
  95. <div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">twanager server
  96. </code></pre></div><h2 id="putting-it-all-together">Putting it all together</h2>
  97. <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>
  98. <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>
  99. <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>
  100. </div>
  101. <aside class="postpromonav">
  102. <nav>
  103. <ul class="pager clearfix">
  104. <li class="previous">
  105. <a href="/posts/is-my-terminal-window-active.html" rel="prev" title="Is My Terminal Window Active?">&larr; Previous post</a>
  106. </li>
  107. <li class="next">
  108. <a href="/posts/cloudflare-shenanigans.html" rel="next" title="Cloudflare Shenanigans">Next post &rarr;</a>
  109. </li>
  110. </ul>
  111. </nav>
  112. </aside>
  113. <section class="comments">
  114. <script
  115. data-isso="https://isso.pleasantprogrammer.com/"
  116. data-isso-require-author="true"
  117. data-isso-vote="false"
  118. src="https://isso.pleasantprogrammer.com/js/embed.min.js">
  119. </script>
  120. <section id="isso-thread"></section>
  121. </section>
  122. </article>
  123. </main>
  124. <footer id="footer" role="contentinfo">
  125. <p>
  126. <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
  127. <img alt="CC-BY-SA" style="border-width:0" src="https://licensebuttons.net/l/by-sa/3.0/80x15.png">
  128. </a> &copy; 2020 Thomas Dy - Powered by <a href="http://gohugo.io">Hugo</a></p>
  129. </footer>
  130. </div>
  131. <script src="/assets/js/konami.js"></script>
  132. <script>
  133. var easter_egg = new Konami();
  134. easter_egg.code = function() {
  135. var el = document.getElementById('thomas');
  136. if(el.className == "whoa") {
  137. el.className = "";
  138. }
  139. else {
  140. el.className = "whoa";
  141. }
  142. document.body.scrollTop = document.documentElement.scrollTop = 0;
  143. }
  144. easter_egg.load();
  145. </script>
  146. </body>
  147. </html>