login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for AxServer revision 2 of 3

1 2 3
Editor: alfredo
Time: 2008/03/16 20:15:19 GMT-7
Note:

changed:
-notangle -RServer$\backslash$ Lisp axserver.pamphlet $>$ http.lisp
\begin{verbatim}
notangle -RServer$\backslash$ Lisp axserver.pamphlet > http.lisp
\end{verbatim}

added:
(defun |Open| (path)
  (si::open path :direction :input :if-exists nil :if-does-not-exist nil)
  )


removed:
-
-

removed:
-

removed:
-

changed:
-               (sleep 3)
               (sleep 10000)

changed:
-notangle axserver.pamphlet $>$ axserver.spad
\begin{verbatim}
notangle axserver.pamphlet > axserver.spad
\end{verbatim}

removed:
-   fileserver: SExpression -> Void
-   axget: SExpression -> Void
-   axpost: SExpression -> Void
-

changed:
-   formatMessages1: String -> String
   getContentType: String -> String

changed:
-         WriteLine("multiServ")$Lisp
         WriteLine("multiServ begin")$Lisp

added:
         WriteLine("multiServ end")$Lisp
         WriteLine("")$Lisp

added:
       WriteLine("")$Lisp

changed:
-           q:=OPEN(pathvar)$Lisp
       --first determine Content-Type from file extension
           contentType:String := getContentType(pathvar)
           q:=Open(pathvar)$Lisp
	   if null? q then
	     q := MAKE_-STRING_-INPUT_-STREAM("File doesn't exist")$Lisp
	     WriteLine("File does not exist.")$Lisp

changed:
-       while (char := STRING(READ_-CHAR_-NO_-HANG(q,NIL$Lisp,'EOF)$Lisp)$Lisp) ^= "EOF" repeat
-           file := concat [file,char]
       WriteLine("begin reading file")$Lisp
       r := MAKE_-STRING_-OUTPUT_-STREAM()$Lisp
       SiCopyStream(q,r)$Lisp
       filestream:String := GET_-OUTPUT_-STREAM_-STRING(r)$Lisp
       CLOSE(r)$Lisp

changed:
-       file := concat ["Content-Length: ",string(#file),STRING(NewLine$Lisp)$Lisp,STRING(NewLine$Lisp)$Lisp,file]
       WriteLine("end reading file")$Lisp
       filelength:String := string(#filestream)
       file := concat ["Content-Length: ",filelength,STRING(NewLine$Lisp)$Lisp,STRING(NewLine$Lisp)$Lisp,file]

changed:
-       file := concat ["Content-Type: application/xhtml+xml",STRING(NewLine$Lisp)$Lisp,file]
       file := concat ["Content-Type: ",contentType,STRING(NewLine$Lisp)$Lisp,file]

added:
       file := concat [file,filestream]

added:
       WriteLine("getFile end")$Lisp
       WriteLine("")$Lisp

changed:
-       axans:String := concat ["<div><div class=_"command_">Input: ",command,"</div><div class=_"stepnum_">Step number: ",lastStep(),"</div><div class=_"algebra_">",algebra,"</div><div class=_"mathml_">",mathml,"</div><div class=_"type_">Type: ",lastType(),"</div></div>"]
--       axans:String := concat ["<div><div class=_"command_">(",lastStep(),") -> ",command,"</div><div class=_"algebra_">",algebra,"</div><div class=_"mathml_">",mathml,"</div><div class=_"type_">Type: ",lastType(),"</div></div>"]
       axans:String := concat ["<div class=_"stepnum_">", lastStep(), "</div><div class=_"command_">", command, "</div><div class=_"algebra_">",algebra,"</div><div class=_"mathml_">",mathml,"</div><div class=_"type_">",lastType(),"</div>"]       

added:

   getContentType(pathvar:String):String ==
       WriteLine("getContentType begin")$Lisp
       -- set default content type
       contentType:String := "text/plain"
       -- need to test for successful match?
       StringMatch(".*\.(.*)$", pathvar)$Lisp
       u:UniversalSegment(Integer)
       u := segment(MatchBeginning(1)$Lisp+1,MatchEnd(1)$Lisp)$UniversalSegment(Integer)
       extension:String := pathvar.u
       WriteLine$Lisp concat ["file extension: ",extension]
       -- test for extensions: html, htm, xml, xhtml, js, css
       if extension = "html" then
           contentType:String := "text/html"
       else if extension = "htm" then
           contentType:String := "text/html"
       else if extension = "xml" then
           contentType:String := "text/xml"
       else if extension = "xhtml" then
           contentType:String := "application/xhtml+xml"
       else if extension = "js" then
           contentType:String := "text/javascript"
       else if extension = "css" then
           contentType:String := "text/css"
       else if extension = "png" then
           contentType:String := "image/png"
       else if extension = "jpg" then
           contentType:String := "image/jpeg"
       else if extension = "jpeg" then
           contentType:String := "image/jpeg"
       WriteLine$Lisp concat ["Content-Type: ",contentType]
       WriteLine("getContentType end")$Lisp
       contentType


removed:
-\section{Axiom javascript}
-
-The javascript is currently included in a "script" element in the
-Axiom xml page.
-
-<<axiom javascript>>=
-
-function init() {
-}
-
-
-function makeRequest() {
-//    The following instantiation of the XMLHttpRequest object is for
-//    browsers other than IE.  IE requires something different.
-   http_request = new XMLHttpRequest();
-   var command = document.getElementById('comm').value;
-   http_request.open('POST', '127.0.0.1:8085', true);
-   http_request.onreadystatechange = handleResponse;
-//    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-//    http_request.send("command="+encodeURIComponent(command));
-   http_request.setRequestHeader('Content-Type', 'text/plain');
-   http_request.send("command="+command);
-}
-
-function handleResponse() {
-   if (http_request.readyState == 4) {
-       if (http_request.status == 200) {
-// stick response in div=mathBox
-           var mathString = http_request.responseText;
-           var mathRange = document.createRange();
-           var mathBox = document.createElementNS('http://www.w3.org/1999/xhtml','div');
-           mathRange.selectNodeContents(mathBox);
-           var mathFragment = mathRange.createContextualFragment(mathString);
-           mathBox.appendChild(mathFragment);
-// set id on mathBox
-//          var stepNum = mathBox.firstChild.firstChild.data;
-//          mathBox.setAttribute('id', 'step'+stepNum);
-//          mathBox.setAttribute('class', 'mathbox');
-// remove old mathbox
-           document.getElementById('mathAns').removeChild(document.getElementById('mathAns').firstChild)
-
-// insert everything into the document
-
-           document.getElementById('mathAns').appendChild(mathBox);
-
-// delete linenum box
-//            mathBox.removeChild(mathBox.firstChild);
-
-       } else
-       {
-           alert('There was a problem with the request.'+ http_request.statusText);
-       }
-   }
-}
-
-@
-
-\section{Axiom xml}
-
-Extract the Axiom xml interface page with the commmand
-
-notangle -RAxiom$\backslash$ xml axserver.pamphlet $>$ axiom.xml
-
-or in fact make the file name whatever you like instead of
-"axiom.xml".
-
-<<Axiom xml>>=
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-<<license-xml>>
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" [
-<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
-<!ENTITY InvisibleTimes " ">
-]>
-
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">
-
-<head>
-<title>Axiom Interface</title>
-&lt;disabled script type="text/javascript"&gt;
-<<axiom javascript>>
-&lt;disabled /script&gt;
-
-</head>
-
-<body id="body">
-
- <form id="commreq" action="javascript:makeRequest();">
-   <p>
-     Enter command: <input type="text" id="comm" name="command" size="80"/>
-     <input type="submit" value="submit command"/>
-   </p>
- </form>
-
-<div id="mathAns"><div></div></div>
-
-
-
-</body>
-
-</html>
-
-@
-

removed:
-

added:
or you can run inside axiom:

)read axserver.input

\subsection{axserver.input}

<<axserver.input>>=
)set mes auto off
)set out mathml on
)lisp (load "http.lisp")
)compile axserver.spad
axServer(8085, multiServ)$AXSERV
@

removed:
-
-<<license-xml>>=
- Copyright (c) 2007 Arthur C. Ralfs
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
-     - Redistributions of source code must retain the above copyright
-       notice, this list of conditions and the following disclaimer.
-
-     - Redistributions in binary form must reproduce the above copyright
-       notice, this list of conditions and the following disclaimer in
-       the documentation and/or other materials provided with the
-       distribution.
-
-     - Neither the name of Arthur C. Ralfs nor the
-       names of its contributors may be used to endorse or promote products
-       derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-@

Download: pdf dvi ps src tex log