[wikia-pywikibot] / families / README-family.txt Repository:

Annotation of /families/README-family.txt

Parent Directory Parent Directory Revision Log Revision Log


Revision 13 - View Download

1 : dantman 13 How to create a new family file to add a new wiki to the bot framework.
2 :    
3 :     (c) 2008, the Pywikipediabot team
4 :    
5 :     Copy and paste the text below "COPY HERE" into your favorite text editor, and
6 :     save it as WIKINAME_family.py in the families/ subdirectory. Replace
7 :     WIKINAME with the name you want to use for the new wiki family, making sure
8 :     that it doesn't duplicate any existing name.
9 :    
10 :     A "family" is any group of wikis located on the same server; usually they
11 :     are versions of the same type of content in different languages, but this
12 :     isn't required. A family can consist of just one wiki, or more; if there is
13 :     more than one wiki, each wiki needs to be identified by a unique code.
14 :    
15 :     After you copy the text, go through and edit it, based upon the comment
16 :     lines. First, do a global search-and-replace to change all instances of
17 :     'WIKINAME' to your actual wiki name. Everything in the example below is
18 :     based on the bot's default settings, except for the namespace names, which
19 :     are made-up examples. You only need to change it if your wiki's value is
20 :     different from the default. You can delete anything that is not indicated as
21 :     "REQUIRED", if your new wiki doesn't vary from the default settings.
22 :    
23 :     == COPY HERE ==
24 :    
25 :     # -*- coding: utf-8 -*- # REQUIRED
26 :     import config, family, urllib # REQUIRED
27 :    
28 :     class Family(family.Family): # REQUIRED
29 :     def __init__(self): # REQUIRED
30 :     family.Family.__init__(self) # REQUIRED
31 :     self.name = 'WIKINAME' # REQUIRED; replace with actual name
32 :    
33 :     self.langs = { # REQUIRED
34 :     'en': 'www.example.com', # Include one line for each wiki in family
35 :     'fr': 'www.example.fr', # in the format 'code': 'hostname',
36 :     }
37 :    
38 :     # Translation used on all wikis for the different namespaces.
39 :     # Most namespaces are inherited from family.Family.
40 :     # Check the family.py file (in main directory) to see the standard
41 :     # namespace translations for each known language.
42 :    
43 :     # You only need to enter translations that differ from the default.
44 :     # There are two ways of entering namespace translations.
45 :     # 1. If you only need to change the translation of a particular
46 :     # namespace for one or two languages, use this format:
47 :     self.namespaces[2]['en'] = u'Wikiuser'
48 :     self.namespaces[3]['en'] = u'Wikiuser talk'
49 :    
50 :     # 2. If you need to change the translation for many languages
51 :     # for the same namespace number, use this format (this is common
52 :     # for namespaces 4 and 5, because these are usually given a
53 :     # unique name for each wiki):
54 :     self.namespaces[4] = {
55 :     '_default': [u'WIKINAME', self.namespaces[4]['_default']], # REQUIRED
56 :     'de': 'Name des wiki',
57 :     'es': 'Nombre del wiki',
58 :     'fr': 'Nom du wiki',
59 :     # ETC.
60 :     }
61 :    
62 :     # Wikimedia wikis all use "bodyContent" as the id of the <div>
63 :     # element that contains the actual page content; change this for
64 :     # wikis that use something else (e.g., mozilla family)
65 :     self.content_id = "bodyContent"
66 :    
67 :     # On most wikis page names must start with a capital letter, but some
68 :     # languages don't use this. This should be a list of languages that
69 :     # _don't_ require the first letter to be capitalized; e.g.,
70 :     # self.nocapitalize = ['foo', 'bar']
71 :     self.nocapitalize = []
72 :    
73 :     # SETTINGS FOR WIKIS THAT USE DISAMBIGUATION PAGES:
74 :    
75 :     # A list of disambiguation template names in different languages
76 :     self.disambiguationTemplates = {
77 :     'en': ['disambig', 'disambiguation'],
78 :     }
79 :    
80 :     # A list with the name of the category containing disambiguation
81 :     # pages for the various languages. Only one category per language,
82 :     # and without the namespace, so add things like:
83 :     self.disambcatname = {
84 :     'en': "Disambiguation",
85 :     }
86 :    
87 :     # SETTINGS FOR WIKIS THAT USE INTERLANGUAGE LINKS:
88 :    
89 :     # attop is a list of languages that prefer to have the interwiki
90 :     # links at the top of the page.
91 :     self.interwiki_attop = []
92 :    
93 :     # on_one_line is a list of languages that want the interwiki links
94 :     # one-after-another on a single line
95 :     self.interwiki_on_one_line = []
96 :    
97 :     # String used as separator between interwiki links and the text
98 :     self.interwiki_text_separator = '\r\n\r\n'
99 :    
100 :     # Which languages have a special order for putting interlanguage links,
101 :     # and what order is it? If a language is not in interwiki_putfirst,
102 :     # alphabetical order on language code is used. For languages that are in
103 :     # interwiki_putfirst, interwiki_putfirst is checked first, and
104 :     # languages are put in the order given there. All other languages are put
105 :     # after those, in code-alphabetical order.
106 :     self.interwiki_putfirst = {}
107 :    
108 :     # Languages in interwiki_putfirst_doubled should have a number plus a list
109 :     # of languages. If there are at least the number of interwiki links, all
110 :     # languages in the list should be placed at the front as well as in the
111 :     # normal list.
112 :     self.interwiki_putfirst_doubled = {}
113 :    
114 :     # Some families, e. g. commons and meta, are not multilingual and
115 :     # forward interlanguage links to another family (wikipedia).
116 :     # These families can set this variable to the name of the target
117 :     # family.
118 :     self.interwiki_forward = None
119 :    
120 :     # Which language codes no longer exist and by which language code
121 :     # should they be replaced. If for example the language with code xx:
122 :     # has been replaced by code yy:, add {'xx':'yy'} to obsolete.
123 :     # If all links to language xx: should be removed, add {'xx': None}.
124 :     self.obsolete = {}
125 :    
126 :     # SETTINGS FOR CATEGORY LINKS:
127 :    
128 :     # Languages that want the category links at the top of the page
129 :     self.category_attop = []
130 :    
131 :     # languages that want the category links
132 :     # one-after-another on a single line
133 :     self.category_on_one_line = []
134 :    
135 :     # String used as separator between category links and the text
136 :     self.category_text_separator = '\r\n\r\n'
137 :    
138 :     # When both at the bottom should categories come after interwikilinks?
139 :     self.categories_last = []
140 :    
141 :     def protocol(self, code):
142 :     """
143 :     Can be overridden to return 'https'. Other protocols are not supported.
144 :     """
145 :     return 'http'
146 :    
147 :     def scriptpath(self, code):
148 :     """The prefix used to locate scripts on this wiki.
149 :    
150 :     This is the value displayed when you enter {{SCRIPTPATH}} on a
151 :     wiki page (often displayed at [[Help:Variables]] if the wiki has
152 :     copied the master help page correctly).
153 :    
154 :     The default value is the one used on Wikimedia Foundation wikis,
155 :     but needs to be overridden in the family file for any wiki that
156 :     uses a different value.
157 :    
158 :     """
159 :     return '/w'
160 :    
161 :     # IMPORTANT: if your wiki does not support the api.php interface,
162 :     # you must uncomment the second line of this method:
163 :     def apipath(self, code):
164 :     # raise NotImplementedError, "%s wiki family does not support api.php" % self.name
165 :     return '%s/api.php' % self.scriptpath(code)
166 :    
167 :     # Which version of MediaWiki is used?
168 :     def version(self, code):
169 :     # Replace with the actual version being run on your wiki
170 :     return '1.13alpha'
171 :    
172 :     def code2encoding(self, code):
173 :     """Return the encoding for a specific language wiki"""
174 :     # Most wikis nowadays use UTF-8, but change this if yours uses
175 :     # a different encoding
176 :     return 'utf-8'

svn@nadir-point.com
Subversion  TortoiseSVN  ViewVC