[Bio] / FigKernelPackages / HTML.py Repository:
ViewVC logotype

Annotation of /FigKernelPackages/HTML.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : olson 1.1 #
2 :     # Simple binding of the HTML.pm module to python.
3 :     #
4 :     # This necessitated adding
5 :     #
6 :     # shift if UNIVERSAL::isa($_[0],__PACKAGE__);
7 :     #
8 :     # to the HTML.pm routines.
9 :     #
10 :     # Simple use:
11 :     #
12 :     # from FigKernelPackages import HTML
13 :     # h = HTML.HTML()
14 :     # print h.compute_html_header()
15 :     #
16 :     # One *should* be able to do the following cooler thing, but because
17 :     # the CallPerl module doesn't currently translate blessed refs as
18 :     # method call arguments, it doesn't work.
19 :     #
20 :     #
21 :     # from FigKernelPackages import HTML
22 :     # import CallPerl
23 :     #
24 :     # h = HTML.HTML()
25 :     #
26 :     # CallPerl.use("CGI")
27 :     # c = CallPerl.new_object("CGI", "new")
28 :     #
29 :     # h.show_page(c, ["firstline", "sec line"])
30 :     #
31 :    
32 : olson 1.2 import FIG
33 :     import FIG_Config
34 :     import time
35 :     import os
36 :     import os.path
37 :     import re
38 : olson 1.1
39 : olson 1.2 def compute_html_header(additional_insert = '', user = ''):
40 : olson 1.1
41 : olson 1.2 html_hdr_file = "./Html/html.hdr"
42 : olson 1.1
43 : olson 1.2 if not os.path.isfile(html_hdr_file):
44 :     html_hdr_file = os.path.join(FIG_Config.fig, "CGI/Html/html.hdr")
45 : olson 1.1
46 : olson 1.2 html_hdr = open(html_hdr_file).readlines()
47 : olson 1.1
48 : olson 1.2 html_hdr.append("<br><a href=\"%sindex.cgi?user=%s\">FIG search</a>\n" % (FIG_Config.cgi_base, user) );
49 : olson 1.1
50 : olson 1.2 ver = open(os.path.join(FIG_Config.fig_disk, "CURRENT_RELEASE")).readline().strip()
51 : olson 1.1
52 : olson 1.2 m = re.search("cvs-(\d+)", ver)
53 :     if m is not None:
54 :     ver += " (%s)" % (time.ctime(int(m.group(1))))
55 : olson 1.1
56 : olson 1.2 host = FIG.get_local_hostname()
57 :     insert_stuff = "SEED version <b>%s</b> on %s" % (ver, host)
58 :     if additional_insert != "":
59 :     insert_stuff += "<br>" + additional_insert;
60 : olson 1.1
61 : olson 1.2 out_hdr = []
62 :     for line in html_hdr:
63 :     line = re.sub(r'(href|img\s+src)="/FIG/', r'\1="%s' % (FIG_Config.cgi_base), line)
64 :     if line == "<!-- HEADER_INSERT -->\n":
65 :     line = insert_stuff
66 :     out_hdr.append(line)
67 : olson 1.1
68 : olson 1.2 return out_hdr

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3