Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78794580
webpage.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 23, 00:52
Size
11 KB
Mime Type
text/x-c
Expires
Sun, Aug 25, 00:52 (2 d)
Engine
blob
Format
Raw Data
Handle
20103003
Attached To
R3600 invenio-infoscience
webpage.py
View Options
## $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
messages
import
*
from
webuser
import
create_userinfobox_body
import
re
import
string
import
sys
import
time
import
traceback
import
urllib
## start Python:
<
protect
>
## $Id$</protect>
<
protect
>
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
"""CDSware Web Page Template"""
page_template_header
=
"""
<!-- DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware SOURCES. LOOK THERE FOR THE COPYRIGHT INFO. -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><!--CDSNAMEINTL-->: %s</title>
<link rev="made" href="mailto:<SUPPORTEMAIL>">
<link rel="stylesheet" href="<WEBURL>/img/cds.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="%s">
<meta name="keywords" content="%s">
</head>
<body>
<div class="pageheader">
%s
%s
</div>
"""
page_template_footer
=
"""
<div class="pagefooter">
%s
%s
</div>
</body>
</html>
"""
page_template_body
=
"""
<div class="pagebody">
<div class="pagebodystripeleft">
<div class="pageboxlefttop"><CDSPAGEBOXLEFTTOP></div>
<div class="pageboxlefttopadd">%s</div>
<div class="pageboxleftbottomadd">%s</div>
<div class="pageboxleftbottom"><CDSPAGEBOXLEFTBOTTOM></div>
</div>
<div class="pagebodystriperight">
<div class="pageboxrighttop"><CDSPAGEBOXRIGHTTOP></div>
<div class="pageboxrighttopadd">%s</div>
<div class="pageboxrightbottomadd">%s</div>
<div class="pageboxrightbottom"><CDSPAGEBOXRIGHTBOTTOM></div>
</div>
<div class="pagebodystripemiddle">
%s
<h1 class="headline">%s</h1>
%s
%s
</div>
</div>
"""
def
create_navtrailbox_body
(
title
,
previous_links
,
prolog
=
""
,
separator
=
""" > """
,
epilog
=
""
,
language
=
cdslang
):
"""Create navigation trail box body
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
!=
cdsnameintl
[
language
]:
out
+=
"""<a class="navtrail" href="%s?ln=%s">%s</a>"""
%
(
weburl
,
language
,
msg_home
[
language
])
if
previous_links
:
if
out
:
out
+=
separator
out
+=
previous_links
if
title
:
if
out
:
out
+=
separator
if
title
==
cdsnameintl
[
language
]:
# hide site name, print Home instead
out
+=
msg_home
[
language
]
else
:
out
+=
title
return
prolog
+
out
+
epilog
def
page
(
title
,
body
,
navtrail
=
""
,
description
=
""
,
keywords
=
""
,
uid
=
0
,
cdspageheaderadd
=
""
,
cdspageboxlefttopadd
=
""
,
cdspageboxleftbottomadd
=
""
,
cdspageboxrighttopadd
=
""
,
cdspageboxrightbottomadd
=
""
,
cdspagefooteradd
=
""
,
lastupdated
=
""
,
language
=
cdslang
,
urlargs
=
""
,
verbose
=
1
,
titleprologue
=
""
,
titleepilogue
=
""
):
"""page(): display CDS web 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
cdspageboxlefttopadd is a message to be displayed in the page body on left top
cdspageboxleftbottomadd is a message to be displayed in the page body on left bottom
cdspageboxrighttopadd is a message to be displayed in the page body on right top
cdspageboxrightbottomadd is a message to be displayed in the page body on right bottom
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)
language is the language version of the page
urlargs are the URL arguments of the page to display (useful to affect languages)
verbose is verbosity of the page (useful for debugging)
titleprologue is to be printed right before page title
titleepilogue is to be printed right after page title
output: the final cds page with header, footer, etc.
"""
if
title
==
cdsnameintl
[
language
]:
headerstitle
=
msg_home
[
language
]
else
:
headerstitle
=
title
out
=
page_template_header
%
(
headerstitle
,
description
,
keywords
,
cdspageheader
,
cdspageheaderadd
)
out
+=
page_template_body
%
(
cdspageboxlefttopadd
,
cdspageboxleftbottomadd
,
cdspageboxrighttopadd
,
cdspageboxrightbottomadd
,
titleprologue
,
title
,
titleepilogue
,
body
)
out
+=
page_template_footer
%
(
cdspagefooteradd
,
cdspagefooter
)
out
=
re
.
sub
(
r"<!--CDSNAMEINTL-->"
,
cdsnameintl
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSEARCH-->"
,
msg_search
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSUBMIT-->"
,
msg_submit
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGCONVERT-->"
,
msg_convert
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGAGENDA-->"
,
msg_agenda
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGWEBCAST-->"
,
msg_webcast
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGBULLETIN-->"
,
msg_bulletin
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGLIBRARY-->"
,
msg_library
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGHELP-->"
,
msg_help
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGPERSONALIZE-->"
,
msg_personalize
[
language
],
out
)
out
=
re
.
sub
(
r"<!--LN-->"
,
language
,
out
)
out
=
re
.
sub
(
r"<!--NAVTRAILBOXBODY-->"
,
create_navtrailbox_body
(
title
,
navtrail
,
language
=
language
),
out
)
out
=
re
.
sub
(
r"<!--USERINFOBOXBODY-->"
,
create_userinfobox_body
(
uid
,
language
),
out
)
out
=
re
.
sub
(
r"<!--LANGUAGESELECTIONBOX-->"
,
create_language_selection_box
(
urlargs
,
language
),
out
)
out
=
re
.
sub
(
r"<!--POWEREDBY-->"
,
msg_powered_by
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MAINTAINEDBY-->"
,
msg_maintained_by
[
language
],
out
)
if
lastupdated
:
out
=
re
.
sub
(
r"<!--LASTUPDATED-->"
,
msg_last_updated
[
language
]
+
" "
+
lastupdated
,
out
)
return
out
def
pageheaderonly
(
title
,
navtrail
=
""
,
description
=
""
,
keywords
=
""
,
uid
=
0
,
cdspageheaderadd
=
""
,
language
=
cdslang
,
urlargs
=
""
,
verbose
=
1
):
"""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
(
r"<!--CDSNAMEINTL-->"
,
cdsnameintl
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSEARCH-->"
,
msg_search
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSUBMIT-->"
,
msg_submit
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGCONVERT-->"
,
msg_convert
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGAGENDA-->"
,
msg_agenda
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGWEBCAST-->"
,
msg_webcast
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGBULLETIN-->"
,
msg_bulletin
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGLIBRARY-->"
,
msg_library
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGHELP-->"
,
msg_help
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGPERSONALIZE-->"
,
msg_personalize
[
language
],
out
)
out
=
re
.
sub
(
r"<!--LN-->"
,
language
,
out
)
out
=
re
.
sub
(
r"<!--NAVTRAILBOXBODY-->"
,
create_navtrailbox_body
(
title
,
navtrail
,
language
=
language
),
out
)
out
=
re
.
sub
(
r"<!--USERINFOBOXBODY-->"
,
create_userinfobox_body
(
uid
,
language
),
out
)
out
=
re
.
sub
(
r"<!--LANGUAGESELECTIONBOX-->"
,
create_language_selection_box
(
urlargs
,
language
),
out
)
return
out
def
pagefooteronly
(
cdspagefooteradd
=
""
,
lastupdated
=
""
,
language
=
cdslang
,
urlargs
=
""
,
verbose
=
1
):
"""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
)
out
=
re
.
sub
(
r"<!--CDSNAMEINTL-->"
,
cdsnameintl
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSEARCH-->"
,
msg_search
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGSUBMIT-->"
,
msg_submit
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGCONVERT-->"
,
msg_convert
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGAGENDA-->"
,
msg_agenda
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGWEBCAST-->"
,
msg_webcast
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGBULLETIN-->"
,
msg_bulletin
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGLIBRARY-->"
,
msg_library
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGHELP-->"
,
msg_help
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MSGPERSONALIZE-->"
,
msg_personalize
[
language
],
out
)
out
=
re
.
sub
(
r"<!--LN-->"
,
language
,
out
)
out
=
re
.
sub
(
r"<!--POWEREDBY-->"
,
msg_powered_by
[
language
],
out
)
out
=
re
.
sub
(
r"<!--MAINTAINEDBY-->"
,
msg_maintained_by
[
language
],
out
)
out
=
re
.
sub
(
r"<!--LANGUAGESELECTIONBOX-->"
,
create_language_selection_box
(
urlargs
,
language
),
out
)
if
lastupdated
:
out
=
re
.
sub
(
r"<!--LASTUPDATED-->"
,
msg_last_updated
[
language
]
+
" "
+
lastupdated
,
out
)
return
out
def
create_error_box
(
req
,
title
=
None
,
verbose
=
1
,
ln
=
cdslang
):
"""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.
If TRACEBACK_P is set to 0, then don't print traceback, only the error."""
if
title
==
None
:
title
=
msg_internal_error
[
ln
]
boxhead
=
"""<p>%s %s %s"""
%
(
title
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
])
boxbody
=
"""<p>"""
+
msg_please_contact_and_quote
[
ln
]
%
(
urllib
.
quote
(
supportemail
),
supportemail
)
boxbody
+=
"""<blockquote><pre>"""
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
if
verbose
>=
1
:
boxbody
+=
"""Error: %s %s\n"""
%
(
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
])
if
verbose
>=
9
:
boxbody
+=
"Traceback:
\n
%s
"
%
string
.
join
(
traceback
.
format_tb
(
sys
.
exc_info
()[
2
]),
"
\n
"
)
boxbody
+=
"""</pre></blockquote>"""
out
=
"""
<table class="errorbox">
<thead>
<tr>
<th class="errorboxheader">
%s
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="errorboxbody">%s</td>
</tr>
</tbody>
</table>"""
%
(
boxhead
,
boxbody
)
return
out
Event Timeline
Log In to Comment