emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: John Hendy <jw.hendy@gmail.com>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [ANN, OT] Emacs web-server, a new option for serving Org-mode files
Date: Sun, 12 Jan 2014 09:21:06 -0700	[thread overview]
Message-ID: <87vbxpnpcd.fsf@gmail.com> (raw)
In-Reply-To: CA+M2ft9_J8nyUjBLRTutdOsO0RszgBJfEMgbO12mOiq4MQX3tg@mail.gmail.com

>
> 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

  reply	other threads:[~2014-01-12 16:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 18:09 [ANN, OT] Emacs web-server, a new option for serving Org-mode files Eric Schulte
2014-01-11 19:12 ` Thomas S. Dye
2014-01-11 21:53   ` Eric Schulte
2014-01-12  1:12     ` Thomas S. Dye
2014-01-11 22:21 ` John Hendy
2014-01-11 22:27   ` David Belohrad
2014-01-11 22:33     ` Eric Schulte
2014-01-12 16:38       ` David Belohrad
2014-01-11 22:29   ` Eric Schulte
2014-01-11 23:22     ` John Hendy
2014-01-12  0:26       ` Eric Schulte
2014-01-12  1:10         ` John Hendy
2014-01-12  1:53           ` Eric Schulte
2014-01-12 14:40             ` John Hendy
2014-01-12 16:21               ` Eric Schulte [this message]
2014-01-16  0:51 ` Andrea Rossetti
2014-01-17 17:37   ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vbxpnpcd.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jw.hendy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).