Пример #1
0
def main(*argv):
    parser = optparse.OptionParser(
        usage='Usage: %prog old-text new-text wiki-page ... trac-env',
        version='ReplaceInPage 1.0')
    parser.add_option('-d',
                      '--debug',
                      help='Activate debugging',
                      action='store_true',
                      default=False)
    (options, args) = parser.parse_args(list(argv[1:]))
    if len(args) < 3:
        parser.error("Not enough arguments")

    oldname = args[0]
    newname = args[1]
    wikipages = args[2:len(args) - 2]
    envpath = args[len(args - 1)]
    env = Environment(envpath)
    wiki_text_replace(env,
                      oldtext,
                      newtext,
                      wikipages,
                      username(),
                      '127.0.0.1',
                      debug=options.debug)
Пример #2
0
    def render_admin_panel(self, req, cat, page, path_info):
        wikipages = urllib.unquote_plus(req.args.get('wikipages',''));
        parts = wikipages.splitlines();

        data = {
            'find': urllib.unquote_plus(req.args.get('find','')),
            'replace': urllib.unquote_plus(req.args.get('replace','')),
            'wikipages': parts,
            'redir': req.args.get('redirect','') == '1',
        }
        
        if req.method == 'POST':
            # Check that required fields are filled in.
            if not data['find']:
                add_warning(req, 'The Find field was empty. Nothing was changed.')
            if not data['wikipages'] or not data['wikipages'][0]:
                add_warning(req, 'The Wiki pages field was empty. Nothing was changed.')            
            
            # Replace the text if the find and wikipages fields have been input.
            if data['find'] and data['wikipages'] and data['wikipages'][0]:
                add_notice(req, 'Replaced "%s" with "%s". See the timeline for modified pages.'
                           % (data['find'], data['replace']))
                wiki_text_replace(self.env, data['find'], data['replace'], data['wikipages'],
                                  req.authname, req.remote_addr, debug=self.log.debug)
                
            # Reset for the next display
            data['find'] = ''
            data['replace'] = ''
            data['wikipages'] = ''

        return 'admin_wikireplace.html', data
Пример #3
0
def main(*argv):
    parser = optparse.OptionParser(usage='Usage: %prog old-text new-text wiki-page ... trac-env', version='ReplaceInPage 1.0')
    parser.add_option('-d','--debug',help='Activate debugging', action='store_true', default=False)
    (options, args) = parser.parse_args(list(argv[1:]))
    if len(args) < 3:
        parser.error("Not enough arguments")

    oldname = args[0]
    newname = args[1]
    wikipages = args[2:len(args)-2]
    envpath = args[len(args-1)]
    env = Environment(envpath)
    wiki_text_replace(env, oldtext, newtext, wikipages, username(), '127.0.0.1', debug=options.debug)
Пример #4
0
    def render_admin_panel(self, req, cat, page, path_info):
        wikipages = urllib.unquote_plus(req.args.get('wikipages', ''))
        parts = wikipages.splitlines()

        data = {
            'find': urllib.unquote_plus(req.args.get('find', '')),
            'replace': urllib.unquote_plus(req.args.get('replace', '')),
            'wikipages': parts,
            'redir': req.args.get('redirect', '') == '1',
        }

        if req.method == 'POST':
            # Check that required fields are filled in.
            if not data['find']:
                add_warning(req,
                            'The Find field was empty. Nothing was changed.')
            if not data['wikipages'] or not data['wikipages'][0]:
                add_warning(
                    req,
                    'The Wiki pages field was empty. Nothing was changed.')

            # Replace the text if the find and wikipages fields have been input.
            if data['find'] and data['wikipages'] and data['wikipages'][0]:
                add_notice(
                    req,
                    'Replaced "%s" with "%s". See the timeline for modified pages.'
                    % (data['find'], data['replace']))
                wiki_text_replace(self.env,
                                  data['find'],
                                  data['replace'],
                                  data['wikipages'],
                                  req.authname,
                                  req.remote_addr,
                                  debug=self.log.debug)

            # Reset for the next display
            data['find'] = ''
            data['replace'] = ''
            data['wikipages'] = ''

        return 'admin_wikireplace.html', data