# =========================================================================== # eXe # Copyright 2004-2005, University of Auckland # Copyright 2004-2008 eXe Project, http://eXeLearning.org/ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # =========================================================================== """ This class transforms an eXe node into a page on a single page website """ import logging import re from cgi import escape from urllib import quote from exe.webui.blockfactory import g_blockFactory from exe.engine.error import Error from exe.engine.path import Path from exe.export.pages import Page, uniquifyNames from exe.webui import common log = logging.getLogger(__name__) # =========================================================================== class SinglePage(Page): """ This class transforms an eXe node into a page on a single page website """ def save(self, filename, for_print=0): """ Save page to a file. 'outputDir' is the directory where the filenames will be saved (a 'path' instance) """ outfile = open(filename, "w") outfile.write(self.render(self.node.package,for_print).encode('utf8')) outfile.close() def render(self, package, for_print=0): """ Returns an XHTML string rendering this page. """ html = self.renderHeader(package.name, for_print) if for_print: # include extra onload bit: html += u'
\n' else: html += u"\n" html += u"' html += escape(node.titleLong) html += '