Roundup Tracker

Simplest setup first - make regular message displays handle WikiWikiMarkup. To achieve this, add the following as a new file "wiki.py" in your tracker's "extensions" directory:

   1 import re
   2 
   3 wn_re = re.compile(r'(?P<wn>[A-Z][a-z]+([A-Z][a-z]+)+)')
   4 def wikimarkup(utils, text):
   5     '''Mark up text in a wiki-like fashion.
   6         
   7     WikiName -> issue with the title "WikiName"
   8                 if undefined, has a link to create a new issue with the
   9                 title WikiName
  10     (normal issueNNN / URL markup will be done too)
  11     '''
  12     text = text.hyperlinked()
  13     def wn_replace(match, db=utils.client.db, classname=utils.client.classname):    
  14         wn = match.group('wn')
  15         id = db.getclass(classname).stringFind(title=wn)
  16         if id: 
  17             return '<a href="%s%s">%s</a>'%(classname, id[0], wn)
  18         else:
  19             return '%s<a href="%s?@template=item&title=%s">?</a>'%(wn,
  20                 classname, wn)
  21     return wn_re.sub(wn_replace, text)
  22 
  23 def init(tracker):
  24     tracker.registerUtil('wiki', wikimarkup)

This is enough to get Wiki links going in your tracker straight away - with "?" markers to allow you to define new "terms".

To have specialised wiki-only pages, add this to your tracker's schema.py:

wiki = FileClass(db, "wiki", title=String())

And a new page to your tracker's "html" directory called "wiki.item.html" with the contents:

  <tal:block metal:use-macro="templates/page/macros/icing">
  <title metal:fill-slot="head_title">
  <tal:block condition="context/id" i18n:translate=""
  >Issue <span tal:replace="context/id" i18n:name="id"
  />: <span tal:replace="context/title" i18n:name="title"
  /> - <span tal:replace="config/TRACKER_NAME" i18n:name="tracker"
  /></tal:block>
  <tal:block condition="not:context/id" i18n:translate=""
  >New Issue - <span tal:replace="config/TRACKER_NAME" i18n:name="tracker"
  /></tal:block>
  </title>
  <tal:block metal:fill-slot="body_title">
  <span tal:condition="python:not context.id"
        tal:content="string:New Wiki Page: ${request/form/title/value}" />
  <span tal:condition="python:context.id" tal:content="context/title" />
  </tal:block>

  <td class="content"  tal:define="editmode python:context.is_edit_ok() and
          (not context.id or request.form.has_key('@editmode'))"
          metal:fill-slot="content">

  <form tal:condition="editmode"
      method="POST" name="itemSynopsis" onSubmit="return submit_once()"
      enctype="multipart/form-data" tal:attributes="action context/designator">

  <table class="form">
  <tr>
  <td colspan="2">
    <span tal:content="context/title | request/form/title/value" />
    <input type="hidden" name="title"
          tal:attributes="value context/title | request/form/title/value">
  </td>
  </tr>

  <tr>
  <td colspan=2>
    <textarea tal:content="context/content/plain"
              name="content" wrap="hard" rows="20" cols="80"></textarea>
  </td>
  </tr>

  <tr>
  <td>
    &nbsp;
    <input type="hidden" name="@template" value="item">
    <input type="hidden" name="@required" value="title">
  </td>
  <td colspan=3 tal:content="structure context/submit">
    submit button will go here
  </td>
  </tr>
  </table>
  </form>

  <table tal:condition="not:editmode" class="messages">
  <tr>
  <td colspan="2" class="content">
    <pre tal:content="structure python:utils.wiki(context.content)">content</pre>
  </td>
  </tr>
  <tr>
  <a tal:attributes="href string:wiki${context/id}?@template=item&@editmode=yes">edit</a>
  </tr>
  </table>

  <p tal:condition="context/id" i18n:translate="">
  Created on <b><tal:x replace="context/creation" i18n:name="creation" /></b>
  by <b><tal:x replace="context/creator" i18n:name="creator" /></b>,
  last changed <b><tal:x replace="context/activity" i18n:name="activity" /></b>
  by <b><tal:x replace="context/actor" i18n:name="actor" /></b>.
  </p>


  <tal:block tal:condition="context/id" tal:replace="structure context/history" />

  </td>

  </tal:block>

The key to the wiki formatting is the line where we invoke the wiki utils method:

  <pre tal:content="structure python:utils.wiki(context.content)">content</pre>

Finally, to start adding wiki items to your tracker, use a link ending in "wiki?@template=item&title=FrontPage" (so for the demo tracker, this would be something like "http://short.local:8917/demo/wiki?@template=item&title=FrontPage")

-- RichardJones

From als Tue Jul 27 15:57:25 -0400 2004
Wrom: JSN
Date: Tue, 27 Jul 2004 15:57:25 -0400
Subject: excellent idea!
Message-ID: <20040727015725-0400@www.mechanicalcat.net>

having wiki in roundup would be great.

From unknown Wed Jul 28 03:37:32 -0400 2004
Wrom: 
Date: Wed, 28 Jul 2004 03:37:32 -0400
Subject: I'm not so sure.
Message-ID: <20040727133732-0400@www.mechanicalcat.net>

What about name collision?

From unknown Wed Jul 28 07:54:45 -0400 2004
From: 
Date: Wed, 28 Jul 2004 07:54:45 -0400
Subject: automagically handled
Message-ID: <20040727175445-0400@www.mechanicalcat.net>

The code will just pick the first match found. Dupes are quite unlikely if you go with the extension - implementing the wiki class. Regular users can't change the name (title) of a wiki item. It's "hard-coded" into the edit page.

Altering the wiki link generator to cope with multiple matches would be easy - you'd just generate a link to an index page with the matches listed ('@template=index&title=WikiName').