File: html_page.html

package info (click to toggle)
lg-issue19 3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,388 kB
  • ctags: 122
  • sloc: sh: 73; makefile: 37
file content (70 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD><title>Class for generating HTML pages </title></HEAD> 
<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">


<pre>


#!/usr/bin/python
#
#  Class for generating HTML pages
#

class Html_Page:

    def __init__ (self, t="", h=""):
	self.title = t
	self.heading = h

    def generate_heading (self, bgcolor=""):
	#
	# Generate heading for a page
	#
	self.f.write ("&lt;html&gt;\n")
	self.f.write ("&lt;head&gt;\n")
	self.f.write ("&lt;title&gt;" + self.title + "&lt;/title&gt;\n")
	self.f.write ("&lt;/head&gt;\n")
	self.f.write ("&lt;body bgcolor=" + bgcolor + "&gt;\n")
	self.f.write ("&lt;h1 align=center&gt;" + self.heading + "&lt;/h1&gt;\n")

    def generate_body (self):
	#
	# Empty function - to be redefined in a descendant
	#
	print ""

    def generate_trailer (self):
	#
	# generate the trailer for a page
	#
	self.f.write ("&lt;/body&gt;\n")
	self.f.write ("&lt;/html&gt;\n")
    
    def generate (self, bgcolor=""):
	self.generate_heading (bgcolor)
	self.generate_body ()
	self.generate_trailer ()

#
# Code to test this class
#

if __name__ == "__main__":
    p = html_page ("This is the title", "&lt;i&gt;This is the top heading&lt;/i&gt;")
    p.generate ("lightblue")

</pre>
<!--===================================================================-->
<P> <hr> <P> 
<center><H5>Copyright &copy; 1997, Richie Bielak<BR> 
Published in Issue 19 of the Linux Gazette, July 1997</H5></center>

<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->