diff --git a/modules/webstyle/lib/webpage.py b/modules/webstyle/lib/webpage.py index 538e59507..b6e1d175f 100644 --- a/modules/webstyle/lib/webpage.py +++ b/modules/webstyle/lib/webpage.py @@ -1,171 +1,178 @@ ## $Id$ ## CDSware Web Page Template. ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002 CERN. ## ## The CDSware 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. ## ## The CDSware 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 CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## read config variables: #include "config.wml" #include "configbis.wml" from config import * from webuser import create_user_infobox import re import string import sys import time import traceback import urllib ## start Python: ## $Id$ ## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES. """CDSware Web Page Template""" page_template_header = """ <CDSNAME>: %s """ page_template_footer = """ """ page_template_body = """
%s

%s

%s
%s
""" def create_navtrail(title, previous_links, prolog="", separator=""" > """, epilog=""): """create_navtrail(): create navigation trail table box input: title = page title; previous_links = the trail content from site title until current page (both ends exlusive). output: text containing the navtrail """ out = "" if title != cdsname: out += """%s""" % (weburl, "Home") if previous_links: if out: out += separator out += previous_links if title: if out: out += separator if title==cdsname: out += "Home" else: out += title return prolog + out + epilog -def page(title, body, navtrail="", description="", keywords="", uid=0, cdspagerightstripeadd="", cdspageheaderadd="", cdspagebodyadd="", cdspagefooteradd=""): +def page(title, body, navtrail="", description="", keywords="", uid=0, cdspagerightstripeadd="", cdspageheaderadd="", cdspagebodyadd="", cdspagefooteradd="", lastupdated=""): """page(): display the cds page input: title of the page; body of the page in html format; description goes to the metadata in the header of the HTML page keywords goes to the metadata in the header of the html page cdspageheaderadd is a message to be displayed just under the page header - cdspagefooteradd is a message to be dusplayed on the top of the page footer + cdspagefooteradd is a message to be displayed on the top of the page footer + lastupdated is a text containing the info on last update (optional) output: the final cds page with header, footer, etc. """ out = page_template_header % (title, description, keywords, cdspageheader, cdspageheaderadd) out = re.sub("", create_navtrail(title, navtrail), out) out = re.sub("", create_user_infobox(uid), out) out += page_template_body % (cdspagebodyadd, title, body, cdspagerightstripeadd) out += page_template_footer % (cdspagefooteradd, cdspagefooter) + if lastupdated: + out = re.sub("", "Last updated " + lastupdated, out) return out def pageheaderonly(title, navtrail="", description="", keywords="", uid=0, cdspageheaderadd=""): - """Return just the beginning of page().""" + """Return just the beginning of page(), with full headers. + Suitable for the search results page and any long-taking scripts.""" out = page_template_header % (title, description, keywords, cdspageheader, cdspageheaderadd) out = re.sub("", create_navtrail(title, navtrail), out) out = re.sub("", create_user_infobox(uid), out) return out -def pagefooteronly(cdspagefooteradd=""): - """Return just the beginning of page().""" +def pagefooteronly(cdspagefooteradd="", lastupdated=""): + """Return just the ending of page(), with full footer. + Suitable for the search results page and any long-taking scripts.""" out = page_template_footer % (cdspagefooteradd, cdspagefooter) + if lastupdated: + out = re.sub("", "Last updated " + lastupdated, out) return out def create_error_box(req, title="Internal Error:"): """Analyse the req object and the sys traceback and return a text message box with internal information that would be suitful to display when something bad has happened.""" boxhead = """

%s %s %s""" % (title, sys.exc_info()[0], sys.exc_info()[1]) boxbody = """

Please contact %s quoting the following information:

""" % (urllib.quote(supportemail), supportemail)
     boxbody += """URI: http://%s%s\n""" % (req.hostname, req.unparsed_uri)
     boxbody += """Time: %s\n""" % time.strftime("%02d/%b/%Y:%H:%M:%S %z")
     if req.headers_in.has_key('User-Agent'):
         boxbody += """Browser: %s\n""" % req.headers_in['User-Agent']
     boxbody += """Client: %s\n""" % req.connection.remote_ip
     boxbody += """Error: %s %s\n""" % (sys.exc_info()[0], sys.exc_info()[1])
     boxbody += "Traceback: \n%s" % string.join(traceback.format_tb(sys.exc_info()[2]),"\n")
     boxbody += """
""" out = """
%s
%s
""" % (boxhead, boxbody) return out diff --git a/modules/webstyle/lib/webpage.py.wml b/modules/webstyle/lib/webpage.py.wml index 538e59507..b6e1d175f 100644 --- a/modules/webstyle/lib/webpage.py.wml +++ b/modules/webstyle/lib/webpage.py.wml @@ -1,171 +1,178 @@ ## $Id$ ## CDSware Web Page Template. ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002 CERN. ## ## The CDSware 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. ## ## The CDSware 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 CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## read config variables: #include "config.wml" #include "configbis.wml" from config import * from webuser import create_user_infobox import re import string import sys import time import traceback import urllib ## start Python: ## $Id$ ## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES. """CDSware Web Page Template""" page_template_header = """ <CDSNAME>: %s """ page_template_footer = """ """ page_template_body = """
%s

%s

%s
%s
""" def create_navtrail(title, previous_links, prolog="", separator=""" > """, epilog=""): """create_navtrail(): create navigation trail table box input: title = page title; previous_links = the trail content from site title until current page (both ends exlusive). output: text containing the navtrail """ out = "" if title != cdsname: out += """%s""" % (weburl, "Home") if previous_links: if out: out += separator out += previous_links if title: if out: out += separator if title==cdsname: out += "Home" else: out += title return prolog + out + epilog -def page(title, body, navtrail="", description="", keywords="", uid=0, cdspagerightstripeadd="", cdspageheaderadd="", cdspagebodyadd="", cdspagefooteradd=""): +def page(title, body, navtrail="", description="", keywords="", uid=0, cdspagerightstripeadd="", cdspageheaderadd="", cdspagebodyadd="", cdspagefooteradd="", lastupdated=""): """page(): display the cds page input: title of the page; body of the page in html format; description goes to the metadata in the header of the HTML page keywords goes to the metadata in the header of the html page cdspageheaderadd is a message to be displayed just under the page header - cdspagefooteradd is a message to be dusplayed on the top of the page footer + cdspagefooteradd is a message to be displayed on the top of the page footer + lastupdated is a text containing the info on last update (optional) output: the final cds page with header, footer, etc. """ out = page_template_header % (title, description, keywords, cdspageheader, cdspageheaderadd) out = re.sub("", create_navtrail(title, navtrail), out) out = re.sub("", create_user_infobox(uid), out) out += page_template_body % (cdspagebodyadd, title, body, cdspagerightstripeadd) out += page_template_footer % (cdspagefooteradd, cdspagefooter) + if lastupdated: + out = re.sub("", "Last updated " + lastupdated, out) return out def pageheaderonly(title, navtrail="", description="", keywords="", uid=0, cdspageheaderadd=""): - """Return just the beginning of page().""" + """Return just the beginning of page(), with full headers. + Suitable for the search results page and any long-taking scripts.""" out = page_template_header % (title, description, keywords, cdspageheader, cdspageheaderadd) out = re.sub("", create_navtrail(title, navtrail), out) out = re.sub("", create_user_infobox(uid), out) return out -def pagefooteronly(cdspagefooteradd=""): - """Return just the beginning of page().""" +def pagefooteronly(cdspagefooteradd="", lastupdated=""): + """Return just the ending of page(), with full footer. + Suitable for the search results page and any long-taking scripts.""" out = page_template_footer % (cdspagefooteradd, cdspagefooter) + if lastupdated: + out = re.sub("", "Last updated " + lastupdated, out) return out def create_error_box(req, title="Internal Error:"): """Analyse the req object and the sys traceback and return a text message box with internal information that would be suitful to display when something bad has happened.""" boxhead = """

%s %s %s""" % (title, sys.exc_info()[0], sys.exc_info()[1]) boxbody = """

Please contact %s quoting the following information:

""" % (urllib.quote(supportemail), supportemail)
     boxbody += """URI: http://%s%s\n""" % (req.hostname, req.unparsed_uri)
     boxbody += """Time: %s\n""" % time.strftime("%02d/%b/%Y:%H:%M:%S %z")
     if req.headers_in.has_key('User-Agent'):
         boxbody += """Browser: %s\n""" % req.headers_in['User-Agent']
     boxbody += """Client: %s\n""" % req.connection.remote_ip
     boxbody += """Error: %s %s\n""" % (sys.exc_info()[0], sys.exc_info()[1])
     boxbody += "Traceback: \n%s" % string.join(traceback.format_tb(sys.exc_info()[2]),"\n")
     boxbody += """
""" out = """
%s
%s
""" % (boxhead, boxbody) return out