С Википедије, слободне енциклопедије

For use with Global message delivery/Targets, mostly. Examples:

{{target | page = Wikiversidad:Claustro Wikiversitario | site = es.wikiversity.org}}

Wikiversidad:Claustro Wikiversitario [at] es.wikiversity.org

{{target | user=Nemo bis | site = it.wikiquote.org}}

Nemo bis [at] it.wikiquote.org

The current global delivery script looks for this template on each line. The line may be preceded by * or #, but this is not necessary.

Note: Unlike when invoking MediaWiki templates elsewhere, the script requires that each {{target}} entry be on its own line (with all of its parameters) in the specified order. Putting the "site" parameter before the "page" or "user" parameter will not work. Putting the parameters on their own lines will not work.

For those who are technically inclined, the current script's code looks something like this:

# Define two nasty regexen
target_template_user_re = re.compile(r'\{\{\s*target\s*\|\s*user\s*=\s*(.+)\s*\|\s*site\s*=\s*(.+)\s*\}\}')
target_template_page_re = re.compile(r'\{\{\s*target\s*\|\s*page\s*=\s*(.+)\s*\|\s*site\s*=\s*(.+)\s*\}\}')

def parse_input_page(home_wiki, input_page):
    global target_template_user_re
    global target_template_page_re
    targets_list = []
    targets_obj = wikitools.Page(home_wiki, input_page, followRedir=False)
    targets_page_text = targets_obj.getWikiText()
    for line in targets_page_text.split('\n'):
        if target_template_user_re.search(line):
            input_target_user = target_template_user_re.search(line).group(1).strip()
            input_target_site = target_template_user_re.search(line).group(2).strip()
            if re.search(r'[A-Za-z.\-]', input_target_site):
                targets_list.append([input_target_site, 'User talk:' + input_target_user])
        elif target_template_page_re.search(line):
            input_target_user = target_template_page_re.search(line).group(1).strip()
            input_target_site = target_template_page_re.search(line).group(2).strip()
            if re.search(r'[A-Za-z.]', input_target_site):
                targets_list.append([input_target_site, input_target_user])
    targets_list = sorted(targets_list)
    return targets_list