• Publicity: Public Only All

mime-procs.tcl

Provides procedures needed to determine mime type required for the client browser, as well as other additional header information.

Location:
packages/acs-templating/tcl/mime-procs.tcl
Created:
12 January 2001
Author:
Shan Shan Huang <shuang@arsdigita.com>
CVS Identification:
$Id: mime-procs.tcl,v 1.8 2017/08/07 23:48:02 gustafn Exp $

Procedures in this file

Detailed information

template::get_mime_header_preamble (public)

 template::get_mime_header_preamble mime_type
Parameters:
mime_type (required)
Returns:
the mime_header preamble if exists otherwise ""

Partial Call Graph (max 5 caller/called nodes):
%3 adp_parse_ad_conn_file adp_parse_ad_conn_file (private) template::get_mime_header_preamble template::get_mime_header_preamble adp_parse_ad_conn_file->template::get_mime_header_preamble

Testcases:
No testcase defined.

template::get_mime_template_extension (public)

 template::get_mime_template_extension mime_type
Parameters:
mime_type (required)
Returns:
the template extension associated with mime_type (default "adp")

Partial Call Graph (max 5 caller/called nodes):
%3 template::adp_parse template::adp_parse (public) template::get_mime_template_extension template::get_mime_template_extension template::adp_parse->template::get_mime_template_extension

Testcases:
No testcase defined.

template::get_mime_type (public)

 template::get_mime_type

gets the mimetype from the outputheaders and if missing guesses text/html

Partial Call Graph (max 5 caller/called nodes):
%3 adp_parse_ad_conn_file adp_parse_ad_conn_file (private) template::get_mime_type template::get_mime_type adp_parse_ad_conn_file->template::get_mime_type template::adp_parse template::adp_parse (public) template::adp_parse->template::get_mime_type

Testcases:
No testcase defined.

template::register_mime_type (public)

 template::register_mime_type mime_type file_extension header_preamble

sets the template_extension and template_header_preamble nsv's with the provided data.

Parameters:
mime_type (required)
file_extension (required)
header_preamble (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

namespace eval template {}

ad_library {
    Provides procedures needed to determine mime type required for the
    client browser, as well as other additional header information.

    @author Shan Shan Huang (shuang@arsdigita.com)
    @creation-date 12 January 2001
    @cvs-id $Id: mime-procs.tcl,v 1.8 2017/08/07 23:48:02 gustafn Exp $
}

ad_proc -public template::register_mime_type { mime_type file_extension header_preamble } {
    sets the template_extension and template_header_preamble nsv's with the 
    provided data.
} {
    if { [info exists template_extension($mime_type)] } {
        nsv_unset template_extension($mime_type)
    }
    if { [info exists template_header_preamble($mime_type)] } {
        unset template_header_preamble($mime_type)
    }

    nsv_set template_extension $mime_type $file_extension
    nsv_set template_header_preamble $mime_type $header_preamble
}

ad_proc -public template::get_mime_template_extension { mime_type } {
    @return the template extension associated with mime_type (default "adp")
} {
    if { [nsv_exists template_extension $mime_type] } {
        return [nsv_get template_extension $mime_type]
    } else {
        return "adp"
    }
}

ad_proc -public template::get_mime_header_preamble { mime_type } {
    @return the mime_header preamble if exists otherwise ""
} {
    if { [nsv_exists template_header_preamble $mime_type] } {
        return [nsv_get template_header_preamble $mime_type]
    } else {
        return ""
    }
}

ad_proc -public template::get_mime_type {} {
    gets the mimetype from the outputheaders and if missing guesses 
    text/html
} {
    if {[ns_conn isconnected]} {
        set mime_type [ns_set iget [ns_conn outputheaders] "content-type"]
    } else { 
        set mime_type {} 
    }
    if { $mime_type eq "" } {
        set mime_type "text/html"
    }

    return $mime_type
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: