nerak repo
This commit is contained in:
@@ -171,7 +171,7 @@ select id, title from todos;
|
|||||||
Render the rows Nerak stores under `todos_data`:
|
Render the rows Nerak stores under `todos_data`:
|
||||||
|
|
||||||
**`todos.html`**
|
**`todos.html`**
|
||||||
```diff
|
```
|
||||||
{{< home}}
|
{{< home}}
|
||||||
{{$body}}
|
{{$body}}
|
||||||
<h1>My Todos</h1>
|
<h1>My Todos</h1>
|
||||||
@@ -188,7 +188,7 @@ Render the rows Nerak stores under `todos_data`:
|
|||||||
Wire up the module, database, and query:
|
Wire up the module, database, and query:
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
+#include <sqlite.h>
|
+#include <sqlite.h>
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ insert into todos(title) values({{title}});
|
|||||||
Add the form, repopulating the field and showing the error after a failed submit:
|
Add the form, repopulating the field and showing the error after a failed submit:
|
||||||
|
|
||||||
**`todos.html`**
|
**`todos.html`**
|
||||||
```diff
|
```
|
||||||
{{< home}}
|
{{< home}}
|
||||||
{{$body}}
|
{{$body}}
|
||||||
<h1>My Todos</h1>
|
<h1>My Todos</h1>
|
||||||
@@ -254,7 +254,7 @@ Add the form, repopulating the field and showing the error after a failed submit
|
|||||||
Add a `.post` verb and an `.errors` handler:
|
Add a `.post` verb and an `.errors` handler:
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
#include <sqlite.h>
|
#include <sqlite.h>
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ Enter `{{#todo_data}}` first; after the join, `comments` lives inside each todo
|
|||||||
Link each list item to its detail page. `{{url:todo}}` resolves to the `todo` resource's pattern (`/todos/:id`) and fills `:id` from the current row, so no argument is needed:
|
Link each list item to its detail page. `{{url:todo}}` resolves to the `todo` resource's pattern (`/todos/:id`) and fills `:id` from the current row, so no argument is needed:
|
||||||
|
|
||||||
**`todos.html`**
|
**`todos.html`**
|
||||||
```diff
|
```
|
||||||
{{#todos_data}}
|
{{#todos_data}}
|
||||||
- <li>{{title}}</li>
|
- <li>{{title}}</li>
|
||||||
+ <li><a href='{{url:todo}}'>{{title}}</a></li>
|
+ <li><a href='{{url:todo}}'>{{title}}</a></li>
|
||||||
@@ -351,7 +351,7 @@ Link each list item to its detail page. `{{url:todo}}` resolves to the `todo` re
|
|||||||
Register the migration and add a `todo` resource:
|
Register the migration and add a `todo` resource:
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
#include <sqlite.h>
|
#include <sqlite.h>
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ Both queries in one `sqlite_query()` call run concurrently. `join()` lifts `comm
|
|||||||
Show the responses on the home page:
|
Show the responses on the home page:
|
||||||
|
|
||||||
**`home.html`**
|
**`home.html`**
|
||||||
```diff
|
```
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<nav><a href='{{url:home}}'>Home</a> · <a href='{{url:todos}}'>My Todos</a></nav>
|
<nav><a href='{{url:home}}'>Home</a> · <a href='{{url:todos}}'>My Todos</a></nav>
|
||||||
@@ -436,7 +436,7 @@ Show the responses on the home page:
|
|||||||
Fetch both services concurrently before rendering:
|
Fetch both services concurrently before rendering:
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
#include <sqlite.h>
|
#include <sqlite.h>
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ insert into daily_stats(todo_count) select count(*) from todos;
|
|||||||
Register the migration, define the tasks, dispatch them from the POST:
|
Register the migration, define the tasks, dispatch them from the POST:
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
#include <sqlite.h>
|
#include <sqlite.h>
|
||||||
+#include <dispatch.h>
|
+#include <dispatch.h>
|
||||||
@@ -585,7 +585,7 @@ This step moves todos into its own module and adds an `activity` module that rec
|
|||||||
```
|
```
|
||||||
|
|
||||||
**`app.c`**
|
**`app.c`**
|
||||||
```diff
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
-#include <sqlite.h>
|
-#include <sqlite.h>
|
||||||
-#include <dispatch.h>
|
-#include <dispatch.h>
|
||||||
@@ -656,7 +656,7 @@ This step moves todos into its own module and adds an `activity` module that rec
|
|||||||
Add an Activity link to the shared nav:
|
Add an Activity link to the shared nav:
|
||||||
|
|
||||||
**`home.html`**
|
**`home.html`**
|
||||||
```diff
|
```
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
- <nav><a href='{{url:home}}'>Home</a> · <a href='{{url:todos}}'>My Todos</a></nav>
|
- <nav><a href='{{url:home}}'>Home</a> · <a href='{{url:todos}}'>My Todos</a></nav>
|
||||||
@@ -679,7 +679,7 @@ Add an Activity link to the shared nav:
|
|||||||
The todos logic moves into the module unchanged, gaining a `publish()` and an `emit()` step. Both todo resources come along:
|
The todos logic moves into the module unchanged, gaining a `publish()` and an `emit()` step. Both todo resources come along:
|
||||||
|
|
||||||
**`todos/todos.c`**
|
**`todos/todos.c`**
|
||||||
```c
|
```
|
||||||
#include <nerak.h>
|
#include <nerak.h>
|
||||||
#include <sqlite.h>
|
#include <sqlite.h>
|
||||||
#include <pubsub.h>
|
#include <pubsub.h>
|
||||||
@@ -1491,7 +1491,7 @@ fetch({.url = "https://api.dev/charge", .ctx_key = "receipt", .meth = n_post, .j
|
|||||||
```
|
```
|
||||||
|
|
||||||
**`.json`**: literal JSON request body; supports `{{interpolation}}`.
|
**`.json`**: literal JSON request body; supports `{{interpolation}}`.
|
||||||
```c
|
```
|
||||||
fetch({.url = "https://api.push.dev/notify", .meth = n_post, .json = "{\"text\":\"New todo: {{title}}\"}"})
|
fetch({.url = "https://api.push.dev/notify", .meth = n_post, .json = "{\"text\":\"New todo: {{title}}\"}"})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user