create new tag
, view all tags

Linking back to TWiki from CVS

As mentioned in CvsWeb, linking to a CVS repository is easy with InterwikiPlugin installed and the respective CGIs (cvsweb, viewcvs) on the server.

As our department's server has viewcvs only, I had a look at the code.

As far as I can see, viewcvs.py requires only little additional code. This would be around function htmlify. First addition would be to define a regular expression to look for Webname.WikiWord. The second would embed the content into an html-anchor just as viewcvs itself does.

Lines 3 and 8 are what I have added and what works for me:

_re_rewrite_url = re.compile('((http|ftp)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*(#([-a-zA-Z\
_re_rewrite_email = re.compile('([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})')
_re_rewrite_wiki = re.compile('([A-Z]+[a-z\d]*\.[A-Z]+[a-z]+[A-Z]+[a-zA-Z\d]*)')
def htmlify(html):
  html = cgi.escape(html)
  html = re.sub(_re_rewrite_url, r'<a href="\1">\1</a>', html)
  html = re.sub(_re_rewrite_email, r'<a href="mailto:\1">\1</a>', html)
  html = re.sub(_re_rewrite_wiki, r'<a href="http://twikiserver/cgi-bin/view/\1">\1</a>', html)
  return html

def htmlify(html) is line 474 in viewcvs.py, version 1.0-dev.

Maybe one should check for whitespace before the web-name, the code above matches webnamE.TopicName, which is not valid, IIRC.

BTW: anyone using Bugzilla, too, might like to add the following lines :

_re_rewrite_bug = re.compile('BUG#([\d]+)')

  html = re.sub(_re_rewrite_bug, r'<a href="http://bugzillaserver/cgi-bin/bugzilla/show_bug.cgi?id=\1">BUG#\1</a>',html)

-- PatrickHansmeier - 02 Oct 2003

PatrickHansmeier, looks like your patch would allow to build TWikiForGForge -like system without GForge - just using Twiki for forums (via CommentPlugin smile ) and twiki-based bug tracker.

BUT - looks like link into twiki is hardcoded - maybe better approach would be to have parameter table (may I dream? Twiki page?), and for different CVS repositories have different bugtracking webs. To allow multiple projects (each with separate CVS repository and bugtracking web) run in same Twiki site.

Are you interested? I am - a lot. smile

-- PeterMasiar - 02 Oct 2003

This would be really useful and could even apply to TWiki.org if it's re-hosted, though it would be necessary to run ViewCVS on a different host to the CVS server.

It would be nice if this ViewCVS patch works with the TWiki InternationalisationEnhancements, which enable 8-bit accented characters (and even non-Latin character sets) in WikiWords - have a look at the setupRegexes code in CVS:lib/TWiki.pm for examples of the regexes that are defined.

Python has some I18N support for regexes, but is not as easy to use as Perl's [:alpha:] type features, since only \w is provided, which matches alphanumeric and underscores - see the Python Regex HOWTO (the LOCALE flag is important) and the re module's regex syntax section. It may be possible to do something with \w, but it would require some regex trickery... Given Python's lack of support for this at present, implementing I18N regexes may not really be feasible for a simple patch.

-- RichardDonkin - 03 Oct 2003

Peter is right, it's exactly been Savannah and GForge that sparked the idea. My aim would be to interlink (not integrate) CVS, Bugzilla and TWiki. An integrated package like GForge or Savannah would not add a new view at existing data but require the maintenance of redundante data in several places (for our department's needs, as far a I am aware of them). Not having the link into TWiki hardcoded in the python code is definitely a feature to look for. At the moment I can't think of a convenient way to do this. I can't even give an estimat if this was done best on the side of viewcvs (is it web-configurable?) or TWiki.

  • Multiple repositories linking back to different webs is no problem, as my code requires that a web is stated explicitly.
  • Viewcvs parsing a TWiki topic would require a hard link, again.
  • Does viewcvs allow setting variables depending on the repository? This could be an way to automagically link plain wiki words in a repository to the corresponding web, while an explicit Otherweb.WikiWord would link elsewhere.

I am unfamliar with the problems of I18N and know very little about Python in that respect, so I can't make educated guessed on this behalf. (Actually, I required our users to use double-vowels instead of german umlauts with topicnames, so it's s.th. I usually forget about.)

-- PatrickHansmeier - 13 Oct 2003

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2003-10-13 - PatrickHansmeier
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.