Update documentation for perl-lib and install-environment
authorChip Black <bytex64@bytex64.net>
Sat, 29 Mar 2014 20:24:41 +0000 (15:24 -0500)
committerChip Black <bytex64@bytex64.net>
Sat, 29 Mar 2014 20:24:41 +0000 (15:24 -0500)
www/css/doc.css
www/doc/index.html

index be17dda..1173b95 100644 (file)
@@ -11,6 +11,12 @@ h1, h2, h3, h4, h5 {
        clear: both;
 }
 
+pre {
+       background-color: #090909;
+       color: #F7F7F7;
+       padding: 0.5em;
+}
+
 .pizzapie {
        width: 25%;
        font-family: sans-serif;
index e98ef47..61b8035 100644 (file)
@@ -3,6 +3,7 @@
 <head>
 <title>Blërg Documentation</title>
 <link rel="stylesheet" href="/css/doc.css">
+<meta http-equiv="content-type" content="text/html; charset=utf8">
 </head>
 <body>
 
@@ -17,7 +18,7 @@ as either a standalone HTTP server, or a CGI.  Blërg is written in pure
 C.
 
 <ul class="toc">
-  <li><a href="#installing">Installing</a>
+  <li><a href="#running">Running Blërg</a>
     <ul>
       <li><a href="#getting_the_source">Getting the source</a></li>
       <li><a href="#requirements">Requirements</a></li>
@@ -43,6 +44,12 @@ C.
       <li><a href="#api_passwd">/passwd - Change a user's password</a></li>
     </ul>
   </li>
+  <li><a href="#libraries">Libraries</a>
+    <ul>
+      <li><a href="#lib_c">C</a></li>
+      <li><a href="#lib_perl">Perl</a></li>
+    </ul>
+  </li>
   <li><a href="#design">Design</a>
     <ul>
       <li><a href="#motivation">Motivation</a></li>
@@ -54,7 +61,7 @@ C.
   </li>
 </ul>
 
-<h2><a name="installing">Installing</a></h2>
+<h2><a name="running">Running Blërg</a></h2>
 
 <h3><a name="getting_the_source">Getting the source</a></h3>
 
@@ -123,26 +130,17 @@ reason, it's better to use a subdomain (i.e., blerg.yoursite.com is
 easier than yoursite.com/blerg/).  If you do want to put it in a
 subdirectory, you will have to modify <code>www/js/blerg.js</code> and
 change baseURL at the top as well as a number of other self-references
-in that file and <code>www/index.html</code>.  The CGI version should
-work fine this way, but the HTTP version will require the request to be
-rewritten, as it expects to be serving from the root.
+in that file and <code>www/index.html</code>.
 
 <p>You cannot serve the database and client from different domains
 (i.e., yoursite.com vs othersite.net, or even foo.yoursite.com and
 bar.yoursite.com).  This is a requirement of the web browser &mdash; the
 same origin policy will not allow an AJAX request to travel across
-domains.
-
-<h4>For the standalone web server:</h4>
+domains (though you can probably get around it these days with <a
+  href="http://en.wikipedia.org/wiki/Cross-origin_resource_sharing">Cross-origin
+  resource sharing</a>).
 
-<p>Right now, <code>blerg.httpd</code> doesn't serve any static assets,
-so you're going to have to put it behind a real webserver like apache,
-lighttpd, nginx, or similar.  Set the document root to the www
-directory, then proxy /info, /create, /login, /logout, /get, /tag, and
-/put to blerg.httpd.  You can change the port <code>blerg.httpd</code>
-listens on in <code>config.h</code>.
-
-<h4>For the CGI version:</h4>
+<h4>For straight CGI with Apache</h4>
 
 <p>Copy the files in www/ to the root of your web server.  Copy
 <code>blerg.cgi</code> to your web server.  Included in www-configs/ is
@@ -150,10 +148,47 @@ a .htaccess file for Apache that will rewrite the URLs.  If you need to
 call the CGI something other than <code>blerg.cgi</code>, the .htaccess
 file will need to be modified.
 
+<h4>For nginx</h4>
+
+<p>Nginx can't run CGI directly, and there's currently no FastCGI
+version of Blërg, so you will have to run it under some kind of CGI to
+FastCGI gateway, like the one described <a
+href="http://wiki.nginx.org/SimpleCGI">here on the nginx wiki</a>.  This
+pretty much destroys the performance of Blërg, but it's all we've got
+right now.
+
 <h4>The extra RSS CGI</h4>
 
 <p>There is an optional RSS cgi (<code>rss.cgi</code>) that will serve
 RSS feeds for users.  Install this like <code>blerg.cgi</code> above.
+As of 1.9.0, this is a perl FastCGI script, so you will have to make
+sure the perl libraries are available to it.  A good way of doing that
+is to install to an environment directory, as described below.
+
+<h4>Installing to an environment directory</h4>
+
+<p>The Makefile has support for installing Blërg into a directory that
+includes tools, libraries, and configuration snippets for shell and web
+servers.  Use it as <code>make install-environment
+  ENV_DIR=&lt;directory&gt;</code>.  Under &lt;directory&gt;/etc will be
+a shell script that sets environment variables, and configuration
+snippets for nginx and apache to do the same.  This should make it
+somewhat easier to use Blërg in a self-contained way.
+
+<p>For example, this will install Blërg to an environment directory
+inside your home directory:
+
+<pre>user@devhost:~/blerg$ make install-environment ENV_DIR=$HOME/blerg-env
+...
+user@devhost:~/blerg$ . ~/blerg-env/etc/env.sh
+</pre>
+
+<p>Then, you will be able to run tools like <code>blergtool</code>, and
+it will operate on data inside <code>~/blerg-env/data</code>.  Likewise,
+you can include
+<code>/home/user/blerg-env/etc/nginx-fastcgi-vars.conf</code> or
+<code>/home/user/blerg-env/etc/apache-setenv.conf</code> in your
+webserver to make the CGI/FastCGI scripts to the same thing.
 
 
 <h2><a name="api">API</a></h2>
@@ -357,6 +392,29 @@ the password matches, the user's password is set to
 If the password doesn't match, or one of <code>password</code> or
 <code>new_password</code> are missing, the server returns JSON failure.
 
+<h2><a name="libraries">Libraries</a></h2>
+
+<h3><a name="lib_c">C</a></h3>
+
+<p>Most of Blërg's core functionality is packaged in a static library
+called <code>blerg.a</code>.  It's not designed to be public or
+installed with `make install-environment`, but it should be relatively
+straightforward to use it in C programs.  Look at the headers under the
+<code>databse</code> directory.
+
+<p>A secondary library called <code>blerg_auth.a</code> handles the
+authentication layer of Blërg.  To use it, look at
+<code>common/auth.h</code>.
+
+<h3><a name="lib_perl">Perl</a></h3>
+
+<p>As of 1.9.0, Blërg includes a perl library called
+<code>Blerg::Database</code>.  It wraps the core and authentication
+functionality in a perlish interface.  The module has its own POD
+documentation, which you can read with your favorite POD reader, from
+the manual installed in an environment directory, or in HTML <a
+href="perl/Blerg-Database.html">here</a>.
+
 <h2><a name="design">Design</a></h2>
 
 <h3><a name="motivation">Motivation</a></h3>