[Moin-user] 2 questions on schemes and linking

bragiba at simi.is bragiba at simi.is
Mon Sep 24 07:57:03 EDT 2001


Hi:

I cannot get the following working
I was trying to insert links to images using InterWiki names such as
[FundaMentals:Image1.gif  Link to Image 1]. This does not work and the
images still appears in the actual document.

Bracketeted links need a schema:

[wiki:FundaMentals:Image1.gif ...

I tried this but that did not work either.  How do I set up schemes?  Idiot
proof help needed here.

Secondly I have created 2 macros:  Acronyms and AcronymIndex
Acronyms is basically just used to markup a link that points to a page that
explains the acronyms (AcronymIndex)
As an example let´s say I am explaining wave motion in a document and I
would like to explain the acronym FM to the
user further so I do the following:
Frequency Modulation or [[Acronym(FM)]]

          All the user sees is FM

When he clicks on FM he is brought to the AcronymIndex  which is created by
the macro AcronymIndex.  It is basically a page that looks like the
TitleIndex page.
I would like to improve this and bring the user to the heading F as that is
the first letter in the acronym (acronyms are grouped alphabetically by
their first letter).
My attempt was to do the following in the Acronym macro.
return Page('AcronymIndex#%s' % first_letter_in_acronym).link_to(acronym)

I found that quoteFileName does not allow # so I just added # to the list
of safe characters (safe = string.letters + string.digits + '#' )
Is this OK?

Is it maybe possible to add another argument to the Page constructor that
allows a named link such as
__init__(self, pageName, namedLink, **keywords) ?

Bragi


    def _macro_Acronym(self, acronym):
        """This macro makes a link out of an acronym"""

        first_letter = string.upper(acronym[0])
        return Page('AcronymIndex').link_to(acronym)

    def _macro_AcronymIndex(self, args):
        """This macro opens the page acronyms.txt.  Extracts all the macros
and explanations and
           creates an index page similar to a title index"""
        index_letters = []
        s = ''
        page = open('c:/Inetpub/wwwroot/acronyms/acronyms.txt', 'r')
        lines = page.readlines()
        page.close()
        current_letter = None
        for line in lines:
            split = string.split(line, ';')
            try:
                acronym = string.strip(split[0])
                definition = string.strip(split[1])
            except IndexError:
                pass
            letter = acronym[0]
            if letter not in index_letters:
                index_letters.append(letter)
            if letter <> current_letter:
                s = s + '</table>\n<a name="%s"><h3>%s</h3></a>\n<table>' %
(
                    wikiutil.quoteWikiname(letter), string.replace(letter,
'~', 'Others'))
                current_letter = letter

            s = s + '\n<tr>\n    <td><b>%s</b></td><td>%s</td>\n</tr>\n' %
(acronym, definition)
        s = s + '</table>'
        return _make_index_key(index_letters, s)

Bragi x6308  (GSM 892 6308)

_______________________________________________________________________
Þessi tölvupóstur og viðhengi hans gætu innihaldið trúnaðarupplýsingar
eingöngu ætlaðar þeim sem hann er stílaður á. Efni tölvupóstsins og
viðhengi er á ábyrgð sendanda ef það tengist ekki starfsemi Símans.
Sjá nánar: http://www.siminn.is/um_okkur/almennt/tolvupostur.asp

This e-mail and its attachments may contain confidential and privileged
information only intended for the person or entity to which it is
addressed.
Further information: http://www.siminn.is/english/about_us/email.asp
_______________________________________________________________________


More information about the Moin-user mailing list