Commit 8bd869b0 authored by Frank Bergmann's avatar Frank Bergmann

- Updated to OpenACS 5.9.1

parent 01d05d0d
......@@ -2,31 +2,33 @@
<!-- Generated by the OpenACS Package Manager -->
<package key="acs-api-browser" url="http://openacs.org/repository/apm/packages/acs-api-browser/" type="apm_service">
<package-name>ACS API Browser</package-name>
<pretty-plural>ACS API Browsers</pretty-plural>
<initial-install-p>t</initial-install-p>
<singleton-p>t</singleton-p>
<package-name>ACS API Browser</package-name>
<pretty-plural>ACS API Browsers</pretty-plural>
<initial-install-p>t</initial-install-p>
<singleton-p>t</singleton-p>
<version name="5.9.1" url="http://openacs.org/repository/download/apm/acs-api-browser-5.9.1.apm">
<license>GPL V2.0 or any later version</license>
<version name="5.9.0" url="http://openacs.org/repository/download/apm/acs-api-browser-5.9.0.apm">
<owner url="http://openacs.org">OpenACS</owner>
<summary>Interactive documentation for the Tcl and SQL APIs.</summary>
<release-date>2015-10-04</release-date>
<maturity>3</maturity>
<vendor url="http://openacs.org">OpenACS</vendor>
<license url="http://www.gnu.org/copyleft/gpl.html">GPL</license>
<maturity>3</maturity>
<description format="text/html">On line interactive documentation for the locally installed Tcl and SQL APIs. Links to the Tcl core and AOLServer online documentation as well.</description>
<provides url="acs-api-browser" version="5.9.0"/>
<requires url="acs-kernel" version="5.9.0"/>
<callbacks>
</callbacks>
<parameters>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="FancySourceFormattingP" default="1" description="Should we highlight syntax and hyperlink procedure names when showing procedure source code? (1 for yes, 0 for no)"/>
</parameters>
</version>
<owner url="http://openacs.org">OpenACS</owner>
<summary>Interactive documentation for the Tcl and SQL APIs.</summary>
<release-date>2017-08-06</release-date>
<maturity>3</maturity>
<vendor url="http://openacs.org">OpenACS</vendor>
<license url="http://www.gnu.org/copyleft/gpl.html">GPL</license>
<maturity>3</maturity>
<description format="text/html">On line interactive documentation for the locally installed Tcl and SQL APIs. Links to the Tcl core and NaviServer/AOLServer online documentation as well.</description>
<provides url="acs-api-browser" version="5.9.1"/>
<requires url="acs-tcl" version="5.9.1"/>
<requires url="acs-kernel" version="5.9.1"/>
<callbacks>
</callbacks>
<parameters>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="FancySourceFormattingP" default="1" description="Should we highlight syntax and hyperlink procedure names when showing procedure source code? (1 for yes, 0 for no)"/>
<parameter scope="instance" datatype="number" min_n_values="1" max_n_values="1" name="ValidateCSRFP" default="1" description="Boolean parameter to activate/deactivate CSRF protection for this package instance"/>
</parameters>
</version>
</package>
......
......@@ -10,6 +10,7 @@
<input type="text" name="query_string" value="@query_string@"><br>
<input type="submit" value="All matches" name="search_type">
<input type="submit" value="Only best match" name="search_type">
<if @::__csrf_token@ defined><input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@"></if>
</div>
<p><a href="@openacs_browse_url@">Browse OpenACS Tcl API</a></p>
</td>
......@@ -49,12 +50,13 @@
<tr style="background:#DDDDDD">
<td colspan="2">
<form action="@aolserver_search_url@" method="get">
<h4>AOLserver Tcl API Search</h4>
<h4>NaviServer/AOLserver Tcl API Search</h4>
<div>
<input type="text" name="tcl_proc">
<input type="submit" value="Go"><br>
<if @::__csrf_token@ defined><input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@"></if>
(enter <em>exact</em> procedure name)<br>
<a href="@aolserver_tcl_api_root@">Browse AOLserver Tcl API</a>
<a href="@server_tcl_api_root@">Browse NaviServer Tcl API</a>
</div>
</form>
</td>
......@@ -66,6 +68,7 @@
<h4>Tcl Documentation Search</h4>
<div>
<input type="text" name="tcl_proc">
<if @::__csrf_token@ defined><input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@"></if>
<input type="submit" value="Go"><br>
(enter <em>exact</em> procedure name)<br>
<a href="@tcl_docs_root@">Browse the Tcl documentation</a>
......
......@@ -9,30 +9,26 @@
if { ![info exists query_string] } {
set query_string {}
}
set aolserver_tcl_api_root "http://www.aolserver.com/docs/devel/tcl/api/"
set tcl_docs_root "http://tcl.tk/man/tcl[info tclversion]/TclCmd/contents.htm"
set package_url [apm_package_url_from_key "acs-api-browser"]
set openacs_search_url "${package_url}proc-search"
# AOLserver has dropped documentation, use NaviServer docs instead
#set server_tcl_api_root "http://www.aolserver.com/docs/devel/tcl/api/"
set server_tcl_api_root "https://naviserver.sourceforge.io/n/toc.html"
set openacs_browse_url "${package_url}proc-browse"
set tcl_docs_root "http://tcl.tk/man/tcl[info tclversion]/TclCmd/contents.htm"
set openacs_search_url "${package_url}proc-search"
set openacs_browse_url "${package_url}proc-browse"
set openacs_plsql_browse_url "${package_url}plsql-subprograms-all"
set aolserver_search_url "${package_url}tcl-proc-view"
set tcl_search_url "${package_url}tcl-doc-search"
set aolserver_search_url "${package_url}tcl-proc-view"
set tcl_search_url "${package_url}tcl-doc-search"
switch [db_type] {
postgresql {
set db_pretty "PostgreSQL [db_version]"
set db_doc_url "http://www.postgresql.org/docs/[db_version]/interactive/index.html"
set db_doc_search_url "http://search.postgresql.org/www.search"
set db_doc_search_export [export_vars -form { { ul "http://www.postgresql.org/docs/[db_version]/static/%" } }]
set db_doc_search_url "https://www.postgresql.org/search"
set db_doc_search_export [export_vars -form { { ul "https://www.postgresql.org/docs/[db_version]/static/%" } }]
set db_doc_search_query_name "q"
}
oracle {
......
This diff is collapsed.
......@@ -15,7 +15,7 @@
<if @source_link@ ne 0>
<p>
<if @source_p@ eq 0>
<if @source_p;literal@ false>
[ <a href="content-page-view?@url_vars@&amp;source_p=1">show source</a> ]
</if>
<else>
......@@ -28,7 +28,7 @@
the default</a> ]
</if>
<if @source_p@ eq 1>
<if @source_p;literal@ true>
<h4>Content File Source</h4>
<!-- directly display file contents var to avoid translating i18n strings etc -->
......
......@@ -11,7 +11,7 @@ ad_page_contract {
@cvs-id $Id$
} {
version_id:naturalnum,optional
source_p:boolean,optional,trim
source_p:boolean,optional,trim,notnull
path:trim,notnull
} -properties {
title:onevalue
......@@ -26,6 +26,7 @@ set default_source_p [ad_get_client_property -default 0 acs-api-browser api_doc_
if { ![info exists source_p] } {
set source_p $default_source_p
if {$source_p eq ""} {set source_p 0}
}
if { ![info exists version_id] &&
......@@ -67,7 +68,7 @@ if {![file readable $::acs::rootdir/$path] || [file isdirectory $::acs::rootdir/
}
set mime_type [ns_guesstype $path]
if {![string match "text/*" $mime_type]} {
if {![string match "text/*" $mime_type] && [file extension $path] ne ".xql"} {
set source_p 0
set source_link 0
} else {
......@@ -75,7 +76,11 @@ if {![string match "text/*" $mime_type]} {
}
if { $source_p } {
set file_contents [template::util::read_file $::acs::rootdir/$path]
set file_contents [apidoc::tclcode_to_html $file_contents]
if {[file extension $path] eq ".tcl"} {
set file_contents [apidoc::tclcode_to_html $file_contents]
} else {
set file_contents [ns_quotehtml $file_contents]
}
}
template::util::list_to_multirow xql_links [::apidoc::xql_links_list $path]
......
......@@ -6,7 +6,7 @@
<ul>
<multiple name="deprecated">
<li><a
href="proc-view?proc=@deprecated.proc@">@deprecated.proc@</a> <i>@deprecated.args@</i>
href="proc-view?proc=@deprecated.proc@">@deprecated.proc@</a> <em>@deprecated.args@</em>
</multiple>
</ul>
......
......@@ -36,7 +36,7 @@ if {$version_id ne ""} {
where version_id = :version_id
}
if {[info exists pretty_name]} {
lappend context [list "package-view?version_id=$version_id&amp;kind=sql_files" "$pretty_name $version_name"]
lappend context [list [export_vars -base package-view {version_id {kind sql_files}}] "$pretty_name $version_name"]
}
}
lappend context [file tail $url]
......
......@@ -10,7 +10,7 @@ ad_page_contract {
@author Lars Pind (lars@pinds.com)
@cvs-id $Id$
} {
about_package_key:optional
about_package_key:token,trim,optional
} -properties {
title:onevalue
context:onevalue
......
......@@ -22,12 +22,8 @@ set context [list {"plsql-subprograms-all" "All PL/SQL Subprograms"} "One PL/SQL
set source_text ""
db_foreach source_text "select text
from user_source
where name = upper(:name)
and type = upper(:type)
order by line" {
append source_text $text
db_foreach source_text {} {
append source_text $text \n\n\n
}
switch $type {
......
......@@ -6,7 +6,7 @@
<fullquery name="all_subprograms">
<querytext>
select object_type as type, object_name as name
select object_type as type, object_name as name, 0 as nargs
from user_objects
where object_type in ('PACKAGE', 'PROCEDURE', 'FUNCTION')
order by
......
......@@ -6,11 +6,11 @@
<fullquery name="all_subprograms">
<querytext>
select proname as name, 'FUNCTION' as type
select proname as name, 'FUNCTION' as type, pronargs as nargs
from pg_proc
where proowner=(select usesysid from pg_user
where usename = current_user)
order by proname
order by proname, pronargs
</querytext>
</fullquery>
......
......@@ -7,7 +7,7 @@
<ul>
<group column="type">
<li><a href="plsql-subprogram-one?type=<%= [ns_urlencode @all_subprograms.type@] %>&name=<%= [ns_urlencode @all_subprograms.name@] %>"><code><%= [string tolower @all_subprograms.name@] %></code></a></li>
<li><a href="@all_subprograms.url;noi18n@"><code>@all_subprograms.label@</code></a></li>
</group>
</ul>
......
......@@ -16,9 +16,15 @@ set context [list "All PL/SQL Subprograms"]
#
# Organize the subprograms und types like FUNCTION, PROCEDURE, and
# PACKAGE in oracle or FUNCTION in PostgresSQL
# PACKAGE in oracle or FUNCTION in PostgreSQL
#
db_multirow all_subprograms all_subprograms {}
db_multirow -extend { url label } all_subprograms all_subprograms {} {
set url [export_vars -base plsql-subprogram-one {type name}]
set label [string tolower $name]
if {$nargs > 0} {
append label /$nargs
}
}
# Local variables:
# mode: tcl
......
......@@ -9,7 +9,7 @@
<multiple name="proc_list">
<% if { $proc_list(file) != $last_file } { %>
<% if {[incr count] >1} { %> </ul> <% } %>
<b>@proc_list.file@</b> <ul>
<strong>@proc_list.file@</strong> <ul>
<% set last_file @proc_list.file@ %>
<% } %>
<li><a href="@proc_list.url@">@proc_list.proc@</a>
......
......@@ -42,9 +42,9 @@ foreach proc [nsv_array names api_proc_doc] {
lappend matches [list $proc $doc_elements(script)]
} elseif {$type eq "Deprecated" && $doc_elements(deprecated_p)} {
lappend matches [list $proc $doc_elements(script)]
} elseif {$type eq "Private" && $doc_elements(private_p) } {
} elseif {$type eq "Private" && $doc_elements(protection) eq "private" } {
lappend matches [list $proc $doc_elements(script)]
} elseif {$type eq "Public" && $doc_elements(public_p) } {
} elseif {$type eq "Public" && $doc_elements(protection) eq "public" } {
lappend matches [list $proc $doc_elements(script)]
}
}
......
......@@ -11,7 +11,7 @@
<ul>
<multiple name="results">
<li> <if @results.score@ lt 10>&nbsp;&nbsp;</if>@results.score@: <a href="@results.url@">@results.proc@</a>
<i>@results.args;noquote@</i>
<em>@results.args;noquote@</em>
</multiple>
</ul>
......@@ -21,40 +21,40 @@ No results found
<if @private_results:rowcount@ gt 0>
<if @show_private_p@ true>
<if @show_private_p;literal@ true>
<p>
<b>Show</b> | <a href="@hide_private_url@">Hide</a> <b>@private_results:rowcount@ private</b> procedure matches
<strong>Show</strong> | <a href="@hide_private_url@">Hide</a> <strong>@private_results:rowcount@ private</strong> procedure matches
</p>
<ul>
<multiple name="private_results">
<li><if @private_results.score@ lt 10>&nbsp;&nbsp;</if>@private_results.score@: <a href="@private_results.url@">@private_results.proc@</a>
<i>@private_results.args;noquote@</i>
<em>@private_results.args;noquote@</em>
</multiple>
</ul>
</if>
<else>
<p>
<a href="@show_private_url@">Show</a> | <b>Hide</b> <b>@private_results:rowcount@ private</b> procedure matches
<a href="@show_private_url@">Show</a> | <strong>Hide</strong> <strong>@private_results:rowcount@ private</strong> procedure matches
</p>
</else>
</if>
<if @deprecated_results:rowcount@ gt 0>
<if @show_deprecated_p@ true>
<if @show_deprecated_p;literal@ true>
<p>
<b>Show</b> | <a href="@hide_deprecated_url@">Hide</a> <b>@deprecated_results:rowcount@ deprecated</b> procedure matches
<strong>Show</strong> | <a href="@hide_deprecated_url@">Hide</a> <strong>@deprecated_results:rowcount@ deprecated</strong> procedure matches
</p>
<ul>
<multiple name="deprecated_results">
<li><if @deprecated_results.score@ lt 10>&nbsp;&nbsp;</if>@deprecated_results.score@: <a href="@deprecated_results.url@">@deprecated_results.proc@</a>
<i>@deprecated_results.args;noquote@</i>
<em>@deprecated_results.args;noquote@</em>
</multiple>
</ul>
</if>
<else>
<p>
<a href="@show_deprecated_url@">Show</a> | <b>Hide</b> <b>@deprecated_results:rowcount@ deprecated</b> procedure matches
<a href="@show_deprecated_url@">Show</a> | <strong>Hide</strong> <strong>@deprecated_results:rowcount@ deprecated</strong> procedure matches
</p>
</else>
</if>
......
......@@ -3,7 +3,7 @@
ad_page_contract {
Searches for procedures with containing query_string
if lucky redirects to best match
Weight the different hits with the propper weights
Weight the different hits with the proper weights
Shows a list of returned procs with links to proc-view
......@@ -13,14 +13,14 @@ ad_page_contract {
@creation-date Jul 14, 2000
@cvs-id $Id$
} {
{name_weight:optional 0}
{doc_weight:integer,optional 0}
{param_weight:integer,optional 0}
{source_weight:integer,optional 0}
{name_weight:notnull 0}
{doc_weight:integer,notnull 0}
{param_weight:integer,notnull 0}
{source_weight:integer,notnull 0}
{search_type:optional 0}
{show_deprecated_p:boolean 0}
{show_private_p:boolean 0}
query_string
{show_deprecated_p:boolean,notnull 0}
{show_private_p:boolean,notnull 0}
{query_string:token,notnull}
} -properties {
title:onevalue
context:onevalue
......@@ -30,6 +30,8 @@ ad_page_contract {
source_weight:onevalue
query_string:onevalue
results:multirow
} -validate {
csrf { csrf::validate }
}
##########################################################
......@@ -132,7 +134,7 @@ foreach proc [nsv_array names api_proc_doc] {
if { $doc_elements(deprecated_p) } {
lappend deprecated_matches [list $proc $score $args]
} else {
if { $doc_elements(public_p) } {
if { $doc_elements(protection) eq "public" } {
lappend matches [list $proc $score $args]
} else {
lappend private_matches [list $proc $score $args]
......@@ -168,10 +170,15 @@ foreach output $deprecated_matches {
set url [api_proc_url $proc]
multirow append deprecated_results $score $proc $args $url
}
global __csrf_token
set show_deprecated_url [export_vars -base [ad_conn url] -override { { show_deprecated_p 1 } } { name_weight doc_weight param_weight source_weight search_type query_string show_private_p }]
set show_deprecated_url [export_vars -base [ad_conn url] -override {{ show_deprecated_p 1 }} {
name_weight doc_weight param_weight source_weight search_type query_string show_private_p __csrf_token
}]
set hide_deprecated_url [export_vars -base [ad_conn url] -override { { show_deprecated_p 0 } } { name_weight doc_weight param_weight source_weight search_type query_string show_private_p }]
set hide_deprecated_url [export_vars -base [ad_conn url] -override { { show_deprecated_p 0 } } {
name_weight doc_weight param_weight source_weight search_type query_string show_private_p __csrf_token
}]
multirow create private_results score proc args url
......@@ -183,9 +190,12 @@ foreach output $private_matches {
multirow append private_results $score $proc $args $url
}
set show_private_url [export_vars -base [ad_conn url] -override { { show_private_p 1 } } { name_weight doc_weight param_weight source_weight search_type query_string show_deprecated_p }]
set hide_private_url [export_vars -base [ad_conn url] -override { { show_private_p 0 } } { name_weight doc_weight param_weight source_weight search_type query_string show_deprecated_p }]
set show_private_url [export_vars -base [ad_conn url] -override { { show_private_p 1 } } {
name_weight doc_weight param_weight source_weight search_type query_string show_deprecated_p __csrf_token
}]
set hide_private_url [export_vars -base [ad_conn url] -override { { show_private_p 0 } } {
name_weight doc_weight param_weight source_weight search_type query_string show_deprecated_p __csrf_token
}]
# Local variables:
# mode: tcl
......
<master>
<property name="doc(title)">@title;literal@</property>
<property name="context">@context;literal@</property>
<property name="head">
<style type="text/css">
div.api-doc {background: #e4e4e4;}
div.api-doc dd {margin-left: 2em;}
</style>
</property>
<if @error_msg@ ne "">
@error_msg;noquote@
</if>
<else>
<table width="100%">
<tr><td style="background: #eeeeee">@documentation;literal@</td></tr>
<div class="api-doc">
@documentation;literal@
</div>
</table>
<if @source_p@ eq 0>
<if @source_p;literal@ false>
[ <a href="@procViewToggleURL;noi18n@">show source</a> ]
</if>
<else>
......
......@@ -36,8 +36,9 @@ set default_source_p [ad_get_client_property -default 0 acs-api-browser api_doc_
set return_url [export_vars -base [ad_conn url] {proc version_id}]
set error_msg ""
if { ![info exists source_p] } {
if { ![info exists source_p] || $source_p eq ""} {
set source_p $default_source_p
if {$source_p eq ""} {set source_p 0}
}
if {[string match ::* $proc]} {
......@@ -75,33 +76,43 @@ proc $proc {[info args $proc]} {
}
</pre></p>
}]
} elseif {[info commands $absolute_proc] eq $absolute_proc} {
} elseif {[info commands $absolute_proc] eq $absolute_proc} {
set result [util_memoize [list ::util::http::get -url $::apidoc::ns_api_html_index]]
set page [dict get $result page]
set url [apidoc::search_on_webindex \
-page $page \
-root $::apidoc::ns_api_root \
-host $::apidoc::ns_api_host \
-proc $relative_proc]
if {$url ne ""} {
ns_log notice "api-doc/www/proc-view got URL <$url>"
ad_returnredirect -allow_complete_url $url
#
# In case the cmd is an object, redirect to the object browser
#
if {[info commands ::nsf::is] ne "" && [nsf::is object $absolute_proc]} {
ad_returnredirect [export_vars -base /xotcl/show-object {{object $absolute_proc}}]
ad_script_abort
}
set result [util_memoize [list ::util::http::get -url $::apidoc::tcl_api_html_index]]
set page [dict get $result page]
# Strip the end of the Tcl-URL to obtain the root
regexp {^(.*)/[^/]+} $::apidoc::tcl_api_html_index _ root
append root /
#
# Try NaviSever API documentation
#
set url [apidoc::get_doc_url \
-cmd $relative_proc \
-index $::apidoc::ns_api_html_index \
-root $::apidoc::ns_api_root \
-host $::apidoc::ns_api_host]
if {$url eq ""} {
#
# Try Tcl command documentation
#
regexp {^(.*)/[^/]+} $::apidoc::tcl_api_html_index _ root
append root /
set url [apidoc::get_doc_url \
-cmd $proc \
-index $::apidoc::tcl_api_html_index \
-root $root \
-host $root]
}
set url [apidoc::search_on_webindex -page $page -root $root -host $root -proc $proc]
if {$url ne ""} {
ns_log notice "api-doc/www/proc-view got URL <$url>"
ad_returnredirect -allow_complete_url $url
ad_script_abort
}
......@@ -111,7 +122,7 @@ proc $proc {[info args $proc]} {
<p>The command <b>$proc</b> is an available command on
the server and might be found in the <a
href="$::apidoc::tcl_api_html_index">Tcl</a>
or <a href="$::apidoc::ns_api_html_index">[ns_info name]</a>
or <a href="[lindex $::apidoc::ns_api_html_index 0]">[ns_info name]</a>
documentation or in documentation for a loadable module.
</p>
}]
......
......@@ -2,3 +2,9 @@
set query_string [string range [ad_conn extra_url] [string length "proc/"] end]
set url [export_vars -base [ad_conn package_url]proc-search { query_string { search_type "Feeling Lucky" } }]
ad_returnredirect $url
# Local variables:
# mode: tcl
# tcl-indent-level: 4
# indent-tabs-mode: nil
# End:
......@@ -3,7 +3,8 @@
<property name="context">@context;literal@</property>
<property name="head">
<style type="text/css">
td.doc {background: #e4e4e4;}
div.api-doc {background: #e4e4e4;}
dd {margin-left: 2em;}
</style>
</property>
......@@ -23,13 +24,12 @@
<h3>Detailed information</h3>
<multiple name="proc_doc_list">
<table width="100%">
<tr><td class="doc">@proc_doc_list.doc;noquote@</td></tr>
</table>
&nbsp;<p>
<div class="api-doc">
@proc_doc_list.doc;noquote@
</div>
</multiple>
<if @source_p@ eq 0>
<if @source_p;literal@ false>
[ <a href="procs-file-view?@url_vars@&amp;source_p=1">show source</a> ]
</if>
<else>
......@@ -42,7 +42,7 @@
the default</a> ]
</if>
<if @source_p@ eq 1>
<if @source_p;literal@ true>
<h4>Content File Source</h4>
<!-- directly display file contents var to avoid translating i18n strings etc -->
......
......@@ -3,10 +3,10 @@ ad_page_contract {
@cvs-id $Id$
} {
version_id:naturalnum,optional
version_id:naturalnum,optional,notnull
{ public_p:boolean "" }
path:path,trim
source_p:boolean,optional,trim
source_p:boolean,optional,trim,notnull
} -properties {
title:onevalue
context:onevalue
......@@ -18,12 +18,14 @@ ad_page_contract {
set url_vars [export_vars {path version_id}]
set return_url [ns_urlencode [ad_conn url]?][ns_urlencode $url_vars]
set default_source_p [ad_get_client_property -default 0 acs-api-browser api_doc_source_p]
if { ![info exists source_p] } {
set source_p $default_source_p
if {$source_p eq ""} {set source_p 0}
}
if { ![info exists version_id] &&
[regexp {^packages/([^ /]+)/} $path "" package_key] } {
if { ![info exists version_id]
&& [regexp {^packages/([^ /]+)/} $path "" package_key] } {
db_0or1row version_id_from_package_key {
select version_id
from apm_enabled_package_versions
......@@ -32,7 +34,7 @@ if { ![info exists version_id] &&
}
set path [apidoc::sanitize_path $path]
if {![file readable $::acs::rootdir/$path] || [file isdirectory $::acs::rootdir/$path]} {
if {![file readable ${::acs::rootdir}$path] || [file isdirectory ${::acs::rootdir}$path]} {
if {[info exists version_id]} {
set kind procs
set href [export_vars -base [ad_conn package_url]/package-view {version_id {kind procs}}]
......@@ -76,6 +78,7 @@ if { [info exists version_id] } {
}
set path [string trimleft $path /]
lappend context [file tail $path]
set title [file tail $path]
......@@ -90,7 +93,7 @@ if { [nsv_exists api_proc_doc_scripts $path] } {
foreach proc [lsort [nsv_get api_proc_doc_scripts $path]] {
if { $public_p } {
array set doc_elements [nsv_get api_proc_doc $proc]
if { !$doc_elements(public_p) } {
if { $doc_elements(protection) ne "public"} {
continue
}
}
......@@ -99,7 +102,7 @@ if { [nsv_exists api_proc_doc_scripts $path] } {
foreach proc [lsort [nsv_get api_proc_doc_scripts $path]] {
if { $public_p } {
array set doc_elements [nsv_get api_proc_doc $proc]
if { !$doc_elements(public_p) } {
if { $doc_elements(protection) ne "public"} {
continue
}
}
......
ad_page_contract {
Set user preferences for API browsing.
} {
source_p:boolean,optional,notnull
return_url
source_p:boolean,notnull
return_url:localurl
}
set found_p 0
ad_set_client_property -persistent t acs-api-browser api_doc_source_p $source_p
if { [info exists source_p] } {
ad_set_client_property -persistent t acs-api-browser api_doc_source_p $source_p
set found_p 1
}
if { $found_p } {
ad_returnredirect $return_url
} else {
ad_return_error "Unknown Property" "Couldn't find any property to set"
}
ad_returnredirect $return_url
# Local variables:
# mode: tcl
......
......@@ -6,16 +6,18 @@ Sorry, no Tcl procedures were found with that name.
<p>
You can try searching the <a href="@tcl_docs_url@">Tcl documentation</a> yourself.
You can try searching the <a href="@tcl_docs_url;noi18n@">Tcl documentation</a> yourself.
<p>
<table cellpadding="5">
<tr>
<td bgcolor="#dddddd">
<form action=tcl-doc-search method=get>
<b>Tcl Documentation Search:</b><br>
<input type="text" name="tcl_proc" value="@tcl_proc@"> <input type="submit" value="Go"><br>
<form action="tcl-doc-search" method="get">
<strong>Tcl Documentation Search:</strong><br>
<input type="text" name="tcl_proc" value="@tcl_proc@">
<if @::__csrf_token@ defined><input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@"></if>
<input type="submit" value="Go"><br>
</form>
</td>
</tr>
......
......@@ -7,30 +7,31 @@ ad_page_contract {
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 "<a href=\"(\[^>\]+)\">$search_for</a>" $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"]
......
......@@ -6,14 +6,16 @@ Sorry, no <%= [ns_info name]%> Tcl API procedures were found with that name.
<p>
You can try searching the <a href="@apidoc::ns_api_html_index@"><%= [ns_info name]%> documentation</a> yourself.
You can try searching the <a href="@doc_url;noi18n@"><%= [ns_info name]%> documentation</a> yourself.
<p>
<div style="background: #dddddd; display: inline-block; padding: 5px;">
<form action=tcl-proc-view method=get>
<div><b>Tcl Api Search:</b><br>
<input type="text" name="tcl_proc" value="@tcl_proc@"> <input type="submit" value="Go"><br>
<form action="tcl-proc-view" method="get">
<div><strong>Tcl Api Search:</strong><br>
<input type="text" name="tcl_proc" value="@tcl_proc@">
<!-- <if @::__csrf_token@ defined><input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@"></if> -->
<input type="submit" value="Go"><br>
</div>
</form>
</div>
\ No newline at end of file
......@@ -7,25 +7,14 @@ ad_page_contract {
title:onevalue
context:onevalue
tcl_proc:onevalue
} -validate {
csrf { csrf::validate }
}
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]
#
# 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 url [apidoc::get_doc_url -cmd $tcl_proc \
-index $::apidoc::ns_api_html_index \
-root $::apidoc::ns_api_root \
-host $::apidoc::ns_api_host]
if {$url ne ""} {
ad_returnredirect -allow_complete_url $url
......@@ -34,7 +23,7 @@ if {$url ne ""} {
set title "[ns_info name] Tcl API Search for: \"$tcl_proc\""
set context [list "Tcl API Search: $tcl_proc"]
set doc_url [lindex $::apidoc::ns_api_html_index 0]
# Local variables:
# mode: tcl
# tcl-indent-level: 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment