1 # dynamic_html.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1997-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/applications/pathfinder/dynamic_html.tcl,v 1.12 2002/02/03 04:22:06 lim Exp $
32
33
34 import HTTP_Agent/Play_Agent
35 import HTTP_Agent/SDP_Agent
36 import HTTP_Agent/Rec_Agent
37 import SDPMessage
38 import SDPMedia
39 import SDPTime
40 import Program
41 import SessionCatalog
42
43 Class DynamicHTMLifier
44
45 DynamicHTMLifier proc init_ { } {
46 $self parentify HTTP_Agent/Play_Agent
47 $self parentify HTTP_Agent/SDP_Agent
48 $self parentify HTTP_Agent/Rec_Agent
49 $self parentify SDPMessage
50 $self parentify SDPMedia
51 $self parentify SDPTime
52 $self parentify Program
53 $self parentify SessionCatalog
54
55 # Initialize the html directory.
56 #set html_dir ~/mash/tcl/applications/mash_server/html/
57 set o [$self options]
58 $o load_preferences "pathfinder"
59 set html_dir [$self get_option html_dir]
60
61 # HTML files for the Play_Agent
62 append playback_list $html_dir playback-list.html
63 $self set htmlfiles_(playback_list) $playback_list
64 append playback_msg $html_dir playback-msg.html
65 $self set htmlfiles_(playback_msg) $playback_msg
66 append playback_desc $html_dir playback-desc.html
67 $self set htmlfiles_(playback_desc) $playback_desc
68
69 # HTML files for the SDP_Agent
70 append sessions_list $html_dir live-list.html
71 $self set htmlfiles_(sessions_list) $sessions_list
72 append sessions_msg $html_dir live-msg.html
73 $self set htmlfiles_(sessions_msg) $sessions_msg
74 append sessions_desc $html_dir live-desc.html
75 $self set htmlfiles_(sessions_desc) $sessions_desc
76
77 append media $html_dir media.html
78 $self set htmlfiles_(media) $media
79
80 append time_none $html_dir time_none.html
81 $self set htmlfiles_(time_none) $time_none
82 append time_weekly $html_dir time_weekly.html
83 $self set htmlfiles_(time_weekly) $time_weekly
84 append time_daily $html_dir time_daily.html
85 $self set htmlfiles_(time_daily) $time_daily
86
87 append time1_none $html_dir time1_none.html
88 $self set htmlfiles_(time1_none) $time1_none
89 append time1_weekly $html_dir time1_weekly.html
90 $self set htmlfiles_(time1_weekly) $time1_weekly
91 append time1_daily $html_dir time1_daily.html
92 $self set htmlfiles_(time1_daily) $time1_daily
93
94 # HTML files for the Rec_Agent
95 append recordings_list $html_dir record-list.html
96 $self set htmlfiles_(recordings_list) $recordings_list
97 append record_msg $html_dir record-msg.html
98 $self set htmlfiles_(record_msg) $record_msg
99 append recordings_status $html_dir record-status.html
100 $self set htmlfiles_(recordings_status) $recordings_status
101
102 if { [$self get_option allow_distrib] == "yes" } {
103 $self set htmlfiles_(recordings_status) $recordings_status
104 append distrib_recordings $html_dir distrib-record.html
105 $self set htmlfiles_(distrib_recordings) $distrib_recordings
106 append dr_msg $html_dir dr-msg.html
107 $self set htmlfiles_(dr_msg) $dr_msg
108 }
109
110 $self read_html
111 after 900 "$self read_html"
112 }
113
114
115 DynamicHTMLifier proc parentify { cls } {
116 set super [$cls info superclass]
117 set idx [lsearch -exact $super Object]
118 if { $idx!=-1 } {
119 set super [lreplace $super $idx $idx]
120 }
121 lappend super $self
122 $cls superclass $super
123 }
124
125
126 DynamicHTMLifier proc read_html { } {
127 $self instvar htmlfiles_
128 foreach file [array names htmlfiles_] {
129 puts "Reading HTML file: $htmlfiles_($file)"
130 $self read_file $htmlfiles_($file) $file
131 }
132 }
133
134
135 DynamicHTMLifier proc read_file { filename subscript } {
136 $self instvar html_
137
138 set html_($subscript) ""
139 set file [open $filename]
140 while { ![eof $file] } {
141 append html_($subscript) "[gets $file]\n"
142 }
143 close $file
144 }
145
146
147 DynamicHTMLifier instproc create_dynamic_html { html } {
148 set new_html { }
149
150 set idx [string first "<%" $html]
151 while { $idx != -1 } {
152 append new_html [string range $html 0 [expr $idx-1]]
153 set html [string range $html [expr $idx+2] end]
154 set idx [string first ">" $html]
155 if { $idx==-1 } {
156 error "Error in dynamic HTML: Can't find closing '>'"
157 }
158 set cmd [string range $html 0 [expr $idx-1]]
159 set html [string range $html [expr $idx+1] end]
160 append new_html [eval $cmd]
161 set idx [string first "<%" $html]
162 }
163
164 append new_html $html
165 return $new_html
166 }
167
168 DynamicHTMLifier init_
169
170
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.