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

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