Class Tiddler
In: r4tw.rb
Parent: Object

Tiddler

For creating and manipulating tiddlers

Example

 puts Tiddler.new({'tiddler'=>'Hello','text'=>'Hi there','tags'=>['tag1','tag2']})

Methods

External Aliases

from_tw -> from_remote_tw
from_tw -> from_local_tw

Attributes

fields  [RW] 

Public Class methods

Depending on the arguments this can be used to create or import a tiddler in various ways.

From scratch

If the argument is a Hash then it is used to specify a tiddler to be created from scratch.

Example:

 t = Tiddler.new.from({
   'tiddler'=>'HelloThere',
   'text'=>'And welcome',
 })

Other built-in fields are modified, created, modifier and tags. Any other fields you add will be created as tiddler extended fields. Text is the contents of the tiddler. Tiddler is the title of the tiddler.

From a file

If the argument looks like a file name (ie a string that doesn‘t match the other criteria then create a tiddler with the name being the file name and the contents being the contents of the file. Does some guessing about tags based on the file‘s extension. (This is customisable, see code for details). Also reads the file modified date and uses it.

Example:

 t = Tiddler.new.from("myplugin.js")

From a TiddlyWiki

If the argument is in the form file.html#TiddlerName or sitename.com/#TiddlerName then import TiddlerName from the specified location

Example:

 t1 = Tiddler.new.from("myfile.html#SomeTiddler")
 t2 = Tiddler.new.from("http://www.tiddlywiki.com/#HelloThere")

From a url

Creates a tiddler from a url. The entire contents of the page are the contents of the tiddler. You should set the ‘tiddler’ field and other fields using a hash as the second argument in the same format as creating a tiddler from scratch. There is no automatic tagging for this one so you should add tags yourself as required

Example:

 t = Tiddler.new.from(
   "http://svn.somewhere.org/Trunk/HelloWorld.js",
   {'tiddler'=>'HelloWorld','tags'=>'systemConfig'}
 )

From a div string

If the argument is a string containing a tiddler div such as would be found in a TiddlyWiki storeArea then the tiddler is created from that div

Public Instance methods

Adds a list of tags

Add some text to the end of a tiddler‘s content

Makes a copy of this tiddler

Makes a copy of this tiddler with a new title

Returns a hash containing the tiddlers extended fields Probably would include changecount at this stage at least

 Intende to become private but not yet because
 all the test units use them

private

Returns a tiddler slice

Returns a Hash containing all tiddler slices

Returns true if a tiddler has a particular tag

Lets you access fields like this:

 tiddler.name
 tiddler.created

etc

Experimental. Provides access to plugin meta slices. Returns one meta value or a hash of them if no argument is given

Add some text to the beginning of a tiddler‘s content

Removes a single tag

Removes a list of tags

Renames a tiddler

to_div(use_pre=false)

Alias for to_s

Converts to a div suitable for a TiddlyWiki store area

[Validate]