source: trunk/gui/apps/about.in @ 2035

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