nerak repo

This commit is contained in:
2026-07-12 23:29:41 -05:00
parent 3040b94b0a
commit 97daa62ce1
+13 -13
View File
@@ -171,7 +171,7 @@ select id, title from todos;
Render the rows Nerak stores under `todos_data`:
**`todos.html`**
```diff
```
{{< home}}
{{$body}}
<h1>My Todos</h1>
@@ -188,7 +188,7 @@ Render the rows Nerak stores under `todos_data`:
Wire up the module, database, and query:
**`app.c`**
```diff
```
#include <nerak.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:
**`todos.html`**
```diff
```
{{< home}}
{{$body}}
<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:
**`app.c`**
```diff
```
#include <nerak.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:
**`todos.html`**
```diff
```
{{#todos_data}}
- <li>{{title}}</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:
**`app.c`**
```diff
```
#include <nerak.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:
**`home.html`**
```diff
```
<html>
<body>
<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:
**`app.c`**
```diff
```
#include <nerak.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:
**`app.c`**
```diff
```
#include <nerak.h>
#include <sqlite.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`**
```diff
```
#include <nerak.h>
-#include <sqlite.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:
**`home.html`**
```diff
```
<html>
<body>
- <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:
**`todos/todos.c`**
```c
```
#include <nerak.h>
#include <sqlite.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}}`.
```c
```
fetch({.url = "https://api.push.dev/notify", .meth = n_post, .json = "{\"text\":\"New todo: {{title}}\"}"})
```