Browse code
Add setup instructions
Ed Langley authored on 29/08/2019 18:34:41
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -1,5 +1,11 @@ |
1 | 1 |
#+TITLE: TODO backend implementation using CL and fukamachi/ningle |
2 | 2 |
|
3 |
+* Setup |
|
4 |
+ |
|
5 |
+ - src_sh{git clone https://github.com/fiddlerwoaroof/data-lens.git ~/quicklisp/local-projects/data-lens} |
|
6 |
+ - src_sh{git clone https://github.com/fukamachi/lack.git ~/quicklisp/local-projects/lack} |
|
7 |
+ - src_sh{sbcl --eval '(asdf:load-asd (truename "todo-backend.asd"))' --eval '(ql:quickload :todo-backend)' --eval '(fwoar.todo::ensure-started)'} |
|
8 |
+ |
|
3 | 9 |
* todo API |
4 | 10 |
|
5 | 11 |
We use a fairly simple structure for our "database": a fset map (a |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
4 | 4 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
5 | 5 |
<head> |
6 |
-<!-- 2019-08-29 Thu 13:30 --> |
|
6 |
+<!-- 2019-08-29 Thu 13:34 --> |
|
7 | 7 |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
8 | 8 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
9 | 9 |
<title>TODO backend implementation using CL and fukamachi/ningle</title> |
... | ... |
@@ -285,28 +285,42 @@ for the JavaScript code in this tag. |
285 | 285 |
<h2>Table of Contents</h2> |
286 | 286 |
<div id="text-table-of-contents"> |
287 | 287 |
<ul> |
288 |
-<li><a href="#orge26183a">1. todo API</a> |
|
288 |
+<li><a href="#orge5b67bc">1. Setup</a></li> |
|
289 |
+<li><a href="#orgc8a4f36">2. todo API</a> |
|
289 | 290 |
<ul> |
290 |
-<li><a href="#org7c9af4c">1.1. List-level APIs</a></li> |
|
291 |
-<li><a href="#org7cd504f">1.2. Getting/Replacing a todo</a></li> |
|
292 |
-<li><a href="#org0c4ab78">1.3. Adding and modifying todos</a></li> |
|
293 |
-<li><a href="#org460c7ef">1.4. Examples</a></li> |
|
291 |
+<li><a href="#orgd5eb315">2.1. List-level APIs</a></li> |
|
292 |
+<li><a href="#orgabe7968">2.2. Getting/Replacing a todo</a></li> |
|
293 |
+<li><a href="#org5db19b9">2.3. Adding and modifying todos</a></li> |
|
294 |
+<li><a href="#org9ad7e12">2.4. Examples</a></li> |
|
294 | 295 |
</ul> |
295 | 296 |
</li> |
296 |
-<li><a href="#org54a5346">2. Source</a> |
|
297 |
+<li><a href="#org78dfe6a">3. Source</a> |
|
297 | 298 |
<ul> |
298 |
-<li><a href="#org7df7206">2.1. model.lisp source code</a></li> |
|
299 |
-<li><a href="#orgaddea1e">2.2. routing.lisp source</a></li> |
|
300 |
-<li><a href="#orgf3388f3">2.3. main.lisp source</a></li> |
|
299 |
+<li><a href="#org1dcbc47">3.1. model.lisp source code</a></li> |
|
300 |
+<li><a href="#org2bf9be6">3.2. routing.lisp source</a></li> |
|
301 |
+<li><a href="#org2763c00">3.3. main.lisp source</a></li> |
|
301 | 302 |
</ul> |
302 | 303 |
</li> |
303 | 304 |
</ul> |
304 | 305 |
</div> |
305 | 306 |
</div> |
306 | 307 |
|
307 |
-<div id="outline-container-orge26183a" class="outline-2"> |
|
308 |
-<h2 id="orge26183a"><span class="section-number-2">1</span> todo API</h2> |
|
308 |
+<div id="outline-container-orge5b67bc" class="outline-2"> |
|
309 |
+<h2 id="orge5b67bc"><span class="section-number-2">1</span> Setup</h2> |
|
309 | 310 |
<div class="outline-text-2" id="text-1"> |
311 |
+<ul class="org-ul"> |
|
312 |
+<li></li> |
|
313 |
+ |
|
314 |
+<li></li> |
|
315 |
+ |
|
316 |
+<li></li> |
|
317 |
+</ul> |
|
318 |
+</div> |
|
319 |
+</div> |
|
320 |
+ |
|
321 |
+<div id="outline-container-orgc8a4f36" class="outline-2"> |
|
322 |
+<h2 id="orgc8a4f36"><span class="section-number-2">2</span> todo API</h2> |
|
323 |
+<div class="outline-text-2" id="text-2"> |
|
310 | 324 |
<p> |
311 | 325 |
We use a fairly simple structure for our "database": a fset map (a |
312 | 326 |
clojure-inspired persistent data structure) and a handful of |
... | ... |
@@ -315,9 +329,9 @@ referenced as <code>*todo*</code>, but this is a detail hidden behind the API. |
315 | 329 |
</p> |
316 | 330 |
</div> |
317 | 331 |
|
318 |
-<div id="outline-container-org7c9af4c" class="outline-3"> |
|
319 |
-<h3 id="org7c9af4c"><span class="section-number-3">1.1</span> List-level APIs</h3> |
|
320 |
-<div class="outline-text-3" id="text-1-1"> |
|
332 |
+<div id="outline-container-orgd5eb315" class="outline-3"> |
|
333 |
+<h3 id="orgd5eb315"><span class="section-number-3">2.1</span> List-level APIs</h3> |
|
334 |
+<div class="outline-text-3" id="text-2-1"> |
|
321 | 335 |
<p> |
322 | 336 |
These are functions for getting the todo list and clearing |
323 | 337 |
it. These are activated by the root route: <code>todos</code> for GET requests |
... | ... |
@@ -325,7 +339,7 @@ and <code>clear-todos</code> for DELETE requests. |
325 | 339 |
</p> |
326 | 340 |
|
327 | 341 |
<div class="org-src-container"> |
328 |
-<pre class="src src-lisp" id="orgc5c9786"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">todos</span> <span style="color: #93a8c6;">()</span> |
|
342 |
+<pre class="src src-lisp" id="org9ed5cd8"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">todos</span> <span style="color: #93a8c6;">()</span> |
|
329 | 343 |
<span style="color: #93a8c6;">(</span>gmap:gmap <span style="font-weight: bold;">:seq</span> |
330 | 344 |
<span style="color: #b0b1a3;">(</span><span style="color: #F0DFAF;">lambda</span> <span style="color: #97b098;">(</span>_ b<span style="color: #97b098;">)</span> |
331 | 345 |
<span style="color: #97b098;">(</span><span style="color: #F0DFAF;">declare</span> <span style="color: #aebed8;">(</span>ignore _<span style="color: #aebed8;">)</span><span style="color: #97b098;">)</span> |
... | ... |
@@ -340,9 +354,9 @@ and <code>clear-todos</code> for DELETE requests. |
340 | 354 |
</div> |
341 | 355 |
</div> |
342 | 356 |
|
343 |
-<div id="outline-container-org7cd504f" class="outline-3"> |
|
344 |
-<h3 id="org7cd504f"><span class="section-number-3">1.2</span> Getting/Replacing a todo</h3> |
|
345 |
-<div class="outline-text-3" id="text-1-2"> |
|
357 |
+<div id="outline-container-orgabe7968" class="outline-3"> |
|
358 |
+<h3 id="orgabe7968"><span class="section-number-3">2.2</span> Getting/Replacing a todo</h3> |
|
359 |
+<div class="outline-text-3" id="text-2-2"> |
|
346 | 360 |
<p> |
347 | 361 |
This uses lisp's <a href="http://www.lispworks.com/documentation/HyperSpec/Body/05_a.htm">generalized references</a> to abstract away the |
348 | 362 |
storage details of the todos. We also provide a <code>delete-todo</code> |
... | ... |
@@ -351,7 +365,7 @@ the GET request for a specific todo by id. |
351 | 365 |
</p> |
352 | 366 |
|
353 | 367 |
<div class="org-src-container"> |
354 |
-<pre class="src src-lisp" id="orgd2f1b68"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">todo</span> <span style="color: #93a8c6;">(</span>id<span style="color: #93a8c6;">)</span> |
|
368 |
+<pre class="src src-lisp" id="org539a4dc"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">todo</span> <span style="color: #93a8c6;">(</span>id<span style="color: #93a8c6;">)</span> |
|
355 | 369 |
<span style="color: #93a8c6;">(</span><span style="color: #F0DFAF;">let</span> <span style="color: #b0b1a3;">(</span><span style="color: #97b098;">(</span>todo <span style="color: #aebed8;">(</span>fset:@ *todos* id<span style="color: #aebed8;">)</span><span style="color: #97b098;">)</span><span style="color: #b0b1a3;">)</span> |
356 | 370 |
todo<span style="color: #93a8c6;">)</span><span style="color: #8c8c8c;">)</span> |
357 | 371 |
|
... | ... |
@@ -367,9 +381,9 @@ the GET request for a specific todo by id. |
367 | 381 |
</div> |
368 | 382 |
</div> |
369 | 383 |
|
370 |
-<div id="outline-container-org0c4ab78" class="outline-3"> |
|
371 |
-<h3 id="org0c4ab78"><span class="section-number-3">1.3</span> Adding and modifying todos</h3> |
|
372 |
-<div class="outline-text-3" id="text-1-3"> |
|
384 |
+<div id="outline-container-org5db19b9" class="outline-3"> |
|
385 |
+<h3 id="org5db19b9"><span class="section-number-3">2.3</span> Adding and modifying todos</h3> |
|
386 |
+<div class="outline-text-3" id="text-2-3"> |
|
373 | 387 |
<p> |
374 | 388 |
<code>new-todo</code> is fairly trivial. It's main feature is that it has to |
375 | 389 |
make sure the <code>completed</code> and <code>url</code> keys are set to the appropriate |
... | ... |
@@ -378,7 +392,7 @@ properly. <code>new-todo</code> backs POST requests to the root endpoint. |
378 | 392 |
</p> |
379 | 393 |
|
380 | 394 |
<div class="org-src-container"> |
381 |
-<pre class="src src-lisp" id="org7d447ff"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">new-todo</span> <span style="color: #93a8c6;">(</span>value<span style="color: #93a8c6;">)</span> |
|
395 |
+<pre class="src src-lisp" id="orgd5bb93b"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">new-todo</span> <span style="color: #93a8c6;">(</span>value<span style="color: #93a8c6;">)</span> |
|
382 | 396 |
<span style="color: #93a8c6;">(</span><span style="color: #F0DFAF;">let</span> <span style="color: #b0b1a3;">(</span><span style="color: #97b098;">(</span>id <span style="color: #aebed8;">(</span>next-id<span style="color: #aebed8;">)</span><span style="color: #97b098;">)</span><span style="color: #b0b1a3;">)</span> |
383 | 397 |
<span style="color: #b0b1a3;">(</span>setf <span style="color: #97b098;">(</span>todo id<span style="color: #97b098;">)</span> |
384 | 398 |
<span style="color: #97b098;">(</span>alexandria:alist-hash-table |
... | ... |
@@ -398,7 +412,7 @@ todo endpoint for a specific ID. |
398 | 412 |
</p> |
399 | 413 |
|
400 | 414 |
<div class="org-src-container"> |
401 |
-<pre class="src src-lisp" id="org1f3ff77"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">update-todo</span> <span style="color: #93a8c6;">(</span>id v<span style="color: #93a8c6;">)</span> |
|
415 |
+<pre class="src src-lisp" id="orgcb322aa"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">defun</span> <span style="color: #8CD0D3;">update-todo</span> <span style="color: #93a8c6;">(</span>id v<span style="color: #93a8c6;">)</span> |
|
402 | 416 |
<span style="color: #93a8c6;">(</span>setf <span style="color: #b0b1a3;">(</span>todo id<span style="color: #b0b1a3;">)</span> |
403 | 417 |
<span style="color: #b0b1a3;">(</span>serapeum:merge-tables <span style="color: #97b098;">(</span>or <span style="color: #aebed8;">(</span>todo id<span style="color: #aebed8;">)</span> |
404 | 418 |
<span style="color: #aebed8;">(</span>make-hash-table <span style="font-weight: bold;">:test</span> 'equal<span style="color: #aebed8;">)</span><span style="color: #97b098;">)</span> |
... | ... |
@@ -412,9 +426,9 @@ todo endpoint for a specific ID. |
412 | 426 |
</div> |
413 | 427 |
</div> |
414 | 428 |
|
415 |
-<div id="outline-container-org460c7ef" class="outline-3"> |
|
416 |
-<h3 id="org460c7ef"><span class="section-number-3">1.4</span> Examples</h3> |
|
417 |
-<div class="outline-text-3" id="text-1-4"> |
|
429 |
+<div id="outline-container-org9ad7e12" class="outline-3"> |
|
430 |
+<h3 id="org9ad7e12"><span class="section-number-3">2.4</span> Examples</h3> |
|
431 |
+<div class="outline-text-3" id="text-2-4"> |
|
418 | 432 |
<div class="org-src-container"> |
419 | 433 |
<pre class="src src-lisp"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">in-package</span> <span style="font-weight: bold;">:fwoar.todo</span><span style="color: #8c8c8c;">)</span> |
420 | 434 |
|
... | ... |
@@ -428,10 +442,10 @@ todo endpoint for a specific ID. |
428 | 442 |
</div> |
429 | 443 |
|
430 | 444 |
<pre class="example"> |
431 |
-(#<hash-table "url": "http://localhost:5000/todo/67", |
|
445 |
+(#<hash-table "url": "http://localhost:5000/todo/77", |
|
432 | 446 |
"title": "get groceries", |
433 | 447 |
"completed": YASON:FALSE> |
434 |
- #<hash-table "url": "http://localhost:5000/todo/68", |
|
448 |
+ #<hash-table "url": "http://localhost:5000/todo/78", |
|
435 | 449 |
"title": "write-better-documentation", |
436 | 450 |
"completed": YASON:FALSE>) |
437 | 451 |
</pre> |
... | ... |
@@ -439,13 +453,13 @@ todo endpoint for a specific ID. |
439 | 453 |
</div> |
440 | 454 |
</div> |
441 | 455 |
|
442 |
-<div id="outline-container-org54a5346" class="outline-2"> |
|
443 |
-<h2 id="org54a5346"><span class="section-number-2">2</span> Source</h2> |
|
444 |
-<div class="outline-text-2" id="text-2"> |
|
456 |
+<div id="outline-container-org78dfe6a" class="outline-2"> |
|
457 |
+<h2 id="org78dfe6a"><span class="section-number-2">3</span> Source</h2> |
|
458 |
+<div class="outline-text-2" id="text-3"> |
|
445 | 459 |
</div> |
446 |
-<div id="outline-container-org7df7206" class="outline-3"> |
|
447 |
-<h3 id="org7df7206"><span class="section-number-3">2.1</span> model.lisp source code</h3> |
|
448 |
-<div class="outline-text-3" id="text-2-1"> |
|
460 |
+<div id="outline-container-org1dcbc47" class="outline-3"> |
|
461 |
+<h3 id="org1dcbc47"><span class="section-number-3">3.1</span> model.lisp source code</h3> |
|
462 |
+<div class="outline-text-3" id="text-3-1"> |
|
449 | 463 |
<div class="org-src-container"> |
450 | 464 |
<pre class="src src-lisp"><span style="color: #A6A689; background-color: #2B2B2B;">;; </span><span style="color: #A6A689; background-color: #2B2B2B;">[[file:~/git_repos/lisp-sandbox/todo/README.org::package-include][package-include]]</span> |
451 | 465 |
<span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">in-package</span> <span style="font-weight: bold;">:fwoar.todo</span><span style="color: #8c8c8c;">)</span> |
... | ... |
@@ -526,9 +540,9 @@ todo endpoint for a specific ID. |
526 | 540 |
</div> |
527 | 541 |
</div> |
528 | 542 |
|
529 |
-<div id="outline-container-orgaddea1e" class="outline-3"> |
|
530 |
-<h3 id="orgaddea1e"><span class="section-number-3">2.2</span> routing.lisp source</h3> |
|
531 |
-<div class="outline-text-3" id="text-2-2"> |
|
543 |
+<div id="outline-container-org2bf9be6" class="outline-3"> |
|
544 |
+<h3 id="org2bf9be6"><span class="section-number-3">3.2</span> routing.lisp source</h3> |
|
545 |
+<div class="outline-text-3" id="text-3-2"> |
|
532 | 546 |
<div class="org-src-container"> |
533 | 547 |
<pre class="src src-lisp"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">in-package</span> <span style="font-weight: bold;">:fwoar.todo</span><span style="color: #8c8c8c;">)</span> |
534 | 548 |
|
... | ... |
@@ -573,9 +587,9 @@ todo endpoint for a specific ID. |
573 | 587 |
</div> |
574 | 588 |
</div> |
575 | 589 |
|
576 |
-<div id="outline-container-orgf3388f3" class="outline-3"> |
|
577 |
-<h3 id="orgf3388f3"><span class="section-number-3">2.3</span> main.lisp source</h3> |
|
578 |
-<div class="outline-text-3" id="text-2-3"> |
|
590 |
+<div id="outline-container-org2763c00" class="outline-3"> |
|
591 |
+<h3 id="org2763c00"><span class="section-number-3">3.3</span> main.lisp source</h3> |
|
592 |
+<div class="outline-text-3" id="text-3-3"> |
|
579 | 593 |
<div class="org-src-container"> |
580 | 594 |
<pre class="src src-lisp"><span style="color: #8c8c8c;">(</span><span style="color: #F0DFAF;">in-package</span> <span style="font-weight: bold;">:fwoar.todo</span><span style="color: #8c8c8c;">)</span> |
581 | 595 |
|
... | ... |
@@ -620,7 +634,7 @@ todo endpoint for a specific ID. |
620 | 634 |
</div> |
621 | 635 |
<div id="postamble" class="status"> |
622 | 636 |
<p class="author">Author: Langley</p> |
623 |
-<p class="date">Created: 2019-08-29 Thu 13:30</p> |
|
637 |
+<p class="date">Created: 2019-08-29 Thu 13:34</p> |
|
624 | 638 |
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> |
625 | 639 |
</div> |
626 | 640 |
</body> |