Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 217 lines (194 sloc) 7.419 kB
a9fb877 @nicferrier add elnode.org to the repo
authored
1
aff1389 @nicferrier start storing all our planning in the org file
authored
2 * planned FAQ
3 ** FAQ for installation
4 *** why does it not start?
5 **** have you got something running on port 8000?
6 **** how to change the port and restart
7
937a298 @nicferrier updated FAQ
authored
8 ** programming
9 *** what's a hello world handler look like?
10 **** the simplest elnode handler is
11 (defun hello-world (httpcon)
12 (elnode-send-html httpcon "Hello World"))
13
14 *** how do I start a handler?
15 **** using M-x elnode-start [RET] handler-name
16 ***** the handler-name is any function
17 ***** it will complete in the normal minibuffer way
18 *** how can I make a handler serve some static files?
19 **** so easy, like this:
20 (setq my-webserver-handler (elnode-webserver-handler-maker "~/directory"))
21 *** what if I want to do something a bit unusual to the file before it's served? like tempalting
22 **** you need to write a proper handler for that
23 **** let's say you want to replace {{{name}}} with a single word
24 (defun my-files-handler (httpcon)
25 (elnode-docroot-for DIRECTORY
26 with target-filename
27 on httpcon
28 do
29 (with-current-buffer (find-file-noselect target-filename)
30 (elnode-http-start httpcon 200 '("Content-type" . "text/html"))
31 (elnode-http-return
32 httpcon
33 (replace-regexp-in-string "{{{\\(.*\\)}}}" "bleh"
34 (buffer-substring (point-min) (point-max)))))))
35 *** the logging is crazy, can I turn if off?
36 **** yep.
37 M-x customize-variable [RET] elnode-log-files-directory
38 **** and
39 M-x customize-variable [RET] elnode-error-log-to-messages
40 **** are 2 interesting ones
41
aff1389 @nicferrier start storing all our planning in the org file
authored
42 ** Other questions
43 *** What if my friends laugh at me for running a web browser in my editor?
44 **** Get better friends? #emacs is a good source of fun people
45 **** Alternately start a new business that uses elnode and pisses on the competition
46 ***** because it is faster and more reliable.
47 ***** then buy new friends.
48 **** Or go back to using Ruby because Ruby is, ya know, really cool. Like your friends say.
49
50
51 * auth stuff
52 ** things auth requires
53 *** test
54 **** are you currently authenticated?
55 **** most often this is testing a cookie
56 **** on success do whatever you were going to do
57 *** failure action
58 **** redirect to a login page
59 **** serve a login page
60
61 ** login pages
62 *** test
63 **** are the credentials correct?
64 *** success
65 **** set a token to remember the request somehow
66 ***** store something in the server?
67 ****** so you can validatethe auth
68 ******* login makes token
69 ******* store token against username
70 ******* put token:username:server-secretkey on cookie
71 *******
72 **** redirect to some page
73 ***** maybe identified by a parameter or the referrer
74 *** failure
75 **** redirect to a login failed page
76 **** return the same page with errors
77 *** links
78 **** registration page
79
80
81 (with-elnode-auth
82 (:test cookie
83 :cookie-name my-auth
84 :failure-type redirect
85 :redirect "/mylogin")
86 ...)
87
88 :redirect could be:
89
90 a string - which would point to a relative or absolute url which must
91 be mapped indepentently
92
93 a (dispatcher . handler) pair - a cons of a dispatcher and a handler,
94 the dispatcher is automatically wrapped with a detector for a url
95 that serves the handler
96
97 a (dispatcher handler string) list - as for the
98 dispatcher/handler cons but with the addition of the string to name
99 the url to login
100
101 ** idea about data/handlers
102 *** for login, the processing of the authentication request (the username and password check) is the bit we can specify as part of the auth system
103 **** it goes
104 ***** get a username/password
105 ****** and possibly other things like "cookie approval"
106 ***** check against database
107 ****** plus any other rules, like "cookie approval is yes"
108 ***** make cookie
109 ***** redirect to wherever we were supposed to be redirecting
110 ****** this could have been specified
111 ******* as a parameter
112 ******* or it could be fixed
113 ******* or looked up in the server side environment
114 *** the bit we can't specify
115 **** the look of the login page
116 **** or even the url of the login page
117 **** or how the login page works
118 ***** we need to be able to support AJAX login
119 ***** so you can login from the main page and from non-contextual flows
120 *** it's frustrating because the only thing we care about on the login page is
121 **** the login form, which is very specifiable
122 **** particularly the url which the form POSTs to
123 ***** which must have our auth handler on the end of it
124 *** so we need a high level abstraction for dealing with this
125 *** if we could specify interactive elements, like FORMs as
126 **** a description of the data
127 **** possibly a template
128 ***** it should be possible to have a default template
129 ***** client side template?
130 **** the handler code to handle the call
131 *** and then have those wrap in the same way as the (dispatcher . handler) form above
132 *** reasons this would be good
133 **** the separate description of the data means it could be used for ajax and context pages
134 **** the template is optional
135 ***** maybe we could have contextual templates as well
136 ****** a template for ajax
137 ****** a template for page
138 **** the authentication processor is probably fixed
139 **** this could be the tip of a larger abstraction to do better website building
140
141 how about we make a function to return a wrap spec?
142
143 like this:
144
145 (with-elnode-auth
146 (:test cookie
147 :cookie-name my-auth
148 :failure-type redirect
149 :redirect (elnode-make-auth-wrap 'my-app form-template))
150 ...)
151
152 where (elnode-make-auth-wrap to-wrap template &optional path)
153 => '(my-app (lambda (httpcon) (do-something-with template)) path)
154
155 ** templates for auth - capturing some thoughts
156 *** the current vogue is for mustache like templates
157 *** these are dumb text replacers
158 *** I prefer sed/xslt like templates
159 **** not dumb, but more introspectively transformative
160 *** can we make a simpler, less generic, transform language than xslt?
161 *** it needs to transform data, such as json into HTML or XML
162 *** things it might be
163 **** a sequence of rules
164 ***** for this bit of data, do this
165 ****** { "password": "" } -> <label for="login_password">Password:</label><input id="login_password" type="password" name="password"/>
166 ***** questions about this
167 ****** what's the pattern matching language???
168 ****** how do we link the "things" together?
169 ******* eg: BR tags?
170 ******* wrapping individually in DIVs?
171 **** a bunch of associated rules
172 ***** wrap everything we produce in some tag
173 ****** eg: FORM tags
174
175
176 * v0.9.9 todo
177 ** new async stuff with RLE
178 ** default wiki page and webserver root
a9fb877 @nicferrier add elnode.org to the repo
authored
179
61d59cd @nicferrier what we might need in the screencasts
authored
180 * screencasts
181 ** introducing elnode
182 *** start with plain emacs24
183 *** install marmalade
184 *** install elnode
185 *** what does elnode do out of the box?
186 **** webserver
187 **** wiki
188 **** auth database
189 **** logging
190 ** programming with elnode
57bb600 @nicferrier details on screencasts
authored
191 *** start with some files
192 *** make a webserver with elnode-webserver-handler-maker
61d59cd @nicferrier what we might need in the screencasts
authored
193 *** org-mode
6d47fca @nicferrier some stuff about chat
authored
194 ** chat
195 *** what do you need?
196 **** a list to store chat
197 ***** a list of triples? (username date text)
198 **** a handler to receive the chats
199 ***** a POST or something
200 **** a handler for people to call to wait and receive chats
201 ***** should use elnode-defer-or-do to check for new chats
a9fb877 @nicferrier add elnode.org to the repo
authored
202 * v1.00 todo
203 ** stuff
204 *** vagrant image
205 *** heroku update
206 **** vulcan helps build the version of unix you need to host the build pack
207 ***** http://quickleft.com/blog/hacking-heroku-with-custom-build-packs
208 **** the buildpack
209 ***** https://github.com/technomancy/heroku-buildpack-emacs/tree/master/bin
210 *** ami?
211 ** code
212 *** defer bugs?
213 *** logging to processes
214 *** client server stuff
215 *** htmlize bugs?
aff1389 @nicferrier start storing all our planning in the org file
authored
216 **** these seem to be fixed by new creole
Something went wrong with that request. Please try again.