Index: openacs-4/packages/acs-api-browser/www/tcl-doc-search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/www/tcl-doc-search.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-api-browser/www/tcl-doc-search.tcl 29 Jun 2015 18:52:21 -0000 1.8 +++ openacs-4/packages/acs-api-browser/www/tcl-doc-search.tcl 7 Aug 2017 23:47:46 -0000 1.9 @@ -7,29 +7,36 @@ title:onevalue context:onevalue tcl_proc:onevalue +} -validate { + csrf { csrf::validate } } -set tcl_docs_root "http://tcl.tk/man/tcl[info tclversion]/TclCmd/" -set tcl_docs_url "${tcl_docs_root}contents.htm" -with_catch errmsg { - set tcl_docs_index_result [util_memoize [list util::http::get -url $tcl_docs_url]] - set tcl_docs_index_page [dict get $tcl_docs_index_result page] -} { - ad_return_error "Cannot Connect" "We're sorry, but we're having problems connecting to the server containing the Tcl documentation: $tcl_docs_url" - ad_script_abort -} +# +# Try Tcl command documentation +# -set tcl_proc [lindex $tcl_proc 0] -set len [string length $tcl_proc] +regexp {^(.*)/[^/]+} $::apidoc::tcl_api_html_index _ root +append root / -for { set i [expr { $len-1 }] } { $i >= 0 } { incr i -1 } { - set search_for [string range $tcl_proc 0 $i] - if { [regexp "\]+)\">$search_for" $tcl_docs_index_page match relative_url] } { - ad_returnredirect -allow_complete_url "$tcl_docs_root$relative_url" - ad_script_abort - } +set url [apidoc::get_doc_url \ + -cmd $tcl_proc \ + -index $::apidoc::tcl_api_html_index \ + -root $root \ + -host $root] + +if {$url ne ""} { + ns_log notice "api-doc/www/proc-view got URL <$url>" + ad_returnredirect -allow_complete_url $url + ad_script_abort } +set tcl_docs_url $::apidoc::tcl_api_html_index set title "Tcl API Procedure Search for: \"$tcl_proc\"" set context [list "Tcl API Search: $tcl_proc"] + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: