;;; meta-html.conf: -*- Fundamental -*-  DESCRIPTIVE TEXT.
;;;
;;; Copyright (c) 1996 Brian J. Fox
;;; Author: Brian J. Fox (bfox@samsara.com) Sun Jan  7 11:14:08 1996.
;;;
;;; This is the meta-html configuration file for the Macintosh platform.
;;; It goes in the directory which contains the Engine program.
;;;

;;; Put the full path to the root directory of your server here.
;;; The name is specified in Unix format, which is similar to Web format.
;;; (Actually, either format can be used.)
<set-var mac::document-root = "/mxm/WebStar">

;;; mhttpd-substs.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1995 Brian J. Fox & Samsara Partners
;;;  Author: Brian J. Fox (bfox@samsara.com) Fri Nov 17 18:45:21 1995.

;;; Preload these functions.  This makes page access faster.

;;; Use this where a single statement is expected.
<defsubst prog>%body</defsubst>

;;; Glue several disjoint arguments into one string.
<defsubst concat>%0%1%2%3%4%5%6%7%8%9</defsubst>

;;; <string-eq "foo" "foo"> --> "true"
;;; <string-eq "foo" "Foo"> --> ""
<defsubst string-eq><ifeq "%0" "%1" true></defsubst>

;;; Always reference Meta-HTML as <meta-html>
<defsubst meta-html><small-caps>Meta-HTML</small-caps></defsubst>

;;;
;;; Used like <a> ... </a> this creates a link to view the Meta-HTML
;;; source of the current document.
<defmacro source-link>
  <a href="<concat
    <get-var mhtml::http-prefix-sans-sid>/view-source.mhtml$
    <get-var mhtml::current-url-sans-sid>>">%body</a>
</defmacro>

;;; Use <mailto foo@bar.com> in place of mailto:foo@bar.com
<defsubst mailto whitespace=delete>
  <set-var recipient="%0">
  <get-var mhtml::http-prefix-sans-sid>/mailto.mhtml/=&<cgi-encode recipient>
</defsubst>

;;; action-buttons.mhtml: -*- Meta-HTML -*-
;;;
;;; Copyright (c) 1995 Brian J. Fox
;;; Author: Brian J. Fox (bfox@ai.mit.edu) Thu Sep 21 04:32:58 1995.
;;;
;;; The Netscape browser passes the "value" of the button that was
;;; clicked on in a form, not just the name.  For other browsers, only
;;; the name of the button is passed, and it is passed without any
;;; value. 
;;;
;;; Use <action-button "Save File" "Delete File"> to make the buttons
;;; in the form.
;;;
;;; Use <action-retrieve "Save File" "Delete File"> to set the
;;; variable "action" to the action which was selected.
;;;
<set-var ab::vertical-layout=true>

<defsubst action-buttons>
  <set-var ab::buttons[]="%0\n%1\n%2\n%3\n%4\n%5\n%6\n%7\n%8\n%9" ab::index=0>
  <if <or <not <get-var ab::buttons[1]>>
	  <get-var mhtml::html-2.0-compliant>>
      <prog
	<while <get-var ab::buttons[ab::index]>>
	  <input type=submit name=action
		 value="<get-var ab::buttons[ab::index]>">
	  <increment ab::index>
	</while>>
    <prog
      Select from the following:<br>
      <while <get-var ab::buttons[ab::index]>>
        <input type=radio name="action"
	       value="<get-var ab::buttons[ab::index]>"
	       <if <eq <get-var ab::index> 0> checked>>
	<get-var ab::buttons[ab::index]>
	<if <get-var ab::vertical-layout> <br>>
	<increment ab::index>
      </while>
      <input type=submit name=ignore value="Do It">>>
</defsubst>

;;;
;;; You give the same list to this function as you gave in the
;;; <action-buttons> statement on the input page.  It sets the
;;; variable "action" to the button which was pressed.

<defsubst action-retrieve>
  <when <not <get-var mhtml::html-2.0-compliant action>>>
    <if <not "%1">
	<set-var action="%0">
      <prog
	<set-var
	  ab::buttons[]="%0\n%1\n%2\n%3\n%4\n%5\n%6\n%7\n%8\n%9"
	  ab::index=0
	  ab::posted=<package-vars posted>>
	<while <get-var ab::buttons[ab::index]>>
	  <set-var ab::present = 
	    <match <get-var ab::posted>
		   "action-<get-var ab::buttons[ab::index>">>
	  <if <get-var ab::present>
	      <set-var action="<get-var ab::buttons[ab::index]>" ab::index=10>
	    <increment ab::index>>
	  </while>>>
  </when>
</defsubst>
