Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | In the checklist application, add a /self method and make the magic database name "top" refer to the lexically largest database file. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
752d433361879f3e229dc41886280ff3 |
User & Date: | drh 2019-07-27 15:28:01.022 |
Context
2019-07-27
| ||
15:39 | Add the CGI-Environment and Source-code submenu links to the checklist application. (check-in: a5c38ef1bf user: drh tags: trunk) | |
15:28 | In the checklist application, add a /self method and make the magic database name "top" refer to the lexically largest database file. (check-in: 752d433361 user: drh tags: trunk) | |
15:13 | Fixes to the checklist CGI so that it works better as a Fossil CGI extension. (check-in: 41933da084 user: drh tags: trunk) | |
Changes
Changes to misc/checklist.tcl.
︙ | ︙ | |||
54 55 56 57 58 59 60 | # Show the CGI environment for testing purposes. # proc wapp-page-env {} { sqlite3 db :memory: set v [db one {SELECT sqlite_source_id()}] checklist-verify-login wapp-trim { | | > > > > > > > > > > > > > > > > > > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # Show the CGI environment for testing purposes. # proc wapp-page-env {} { sqlite3 db :memory: set v [db one {SELECT sqlite_source_id()}] checklist-verify-login wapp-trim { <div class='fossil-doc' data-title='Checklist Environment'> <pre>%html([wapp-debug-env])} global env foreach e [array names env] { if {![string match FOSSIL* $e]} continue set txt "$e = [list $env($e)]\n" wapp-subst {%html($txt)} } wapp-subst {SQLite = %html($v)</pre>\n</div>\n} } # Show the complete text of this script. # proc wapp-page-self {} { wapp-cache-control max-age=3600 wapp-subst {<div class='fossil-doc' data-title='Checklist Program Listing'>\n} set fd [open [wapp-param SCRIPT_FILENAME] rb] set script [read $fd] close $fd wapp-trim { <p>The following is the complete text of the <a href='https://wapp.tcl.tk/'>Wapp script</a> that implements this <a href='https://fossil-scm.org/home/doc/trunk/www/serverext.wiki'>Fossil CGI extension</a>:</p> <pre>%html($script)</pre> } wapp-subst {</div>\n} } # Check user permissions by looking at the login/password in the # checklist-login cookie. Set the following environment variables: # # CKLIST_USER Name of the user. Empty string if not logged in # CKLIST_WRITE True if the user is allowed to make updates # CKLIST_ADMIN True if the user is an administrator. |
︙ | ︙ | |||
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | # # If the first element of PATH_INFO is not a valid checklist database name, # then change PATH_HEAD to be the database listing method. # proc wapp-before-dispatch-hook {} { global DATADIR set dbname [wapp-param PATH_HEAD] wapp-set-param ROOT_URL [wapp-param BASE_URL] if {[file readable $DATADIR/$dbname.db]} { # an appropriate database has been found wapp-set-param OBJECT $DATADIR/$dbname.db if {[regexp {^([^/]+)(.*)$} [wapp-param PATH_TAIL] all head tail]} { wapp-set-param PATH_HEAD $head wapp-set-param PATH_TAIL [string trimleft $tail /] wapp-set-param SELF_URL /$head } else { wapp-set-param PATH_HEAD {} wapp-set-param PATH_TAIL {} } wapp-set-param BASE [wapp-param BASE_URL]/$dbname } else { # Not a valid database. Change the method to list all available # databases. wapp-set-param OBJECT {} wapp-set-param BASE [wapp-param SCRIPT_NAME] | > > > > > > | > | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | # # If the first element of PATH_INFO is not a valid checklist database name, # then change PATH_HEAD to be the database listing method. # proc wapp-before-dispatch-hook {} { global DATADIR set dbname [wapp-param PATH_HEAD] if {$dbname=="top"} { set filelist [glob -tails -directory $DATADIR 3*.db] set dbname [lindex [lsort -decr $filelist] 0] regsub {.db$} $dbname {} dbname } wapp-set-param ROOT_URL [wapp-param BASE_URL] if {[file readable $DATADIR/$dbname.db]} { # an appropriate database has been found wapp-set-param OBJECT $DATADIR/$dbname.db if {[regexp {^([^/]+)(.*)$} [wapp-param PATH_TAIL] all head tail]} { wapp-set-param PATH_HEAD $head wapp-set-param PATH_TAIL [string trimleft $tail /] wapp-set-param SELF_URL /$head } else { wapp-set-param PATH_HEAD {} wapp-set-param PATH_TAIL {} } wapp-set-param BASE [wapp-param BASE_URL]/$dbname } else { # Not a valid database. Change the method to list all available # databases. wapp-set-param OBJECT {} wapp-set-param BASE [wapp-param SCRIPT_NAME] if {$dbname!="env" && $dbname!="self"} { wapp-set-param PATH_HEAD listing } } } # Start up the web-server wapp-start $::argv |