#!/usr/local/bin/tclsh8.0 source /com/web/docs/projects/ntt/bin/html.tcl proc WebSendHTML {{str ""}} { ## Prepare to send back an html page puts "Content-type: text/html" puts "" if {$str != ""} { puts $str } flush stdout } proc DecodeArguments {a} { set lst [split $a ""] set n [llength $lst] set newlst "" for {set i 0} {$i < $n} {incr i} { set next [lindex $lst $i] if {$next == "%"} { set hex "0x[join [lrange $lst [expr $i + 1] [expr $i + 2]] {}]" set char [format %c $hex] lappend newlst $char incr i 2 } elseif {$next == "+"} { lappend newlst " " } else { lappend newlst $next } } set newlst [join $newlst ""] } proc GetProject {} { global env set path [split $env(REQUEST_URI) /] set project [lindex $path [expr [llength $path] - 2]] return $project } proc ReadName {} { set fp [open name.dat r] set name [gets $fp] close $fp return $name } proc ReadComments {} { proc aaset {ar id var val} { array set tmp [uplevel 1 "set ${ar}($id)"] set tmp($var) $val uplevel 1 "set ${ar}($id) [list [array get tmp]]" } set comments(null) { id null deleted 1 approved 0 confirmed 1 } catch { source comments.dat } set data [array get comments] set n [llength $data] set clist "" for {set i 1} {$i < $n} {incr i 2} { lappend clist [lindex $data $i] } ## Sort by date set clist [lsort -index 1 $clist] return $clist } proc AddComment {comment} { array set tmp $comment set id $tmp(id) set fp [open comments.dat a] puts $fp "" puts $fp "set comments($id) [list $comment]" puts $fp "" flush $fp close $fp } proc ChangeComment {id var val} { set fp [open comments.dat a] puts $fp "" puts $fp "aaset comments $id $var [list $val]" puts $fp "" flush $fp close $fp } proc aref {array var} { set err [catch { uplevel 1 "set ${array}($var)" } val] if {$err == 1} { return "" } return $val } proc GetArgs {array} { global env upvar $array args if {[catch {set env(REQUEST_URI)} tmp] == 1} { set args(NULL) 1 } else { set args(NULL) 1 set data [split [lindex [split $tmp ?] 1] =&] set newdata "" foreach d $data { lappend newdata [DecodeArguments $d] } array set args $newdata } } proc WebMain {} { global env catch { set fp [open ".ntt.log" a] set data "" catch { lappend data [clock seconds] } catch { lappend data $env(REMOTE_HOST) } catch { lappend data $env(REMOTE_ADDR) } catch { lappend data $env(HTTP_USER_AGENT) } catch { lappend data $env(REQUEST_URI) } puts $fp $data close $fp } GetArgs args set action [aref args action] if {$action == ""} { MainPage } elseif {[info procs $action] == $action} { eval $action } else { WebSendHTML HTML { HBody { HText "Error: Action $action not defined" } } } } proc NewComment {{which ""} {mesg ""}} { GetArgs args ## Send the HTML Header WebSendHTML if {$which == ""} { set which [aref args which] } HTML { HHead { HTitle { HText [aref comment subject] } } JavaScript { window.focus(); } HFrameSet rows=70,*,30 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 { HFrame SRC=index.doit?action=CommentHeader SCROLLING=no HFrame SRC=index.doit?action=NewCommentFrame&parent=[aref args parent]&which=$which&error=$mesg HFrame SRC=index.doit?action=NewCommentFooter SCROLLING=no } } } proc ShowComment {} { GetArgs args set which [aref args which] set comments [ReadComments] array set comment [GetComment $comments $which] ## Send the HTML Header WebSendHTML HTML { HHead { HTitle { HText [aref comment subject] } } JavaScript { window.focus(); } HFrameSet rows=70,*,50 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 { HFrame SRC=index.doit?action=CommentHeader SCROLLING=no HFrame SRC=index.doit?action=ShowCommentFrame&which=[aref args which] HFrame SRC=index.doit?action=CommentFooter&which=[aref args which] \ SCROLLING=no } } } proc Blank {} { ## Send the HTML Header WebSendHTML HTML { HBody BGCOLOR=FFFFFF { HSpace 2 } } } proc ApproveComment {} { GetArgs args set which [aref args which] set comments [ReadComments] if {$which == ""} { foreach clist $comments { array set tmp $clist if {$tmp(confirmed) && !$tmp(deleted)} { set which $tmp(id) break } } if {$which == ""} { WebSendHTML HTML { HBody BGCOLOR=FFFFFF { HCenter { HHead2 { HText "There are no comments to approve." HPar HText "Click " HLink href=/projects/ntt target=_top { HText "here" } HText " to return to the NTT-MIT page." } } } } return } } array set comment [GetComment $comments $which] ## Send the HTML Header WebSendHTML HTML { HHead { HTitle { HText [aref comment subject] } } JavaScript { window.focus(); } HFrameSet rows=70,*,* MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 { HFrame SRC=index.doit?action=CommentHeader SCROLLING=no HFrame SRC=index.doit?action=ShowCommentFrame&which=$which HFrame SRC=index.doit?action=ApproveCommentFooter&which=$which \ SCROLLING=no } } } proc CommentHeader {} { WebSendHTML HTML { HBody BGCOLOR=\#FFFFFF { HTable border=0 cellspacing=0 cellpadding=3 width=100% { HTableRow bgcolor=\#CC0000 { HTableData colspan=2 align=center { HFont color=\#FFFFFF size=4 face=helvetica { HBold { HText "NTT-MIT Research Collaboration" } } } } HTableRow bgcolor=\#33333 { HTableData colspan=2 align=center { HFont color=\#FFFFFF size=3 face=helvetica { HBold { if {[catch { ReadName } name] == 1} { HText "Comments" } else { HText "Comments on \"$name\"" } } } } } } } } } proc GetPrevComment {comments which} { # Messy and inefficient, given the simplistic data structure, but it # works to find the prev comment in the tree # If this is every meant to hold a ton of comments, this should be reworked # (Index the data better) set n [llength $comments] for {set i [expr $n - 1]} {$i >= 0} {incr i -1} { array set comment [lindex $comments $i] if {$which == [aref comment id]} { break } } if {$i <= 0} { return ""} set parent [aref comment parent] if {$parent == 0} { ## I'm a root node ## Trace backward, finding the prev root node for {set j [expr $i - 1]} {$j >= 0} {incr j -1} { array set comment [lindex $comments $j] if {[CommentVisible comment]} { if {[aref comment parent] == 0} { set parent [aref comment id] ## Then find that node's last child (if any) for {set k [expr $n - 1]} {$k > $j} {incr k -1} { array set comment2 [lindex $comments $k] if {[CommentVisible comment2]} { if {[aref comment2 parent] == $parent} { return [aref comment2 id] } } } return [aref comment id] } } } return "" } else { ## I'm a child node ## Trace backward, looking for either a sibling or my parent for {set j [expr $i - 1]} {$j >= 0} {incr j -1} { array set comment [lindex $comments $j] # find a sibling or parent if {[CommentVisible comment]} { if {[aref comment id] == $parent || [aref comment parent] == $parent} { return [aref comment id] } } } return "" } } proc GetNextComment {comments which} { # Messy and inefficient, given the simplistic data structure, but it # works to find the next comment in the tree # If this is every meant to hold a ton of comments, this should be reworked # (Index the data better) set n [llength $comments] for {set i 0} {$i < $n} {incr i} { array set comment [lindex $comments $i] if {$which == [aref comment id]} { break } } if {$i >= $n} { return "" } set parent [aref comment parent] if {$parent == 0} { # If I'm a root node # See if I have any visible children later on: for {set j [expr $i + 1]} {$j < $n} {incr j} { array set comment [lindex $comments $j] if {[CommentVisible comment]} { if {[aref comment parent] == $which} { return [aref comment id] } } } # See if there are any more roots to show for {set j [expr $i + 1]} {$j < $n} {incr j} { array set comment [lindex $comments $j] if {[CommentVisible comment]} { if {[aref comment parent] == 0} { return [aref comment id] } } } return "" } else { # If I'm a child node for {set j [expr $i + 1]} {$j < $n} {incr j} { array set comment [lindex $comments $j] # find a sibling if {[CommentVisible comment]} { if {[aref comment parent] == $parent} { return [aref comment id] } } } # no more siblings, find the next root comment after my parent for {set i 0} {$i < $n} {incr i} { array set comment [lindex $comments $i] if {[aref comment id] == $parent} { # Found my parent # See if there are any more roots to show for {set j [expr $i + 1]} {$j < $n} {incr j} { array set comment [lindex $comments $j] if {[CommentVisible comment]} { if {[aref comment parent] == 0} { return [aref comment id] } } } return "" } } } return "" } proc CommentFooter {} { GetArgs args set comments [ReadComments] ## Send the HTML Header WebSendHTML HTML { HBody BGCOLOR=FFFFFF { HCenter { HTable cellpadding=3 { HTableRow { HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=Close" target=comments { HFont COLOR=111111 face=helvetica { HBold { HText "Close Window" } } } } HTableData HTableData BGCOLOR=CCCCCC width=120 align=center { set parent "" catch { array set comment [GetComment $comments [aref args which]] if {[aref comment parent] == 0} { set parent [aref comment id] } else { set parent [aref comment parent] } } HLink "href=index.doit?action=NewComment&parent=$parent" \ target=comments { HFont COLOR=111111 face=helvetica { HBold { HText "Respond" } } } } HTableData width=50 { HSpace 1 } set prev [GetPrevComment $comments [aref args which]] HTableData BGCOLOR=CCCCCC width=120 align=center { if {$prev != ""} { HLink target=comments "href=index.doit?action=ShowComment&which=$prev" { HFont COLOR=111111 face=helvetica { HBold { HText "Prev Comment" } } } } else { HFont COLOR=777777 face=helvetica { HBold { HText "Prev Comment" } } } } HTableData set next [GetNextComment $comments [aref args which]] HTableData BGCOLOR=CCCCCC width=120 align=center { if {$next != ""} { HLink target=comments "href=index.doit?action=ShowComment&which=$next" { HFont COLOR=111111 face=helvetica { HBold { HText "Next Comment" } } } } else { HFont COLOR=777777 face=helvetica { HBold { HText "Next Comment" } } } } } } } DrawRedLine DrawFooterImage } } } proc CommentApproved {} { GetArgs args set which [aref args which] ChangeComment $which approved 1 ToApprove } proc CommentUnApproved {} { GetArgs args set which [aref args which] ChangeComment $which deleted 1 ToApprove } proc ApproveCommentFooter {} { GetArgs args set which [aref args which] set comments [ReadComments] ## Send the HTML Header WebSendHTML HTML { HBody BGCOLOR=FFFFFF { HCenter { HTable cellpadding=3 { HTableRow { HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=CommentApproved&which=$which" \ target=_top { HFont COLOR=111111 face=helvetica { HBold { HText "Approve" } } } } HTableData width=50 { HSpace 1 } HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=CommentUnApproved&which=$which" \ target=_top { HFont COLOR=111111 face=helvetica { HBold { HText "Delete" } } } } } } } DrawRedLine DrawFooterImage } } } proc ConfirmCommentFrame {} { WebSendHTML HTML { HBody BGCOLOR=FFFFFF { HCenter { HPar HSpace 2 HHead1 { HText "Thank you for your comment." HPar HText "It will appear on the web page shortly." } HPar HSpace 2 HPar HSpace 2 HPar HSpace 2 HPar HTable { HTableRow { HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=Close" target=comments { HFont COLOR=111111 face=helvetica { HBold { HText "Close Window" } } } } } } } } } } proc ConfirmComment {} { GetArgs args set which [aref args which] ChangeComment $which confirmed 1 set comments [ReadComments] array set comment [GetComment $comments $which] set name "" catch { set name [ReadName] } set project [GetProject] Notify "New Comment Added" [subst { The following comment has been added to the web page "$name". It can be deleted by visiting this page: http://www.ai.mit.edu/projects/ntt/projects/$project/admin.html ---------------------------------------------------------------------- Comment From: [aref comment name] (unverified) Email: [aref comment email] Add to Page: $project: $name Subject: [aref comment subject] Comment: [aref comment message] ---------------------------------------------------------------------- }] WebSendHTML HTML { HHead { HTitle { HText [aref comment subject] } } JavaScript { window.focus(); } HFrameSet rows=70,*,50 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 { HFrame SRC=index.doit?action=CommentHeader SCROLLING=no HFrame SRC=index.doit?action=ConfirmCommentFrame SCROLLING=no HFrame SRC=index.doit?action=NewCommentFooter SCROLLING=no } } } proc DeleteComment {} { GetArgs args set which [aref args which] ChangeComment $which deleted 1 WebSendHTML JavaScript { window.close() } } proc SubmitCommentFooter {} { ## Send the HTML Header WebSendHTML GetArgs args set which [aref args which] HTML { HBody BGCOLOR=FFFFFF { HCenter { HTable cellpadding=3 { HTableRow { HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=ConfirmComment&which=$which" \ target=comments { HFont COLOR=CC0000 face=helvetica { HBold { HText "Confirm Comment" } } } } HTableData HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=NewComment&which=$which" \ target=comments { HFont COLOR=111111 face=helvetica { HBold { HText "Edit Comment" } } } } HTableData HTableData BGCOLOR=CCCCCC width=120 align=center { HLink "href=index.doit?action=DeleteComment&which=$which" \ target=comments { HFont COLOR=111111 face=helvetica { HBold { HText "Delete Comment" } } } } } } } DrawRedLine DrawFooterImage } } } proc IsEmpty {str} { return [expr ![regexp {[a-zA-Z0-9]} $str]] } proc Close {} { WebSendHTML HTML { HBody onload=window.close() { HSpace 2 } } } proc SubmitComment {} { GetArgs args set which [aref args which] if {[aref args send] == "Cancel"} { Close return } set date [clock seconds] if {$which == ""} { set comment(id) "$date-[clock clicks]" set which $comment(id) } else { set comment(id) $which } set comment(name) [aref args name] set comment(date) $date set comment(email) [aref args email] set comment(subject) [aref args subject] set comment(parent) [aref args parent] if {$comment(parent) == ""} { set comment(parent) 0 } set comment(approved) 1 set comment(html) [aref args html] set comment(deleted) 0 set comment(confirmed) 0 set comment(message) [aref args message] AddComment [array get comment] if {[IsEmpty $comment(name)] || [IsEmpty $comment(email)] || [IsEmpty $comment(subject)] || [IsEmpty $comment(message)]} { NewComment $which EmptyField return } ## Send the HTML Header WebSendHTML HTML { HHead { HTitle { HText [aref comment subject] } } JavaScript { window.focus(); } HFrameSet rows=70,*,50 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 { HFrame SRC=index.doit?action=CommentHeader SCROLLING=no HFrame SRC=index.doit?action=ShowCommentFrame&which=$comment(id) HFrame SRC=index.doit?action=SubmitCommentFooter&which=$comment(id) \ SCROLLING=no } } } proc NewCommentFrame {} { GetArgs args set which [aref args which] ## Send the HTML Header WebSendHTML set comments [ReadComments] set iname "" set iemail "" set isubject "" set ihtml 0 set imessage "" catch { array set tmp [GetComment $comments $which] set iname $tmp(name) set iemail $tmp(email) set isubject $tmp(subject) set ihtml $tmp(html) set imessage $tmp(message) unset tmp } HTML { HBody BGCOLOR=FFFFFF { HForm "action=index.doit" method=GET target=comments { HTable border=0 cellspacing=0 cellpadding=1 width=100% height=95% { if {[aref args error] == "EmptyField"} { HTableRow { HTableData colspan=4 align=center BGCOLOR=DDDDDD { HFont COLOR=CC0000 size=4 { HBold { HText "** Please fill in all the fields **" } } } } } set parent [aref args parent] if {$parent != ""} { if {[catch {array set comment [GetComment $comments $parent]}] == 0} { HTableRow { HTableData colspan=4 height=25 valign=top { HCenter { HText "Response to the thread started by [aref comment name], subject \"[aref comment subject]\"" } } } } } HTableRow { HTableData { HText "Name:" } HTableData { HInput type=text name=name value=$iname size=20; HSpace 3 } HTableData { HText "Email:" } HTableData { HInput type=text name=email value=$iemail size=20 } } HTableRow { HTableData { HText "Subject: " } HTableData { HInput type=text name=subject value=$isubject size=20 } HTableData colspan=2 { HText "Comment in HTML?" if {$ihtml == 1} { HSpace 2; HInput type=radio name=html value=1 checked; HText "Yes" HSpace 2; HInput type=radio name=html value=0; HText "No" } else { HSpace 2; HInput type=radio name=html value=1; HText "Yes" HSpace 2; HInput type=radio name=html value=0 checked; HText "No" } } } HTableRow { HTableData valign=top { HBreak; HText "Comment:"; HSpace 5 } HTableData COLSPAN=3 valign=top { HTextArea COLS=50 ROWS=9 name=message wrap=soft { HText $imessage } } } HTableRow { HTableData colspan=4 align=center { HInput type=hidden "value=SubmitComment" name=action HInput type=hidden "value=$which" name=which HInput type=hidden "value=[aref args parent]" name=parent HInput type=submit "value=Submit Comment" name=send HSpace 10 HInput type=submit "value=Cancel" name=send } } } } } } } proc NewCommentFooter {} { ## Send the HTML Header WebSendHTML HTML { HBody BGCOLOR=FFFFFF { DrawRedLine DrawFooterImage } } } proc GetComment {comments id} { foreach c $comments { array set comment $c if {[aref comment id] == $id} { break } unset c } if {[aref comment id] != $id} { error "Comment not found" } return [array get comment] } proc ShowCommentFrame {} { GetArgs args set which [aref args which] ## Now read in the comments set comments [ReadComments] ## Send the HTML Header WebSendHTML array set comment [GetComment $comments $which] HTML { HHead { HTitle { HText [aref comment subject] } } HBody BGCOLOR=FFFFFF { HBase target=_new HPar HTable { HTableRow { HTableData { HText "From:" } HTableData { HText "[aref comment name] " HSpace 2 HLink href=mailto:[aref comment email] { HText "<[aref comment email]>" } } } HTableRow { HTableData { HText "Subject:" } HTableData { HText "[aref comment subject]" } } if {[aref comment parent] != 0} { array set parent [GetComment $comments [aref comment parent]] HTableRow { HTableData { HText "References:" } HTableData { HText "\"[aref parent subject]\" ([aref parent name])" } } } HTableRow { HTableData { HText "Date:" } HTableData { HText "[clock format [aref comment date]]" } } } if {[aref comment html] == 1} { HBlockQuote { HText "[aref comment message]" } } else { HBlockQuote { regsub -all {[<]} [aref comment message] {\<} mesg regsub -all "\n\n" [aref comment message] {
} mesg
regsub -all "\n" [aref comment message] {
} mesg
HText $mesg
}
}
}
}
}
proc ToApprove {} {
## Send the HTML Header
WebSendHTML
HTML {
HHead {
HTitle { HText [aref comment subject] }
}
JavaScript {
window.focus();
}
HFrameSet rows=250,* MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 {
HFrame SRC=index.doit?action=ToApproveList
HFrame SRC=index.doit?action=ApproveComment name=comments2
}
}
}
proc ToApproveList {} {
## Send the HTML Header
WebSendHTML
## Now read in the comments
set comments [ReadComments]
set name ""
catch { set name [ReadName] }
HTML {
HHead { HTitle { HText { Comments on $name } } }
JavaScript {
function ApproveComment(id) {
window.open('index.doit?action=ApproveComment&which='+id ,"comments", "toolbar=no,scrollbars=no,width=575,height=480");
}
}
HBody BGCOLOR=FFFFFF {
## And go through the comments
HCenter {
HHead1 {
HText "Comments to Approve for \"$name\""
HBreak
}
HHead2 {
HText "Click "
HLink href=/projects/ntt target=_top { HText "here" }
HText " to return to the NTT-MIT page."
}
}
set any 0
HUList {
foreach comment $comments {
array set tmp $comment
if {$tmp(confirmed) && !$tmp(deleted)} {
set any 1
HListElt {
HLink "href=index.doit?action=ApproveComment&which=$tmp(id)" \
target=comments2 {
HText "$tmp(subject)"
}
HSpace 3
HText "("
HLink href=mailto:$tmp(email) {
HText "$tmp(email)"
}
HText ")"
}
}
}
unset tmp
if {$any == 0} {
HListElt {
HText { No comments need approval }
}
}
}
}
}
}
proc CommentVisible {tmp} {
array set comment [uplevel 1 "array get $tmp"]
set err [catch {
expr ($comment(confirmed)) && ($comment(approved)) && (!$comment(deleted))
} val]
if {$err == 1} { return 0}
return $val
}
proc ContentHeader {} {
WebSendHTML
HTML {
HBody BGCOLOR=\#FFFFFF {
HTable border=0 cellspacing=0 cellpadding=3 width=100% {
HTableRow bgcolor=\#CC0000 {
HTableData colspan=2 align=center {
HFont color=\#FFFFFF size=4 face=helvetica {
HBold {
HText "NTT-MIT Research Collaboration"
}
}
}
}
HTableRow bgcolor=\#33333 {
HTableData colspan=2 align=center {
HFont color=\#FFFFFF size=3 face=helvetica {
HBold {
if {[catch { ReadName } name] == 1} {
HText "Additional Content"
} else {
HText "Additional Content for \"$name\""
}
}
}
}
}
}
}
}
}
proc NewContentFrame {} {
GetArgs args
## Send the HTML Header
WebSendHTML
set which ""
set iname ""
set iemail ""
set isubject ""
set ihtml 0
set imessage ""
catch {
array set tmp [GetComment $comments $which]
set iname $tmp(name)
set iemail $tmp(email)
set isubject $tmp(subject)
set ihtml $tmp(html)
set imessage $tmp(message)
unset tmp
}
HTML {
HBody BGCOLOR=FFFFFF {
HForm "action=index.doit" method=GET target=comments {
HTable border=0 cellspacing=0 cellpadding=0 width=100% height=95% {
set parent [aref args parent]
if {$parent != ""} {
if {[catch {array set comment [GetComment $comments $parent]}] == 0} {
HTableRow {
HTableData colspan=4 height=25 valign=top {
HCenter {
HText "Response to the thread started by [aref comment name], subject \"[aref comment subject]\""
}
}
}
}
}
HTableRow {
HTableData { HText "Name:" }
HTableData {
HInput type=text name=name value=$iname size=20;
HSpace 3
}
HTableData { HText "Email:" }
HTableData { HInput type=text name=email value=$iemail size=20 }
}
HTableRow {
HTableData { HText "Section: " }
HTableData colspan=3 {
HInput type=radio name=section value=Demos checked
HText "Demos"
HSpace 5
HInput type=radio name=section value=Presentations
HText "Presentations"
HSpace 5
HInput type=radio name=section value=Publications
HText "Publications"
HSpace 5
HInput type=radio name=section "value=More Information"
HText "More Information"
HSpace 5
}
}
HTableRow {
HTableData valign=top { HBreak; HText "Content:"; HSpace 5 }
HTableData COLSPAN=3 {
HTextArea COLS=50 ROWS=9 name=message wrap=soft {
HText $imessage
}
}
}
HTableRow {
HTableData colspan=4 align=center {
HInput type=hidden "value=SubmitContent" name=action
HInput type=hidden "value=$which" name=which
HInput type=submit "value=Submit Content" name=send
HSpace 10
HInput type=submit "value=Cancel" name=send
}
}
}
}
}
}
}
proc SubmitContent {} {
GetArgs args
if {[aref args send] == "Cancel"} {
Close
return
}
set name ""
catch { set name [ReadName] }
set project [GetProject]
Notify "New Content Added" \
[subst {
Message From: [aref args name] (unverified)
Email: [aref args email]
Add to Page: $project: $name
Add to Section: [aref args section]
Content:
----------------------------------------------------------------------
[aref args message]
----------------------------------------------------------------------
}]
## Send the HTML Header
WebSendHTML
HTML {
HHead {
HTitle { HText "Add Content" }
}
JavaScript {
window.focus();
}
HFrameSet rows=70,*,30 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 {
HFrame SRC=index.doit?action=ContentHeader SCROLLING=no
HFrame SRC=index.doit?action=SubmitContentFrame
HFrame SRC=index.doit?action=NewCommentFooter SCROLLING=no
}
}
}
proc SubmitContentFrame {} {
## Send the HTML Header
WebSendHTML
HTML {
HBody BGCOLOR=FFFFFF {
HPar
HSpace 2
HPar
HCenter {
HHead2 {
HText { Your additions have been submitted, }
HBreak
HText {and should appear on the page shortly. }
HPar
HText {If you have questions, please email}
HBreak
HText { Annika Pfluger }
HLink href=mailto:annika@ai.mit.edu {
HText { <annika@ai.mit.edu>}
}
}
HPar
HSpace 2
HPar
HSpace 2
HTable cellpadding=3 {
HTableRow {
HTableData BGCOLOR=CCCCCC align=center {
HLink "href=index.doit?action=Close" target=comments {
HFont COLOR=CC0000 face=helvetica SIZE=4 {
HBold {
HText "Close Window"
}
}
}
}
}
}
}
}
}
}
proc NewContent {} {
GetArgs args
## Send the HTML Header
WebSendHTML
HTML {
HHead {
HTitle { HText "Add Content" }
}
JavaScript {
window.focus();
}
HFrameSet rows=70,*,30 MARGINHEIGHT=0 MARGINWIDTH=0 BORDER=0 FRAMEBORDER=NO FRAMESPACING=0 {
HFrame SRC=index.doit?action=ContentHeader SCROLLING=no
HFrame SRC=index.doit?action=NewContentFrame
HFrame SRC=index.doit?action=NewCommentFooter SCROLLING=no
}
}
}
proc MainPage {} {
global env
## Find out which project we're talking about
set project [GetProject]
## Send the HTML Header
WebSendHTML
## Read the project's html file
set fp [open $project.html r]
set data [read $fp]
close $fp
## And write out to stdout
puts $data
## Now read in the comments
set comments [ReadComments]
## Put the header in
puts {
Comments |