ircmeeting/writers.py - add mediawiki upload patch from David Narvaez
Ignore-this: 9044e960dbc799ff5b27af8780da4e77 - This allows the MediaWiki writer to upload directly to a MediaWiki instance. - Configuration is via the extension-kwargs mechanism: .mw|mwsite=blah|mwpath=blah|mwusername=blah|mwpassword=blah - Patch contributed by David Narvaez - thanks very much! darcs-hash:20101210094715-82ea9-f7f1ca46508789049a5a7e5cc952b0446fa16723.gz
This commit is contained in:
parent
0790138e94
commit
85b33eb4a8
@ -509,6 +509,18 @@ And to set it (again, in private message with the bot)::
|
||||
|
||||
<MrBeige> config plugins.MeetBot.writer_map HTML2:.html MediaWiki:.mw HTMLlog2:.log.html Text:.txt
|
||||
|
||||
There is a special way to pass arguments to writers. Learn by
|
||||
example::
|
||||
|
||||
writer_map = {
|
||||
'.mw|mwsite=http://site.net|mwpath=Meetings':writers.MediaWiki,
|
||||
}
|
||||
|
||||
or via supybot::
|
||||
|
||||
config plugins.MeetBot.writer_map MediaWiki:.mw|mwsite=http://site.net|mwpath=Meetings
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -541,8 +553,21 @@ default):
|
||||
A meeting notes format, as a plain text file
|
||||
|
||||
``MediaWiki``
|
||||
MediaWiki output. This doesn't upload *to* a MediaWiki instance,
|
||||
but that could be added later.
|
||||
MediaWiki output.
|
||||
|
||||
The MediaWiki writer has the
|
||||
ability to upload to a MediaWiki site directly. You use the
|
||||
custom variables ``mwsite``: site name to upload to, ``mwpath``:
|
||||
subpage to upload to (final location is
|
||||
``%(mwpath)/%(file_basename)), ``mwusername`` and ``mwpassword``:
|
||||
username and password to log in as.
|
||||
|
||||
An upload is attempted if ``mwsite`` is given. A login is
|
||||
attempted if ``mwusername`` is given. An example configuration::
|
||||
|
||||
writer_map = {
|
||||
'.mw|mwsite=http://site.net|mwpath=Meetings':writers.MediaWiki,
|
||||
}
|
||||
|
||||
``PmWiki``
|
||||
PmWiki output. This doesn't upload *to* a PmWiki instance,
|
||||
@ -570,7 +595,7 @@ default):
|
||||
...
|
||||
'.tmpl.txt|template=+template.txt' = writers.Template,
|
||||
}
|
||||
.
|
||||
|
||||
When setting a template writer by the suybot registry, one would do::
|
||||
|
||||
/msg YourBot config plugins.MeetBot.writer_map <other writers> Template:.EXTENSION_NAME|template=TEMPLATE_FILE ...
|
||||
|
@ -1132,7 +1132,7 @@ class MediaWiki(_BaseWriter):
|
||||
sWRAPsMeeting started by %(owner)s at %(starttime)s
|
||||
%(timeZone)s. The full logs are available at
|
||||
%(fullLogsFullURL)s .eWRAPe""")
|
||||
def format(self, extension=None):
|
||||
def format(self, extension=None, **kwargs):
|
||||
"""Return a MediaWiki formatted minutes summary."""
|
||||
M = self.M
|
||||
|
||||
@ -1157,6 +1157,26 @@ class MediaWiki(_BaseWriter):
|
||||
body = "\n\n\n\n".join(body)
|
||||
body = replaceWRAP(body)
|
||||
|
||||
|
||||
# Do we want to upload?
|
||||
if 'mwpath' in kwargs:
|
||||
import mwclient
|
||||
mwsite = kwargs['mwsite']
|
||||
mwpath = kwargs['mwpath']
|
||||
mwusername = kwargs.get('mwusername', None)
|
||||
mwpassword = kwargs.get('mwpassword', '')
|
||||
subpagename = os.path.basename(self.M.config.filename())
|
||||
mwfullname = "%s/%s" % (mwpath, subpagename)
|
||||
force_login = (mwusername != None)
|
||||
|
||||
site = mwclient.Site(mwsite, force_login=force_login)
|
||||
if(login):
|
||||
site.login(mwusername, mwpassword)
|
||||
page = site.Pages[mwfullname]
|
||||
some = page.edit()
|
||||
page.save(body, summary="Meeting")
|
||||
|
||||
|
||||
return body
|
||||
|
||||
class PmWiki(MediaWiki, object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user