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: Sat, 11 Jan 2014 17:26:21 -0700 Message-ID: <874n5ayriq.fsf@gmail.com> References: <87zjn24cgx.fsf@gmail.com> <87mwj2ywy2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W28ua-0006hv-5C for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 19:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W28uV-0007Ia-Q2 for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 19:28:20 -0500 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:54504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W28uV-0007IV-DK for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 19:28:15 -0500 Received: by mail-pa0-f52.google.com with SMTP id kx10so2390494pab.39 for ; Sat, 11 Jan 2014 16:28:14 -0800 (PST) In-Reply-To: (John Hendy's message of "Sat, 11 Jan 2014 17:22:58 -0600") 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 John Hendy writes: > On Sat, Jan 11, 2014 at 4:29 PM, Eric Schulte wrote: >>> >>> The "Hello world" example worked splendidly for me out of the box. I'm >>> having a bit of difficulty with serving up a file via this example: >>> http://eschulte.github.io/emacs-web-server/File-Server.html#File-Server >>> >>> Perhaps I don't understand how the function is supposed to work... It >>> says that the docroot is the current working directory in the example, >>> so I cd'd to a directory with an .html file in it, started `emacs -Q` >>> from the command line, ran `M-x load-file RET ~/.emacs`, and then >>> evaluated the code from the example in the *scratch* buffer. I'm >>> getting the 404 error. Should I be modifying that code somehow? >>> >> >> Since the value of the default-directory variable may not be easy to >> predict, you're probably better off changing >> >> (docroot default-directory) >> >> to >> >> (docroot "/full/path/to/directory/of/org/files") >> >> I only used default-directory in the example because I couldn't think of >> a good static path which would probably exist on most people's systems. > > Hmmm. Still having trouble. I tried: > > (lexical-let ((docroot "/home/jwhendy/Desktop/e-web-server-test")) > (ws-start > (list (cons (cons :GET ".*") > (lambda (request) > (with-slots (process headers) request > (let ((path (substring (cdr (assoc :GET headers)) 1))) > (if (ws-in-directory-p docroot path) > (ws-send-file process (expand-file-name path docroot)) > (ws-send-404 process))))))) > 9003)) > > That directory contains just two .org files. When I open > localhost:9003, it downloads a file called `download`, containing the > following: > > HTTP/1.1 500 Internal Server Error > Content-type: text/plain > > Caught Error: (error "IO error reading > /home/jwhendy/Desktop/e-web-server-test: Is a directory") > > So, I then tried with the first line like so (trailing slash): > > (lexical-let ((docroot "/home/jwhendy/Desktop/e-web-server-test/")) > > Then I'm back to the 404 error. Sorry if I'm being dense and didn't > follow something else implied. I noticed the tutorial mentioned > mime-types. Do I need to set something with xdg-mime for .org files or > do anything else other than simply doing (require 'web-server)? > > Since the hello world example worked, I'm assuming the setup is at > least partially sound. > Oh, the example is confusing, I just updated both the example and the documentation. The problem is that the example serves files, but not directory listings. So since you just requested "/" it said there was nothing there. If you pull down the latest version of the web-server that example will now give a directory listing when "/" is requested. > > I did wonder why I get no completions for `M-x ws-TAB`. Should emacs > be aware of ws-* functions? Or is that not how one would run them > (e.g. M-x something is actually a command, not a function and my > nomenclature is incorrect)? > Because none of the ws-* functions are commands, they are all functions (meaning they don't have an interactive spec). If you do `M-x describe-function ws-TAB' you'll see a completion list. This is because ws-* functions are all meant to be used from source code, not called with M-x. If you think any should have an interactive spec added please let me know. Thanks, > > > Thanks, > John > >> >>> >>> >>> Thanks and great work -- this is really neat! >> >> Thanks, and please do let me know if anything else doesn't work as >> expected. >> >> Best, >> >>> >>> John >>> >>> >>>> Best, >>>> >>>> Footnotes: >>>> [1] https://github.com/eschulte/emacs-web-server >>>> >>>> [2] http://eschulte.github.io/emacs-web-server/tutorials/#sec-1 >>>> >>>> [3] http://eschulte.github.io/emacs-web-server/Org_002dmode-Export.html#Org_002dmode-Export >>>> >>>> [4] https://github.com/eschulte/emacs-web-server/blob/master/examples/013-org-export-service.el >>>> >>>> [5] https://github.com/eschulte/emacs-web-server/blob/master/examples/011-org-agenda.el >>>> >>>> [6] https://github.com/eschulte/org-ehtml >>>> >>>> [7] http://eschulte.github.io/emacs-web-server/benchmark/ >>>> >>>> -- >>>> Eric Schulte >>>> https://cs.unm.edu/~eschulte >>>> PGP: 0x614CA05D >>>> >> >> -- >> Eric Schulte >> https://cs.unm.edu/~eschulte >> PGP: 0x614CA05D -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D