added --print-template-prefix argument and print_template_prefix parameter passed to mw-serve.
1 --- a/docs/commands.txt Tue Nov 18 14:23:14 2008 +0100
2 +++ b/docs/commands.txt Tue Nov 18 14:45:20 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/mwapidb.py Tue Nov 18 14:23:14 2008 +0100
1.2 +++ b/mwlib/mwapidb.py Tue Nov 18 14:45:20 2008 +0100
1.3 @@ -543,8 +543,6 @@
1.4
1.5
1.6 class WikiDB(wikidbbase.WikiDBBase):
1.7 - print_template = u'Template:Print%s' # set this to none to deacticate # FIXME
1.8 -
1.9 ip_rex = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
1.10 bot_rex = re.compile(r'bot\b', re.IGNORECASE)
1.11
1.12 @@ -555,6 +553,7 @@
1.13 domain=None,
1.14 template_blacklist=None,
1.15 template_exclusion_category=None,
1.16 + print_template_prefix=None,
1.17 api_helper=None,
1.18 script_extension=None,
1.19 ):
1.20 @@ -580,6 +579,9 @@
1.21 be excluded (optional)
1.22 @type template_exclusion_category: unicode
1.23
1.24 + @param print_template_prefix: prefix for print templates (optional)
1.25 + @type print_template_prefix: unicode
1.26 +
1.27 @param api_helper: APIHelper instance
1.28 @type api_helper: L{APIHelper}
1.29
1.30 @@ -604,11 +606,13 @@
1.31 self.setTemplateExclusion(
1.32 blacklist=template_blacklist,
1.33 category=template_exclusion_category,
1.34 + prefix=print_template_prefix,
1.35 )
1.36 self.source = None
1.37
1.38 - def setTemplateExclusion(self, blacklist=None, category=None):
1.39 + def setTemplateExclusion(self, blacklist=None, category=None, prefix=None):
1.40 self.template_exclusion_category = category
1.41 + self.print_template_prefix = prefix
1.42 self.template_blacklist = []
1.43 if blacklist:
1.44 raw = self.getRawArticle(blacklist)
1.45 @@ -697,8 +701,8 @@
1.46 pass
1.47
1.48 titles = ['Template:%s' % name]
1.49 - if self.print_template:
1.50 - titles.insert(0, self.print_template % name)
1.51 + if self.print_template_prefix:
1.52 + titles.insert(0, 'Template:%s%s' % (self.print_template_prefix, name))
1.53 for title in titles:
1.54 raw = self.getRawArticle(title)
1.55 if raw is None:
2.1 --- a/mwlib/options.py Tue Nov 18 14:23:14 2008 +0100
2.2 +++ b/mwlib/options.py Tue Nov 18 14:45:20 2008 +0100
2.3 @@ -35,6 +35,11 @@
2.4 self.add_option("--template-exclusion-category",
2.5 help="Name of category for templates to be excluded",
2.6 metavar='CATEGORY',
2.7 + )
2.8 + self.add_option("--print-template-prefix",
2.9 + help="Prefix for print templates",
2.10 + metavar='PREFIX',
2.11 + default='Print',
2.12 )
2.13 self.add_option("--template-blacklist",
2.14 help="Title of article containing blacklisted templates",
2.15 @@ -128,11 +133,14 @@
2.16 )
2.17 if self.options.noimages:
2.18 env.images = None
2.19 - if self.options.template_blacklist or self.options.template_exclusion_category:
2.20 + if self.options.template_blacklist\
2.21 + or self.options.template_exclusion_category\
2.22 + or self.options.print_template_prefix:
2.23 if hasattr(env.wiki, 'setTemplateExclusion'):
2.24 env.wiki.setTemplateExclusion(
2.25 blacklist=self.options.template_blacklist,
2.26 category=self.options.template_exclusion_category,
2.27 + prefix=self.options.print_template_prefix,
2.28 )
2.29 else:
2.30 log.warn('WikiDB does not support setting a template blacklist')
3.1 --- a/mwlib/serve.py Tue Nov 18 14:23:14 2008 +0100
3.2 +++ b/mwlib/serve.py Tue Nov 18 14:45:20 2008 +0100
3.3 @@ -57,6 +57,7 @@
3.4 'script_extension',
3.5 'template_blacklist',
3.6 'template_exclusion_category',
3.7 + 'print_template_prefix',
3.8 'login_credentials',
3.9 ):
3.10 sio.write(repr(data.get(key)))
3.11 @@ -234,6 +235,7 @@
3.12 writer_options = post_data.get('writer_options', '')
3.13 template_blacklist = post_data.get('template_blacklist', '')
3.14 template_exclusion_category = post_data.get('template_exclusion_category', '')
3.15 + print_template_prefix = post_data.get('print_template_prefix', '')
3.16 login_credentials = post_data.get('login_credentials', '')
3.17 force_render = bool(post_data.get('force_render'))
3.18 script_extension = post_data.get('script_extension', '')
3.19 @@ -308,6 +310,8 @@
3.20 args.extend(['--template-blacklist', template_blacklist])
3.21 if template_exclusion_category:
3.22 args.extend(['--template-exclusion-category', template_exclusion_category])
3.23 + if print_template_prefix:
3.24 + args.extend(['--print-template-prefix', print_template_prefix])
3.25 if language:
3.26 args.extend(['--language', language])
3.27 else:
3.28 @@ -331,6 +335,8 @@
3.29 args.extend(['--template-blacklist', template_blacklist])
3.30 if template_exclusion_category:
3.31 args.extend(['--template-exclusion-category', template_exclusion_category])
3.32 + if print_template_prefix:
3.33 + args.extend(['--print-template-prefix', print_template_prefix])
3.34 if login_credentials:
3.35 args.extend(['--login', login_credentials])
3.36 if script_extension:
3.37 @@ -461,6 +467,7 @@
3.38 return self.error_response('POST argument required: %s' % exc)
3.39 template_blacklist = post_data.get('template_blacklist', '')
3.40 template_exclusion_category = post_data.get('template_exclusion_category', '')
3.41 + print_template_prefix = post_data.get('print_template_prefix', '')
3.42 login_credentials = post_data.get('login_credentials', '')
3.43 script_extension = post_data.get('script_extension', '')
3.44
3.45 @@ -525,6 +532,8 @@
3.46 args.extend(['--template-blacklist', template_blacklist])
3.47 if template_exclusion_category:
3.48 args.extend(['--template-exclusion-category', template_exclusion_category])
3.49 + if print_template_prefix:
3.50 + args.extend(['--print-template-prefix', print_template_prefix])
3.51 if login_credentials:
3.52 args.extend(['--login', login_credentials])
3.53 if script_extension: