Iframe-idevice

This is a very simple iDevice that uses the iframe html tag in-order to embed a webpage. It demonstrates the use of multiple text fields, and using the values entered as parameters in formated XHTML. It could, for example be used to embed a shared Scribblar white board into an exercise.

The same results can be achieved much more simply by choosing to modify the html in free text fields, but the features demonstrated can be applied to other situations.

iframeidevice.py

 * 1) eXe
 * 2) Copyright 2004-2005, University of Auckland
 * 3) This program is free software; you can redistribute it and/or modify
 * 4) it under the terms of the GNU General Public License as published by
 * 5) the Free Software Foundation; either version 2 of the License, or
 * 6) (at your option) any later version.
 * 7) This program is distributed in the hope that it will be useful,
 * 8) but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 9) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 10) GNU General Public License for more details.
 * 11) You should have received a copy of the GNU General Public License
 * 12) along with this program; if not, write to the Free Software
 * 13) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 1) You should have received a copy of the GNU General Public License
 * 2) along with this program; if not, write to the Free Software
 * 3) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 1) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

""" Allows the embedding of a webpage within the eXe page, using the iframe html tag. Produced by Educational Develoment Unit, University of Derby """

import logging from exe.engine.idevice import Idevice from exe.engine.field  import TextField log = logging.getLogger(__name__)

class iFrameIdevice(Idevice): """   This is an example of a user created iDevice plugin.  If it is copied    into the user's ~/.exe/idevices dircectory it will be loaded along with    the system idevices.    """ def __init__(self, content=""): Idevice.__init__(self, _(u"iFrame"),                         _(u"University of Derby"),                          _(u"""Embeds an external website within your page."""), "", "") self.emphasis = Idevice.NoEmphasis self.url = TextField(_(u"URL"),                               _(u"Enter the site's URL here"),                               "http://") self.width = TextField(_(u"Width"),                                 _(u"Width of the iFrame"),                                 "850") self.height = TextField(_(u"Height"),                                  _(u"Height of the iFrame"),                                  "650") self.url.idevice = self self.width.idevice = self self.height.idevice = self

def register(ideviceStore): """Register with the ideviceStore""" ideviceStore.extended.append(iFrameIdevice)



iframeblock.py
""" iFrameBlock can render and process iFrameIdevices as XHTML """
 * 1) eXe
 * 2) Copyright 2004-2005, University of Auckland
 * 3) This program is free software; you can redistribute it and/or modify
 * 4) it under the terms of the GNU General Public License as published by
 * 5) the Free Software Foundation; either version 2 of the License, or
 * 6) (at your option) any later version.
 * 7) This program is distributed in the hope that it will be useful,
 * 8) but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 9) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 10) GNU General Public License for more details.
 * 11) You should have received a copy of the GNU General Public License
 * 12) along with this program; if not, write to the Free Software
 * 13) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 1) You should have received a copy of the GNU General Public License
 * 2) along with this program; if not, write to the Free Software
 * 3) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 1) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import logging from exe.webui.block           import Block from exe.webui.element         import TextElement

log = logging.getLogger(__name__)

class iFrameBlock(Block): """   ExampleBlock can render and process ExampleIdevices as XHTML    GenericBlock will replace it..... one day    """ def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.urlElement = TextElement(idevice.url) self.widthElement = TextElement(idevice.width) self.heightElement = TextElement(idevice.height)

def process(self, request): """       Process the request arguments from the web server to see if any        apply to this block        """ Block.process(self, request) url = self.urlElement.process(request) if url: self.idevice.url = url width = self.widthElement.process(request) if width: self.idevice.width = width height = self.heightElement.process(request) if height: self.idevice.height = height

def renderEdit(self, style): """       Returns an XHTML string with the form element for editing this block        """ html = u" \n" html += self.urlElement.renderEdit html += self.widthElement.renderEdit html += self.heightElement.renderEdit html += self.renderEditButtons html += u" \n" return html

def renderPreview(self, style): """       Returns an XHTML string for previewing this block        """ html = u"\n" html += " \n" html += self.renderViewButtons html += " \n" return html

def renderView(self, style): """       Returns an XHTML string for viewing this block        """ html = u"\n" html += " \n" html += u" \n" return html

def register: """Register this block with the BlockFactory""" from iframeidevice import iFrameIdevice from exe.webui.blockfactory    import g_blockFactory g_blockFactory.registerBlockType(iFrameBlock, iFrameIdevice)