Revision: 5107 Author: russblau Date: 2008-03-07 14:16:41 +0000 (Fri, 07 Mar 2008)
Log Message: ----------- Create a help file for people trying to create new families.
Added Paths: ----------- trunk/pywikipedia/families/README-family.txt
Added: trunk/pywikipedia/families/README-family.txt =================================================================== --- trunk/pywikipedia/families/README-family.txt (rev 0) +++ trunk/pywikipedia/families/README-family.txt 2008-03-07 14:16:41 UTC (rev 5107) @@ -0,0 +1,191 @@ +How to create a new family file to add a new wiki to the bot framework. + +(c) 2008, the Pywikipediabot team + +Copy and paste the text below "COPY HERE" into your favorite text editor, and +save it as WIKINAME_family.py in the families/ subdirectory. Replace +WIKINAME with the name you want to use for the new wiki family, making sure +that it doesn't duplicate any existing name. + +A "family" is any group of wikis located on the same server; usually they +are versions of the same type of content in different languages, but this +isn't required. A family can consist of just one wiki, or more; if there is +more than one wiki, each wiki needs to be identified by a unique code. + +After you copy the text, go through and edit it, based upon the comment +lines. First, do a global search-and-replace to change all instances of +'WIKINAME' to your actual wiki name. Everything in the example below is +based on the bot's default settings, except for the namespace names, which +are made-up examples. You only need to change it if your wiki's value is +different from the default. You can delete anything that is not indicated as +"REQUIRED", if your new wiki doesn't vary from the default settings. + +== COPY HERE == + +# -*- coding: utf-8 -*- # REQUIRED +import config, family, urllib # REQUIRED + +class Family(family.Family): # REQUIRED + def __init__(self): # REQUIRED + family.Family.__init__(self) # REQUIRED + self.name = 'WIKINAME' # REQUIRED; replace with actual name + + self.langs = { # REQUIRED + 'en': 'www.example.com', # Include one line for each wiki in family + 'fr': 'www.example.fr', # in the format 'code': 'hostname', + } + + # Translation used on all wikis for the different namespaces. + # Most namespaces are inherited from family.Family. + # Check the family.py file (in main directory) to see the standard + # namespace translations for each known language. + + # You only need to enter translations that differ from the default. + # There are two ways of entering namespace translations. + # 1. If you only need to change the translation of a particular + # namespace for one or two languages, use this format: + self.namespaces[2]['en'] = u'Wikiuser' + self.namespaces[3]['en'] = u'Wikiuser talk' + + # 2. If you need to change the translation for many languages + # for the same namespace number, use this format (this is common + # for namespaces 4 and 5, because these are usually given a + # unique name for each wiki): + self.namespaces[4] = { + '_default': [u'WIKINAME', self.namespaces[4]['_default']], # REQUIRED + 'de': 'Name des wiki', + 'es': 'Nombre del wiki', + 'fr': 'Nom du wiki', + # ETC. + } + + # Wikimedia wikis all use "bodyContent" as the id of the <div> + # element that contains the actual page content; change this for + # wikis that use something else (e.g., mozilla family) + self.content_id = "bodyContent" + + # On most wikis page names must start with a capital letter, but some + # languages don't use this. This should be a list of languages that + # _don't_ require the first letter to be capitalized; e.g., + # self.nocapitalize = ['foo', 'bar'] + self.nocapitalize = [] + + # SETTINGS FOR WIKIS THAT USE DISAMBIGUATION PAGES: + + # A list of disambiguation template names in different languages + self.disambiguationTemplates = { + 'en': ['disambig', 'disambiguation'], + } + + # A list with the name of the category containing disambiguation + # pages for the various languages. Only one category per language, + # and without the namespace, so add things like: + self.disambcatname = { + 'en': "Disambiguation", + } + + # SETTINGS FOR WIKIS THAT USE INTERLANGUAGE LINKS: + + # attop is a list of languages that prefer to have the interwiki + # links at the top of the page. + self.interwiki_attop = [] + + # on_one_line is a list of languages that want the interwiki links + # one-after-another on a single line + self.interwiki_on_one_line = [] + + # String used as separator between interwiki links and the text + self.interwiki_text_separator = '\r\n\r\n' + + # Which languages have a special order for putting interlanguage links, + # and what order is it? If a language is not in interwiki_putfirst, + # alphabetical order on language code is used. For languages that are in + # interwiki_putfirst, interwiki_putfirst is checked first, and + # languages are put in the order given there. All other languages are put + # after those, in code-alphabetical order. + self.interwiki_putfirst = {} + + # Languages in interwiki_putfirst_doubled should have a number plus a list + # of languages. If there are at least the number of interwiki links, all + # languages in the list should be placed at the front as well as in the + # normal list. + self.interwiki_putfirst_doubled = {} + + # Some families, e. g. commons and meta, are not multilingual and + # forward interlanguage links to another family (wikipedia). + # These families can set this variable to the name of the target + # family. + self.interwiki_forward = None + + # Which language codes no longer exist and by which language code + # should they be replaced. If for example the language with code xx: + # has been replaced by code yy:, add {'xx':'yy'} to obsolete. + # If all links to language xx: should be removed, add {'xx': None}. + self.obsolete = {} + + # SETTINGS FOR CATEGORY LINKS: + + # Languages that want the category links at the top of the page + self.category_attop = [] + + # languages that want the category links + # one-after-another on a single line + self.category_on_one_line = [] + + # String used as separator between category links and the text + self.category_text_separator = '\r\n\r\n' + + # When both at the bottom should categories come after interwikilinks? + self.categories_last = [] + + # If your wiki uses a translated version of the "#REDIRECT" keyword, + # enter it in this dict; the key is the language code + # Note that redirect codes are case-insensitive, so it is enough + # to enter the code in lowercase here. + redirect = { + 'sk': [u'presmeruj'], + } + + # Same for magic words "PAGENAME" and "PAGENAMEE": + pagename = { + } + + pagenamee = { + } + + def protocol(self, code): + """ + Can be overridden to return 'https'. Other protocols are not supported. + """ + return 'http' + + def scriptpath(self, code): + """The prefix used to locate scripts on this wiki. + + This is the value displayed when you enter {{SCRIPTPATH}} on a + wiki page (often displayed at [[Help:Variables]] if the wiki has + copied the master help page correctly). + + The default value is the one used on Wikimedia Foundation wikis, + but needs to be overridden in the family file for any wiki that + uses a different value. + + """ + return '/w' + + # IMPORTANT: if your wiki does not support the api.php interface, + # you must uncomment the second line of this method: + def apipath(self, code): + # raise NotImplementedError, "%s wiki family does not support api.php" % self.name + return '%s/api.php' % self.scriptpath(code) + + # Which version of MediaWiki is used? + def version(self, code): + # Replace with the actual version being run on your wiki + return '1.13alpha' + + def code2encoding(self, code): + """Return the encoding for a specific language wiki""" + # Most wikis nowadays use UTF-8, but change this if yours uses + # a different encoding + return 'utf-8'