changeset 588:50f81f786081

Initial Version of a parser and actions for accessing a BigBlueButton instance. BigBlueButton is an open source web conferencing system for distance education. This plugin enables your wiki to keep session parameter and to manage meetings.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 31 May 2012 09:09:45 +0200
parents 1b06afc3a430
children c5aac4f4f04c
files data/plugin/action/submit_bbb_close_meeting.py data/plugin/action/submit_bbb_create_meeting.py data/plugin/action/submit_bbb_join_meeting.py data/plugin/parser/bbb_create.py
diffstat 4 files changed, 266 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/submit_bbb_close_meeting.py	Thu May 31 09:09:45 2012 +0200
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - Create Meeting for bigbluebutton
+
+    @copyright: 2012 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import urllib
+from MoinMoin.Page import Page
+# pip install bigbluebutton
+from bigbluebutton import Meeting
+import bbb_settings
+
+
+def execute(pagename, request):
+    """
+    Lets a Moderator of a meeting closing this meeting.
+    It requires a bbb_admin_group defined in wikiconfig.py.
+    Only a user of this group is allowed to use this action. 
+    On same directory as wikiconfig.py you need
+    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
+
+    Example Call by using http://moinmo.in/MacroMarket/FormCreate
+    <<FormHeader(submit_bbb_close_meeting)>>
+    || Meeting ID || <<FormText(meeting_id,maxlength=50)>> ||
+    || Moderator Password: || <<FormText(password,maxlength=50)>> ||
+    ||<-2:> <<FormSubmit(Send)>> ||
+    <<FormFooter()>>
+    """
+
+    _ = request.getText
+    username = request.user.name
+    groups = request.groups
+    msg = ["Sorry you have not enough previledges", "error"]
+    try:
+        bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
+    except AttributeError:
+        request.theme.add_msg(msg[0], msg[1])
+        Page(request, pagename).send_page()
+        return
+
+    if request.user.valid and username in bbb_admin_group:
+        meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
+        msg = meeting.end_meeting(request.form["meeting_id"], request.form["password"])
+
+        request.theme.add_msg('OK', 'info')
+        Page(request, pagename).send_page()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/submit_bbb_create_meeting.py	Thu May 31 09:09:45 2012 +0200
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - Create a Meeting for bigbluebutton (http://www.bigbluebutton.org/)
+
+    @copyright: 2012 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.PageEditor import PageEditor
+from MoinMoin.Page import Page
+# pip install bigbluebutton
+from bigbluebutton import Meeting_Setup
+import bbb_settings
+
+def execute(pagename, request):
+    """
+    Creates a bigbluebutton meeting and stores the definitions on a wiki sub page.
+    This page is protected by acls for the responsible user. By reloading the Definition
+    page the session becomes recreated.
+    It requires a bbb_admin_group defined in wikiconfig.py. Only a user of this 
+    group is allowed to use this action. On same directory as wikiconfig.py you need
+    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
+
+    Example Call by using http://moinmo.in/MacroMarket/FormCreate
+
+    <<FormHeader(submit_bbb_create_meeting)>>
+    || Meeting Name: || <<FormText(meeting_name,maxlength=50)>> ||
+    || Meeting ID || <<FormText(meeting_id,maxlength=50)>> ||
+    || Moderator Passwort: || <<FormText(moderator_password,maxlength=50)>> ||
+    || Attendee Passwort: || <<FormText(attendee_password,maxlength=50)>> ||
+    ||<-2:> <<FormSubmit(Send)>> ||
+    <<FormFooter()>>
+
+    """
+    username = request.user.name
+    groups = request.groups
+    msg = ["Sorry you have not enough previledges", "error"]
+    try:
+        bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
+    except AttributeError:
+        request.theme.add_msg(msg[0], msg[1])
+        Page(request, pagename).send_page()
+        return
+
+    if request.user.valid and username in bbb_admin_group:
+        _ = request.getText
+
+        attendee_password = request.form["attendee_password"]
+        moderator_password = request.form["moderator_password"]
+
+        if not attendee_password.strip() or not moderator_password.strip():
+            msg = ["Sorry, we don't support empty passwords!", "error"]
+            request.theme.add_msg(msg[0], msg[1])
+            Page(request, pagename).send_page()
+            return
+
+        session = Meeting_Setup(bbb_api_url=bbb_settings.BBB_API_URL,
+                                salt=bbb_settings.SALT,
+                                meeting_name=request.form["meeting_name"],
+                                meeting_id=request.form["meeting_id"],
+                                attendee_password=attendee_password,
+                                moderator_password=moderator_password,
+                               )
+        session.create_meeting()
+
+        sub_pagename = u'%s/%s' % (pagename, request.form["meeting_name"])
+        keyval = "\n".join([' %s:: %s' % (key, value) for key, value in request.form.iteritems() if not (key.startswith('labels') or key.startswith('action') or key.startswith('doit'))])
+        result = """#acl %(username)s:read,write,delete,revert All:
+#format bbb_create
+ responsible:: %(username)s
+%(keyval)s""" % {"username": username,
+                 "keyval": keyval}
+
+        try:
+            # We write without acl check
+            PageEditor(request, sub_pagename)._write_file(result, action='SAVE')
+            msg = (_(u"OK!"), "info")
+        except PageEditor.SaveError:
+            msg = (_(u"A severe error occured:"), "error")
+    request.theme.add_msg(msg[0], msg[1])
+    Page(request, pagename).send_page()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/submit_bbb_join_meeting.py	Thu May 31 09:09:45 2012 +0200
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - Create Meeting for bigbluebutton (http://www.bigbluebutton.org/)
+
+    @copyright: 2012 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import urllib
+from MoinMoin.Page import Page
+# pip install bigbluebutton
+from bigbluebutton import Meeting
+import bbb_settings
+
+
+def execute(pagename, request):
+    """
+    Lets a user join a bigbluebutton meeting.  On same directory as wikiconfig.py you need
+    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
+
+    Example Call by using http://moinmo.in/MacroMarket/FormCreate
+
+    <<FormHeader(submit_bbb_join_meeting)>>
+    || Meeting ID || <<FormText(meeting_id,maxlength=50)>> ||
+    || Name: || <<FormText(name,maxlength=50)>> ||
+    || Password: || <<FormText(password,maxlength=50)>> ||
+    ||<-2:> <<FormSubmit(Send)>> ||
+    <<FormFooter()>>
+    """
+    _ = request.getText
+    meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
+    url = meeting.join_url(request.form["meeting_id"], request.form["name"], request.form["password"])
+    request.http_redirect(url)
+
+    request.theme.add_msg('OK', 'info')
+    Page(request, pagename).send_page()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/parser/bbb_create.py	Thu May 31 09:09:45 2012 +0200
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - Parser for creating a bigbluebutton meeting (http://www.bigbluebutton.org/)
+
+    @copyright: 2012 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import time
+from MoinMoin import wikiutil
+# pip install bigbluebutton
+from bigbluebutton import Meeting_Setup
+import bbb_settings
+
+Dependencies = []
+
+class Parser:
+    """
+    Lets a user create a meeting.
+    It requires a bbb_admin_group defined in wikiconfig.py.
+    Only a user of this group is allowed to use this parser. 
+    On same directory as wikiconfig.py you need
+    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
+    
+    Example:
+    
+    #acl YOURNAME:read,write,delete,revert All:
+    #format bbb_create
+    responsible:: YOURNAME
+    meeting_name:: The name of the meeting
+    meeting_id:: The ID of the meeting
+    attendee_password:: The password for attendee (viewer)
+    moderator_password:: The password for moderator
+    """
+
+    extensions = ''
+    Dependencies = []
+
+    def __init__(self, raw, request, **kw):
+        self.raw = raw
+        self.request = request
+        self.form = request.form
+        self._ = request.getText
+        self.start_line = kw.get('start_line', 0)
+
+    def format(self, formatter):
+        """ Send the text. """
+        content = self.request.dicts.get(formatter.page.page_name, {})
+        request = self.request
+        username = request.user.name
+        groups = request.groups
+        try:
+            bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
+        except AttributeError:
+            wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
+            wiki_parser = wiki_parser.Parser(self.raw, self.request)
+            wiki_parser.format(formatter)
+            return
+
+        msg = ""
+        attendee_password = content["attendee_password"],
+        moderator_password = content["moderator_password"]
+        if not attendee_password or not moderator_password:
+            wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
+            wiki_parser = wiki_parser.Parser(self.raw, self.request)
+            wiki_parser.format(formatter)
+            return
+
+        if request.user.valid and username in bbb_admin_group:
+            recreate = True
+            msg = "(!) Successful restarted :) "
+            try:
+                session = Meeting_Setup(bbb_api_url=bbb_settings.BBB_API_URL, salt=bbb_settings.SALT,
+                                    meeting_name=content["meeting_name"], meeting_id=content["meeting_id"],
+                                    attendee_password=attendee_password,
+                                    moderator_password=moderator_password,
+                                    )
+                try:
+                    session.create_meeting()
+                except TypeError:
+                    recreate = False
+                    msg = "/!\ Usually the meeting is running and you tried to change some important parameters. Stop the Meeting beforehand. X-("
+
+            except KeyError:
+                msg = "/!\ Usually not the right parameters or syntax used! X-(  "
+                recreate = False
+
+
+
+        raw = """
+
+%s
+%s
+""" % (msg, self.raw)
+
+
+        wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
+        wiki_parser = wiki_parser.Parser(raw, self.request)
+        wiki_parser.format(formatter)
+