Sun Microsystems Laboratories Experimental Stuff Text Document
<head>
<title>take link, and add it to the favorites</title>
</head>
<body>

<!-- processing additions to favorites -->

<if query.add>
  <modified>
  <server language=tcl>
    puts "<!-- session=$SessionId -->"

    set set_data [get_data "data"]

    # Add an item to the favorites list
    # - if its already on the list, remove it first
    # - if the list is too big, crunch the last item

    set add [get query.add]
    set list [get favorites]
    regsub " $add " $list {} list
    set list " $add $list"
    if {[regsub -all "  " $list "  " foo] > 4} {
       set kill ""
       regexp { ([^ ]+) +$} $list all kill
       regsub { [^ ]+ +$} $list {} list
       $set_data remove favorite.$kill
    }
    # invent a tab name from the url
    set tag [file tail $add]
    regsub {,id=[a-f0-9]*$} $tag {} tag

    put $set_data favorites $list
    set tag [file rootname $tag]
    if {$tag == "index"} {
	set tag [file tail [file dirname $add]]
    }
    if {$tag == ""} {
	set tag home
    }
    put $set_data favorite.$add $tag
  </server>
  <addheader location=${query.add}${UrlID}>
  <hr>
  Click
  <tag>a href=<get query.add></tag>here</a> to continue.

<!-- presenting change form -->

<else>
  <h1>My favorites</h1>
  <p>
  You may change the <b>tab</b> name by replacing the current value
  indicated in the box, then keying <i>rename favorite labels</i>.

  <!-- renaming the labels -->

  <if query.rename>
    <foreach name=i glob=query.change.*>
	 <set name=favorite.${i.name.1} value=${i.value}>
    </foreach>
    <addheader location=${header.url}${UrlID}>
  </if>

  <!-- deleting all favorites -->

  <if query.delete>
    <h2>All favorites deleted</h2>
    <foreach name=i property=favorites>
	 <set name=favorite.${i}>
    </foreach>
    <set name=favorites>
  </if>
  <tag>table border=2 bgcolor=<get primary></tag><tr><td>
  <form method=post>
  <ol>
  <foreach name=i property=favorites>
     <li><tag>a href=<get i></tag>
	 <get name=favorite.${i}></a>
         (<get i>)
	 <tag>input size=8 name="change.<get i>"
	       value="<get name=favorite.${i}>"
	 </tag>
  </foreach>
  </ol>
  <input type=submit name=rename value="rename favorite labels"></form>
  </td></tr></table>
  <hr>
  <form><input type=submit name=delete value="delete all favorites"></form>
</if>
</body>
This page is: http://www.experimentalstuff.com/About_this_site/favorites.txt
Last Modified: Tue, 18 Jun 2002 22:47:16 GMT
copyright (c) 2000-2007, Sun Microsystems