From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [ANN, OT] Emacs web-server, a new option for serving Org-mode files Date: Sun, 12 Jan 2014 09:21:06 -0700 Message-ID: <87vbxpnpcd.fsf@gmail.com> References: <87zjn24cgx.fsf@gmail.com> <87mwj2ywy2.fsf@gmail.com> <874n5ayriq.fsf@gmail.com> <878uumt17y.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Noj-0001BI-Is for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 11:23:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2Noe-0002lG-So for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 11:23:17 -0500 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:38682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Noe-0002l1-Ka for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 11:23:12 -0500 Received: by mail-pd0-f176.google.com with SMTP id r10so2515743pdi.21 for ; Sun, 12 Jan 2014 08:23:11 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Hendy Cc: Org Mode Mailing List > > I tried two things: > > ;;; file-server.el --- serve any files using Emacs Web Server > (lexical-let ((docroot "/home/jwhendy/Desktop/e-web-server-test/")) > (ws-start > (lambda (request) > (with-slots (process headers) request > (let ((path (substring (cdr (assoc :GET headers)) 1))) > (if (ws-in-directory-p docroot path) > (if (file-directory-p path) > (ws-send-directory-list process > (expand-file-name path docroot) "^[^\.]") > (ws-send-file process (expand-file-name path docroot))) > (ws-send-404 process))))) > 9003)) > > - If I go to localhost:9003, I get 404 not found. Surprising, I don't see that locally, and I don't see how that could be the case. > > - If I go to localhost:9003/personal.org (I threw my non-work notes > file into that directory), it downloads the file. > This is expected. Note, you could serve other file types as well, what this example was meant to illustrate is how the web-server will set the mime-type appropriately based on the file type (e.g., serving foo.jpg with the "image/jpeg" type). If you only care about Org-mode files, maybe look at example 7. > > Next, I replaced the first line with a full path to personal.org: > > (lexical-let ((docroot "/home/jwhendy/Desktop/e-web-server-test/personal.org")) > This makes no sense. The docroot should be a directory. > > Now I get the following error (in the browser) for localhost:9003: > > Caught Error: (void-function ws-send-directory-list) > > If I do localhost:9003/personal.org, it also downloads the file. > > > I feel I must be drastically overcomplicating this somehow... > I've pushed up a small fix to the directory listing which I originally wrote too quickly last night. If you do want to serve files like this locally then it is probably worth it to update your web-server install and try again. If you do update make sure you stop old servers before starting new ones, e.g., by executing the following. (mapc #'ws-stop ws-servers) > > > Thanks again for persisting with me! Sure thing. Sorry if a bug in my hastily written directory listing made things more confusing than they needed to be. > > John > > [snipped emacs terminology discussion] > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D