1 --- a/docs/commands.txt Tue Nov 18 15:50:25 2008 +0100
2 +++ b/docs/commands.txt Tue Nov 18 15:50:43 2008 +0100
3 @@ -81,6 +81,13 @@
4 ``--template-exclusion-category=CATEGORY``
5
6 A name of a category: Templates in this cateogry are excluded during rendering.
7 +
8 +``--print-template-prefix=PREFIX``
9 +
10 + Prefix for "print templates", i.e. templates that are tried to fetch before
11 + regular templates. The default value is 'Print' resultint in print template
12 + names of the form 'Template:PrintNAME' (with NAME being the name of the original
13 + template).
14
15 ``-o, --output=OUTPUT``
16
1.1 --- a/mwlib/_version.py Tue Nov 18 15:50:25 2008 +0100
1.2 +++ b/mwlib/_version.py Tue Nov 18 15:50:43 2008 +0100
1.3 @@ -5,5 +5,5 @@
1.4 def __str__(self):
1.5 return '.'.join([str(x) for x in self])
1.6
1.7 -version = _Version((0,8,6, 'dev'))
1.8 +version = _Version((0,9,1,'dev'))
1.9 del _Version
2.1 --- a/mwlib/mwapidb.py Tue Nov 18 15:50:25 2008 +0100
2.2 +++ b/mwlib/mwapidb.py Tue Nov 18 15:50:43 2008 +0100
2.3 @@ -543,8 +543,6 @@
2.4
2.5
2.6 class WikiDB(wikidbbase.WikiDBBase):
2.7 - print_template = u'Template:Print%s' # set this to none to deacticate # FIXME
2.8 -
2.9 ip_rex = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
2.10 bot_rex = re.compile(r'bot\b', re.IGNORECASE)
2.11
2.12 @@ -555,6 +553,7 @@
2.13 domain=None,
2.14 template_blacklist=None,
2.15 template_exclusion_category=None,
2.16 + print_template_prefix=None,
2.17 api_helper=None,
2.18 script_extension=None,
2.19 ):
2.20 @@ -580,6 +579,9 @@
2.21 be excluded (optional)
2.22 @type template_exclusion_category: unicode
2.23
2.24 + @param print_template_prefix: prefix for print templates (optional)
2.25 + @type print_template_prefix: unicode
2.26 +
2.27 @param api_helper: APIHelper instance
2.28 @type api_helper: L{APIHelper}
2.29
2.30 @@ -604,11 +606,13 @@
2.31 self.setTemplateExclusion(
2.32 blacklist=template_blacklist,
2.33 category=template_exclusion_category,
2.34 + prefix=print_template_prefix,
2.35 )
2.36 self.source = None
2.37
2.38 - def setTemplateExclusion(self, blacklist=None, category=None):
2.39 + def setTemplateExclusion(self, blacklist=None, category=None, prefix=None):
2.40 self.template_exclusion_category = category
2.41 + self.print_template_prefix = prefix
2.42 self.template_blacklist = []
2.43 if blacklist:
2.44 raw = self.getRawArticle(blacklist)
2.45 @@ -697,8 +701,8 @@
2.46 pass
2.47
2.48 titles = ['Template:%s' % name]
2.49 - if self.print_template:
2.50 - titles.insert(0, self.print_template % name)
2.51 + if self.print_template_prefix:
2.52 + titles.insert(0, 'Template:%s%s' % (self.print_template_prefix, name))
2.53 for title in titles:
2.54 raw = self.getRawArticle(title)
2.55 if raw is None:
4.1 --- a/mwlib/options.py Tue Nov 18 15:50:25 2008 +0100
4.2 +++ b/mwlib/options.py Tue Nov 18 15:50:43 2008 +0100
4.3 @@ -35,6 +35,11 @@
4.4 self.add_option("--template-exclusion-category",
4.5 help="Name of category for templates to be excluded",
4.6 metavar='CATEGORY',
4.7 + )
4.8 + self.add_option("--print-template-prefix",
4.9 + help="Prefix for print templates",
4.10 + metavar='PREFIX',
4.11 + default='Print',
4.12 )
4.13 self.add_option("--template-blacklist",
4.14 help="Title of article containing blacklisted templates",
4.15 @@ -128,11 +133,14 @@
4.16 )
4.17 if self.options.noimages:
4.18 env.images = None
4.19 - if self.options.template_blacklist or self.options.template_exclusion_category:
4.20 + if self.options.template_blacklist\
4.21 + or self.options.template_exclusion_category\
4.22 + or self.options.print_template_prefix:
4.23 if hasattr(env.wiki, 'setTemplateExclusion'):
4.24 env.wiki.setTemplateExclusion(
4.25 blacklist=self.options.template_blacklist,
4.26 category=self.options.template_exclusion_category,
4.27 + prefix=self.options.print_template_prefix,
4.28 )
4.29 else:
4.30 log.warn('WikiDB does not support setting a template blacklist')
6.1 --- a/mwlib/serve.py Tue Nov 18 15:50:25 2008 +0100
6.2 +++ b/mwlib/serve.py Tue Nov 18 15:50:43 2008 +0100
6.3 @@ -57,6 +57,7 @@
6.4 'script_extension',
6.5 'template_blacklist',
6.6 'template_exclusion_category',
6.7 + 'print_template_prefix',
6.8 'login_credentials',
6.9 ):
6.10 sio.write(repr(data.get(key)))
6.11 @@ -234,6 +235,7 @@
6.12 writer_options = post_data.get('writer_options', '')
6.13 template_blacklist = post_data.get('template_blacklist', '')
6.14 template_exclusion_category = post_data.get('template_exclusion_category', '')
6.15 + print_template_prefix = post_data.get('print_template_prefix', '')
6.16 login_credentials = post_data.get('login_credentials', '')
6.17 force_render = bool(post_data.get('force_render'))
6.18 script_extension = post_data.get('script_extension', '')
6.19 @@ -308,6 +310,8 @@
6.20 args.extend(['--template-blacklist', template_blacklist])
6.21 if template_exclusion_category:
6.22 args.extend(['--template-exclusion-category', template_exclusion_category])
6.23 + if print_template_prefix:
6.24 + args.extend(['--print-template-prefix', print_template_prefix])
6.25 if language:
6.26 args.extend(['--language', language])
6.27 else:
6.28 @@ -331,6 +335,8 @@
6.29 args.extend(['--template-blacklist', template_blacklist])
6.30 if template_exclusion_category:
6.31 args.extend(['--template-exclusion-category', template_exclusion_category])
6.32 + if print_template_prefix:
6.33 + args.extend(['--print-template-prefix', print_template_prefix])
6.34 if login_credentials:
6.35 args.extend(['--login', login_credentials])
6.36 if script_extension:
6.37 @@ -461,6 +467,7 @@
6.38 return self.error_response('POST argument required: %s' % exc)
6.39 template_blacklist = post_data.get('template_blacklist', '')
6.40 template_exclusion_category = post_data.get('template_exclusion_category', '')
6.41 + print_template_prefix = post_data.get('print_template_prefix', '')
6.42 login_credentials = post_data.get('login_credentials', '')
6.43 script_extension = post_data.get('script_extension', '')
6.44
6.45 @@ -525,6 +532,8 @@
6.46 args.extend(['--template-blacklist', template_blacklist])
6.47 if template_exclusion_category:
6.48 args.extend(['--template-exclusion-category', template_exclusion_category])
6.49 + if print_template_prefix:
6.50 + args.extend(['--print-template-prefix', print_template_prefix])
6.51 if login_credentials:
6.52 args.extend(['--login', login_credentials])
6.53 if script_extension: