Thios page can be a location to put some ideas of how to use Tomboy

ToDo organisation

I have two notes:

  • TodoToday and

  • TodoTomorrow

Both are linked to each other. Now I only add 1-3 important points on the list what i want to do today. If I cant get them done today I move them to tomorrow note. Maybe also a point is not useful any more and gets dumped. This is a very good reminder of what is really important. Them being interlinked makes it very easy to access each one quickly. This is a very simple system that his proved to be very effective here. -- ThiloPfennig 2007-07-26 12:32:30

Tomboy on mobile phone

I've created a set of scripts that make Tomboy really useful to me. It's inspired by how Evernote works with the iPhone. I wanted the same thing but I use an older Sony Ericson phone with very a limited browser in it. Here's what I did:

  1. Created a script that monitors my .tomboy folder. The script uses the FAM frontend fileschanged
  2. When fileschanged discovers that something changed in the folder, it rsyncs it (over ssh) to my home server. The server is set up with a dyndns.org name, so it's always accessible from the Internet.
  3. On the web server I have a really simple php script that translates the folder content to a web page.
  4. On the phone, I've bookmarked the web page.

Both my laptop and my server are Ubuntu 8.04, so most of the needed packaged was already installed. I really only had to install fileschanged:

sudo apt-get install fileschanged

Then I created the script that monitors the .tomboy folder: /home/myuser/scripts/tomboymonitor.sh

fileschanged -r -t=1 /home/myuser/.tomboy | while read file; do
        rsync -avzq -e ssh /home/myuser/.tomboy myuser@myserver.dyndns.org:/home/myuser > /home/myuser/scripts/log/tomboymonitor.log
done

The script needs to be executable for the owner (me), so just:

>chmod o+x /home/myuser/scripts/tomboymonitor.sh

As you can see, I rsync the entire .tomboy folder to a .tomboy folder in my home folder on the server. The apache2 server needs to have the Userdir module setup (on the server):

sudo a2enmod userdir
sudo /etc/init.d/apache2 force-reload

The userdir module will look web content in the public_html folder. The index.php that I've created was placed in a tomboy sub folder:

mkdir /home/myuser/public_html
mkdir /home/myuser/public_html/tomboy

The source of the index.php goes like this:

<?php
$TOMBOY_PATH = "/home/myuser/.tomboy";
$GREETING = "Notes for Me";

function resolveInternalLinks($notes, $text) {
  $links = array();
  foreach($notes as $note) {
    $link = array();
    $link["string"] = "<link:internal>" . $note["content"]["title"] . "</link:internal>";
    $link["title"] = $note["content"]["title"];
    $link["id"] = $note["id"];
    $links[] = $link;
  }
  foreach($links as $link) {
    $text = str_replace($link["string"], "<a href=\"index.php?note=" . $link["id"] . "\">" . $link["title"] . "</a>", $text);
  }
  return $text;
}

function findNoteIdByTitle($notes, $title) {
  foreach($notes as $note) {
    if($note["content"]["title"] == $title) {
      return $note["id"];
    }
  }
  return "";
}

function getNote($id, $rev, $full) {
  global $TOMBOY_PATH, $notes;
  $ret = array();
  #$path = $TOMBOY_PATH . "/0/" . $rev . "/" . $id . ".note";
  $path = $TOMBOY_PATH . "/" . $id . ".note";
  $xmlnotedoc = new DOMDocument();
  $xmlnotedoc->resolveExternals = false;        
  $xmlnotedoc->load($path);
  $node = $xmlnotedoc->documentElement;
  foreach($node->childNodes as $cn) {
    switch($cn->nodeName) {
      case "title":
        $ret["title"] = utf8_decode($cn->nodeValue); 
        break;
      case "text":
        if($full) {
          $note_content_node = $cn->childNodes->item(0);
          $ret["text"] = utf8_decode($xmlnotedoc->saveXML($note_content_node));
          $ret["text"] = str_replace("\n", "<br/>\n", $ret["text"]);
          $ret["text"] = str_replace("<note-content version=\"0.1\">" . $ret["title"] . "<br/>", "<h1>". $ret["title"] . "</h1>", $ret["text"]);
          $ret["text"] = str_replace("</note-content>", "", $ret["text"]);
          /* bold text */
          $ret["text"] = str_replace("<bold>", "<b>", $ret["text"]);
          $ret["text"] = str_replace("</bold>", "</b>", $ret["text"]);
          /* lists */
          $ret["text"] = str_replace("<list>", "<ul>", $ret["text"]);
          $ret["text"] = str_replace("</list>", "</ul>", $ret["text"]);
          /* listitems */
          $ret["text"] = str_replace("<list-item", "<li", $ret["text"]);
          $ret["text"] = str_replace("</list-item>", "</li>", $ret["text"]);
          
          /* links */
          $ret["text"] = resolveInternalLinks($notes, $ret["text"]);
        
        }
    } 
  }
  return $ret;
}


function getNotes() {
  global $TOMBOY_PATH;

  $notes = array();
  $files = scandir($TOMBOY_PATH);
  foreach($files as $file) {
    $path_parts = pathinfo($file);
    if($file != "." && $file != ".." && $path_parts["extension"]=="note") {
          $note = array();
          $note["id"] = $path_parts["filename"];
          $note["rev"] = "0";
          $note["content"] = getNote($note["id"], $note["rev"], false);
          $notes[$note["id"]] = $note;
    }
  }
  return $notes;
}

$notes = getNotes();
?>
  


<html>
<body>
  <?php
  if($_REQUEST["note"] != "") {
    $notes = getNotes();
    $note = $notes[$_REQUEST["note"]];
    $note["content"] = getNote($note["id"], $note["rev"], true);

  ?>
  <?=$note["content"]["text"]?>
  <?php } else {?>

  <table>
    <tr>
        <td><?=$GREETING?></td>
    </tr>  
  <?php foreach($notes as $note) { ?>
    <tr><td>
      <a href="index.php?note=<?=$note["id"]?>"><?=$note["content"]["title"];?>  </a>
    </td></tr>
  <?php } ?>
  </table>
  <?php } ?>
</body>
</html>

The script will translate some but far from all Tomboy markup into HTML. The present script takes care of lists, bold text and internal links, but nothing else. That pretty much covers my needs, but I realize that other users will want more. So go ahead and enhance the script and update this page with your improvements.

Apps/Tomboy/UsageIdeas (last edited 2013-08-09 00:14:58 by WilliamJonMcCann)