Index: openacs-4/packages/acs-api-browser/www/tcl-proc-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/www/tcl-proc-view.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-api-browser/www/tcl-proc-view.tcl 7 Feb 2009 20:32:54 -0000 1.6 +++ openacs-4/packages/acs-api-browser/www/tcl-proc-view.tcl 27 Oct 2014 16:39:00 -0000 1.7 @@ -1,5 +1,5 @@ ad_page_contract { - Will redirect you to aolserver.com if documentation can be found + Will redirect you to the server containing the documentation if it can be found @cvs-id $Id$ } { tcl_proc @@ -9,38 +9,28 @@ tcl_proc:onevalue } -# old aolserver documentation -#set tcl_api_host "http://www.aolserver.com/" -#set tcl_api_index "docs/devel/tcl/api/" +set ns_api_index_result [util_memoize [list ::util::http::get -url $::apidoc::ns_api_html_index]] +set ns_api_index_page [dict get $ns_api_index_result page] -# wiki on dev.aolserver; might be the place in the future -#set tcl_api_host "http://dev.aolserver.com/" -#set tcl_api_index "wiki/Tcl_API" - -# wiki on panpotic -set tcl_api_host "http://panoptic.com/" -set tcl_api_index "wiki/aolserver/Tcl_API" - -set tcl_api_root ${tcl_api_host}${tcl_api_index} -set tcl_api_index_page [util_memoize "ns_httpget $tcl_api_root"] - -ns_log notice index=$tcl_api_root -set tcl_proc [lindex $tcl_proc 0] - -set len [string length $tcl_proc] - -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_api_index_page match relative_url] } { - if {[string match "/*" $relative_url]} { - set url ${tcl_api_host}$relative_url - } else { - set url ${tcl_api_root}$relative_url - } - ad_returnredirect -allow_complete_url $url - ad_script_abort - } +# +# Since man pages contain often a summary of multiple commands, try +# abbreviation in case the full name is not found (e.g. man page "nsv" +# contains "nsv_array", "nsv_set" etc.) +# +for {set i [string length $tcl_proc]} {$i > 1} {incr i -1} { + set proc [string range $tcl_proc 0 $i] + set url [apidoc::search_on_webindex \ + -page $ns_api_index_page \ + -root $::apidoc::ns_api_root \ + -host $::apidoc::ns_api_host \ + -proc $proc] + if {$url ne ""} break } -set title "AOLserver Tcl API Search for: \"$tcl_proc\"" -set context [list "TCL API Search: $tcl_proc"] +if {$url ne ""} { + ad_returnredirect -allow_complete_url $url + ad_script_abort +} + +set title "[ns_info name] Tcl API Search for: \"$tcl_proc\"" +set context [list "Tcl API Search: $tcl_proc"]