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: Sat, 11 Jan 2014 18:53:21 -0700	[thread overview]
Message-ID: <878uumt17y.fsf@gmail.com> (raw)
In-Reply-To: <CA+M2ft9e_n9B6n0r9ukU8QCojj-Nyw3yNLf4VRk2Tqh0FQKYRg@mail.gmail.com> (John Hendy's message of "Sat, 11 Jan 2014 19:10:17 -0600")

John Hendy <jw.hendy@gmail.com> writes:

> On Sat, Jan 11, 2014 at 6:26 PM, Eric Schulte <schulte.eric@gmail.com> wrote:
>> John Hendy <jw.hendy@gmail.com> writes:
>>
>>> On Sat, Jan 11, 2014 at 4:29 PM, Eric Schulte <schulte.eric@gmail.com> 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.
>
> So instead of a path, should I have provided a specific file name? I
> guess I was just going by the description: "The following example
> implements a file server which will serve files from..." Perhaps I'm
> still not understanding what, exactly, the web-server does!
>
> Do you point it to *a* file, or a directory containing numerous files?
>
> Or just to understand better, can you give a concrete example of what
> I could do with my example path which contains .org files (perhaps via
> the original code before you modified it, just so I understand the
> intent).
>
> Or should I have been doing something like http://localhost:9003/file.org?
>

Yes, the above would have worked with the original.  It assumed you
would give it a file name as the end of the URL.

>
>>
>>>
>>> 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.
>
> Gotcha -- indeed, it was my poor grasp of Emacs terminology :)
>
> Sorry for the denseness above. I'm not a super web guy, so I'm
> probably just getting hung up on poor understanding of the term "web
> server" and what exactly it would do in this context. For my limited
> Apache experience I suppose I always had an index.html with links
> elsewhere, so that's sort of the extent of my knowledge.
>

No problem, happy to help and I appreciate your feedback on what parts
are not obvious.

Best,

>
>
> Thanks for all the assistance!
> John
>
>>
>> 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

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

  reply	other threads:[~2014-01-12  1:55 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 [this message]
2014-01-12 14:40             ` John Hendy
2014-01-12 16:21               ` Eric Schulte
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=878uumt17y.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).