TiddlyWiki 5 Documentation

repository·master·Indexed 27 days ago

https://github.com/tiddlywiki/tiddlywiki5

A non-linear personal web notebook available as a single HTML file or a Node.js application. Version 5.5.0-prerelease features high customizability via WikiText and includes tools for serving content via HTTP, automated testing, and text synchronization using Diff Match and Patch. The repository also contains integrated libraries for BibTeX parsing, QR code scanning (Html5-QRCode), QR code generation (node-yaqrcode), and XML/HTML parsing (sax.js).

Tokens
30.5K
Snippets
36
Records
210
Agent score
93%

What's inside TiddlyWiki

  1. Overview of Html5-QRCode library

    master

    Html5-QRCode is a lightweight, cross-platform JavaScript library used to integrate QR code, bar code, and other common code scanning capabilities into web applications. It supports scanning via device cameras (with user permissions) or by selecting local image files.

    Key features include:

    • Support for various 1D and 2D code formats.
    • Cross-platform support (Android, iOS, Windows, Mac, Linux).
    • Browser support (Chrome, Firefox, Safari, Edge, Opera, etc.).
    • Two API modes: Html5QrcodeScanner for an end-to-end UI and Html5Qrcode for a low-level implementation where you build your own UI.
  2. Use Diff Match and Patch for text synchronization

    master

    The Diff Match and Patch library provides robust algorithms for synchronizing plain text through three primary operations:

    1. Diff: Compares two blocks of plain text and returns an efficient list of differences.
    2. Match: Finds the best fuzzy match for a search string within a block of plain text, weighted for both accuracy and location.
    3. Patch: Applies a list of patches to plain text using a best-effort approach, even if the underlying text has changed slightly.

    This library is useful for implementing features similar to Google Docs where multiple users might be editing the same text.

  3. Extract and import tiddlers from an HTML file using utility scripts

    master

    To extract tiddlers from an original HTML file (specifically for the great-interview-project-2010 edition) and import them into a new wiki build, follow these steps:

    1. Extract JSON via Browser Console:

      • Load ./editions/tiddlywiki-surveys/great-interview-project-2010/The great TiddlyWiki interview project.htm in a web browser.
      • Open the developer console and execute the script found at ./editions/tiddlywiki-surveys/scripts/extract-text-tiddlers-via-console.js.
      • The script will generate a JSON representation of the text tiddlers and copy it to your clipboard.
    2. Prepare JSON File:

      • Paste the clipboard content into a new file named 2010-great-interview-project.json located in the ./tmp folder at the repository root.
    3. Run Import Script:

      • Open a terminal in the repository root.
      • Execute the shell script: ./editions/tiddlywiki-surveys/scripts/import-great-interview-project-json.sh.
      • After the script runs, go back to the browser developer console and copy the output. Note: This is a large block of text starting with mkdir -p. Ensure you select the entire block including newlines.
    4. Execute Shell Commands and Build:

      • Paste the copied text from the browser console into your terminal.
      • Build the wiki using the TiddlyWiki Node.js CLI:
        node ./tiddlywiki.js ./editions/tiddlywiki-surveys --build index
    5. Locate Output:

      • The built wiki will be available at ./editions/tiddlywiki-surveys/output/index.html.
    node ./tiddlywiki.js ./editions/tiddlywiki-surveys --build index
  4. Install TiddlyWiki on Node.js

    master

    To use TiddlyWiki as a Node.js application, follow these steps:

    1. Install Node.js based on your platform:
      • Debian/Ubuntu: apt install nodejs (and apt install npm if necessary).
      • Arch Linux: yay -S tiddlywiki (installs both Node and TiddlyWiki).
      • Mac: brew install node.
      • Android: Use Termux.
    2. Install TiddlyWiki globally using npm:
      npm install -g tiddlywiki
       *Note: If you encounter permission errors on Mac/Linux, use `sudo npm install -g tiddlywiki`.*
    3. **Verify installation**:
       ```bash
    tiddlywiki --version

    You should see the version number (e.g., 5.4.1).

  5. Submit a contribution to TiddlyWiki5

    master

    To contribute to TiddlyWiki5, you must sign the Individual Contributor License Agreement (CLA). This is a legally binding document that grants the UnaMesa Association the rights to use, modify, and distribute your contribution.

    Steps to Contribute:

    1. Read the Agreement: Carefully review the licenses/cla-individual.md file.
    2. Check Ownership: Ensure you own the copyright to your contribution. If you do not own the entire work of authorship, follow the specific instructions in contributing.md located in the project root.
    3. Sign and Submit: Follow the electronic submission instructions provided in contributing.md to send your signed agreement to the UnaMesa Association.

    Key Terms for Contributors:

    • Copyright: You retain ownership of your contribution and its copyright.
    • License Grant: You grant a perpetual, worldwide, non-exclusive, transferable, royalty-free, and irrevocable license to the UnaMesa Association to use your contribution as part of the TiddlyWiki5 material.
    • Outbound License: The UnaMesa Association agrees to license your contribution under the same terms used for the project at the time of submission (typically BSD 3-clause "New" or "Revised" License) or Creative Commons Attribution 3.0 for non-software media.
  6. Use sax.js to parse XML or HTML

    master

    sax.js is a SAX-style parser for XML and HTML. It can be used as a simple parser for XML strings or as a streaming parser in Node.js environments.

    To use the parser, initialize it with a strict boolean (set to true for XML, false for HTML/loose mode) and assign callback functions to the parser's event properties (e.g., onopentag, ontext, onend).

    var sax = require("./lib/sax"),
      strict = true, // set to false for html-mode
      parser = sax.parser(strict);
    
    parser.onerror = function (e) {
      // an error happened.
    };
    parser.ontext = function (t) {
      // got some text.  t is the string of text.
    };
    parser.onopentag = function (node) {
      // opened a tag.  node has "name" and "attributes"
    };
    parser.onattribute = function (attr) {
      // an attribute.  attr has "name" and "value"
    };
    parser.onend = function () {
      // parser stream is done, and ready to have more stuff written to it.
    };
    
    parser.write('<xml>Hello, <who name="world">world</who>!</xml>').close();
  7. Initialize and run a TiddlyWiki server

    master

    To create and start a new TiddlyWiki instance using the Node.js client/server configuration:

    1. Initialize a new wiki folder with server components:
      tiddlywiki mynewwiki --init server
    2. **Start the server**:
       ```bash
    tiddlywiki mynewwiki --listen
    1. Access the wiki by visiting http://127.0.0.1:8080/ in your web browser.

    To create an offline copy of your wiki, you can either use the save changes button in the sidebar or run:

    tiddlywiki mynewwiki --build index
    tiddlywiki mynewwiki --init server
    tiddlywiki mynewwiki --listen