Dateianhang 'multilang.diff'

Herunterladen

   1 --- ../../../../../festifn/moin/moin/MoinMoin/Page.py	Wed Oct 23 20:43:58 2002
   2 +++ Page.py	Thu Nov 14 18:06:56 2002
   3 @@ -64,7 +64,11 @@
   4          if self.prev_date:
   5              return os.path.join(config.backup_dir, wikiutil.quoteFilename(self.page_name) + "." + self.prev_date)
   6          else:
   7 -            return os.path.join(config.text_dir, wikiutil.quoteFilename(self.page_name))
   8 +            if config.multilingual_dir:
   9 +                from MoinMoin import multilang
  10 +                return multilang.get_interwiki_filename(self.page_name)
  11 +            else:
  12 +                return os.path.join(config.text_dir, wikiutil.quoteFilename(self.page_name))
  13  
  14  
  15      def _tmp_filename(self):
  16 @@ -147,11 +151,25 @@
  17          if self.exists():
  18              return wikiutil.link_tag(url, text, formatter=fmt, **kw)
  19          elif user.current.show_nonexist_qm:
  20 -            return wikiutil.link_tag(url,
  21 +            result =  wikiutil.link_tag(url,
  22                  '?', 'nonexistent', formatter=fmt, **kw) + text
  23          else:
  24 -            return wikiutil.link_tag(url, text, 'nonexistent', formatter=fmt, **kw)
  25 +            result = wikiutil.link_tag(url, text, 'nonexistent', formatter=fmt, **kw)
  26  
  27 +        if config.multilingual_dir:
  28 +            from MoinMoin import multilang
  29 +            flags = ""
  30 +            translations = multilang.get_translations(self.page_name)
  31 +            if translations:
  32 +                for translation in translations:
  33 +                    if Page(translation).exists():
  34 +                        flags = flags + ' ' + multilang.language_link(
  35 +                            translation, 0)
  36 +            else:
  37 +                pass
  38 +            if flags != "":
  39 +                result = result + ' (' + flags + ' )'
  40 +        return result
  41  
  42      def getSubscribers(self, request, **kw):
  43          """ Get all subscribers of this page.
  44 @@ -451,6 +469,42 @@
  45              'add a page with a name ending in Template.'))
  46          print self.formatter.paragraph(0)
  47  
  48 +        # Translations as templates
  49 +        if config.multilingual_dir:
  50 +            page_name = self.page_name
  51 +            from MoinMoin import multilang
  52 +            import re
  53 +            splitname = re.split('([%s][%s]+)' % \
  54 +                                  (config.upperletters, config.lowerletters),
  55 +                                  self.page_name)
  56 +            search = ''
  57 +            for part in splitname:
  58 +                if len(part) > 3 : search = search + part + '|'
  59 +            search = search[:-1]
  60 +            print `splitname`
  61 +            print search
  62 +            pages = multilang.title_search(search, None, 1)
  63 +            i = 0
  64 +            langlength = len (config.interwikiname)
  65 +            while i < len(pages):
  66 +                if pages[i][0:langlength] == config.interwikiname:
  67 +                    del pages[i]
  68 +                else: i = i + 1
  69 +            pages.sort()
  70 +            print " " + `len(pages)`
  71 +            if len(pages) > 0:
  72 +                print '<h2>Similar Pages in other languages</h2>'
  73 +                print '<ul>'
  74 +                for p in pages:
  75 +                    tag, interwiki, tail = wikiutil.resolve_wiki(p)
  76 +                    print '<li>' + multilang.language_link(p)
  77 +                    print (' ( <a href="%(page_name)s?' +
  78 +                           'action=edit&template=%(tag)s:%(tail)s">' +
  79 +                           'Use as Template</a> ) </li>\n' ) % \
  80 +                           { 'page_name' : self.page_name, 'tag' : tag,
  81 +                             'interwiki' : interwiki, 'tail' : tail}
  82 +                print '</ul>\n'
  83 +
  84          # list similar pages that already exist
  85          start, end, matches = LikePages.findMatches(self.page_name, request)
  86          if matches and not isinstance(matches, type('')):
  87 @@ -488,3 +542,91 @@
  88  
  89          return filter(None, string.split(cache.content(), '\n'))
  90  
  91 +    def inter_wiki_link(self):
  92 +        if config.interwikiname:
  93 +            return config.interwikiname + ':' + self.page_name
  94 +        else: return self.page_name
  95 +
  96 +    def translation(self, request):
  97 +        request.clock.start('send_page')
  98 +        import cgi
  99 +        from MoinMoin.util import pysupport
 100 +        from MoinMoin import wikimacro
 101 +
 102 +        page_name = self.page_name
 103 +
 104 +        # if necessary, load the default formatter
 105 +        if self.default_formatter:
 106 +            from MoinMoin.formatter.text_html import Formatter
 107 +            self.formatter = Formatter(request, store_pagelinks=1)
 108 +        self.form = request.form
 109 +        self.formatter.setPage(self)
 110 +        self.request = request
 111 +        macro = wikimacro.Macro(self)
 112 +
 113 +        # start document output
 114 +        doc_leader = self.formatter.startDocument(self.page_name)
 115 +        # send the document leader
 116 +        webapi.http_headers(request)
 117 +        sys.stdout.write(doc_leader)
 118 +
 119 +        wikiutil.send_title(page_name)
 120 +        from MoinMoin.multilang import *
 121 +        from MoinMoin import multilang        
 122 +        translations = get_translations(page_name)
 123 +        if len(translations) > 0:
 124 +            print "<h2>Translations of " + page_name + '</h3>\n\n<ul>'
 125 +            for translation in translations:
 126 +                tag, interwiki, tail = wikiutil.resolve_wiki(translation)
 127 +                # Link
 128 +                print '<li>' + language_link(translation)
 129 +                # Link for removing
 130 +                print (' ( <a href="%(page_name)s?' +
 131 +                       'action=unsettranslation&page=%(tag)s:%(tail)s">' +
 132 +                       'remove from group</a> ) </li>\n' ) % vars()
 133 +            print '</ul>\n'
 134 +            # Link for removing this page 
 135 +            print ('<p><a href="%(page_name)s?action=unsettranslation&' +
 136 +                   'page=%(page_name)s">' +
 137 +                   'Remove this page from Group</a></p>\n' ) % vars()
 138 +
 139 +        # Show simmilar Pages
 140 +        if request.form.has_key("text_title"):
 141 +            searchtext = request.form["text_title"].value
 142 +        else:
 143 +            searchtext = page_name
 144 +        pages = multilang.title_search(searchtext, None, 1)
 145 +        for translation in translations:
 146 +            if translation in pages: pages.remove(translation)
 147 +        if self.inter_wiki_link() in pages:
 148 +            pages.remove(self.inter_wiki_link())
 149 +        pages.sort()
 150 +        if len(pages) > 0:
 151 +            print '<h2>Similar Pages</h2>'
 152 +            print '<ul>'
 153 +            for p in pages:
 154 +                tag, interwiki, tail = wikiutil.resolve_wiki(p)
 155 +                print '<li>' + language_link(p)
 156 +                print (' ( <a href="%(page_name)s?' +
 157 +                       'action=settranslation&page=%(tag)s:%(tail)s">' +
 158 +                       'Add</a> ) </li>\n' ) % vars()
 159 +            print '</ul>\n'
 160 +
 161 +            print """Search 
 162 +<form method="POST" action="%s">
 163 +    <input type="hidden" name="action" value="TranslationMenu">
 164 +    <input type="text" name="text_title" value="%s" size="30">
 165 +    <input type="image" src="/wiki/img/moin-search.gif" name="button_title"
 166 +    alt="[?]" hspace="3" width="12" height="12" border="0">
 167 +</form>""" % ( page_name, searchtext )
 168 +
 169 +        # Insert new Translations directly
 170 +        print "<h2>Add new Translation</h2>"
 171 +        print "Insert Interwikilink and press Go"
 172 +        print macro.execute('SetTranslation', '')
 173 +
 174 +        # end document output
 175 +        sys.stdout.write(self.formatter.endDocument())
 176 +        request.clock.stop('send_page')
 177 +
 178 +
 179 --- ../../../../../festifn/moin/moin/MoinMoin/PageEditor.py	Thu Jul 18 01:06:31 2002
 180 +++ PageEditor.py	Tue Oct 29 17:23:32 2002
 181 @@ -353,6 +353,11 @@
 182                  except OSError, er:
 183                      import errno
 184                      if er.errno <> errno.ENOENT: raise er
 185 +            # Set translations in multilingual mode
 186 +            if config.multilingual_dir:
 187 +                from MoinMoin import multilang
 188 +                multilang.set_translation_automatically(self.page_name)
 189 +
 190  
 191          # set in-memory content
 192          self.set_raw_body(text)
 193 --- ../../../../../festifn/moin/moin/MoinMoin/wikiutil.py	Fri Nov  8 20:53:36 2002
 194 +++ wikiutil.py	Thu Nov 14 15:48:05 2002
 195 @@ -681,6 +667,17 @@
 196              'pagename': quoteWikiname(keywords['pagename'])}
 197          print '</div>'
 198  
 199 +    # Multilingual Links
 200 +    if config.multilingual_dir:
 201 +        from MoinMoin import multilang
 202 +        links = multilang.get_translations(text)
 203 +        for link in links:
 204 +            tag, interwiki, tail = resolve_wiki(link)
 205 +            print ('<a href="' + interwiki + tail + '">'+
 206 +                   '<img src="/' + config.default_markup +
 207 +                   '/img/'+ config.lang_icons[tag] +
 208 +                   '" align="right" alt="' + tag + '"></a>')
 209 +
 210      # print custom html code after system title (normally "<hr>")
 211      _emit_custom_html(None, config.title2)
 212      # !!! _emit_custom_html(request, config.title2)
 213 --- ../../../../../festifn/moin/moin/MoinMoin/config.py	Fri Nov  8 20:53:36 2002
 214 +++ config.py	Mon Nov 11 20:42:29 2002
 215 @@ -38,6 +38,8 @@
 216  
 217  # default config values
 218  cfg_defaults = {
 219 +    'multilingual_dir': None,
 220 +    'languages': {},
 221      'allow_extended_names': 1,
 222      'allow_subpages': 1,
 223      'allow_numeric_entities': 1,
 224 @@ -165,8 +166,12 @@
 225      except ValueError:
 226          pass
 227  
 228 -# define directories
 229  import os
 230 +# multilangual
 231 +if multilingual_dir:
 232 +    execfile(os.path.join(multilingual_dir, 'languages.py'))
 233 +
 234 +# define directories
 235  data_dir = os.path.normpath(data_dir)
 236  moinmoin_dir = os.path.abspath(os.path.dirname(__file__))
 237  

Gespeicherte Dateianhänge

Um Dateianhänge in eine Seite einzufügen sollte unbedingt eine Angabe wie attachment:dateiname benutzt werden, wie sie auch in der folgenden Liste der Dateien erscheint. Es sollte niemals die URL des Verweises ("laden") kopiert werden, da sich diese jederzeit ändern kann und damit der Verweis auf die Datei brechen würde.
  • [laden | anzeigen] (2002-11-14 19:38:05, 9.3 KB) [[attachment:multilang.diff]]
  • [laden | anzeigen] (2002-11-14 20:03:53, 3.0 KB) [[attachment:multilang.tar.gz]]
 Alle Dateien | Ausgewählte Dateien: löschen verschieben auf Seite kopieren auf Seite

Sie dürfen keine Anhänge an diese Seite anhängen!