Permalink
Browse files

""

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@12 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent d5201c6 commit 67a6c13699ca8b33e71e909fdbaa216af1aa5aaf @klacke committed Feb 12, 2002
Showing with 120 additions and 190 deletions.
  1. +25 −1 src/yaws_api.erl
  2. +2 −7 www/EXHEAD
  3. +3 −7 www/TOPTAB
  4. +7 −3 www/configuration.yaws
  5. +58 −19 www/dynamic.yaws
  6. +3 −1 www/examples.yaws
  7. +0 −91 www/index.html
  8. +14 −7 www/index.yaws
  9. +4 −4 www/motivation.yaws
  10. +4 −5 www/todo.yaws
  11. +0 −45 www/top.yaws
View
@@ -9,6 +9,7 @@
-author('klacke@hyber.org').
-compile(export_all).
+-include("yaws.hrl").
%% these are a bunch of function that are useful inside
%% yaws scripts
@@ -71,7 +72,11 @@ do_parse_spec(<<>>, Spec, Last, Cur, State) ->
[S|Ss] = tail_spec(Spec),
[{Last, coerce_type(S, Cur)}];
do_parse_spec(undefined,_,_,_,_) ->
- [].
+ [];
+do_parse_spec(QueryList, Spec, Last, Cur, State) when list(QueryList) ->
+ do_parse_spec(list_to_binary(QueryList), Spec, Last, Cur, State).
+
+
tail_spec(['ALLSTRINGS']) ->
@@ -147,3 +152,22 @@ code_to_phrase(503) -> "Service Unavailable";
code_to_phrase(504) -> "Gateway Timeout";
code_to_phrase(505) -> "HTTP Version Not Supported".
+
+
+%%
+%% server side include
+%%
+
+ssi(DocRoot, Files) ->
+ L = lists:map(fun(F) ->
+ case file:read_file([DocRoot ++ [$/|F]]) of
+ {ok, Bin} ->
+ Bin;
+ {error, Reason} ->
+ io_lib:format("Cannot include file ~p", [F])
+ end
+ end, Files),
+ {ok, L}.
+
+
+
View
@@ -49,7 +49,7 @@
</HEAD>
<BODY BGCOLOR="#C6C6B5" text="#333333">
-
+<IMG SRC="/icons/yaws_head.gif" width=600 ALT="YAWS">
<table border="0" cellpadding="5" cellspacing="0" height="100%">
<tr>
@@ -65,9 +65,4 @@
<A HREF="mnesiacluster.yaws">-Using Mnesia DBMS to keep cookie state in a cluster </a><br><hr>
</td>
- <td valign=top><IMG SRC="/icons/yaws_head.gif" ALT="Yaws">
- <p></p>
-
- </td>
- </tr>
- </table>
+ <td valign=right width=75%>
View
@@ -1,7 +1,8 @@
+<IMG SRC="/icons/yaws_head.gif" width=600 ALT="YAWS">
<table border="0" cellpadding="5" cellspacing="0" height="100%">
<tr>
- <td valign=top BGCOLOR="#B6B6A5">
+ <td valign=top width=15% BGCOLOR="#B6B6A5">
<IMG SRC="spacer.gif" width=1 height=74 ALT=""><p></p>
<A HREF="index.yaws">- Top Page</a><br><hr>
<A HREF="configuration.yaws">-Configuring and Building Yaws</a><br><hr>
@@ -14,10 +15,5 @@
<A HREF="contacts.yaws">-Contacts </a><br><hr>
</td>
- <td valign=top><IMG SRC="/icons/yaws_head.gif" ALT="YAWS">
- <p></p>
-</td>
-
- </tr>
- </table>
+ <td valign=right width=75%>
View
@@ -2,9 +2,8 @@
<erl>
out(A) ->
- {ok, B1} = file:read_file([A#arg.docroot, "/HEAD"]),
- {ok, B2} = file:read_file([A#arg.docroot, "/TOPTAB"]),
- {ok, [B1, B2]}.
+ yaws_api:ssi(A#arg.docroot, ["/HEAD", "/TOPTAB"]).
+
</erl>
@@ -60,3 +59,8 @@ documentaion will also be copied there.
</ul>
+
+
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/END"]).
+</erl>
View
@@ -2,9 +2,8 @@
<erl>
out(A) ->
- {ok, B1} = file:read_file([A#arg.docroot, "/HEAD"]),
- {ok, B2} = file:read_file([A#arg.docroot, "/TOPTAB"]),
- {ok, [B1, B2]}.
+ yaws_api:ssi(A#arg.docroot, ["/HEAD", "/TOPTAB"]).
+
</erl>
@@ -48,29 +47,46 @@ an uncontrolled way.
</ul>
<h2>The argument</h2>
-The <tt>/out/1</tt> function is supplied with a record argument. The
+The <tt>out/1</tt> function is supplied with a record argument. The
definition of that record is automatically included in the embedded erlang code
and the record definition is:
<xmp>
+
-record(arg, {
clisock, %% the socket leading to the peer client
- method, %% HTTP method, GET, POST ...
- urlpath, %% path in the request
- version, %% HTTP client version {1,0} or {1,1} ....
- accept, %% HTTP Accept header
- host, %% HTTP Host header in client req
- referer, %% HTTP Referer header
- user_agent, %% HTTP User-Agent header
- cookie, %% HTTP Cookie: header
- clidata, %% The client data (as a binary in HTTP requests)
- %% Typically POST requests
- docroot
+ h, %% headers
+ req, %% request
+ clidata, %% The client data (as a binary in POST requests)
+ querydata, %% Was the URL on the form of ....?query (GET reqs)
+ docroot %% where's the data
}).
-
+
+-record(http_request, {method,
+ path,
+ version}).
+
+
+-record(headers, {
+ connection,
+ accept,
+ host,
+ if_modified_since,
+ if_match,
+ if_none_match,
+ if_range,
+ if_unmodified_since,
+ range,
+ referer,
+ user_agent,
+ accept_ranges,
+ cookie = [],
+ keep_alive,
+ content_length}).
+
</xmp>
@@ -82,7 +98,7 @@ We have:
<ul>
<li><tt>some_headers(Arg)</tt> which can be used to generate optional
headers such as Set-Cookie.
-<li><tt>all_headers(Arg)</tt> whhich can be used to generate both the
+<li><tt>all_headers(Arg)</tt> which can be used to generate both the
HTTP status line as well as all the HTTP headers. This can be used to
do for example HTTP redirections.
@@ -105,12 +121,35 @@ We have:
<br>
<ul>
-<li> <tt>parse_post_dataBin, Spec)</tt> <br>
+<li> <tt> parse_post_data(Bin, Spec) </tt> <br>
When data is POSTed to a yaws page, this function can be used to parse the
data in a convenient way. Data which is posted from a form is naturally
arranged as a list of key,value pairs.
+<p> Similarly, when data is fed to a yaws page in the URL as a query part,
+the query can be parsed by this function. <br>
+
+
+<li> <tt> code_to_phrase(Code) </tt> <br>
+Makes a mapping from HTTP status codes to HTTP status code phrases. <br>
+
+
+<li> <tt> ssi(DocRoot, FileList) </tt>
+Server side include. <br>
+
+
+<li> <tt> redirect(Url) </tt> <br>
+This function must be called in the first chunk of erlang coe in a yaws file.
+Furthermore, it must be called from the <tt>all_headers/1</tt> function.
+It will generate a redirect responce to the client.
+<br>
+
+
+
</ul>
-</html>
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/END"]).
+</erl>
+
View
@@ -15,4 +15,6 @@ It can be used to generate any dynamic content, and also, combining Yaws with
the Erlang DBMS Mnesia, we can easily connect persitant data to a Cookie.
-</html>
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/END"]).
+</erl>
View
@@ -1,91 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<HTML>
-<HEAD>
- <meta name="keywords" content="Yaws">
-
-
- <TITLE>HYBER.ORG</TITLE>
-
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
-<STYLE TYPE="text/css">
- BODY {
- background: #C6C6B5;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- color: black;
- }
-
-#menu {
- background: #B6B6A5;
-}
-
- div.links {
- background: green;
- }
-
- H1, H2, H3, H4, H5 {
- text-decoration: none;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: bold;
- font-variant: small-caps
- }
- I { font-family: Times, Verdana, Arial, Helvetica, sans-serif;}
- P { text-decoration: none;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: normal;
- }
- UL { margin-left: -2em }
-
- A { text-decoration: none;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: normal;
- }
- A:visited { font-style: oblique; color: #600000;}
- A:link { color: #0000f0 } /* unvisited link */
- A:active { color: lime } /* active links */
-
-</STYLE>
-
-</HEAD>
-<BODY BGCOLOR="#C6C6B5" text="#333333">
-
-
-<table border="0" cellpadding="5" cellspacing="0" height="100%">
-<tr>
- <td valign=top BGCOLOR="#B6B6A5">
- <IMG SRC="spacer.gif" width=1 height=74 ALT=""><p></p>
- <A HREF="index.html">Top Page</a><br>
- <A HREF="configuration.html"> Configuring and Building Yaws</a><br>
- <A HREF="dynamic.html">Generationg dynamic content</a><br>
- <A HREF="examples.html"> Examples</a><br>
- <A HREF="features.html">Features in yaws</a><br>
- <A HREF="todo.html"> TODO list </a><br>
- <A HREF="contacts.html"> Contacts </a><br>
- </td>
-
- <td valign=top><IMG SRC="hyber_org.jpg" width=800 ALT="Hyber">
- <p></p>
-
-
-
-
-<H2>Yaws - Yet Another Webserver</H2>
-
-
-<p>
-HYBER.ORG är helt enkelt namnet på datorn i vår trapp skrubb. En gammal utjänt utsliten
-Linux box som nu får köra apache, sendmail samt quake3 server.
-
-</p>
-
-<h4> hmmm.... </h4>
-
-
-<br><br><br><br>
-<center>
-<img src="talgoxe.jpg" border=0 width=170 height=170 ALT="hyber"> <br>
-<i> kostnärliga är vi dessutom i vår familj <i>
-</center>
-
-</HTML>
-
View
@@ -4,9 +4,8 @@
<erl>
out(A) ->
- {ok, B1} = file:read_file([A#arg.docroot, "/HEAD"]),
- {ok, B2} = file:read_file([A#arg.docroot, "/TOPTAB"]),
- {ok, [B1, B2]}.
+ yaws_api:ssi(A#arg.docroot, ["/HEAD", "/TOPTAB"]).
+
</erl>
@@ -51,7 +50,13 @@ powered by Yaws.
<h2>Build and install</h2>
-Yaws is hosted by the excellent source code base SourceForge <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=45637&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo"></a>. To cvs check out the latest source first install
+Yaws is hosted by the excellent source code site SourceForge <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=45637&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo"></a>.
+The SourceForge www page is <a href="http://sourceforge.net/projects/erlyaws/">http://sourceforge.net/projects/erlyaws</a>
+
+
+
+
+<p>To cvs check out the latest source first install
an <a href="http://www.erlang.org">Erlang</a> system, then do:
@@ -66,9 +71,11 @@ an <a href="http://www.erlang.org">Erlang</a> system, then do:
Will checkout the bleeding edge source, build it and install it at
127.0.0.1:80 with the docroot set to the local documentation.
+<p>
+Just make, will create a server which listens to localhost:8000.
<br>
-<hr>
-<IMG SRC="/icons/yaws_pb.gif" >
-</html>
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/END"]).
+</erl>
View
@@ -2,9 +2,7 @@
<erl>
out(A) ->
- {ok, B1} = file:read_file([A#arg.docroot, "/HEAD"]),
- {ok, B2} = file:read_file([A#arg.docroot, "/TOPTAB"]),
- {ok, [B1, B2]}.
+ yaws_api:ssi(A#arg.docroot, ["/HEAD", "/TOPTAB"]).
</erl>
@@ -18,7 +16,9 @@ that <a href="http://www.php.net"> php </a> was designed in such a horrible
way that I simply refused to use it.
-</html>
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/END"]).
+</erl>
Oops, something went wrong.

0 comments on commit 67a6c13

Please sign in to comment.