diff --git a/doc/Manual.txt b/doc/Manual.txt index ca833bc..55f0051 100644 --- a/doc/Manual.txt +++ b/doc/Manual.txt @@ -509,6 +509,18 @@ And to set it (again, in private message with the bot):: 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 Template:.EXTENSION_NAME|template=TEMPLATE_FILE ... diff --git a/ircmeeting/writers.py b/ircmeeting/writers.py index b5207d9..745233a 100644 --- a/ircmeeting/writers.py +++ b/ircmeeting/writers.py @@ -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):