source: branches/1.8/apps/about.in @ 6036

Last change on this file since 6036 was 5901, checked in by gah, 9 years ago

first pass on new build

File size: 2.9 KB
Line 
1#!/bin/sh
2# -*- mode: Tcl -*-
3# ----------------------------------------------------------------------
4#  ABOUT PANEL
5#
6#  This little script lets developers create an "about" page for
7#  the first page of a nanoWhim application.  It's sort of like a
8#  web browser, but it shows only one page and handles the links
9#  so they pop things up on the user's desktop
10#
11#  RUN AS FOLLOWS:
12#    about <file.html>
13#
14# ======================================================================
15#  AUTHOR:  Michael McLennan, Purdue University
16#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
17#
18#  See the file "license.terms" for information on usage and
19#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
20# ======================================================================
21#\
22dir=`dirname $0` ; \
23. $dir/rappture.env ; \
24exec wish "$0" "$@"
25# ----------------------------------------------------------------------
26# wish executes everything from here on...
27
28package require http
29package require Rappture
30package require RapptureGUI
31
32option add *BugReport*banner*foreground white
33option add *BugReport*banner*background #a9a9a9
34option add *BugReport*banner*highlightBackground #a9a9a9
35option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
36
37# install a better bug handler
38Rappture::bugreport::install
39
40proc escapeChars {info} {
41    regsub -all & $info \001 info
42    regsub -all \" $info {\&quot;} info
43    regsub -all < $info {\&lt;} info
44    regsub -all > $info {\&gt;} info
45    regsub -all \001 $info {\&amp;} info
46    return $info
47}
48
49#
50# Process command line args to get the name of the HTML file...
51#
52if {[llength $argv] != 1} {
53    puts stderr "usage: about.tcl <file.html>"
54    exit 1
55}
56set url [lindex $argv 0]
57
58Rappture::Scroller .scroller -xscrollmode auto -yscrollmode auto
59pack .scroller -expand yes -fill both
60
61Rappture::HTMLviewer .scroller.html -width 640 -height 480
62.scroller contents .scroller.html
63
64switch -regexp -- $url {
65    ^https?:// {
66        if {[catch {http::geturl $url} token] == 0} {
67            set html [http::data $token]
68            http::cleanup $token
69        } else {
70            set html "<html><body><h1>Oops! Internal Error</h1><p>[escapeChars $token]</p></body></html>"
71        }
72        .scroller.html load $html
73    }
74    default {
75        if {[string range $url 0 6] == "file://"} {
76            set file [string range $url 7 end]
77        } else {
78            set file $url
79        }
80        set cmds {
81            set fid [open $file r]
82            set html [read $fid]
83            close $fid
84        }
85        if {[catch $cmds result]} {
86            set html "<html><body><h1>Oops! File Not Found</h1><p>[escapeChars $result]</p></body></html>"
87        }
88
89        # not HTML? then escape nasty characters and display it.
90        if {![regexp {<html>.*</html>} $html]} {
91            set html "<html><body><p>[escapeChars $html]</p></body></html>"
92        }
93        .scroller.html load $html -in $file
94    }
95}
Note: See TracBrowser for help on using the repository browser.