Wapp

Check-in [654ca1127b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add she-bangs to the self.tcl and self2.tcl examples.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:654ca1127bdc95c91ee6eb78aa14f602cc76a5551438950990e4048d6d718833
User & Date: drh 2018-02-08 02:17:05
Context
2018-02-08
04:42
Fix minor problems with the two self-scripts. check-in: b25f6825c5 user: drh tags: trunk
02:17
Add she-bangs to the self.tcl and self2.tcl examples. check-in: 654ca1127b user: drh tags: trunk
02:07
Add the self2.tcl example script check-in: 0afcafe89f user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to examples/README.md.

62
63
64
65
66
67
68
69
70
71
72
73







When the app is running, the /env page shows the CGI environment for
debugging and testing purposes.

5.0 self.tcl and self2.tcl
--------------------------

These script give examples of Wapp applications that can display
a copy of themselves.  The self-display for self.tcl is in the /self
page and is actually a very small part of the total script. For the
self2.tcl example, the color of the text for the self-display is
controlled by a query parameter.













|




>
>
>
>
>
>
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

When the app is running, the /env page shows the CGI environment for
debugging and testing purposes.

5.0 self.tcl and self2.tcl
--------------------------

These scripts give examples of Wapp applications that can display
a copy of themselves.  The self-display for self.tcl is in the /self
page and is actually a very small part of the total script. For the
self2.tcl example, the color of the text for the self-display is
controlled by a query parameter.

Both of these example scripts are installed on the canonical Wapp
website so that you can easily try them out:

  +  <https://wapp.tcl.tk/examples/self.tcl>
  +  <https://wapp.tcl.tk/examples/self2.tcl>

Changes to examples/self.tcl.



1
2
3
4
5
6
7


# This script demonstrates a Wapp application that can display a copy
# of itself via the /self page.  (See the wapp-page-self procedure for
# how that one page is generated.)
#
# This script also has a homepage and an /env page that show the wapp
# environment.  The header and footer for each page is broken out into
# separate subroutines.
>
>







1
2
3
4
5
6
7
8
9
#!/usr/bin/wapptclsh
#
# This script demonstrates a Wapp application that can display a copy
# of itself via the /self page.  (See the wapp-page-self procedure for
# how that one page is generated.)
#
# This script also has a homepage and an /env page that show the wapp
# environment.  The header and footer for each page is broken out into
# separate subroutines.

Changes to examples/self2.tcl.



1
2
3
4
5
6
7
8
9
10
11






12
13
14
15
16
17
18


# This script demonstrates a Wapp application that can display a copy
# of itself using a font color selected by a query parameter.
#
# The foreground color is whatever value is given by the color= query
# parameter.  The color is inserted into a style= attribute on the
# <pre> element using the %url(...) substitution mechanism of Wapp,
# so it is safe from XSS injections.  Try it!  You won't be able to
# slip in any unwanted HTML, but you can use %23 to get a # for
# an RGB color, like this:
#
#              ?color=%23003f7f






#
package require wapp
proc wapp-default {} {
  wapp-content-security-policy {default_src 'self' 'inline'}
  wapp-allow-xorigin-params
  set fd [open [wapp-param SCRIPT_FILENAME] rb]
  set script [read $fd]
>
>











>
>
>
>
>
>







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
#!/usr/bin/wapptclsh
#
# This script demonstrates a Wapp application that can display a copy
# of itself using a font color selected by a query parameter.
#
# The foreground color is whatever value is given by the color= query
# parameter.  The color is inserted into a style= attribute on the
# <pre> element using the %url(...) substitution mechanism of Wapp,
# so it is safe from XSS injections.  Try it!  You won't be able to
# slip in any unwanted HTML, but you can use %23 to get a # for
# an RGB color, like this:
#
#              ?color=%23003f7f
#
# Notice that the "wapp-content-security-policy" command had to be used
# to enable in-line CSS.  In-line CSS is off by default.
#
# Also notice that the "wapp-allow-xorigin-params" command had to be used
# to enable users to manually add new color= query parameters.
#
package require wapp
proc wapp-default {} {
  wapp-content-security-policy {default_src 'self' 'inline'}
  wapp-allow-xorigin-params
  set fd [open [wapp-param SCRIPT_FILENAME] rb]
  set script [read $fd]