Skip to content

Commit

Permalink
improved default pages and config
Browse files Browse the repository at this point in the history
  • Loading branch information
nicferrier committed Aug 7, 2012
1 parent 0328d54 commit bca3da1
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 3 deletions.
Binary file added default-webserver-image.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions default-webserver-test.html
Expand Up @@ -3,13 +3,18 @@
<h1>This is Elnode's Test HTML file</h1>
<p>If you are reading this then most likely Elnode is working ok.</p>

<p>This file is normally stored in the package directory which can be found in</p>
<p>This file is normally stored in the user's directory. It can
normally be found in:</p>

<pre>
~/.emacs.d/elpa
~/.emacs.d/elnode
</pre>

<p>To learn more about Elnode visit <a href="http://elnode.org">the website</a>.</p>

<p>Just to show that Elnode will serve anything, here's a png:</p>

<img src="emacs.png"/>

</body>
</html>
106 changes: 106 additions & 0 deletions default-wiki-index.creole
Expand Up @@ -3,3 +3,109 @@
This is Elnode's Wiki. It is based on the {{{creole}}} wiki language
and is written completely in EmacsLisp.

== What does it do? ==

It does syntax coloring:

{{{
##! emacs-lisp
(defun elnode-wiki-handler (httpcon wikiroot)
"A low level handler for Wiki operations.
Send the Wiki page requested, which must be a file existing under
the WIKIROOT, back to the HTTPCON.
Update operations are protected by authentication."
(elnode-method httpcon
(GET
(elnode-docroot-for wikiroot
with target-path
on httpcon
do
(if (equal target-path (expand-file-name (concat wikiroot "/")))
(elnode-wiki-page httpcon (concat wikiroot "/index.creole"))
(elnode-wiki-page httpcon target-path))))
(POST
(elnode-with-auth httpcon 'elnode-wiki-auth
(let* ((path (elnode-http-pathinfo httpcon))
(text (elnode-wiki--text-param httpcon)))
(if (not (elnode-http-param httpcon "preview"))
;; A save request in which case save the new text and then
;; send the wiki text.
(elnode-wiki--save-request httpcon wikiroot path text)
;; Might be a preview request in which case send back the WIKI
;; text that's been sent.
(with-temp-file "/tmp/preview"
(insert text))
(elnode-wiki-send httpcon "/tmp/preview" path)))))))
}}}

It does links, for example to
[[http://github.com/nicferrier/elwikicreole|Emacs Creole]] which is
the Wiki render engine used to display pages.

It does all the normal Wiki things like headings and lists.

You can also do some special Emacs things, like org-mode tables:

| Date | Amount | Description |
|------------+--------+---------------------|
| 2011-11-15 | 100.15 | Expensive lunch out |
| 2011-11-18 | 7.30 | Dry cleaning |
| 2011-11-21 | 22.50 | Takeaway curry |
|------------+--------+---------------------|
| | 129.95 | |
#+TBLFM: @5$2=vsum(@I..@II)

and lisp callouts:

<<(
(mapconcat
(lambda (s)
(format "* %s" s))
'("which" "eval" "lisp" "and" "render" "the" "results")
"\n")
)>>


== Authentication ==

By default, the Wiki uses an authentication database in the Emacs
instance running Elnode and the Wiki server.

If you want to add a user to the Wiki so you can edit pages you can do this in Emacs:

{{{
M-x elnode-auth-user-add
}}}

and it will ask you for a username and a password. The user will be
stored in a persistent database.


== Where the Wiki pages are ==

By default the Elnode Wiki stores files in your {{{~/.emacs.d}}}
directory which is actually defined by the variable
{{{user-emacs-directory}}} in Emacs.

There is normally a directory {{{elnode}}} in that directory which
contains directories for the Web server document root and the Wiki.

The location of the Wiki files can be configured though, try:

{{{
M-x customize-variable [RET] elnode-wikiserver-wikiroot
}}}

== More customization ==

There are many other things in Elnode's Wiki that can be customized,
including the header and footer. Use:

{{{
M-x customize-group [RET] elnode-wikiserver [RET]
}}}

There is more to do with the Elnode Wiki server because there is so
much that Emacs can do.
18 changes: 17 additions & 1 deletion elnode.el
Expand Up @@ -76,6 +76,18 @@ This is an alist of proc->server-process:
(port . process)")

;;;###autoload
(defconst elnode-config-directory
(expand-file-name (concat user-emacs-directory "elnode/"))
"The config directory for elnode to store peripheral files.
This is used as a base for other constant directory or file
names (the elnode auth database is a file in this directory, the
elnode webserver has a docroot directory in this directory).
It is based on the `user-emacs-directory' which always seems to
be set, even when emacs is started with -Q.")


;; Error log handling

Expand Down Expand Up @@ -2333,7 +2345,11 @@ off the standard webserver indexing in elnode's webserver."
(elnode--dir-setup elnode-webserver-docroot
elnode-webserver-docroot-default
"default-webserver-test.html"
"test.html"))
"test.html")
(elnode--dir-setup elnode-webserver-docroot
elnode-webserver-docroot-default
"default-webserver-image.png"
"emacs.png"))

(defun elnode-url-encode-path (path)
"Return a url encoded version of PATH.
Expand Down

0 comments on commit bca3da1

Please sign in to comment.